2121import gi
2222
2323gi .require_version ('Gtk' , '3.0' )
24- gi .require_version ('Granite' , '1.0' )
2524
26- from gi .repository import Gtk , Gio , Gdk , Granite
25+ from gi .repository import Gtk , Gio , Gdk
2726
2827import window as wn
2928import constants as cn
29+
3030class Application (Gtk .Application ):
3131
3232 def do_activate (self ):
33+ '''Here we are creating a new instante of the Windows, setting its
34+ size and connecting the delete-event signal to correctly handle
35+ the application exit.'''
3336 self .win = wn .Window ()
3437 self .win .set_default_size (600 , 600 )
3538 self .win .connect ("delete-event" , Gtk .main_quit )
@@ -41,19 +44,23 @@ def do_activate(self):
4144
4245app = Application ()
4346
47+ '''Here we are defining the application colors, using the parameters
48+ defined in the constants file.'''
4449stylesheet = f"""
4550 @define-color colorPrimary { cn .Colors .primary_color } ;
4651 @define-color textColorPrimary { cn .Colors .primary_text_color } ;
4752 @define-color textColorPrimaryShadow { cn .Colors .primary_text_shadow_color } ;
4853"""
4954
55+ '''And here we are injecting the style CSS in the application'''
5056style_provider = Gtk .CssProvider ()
5157style_provider .load_from_data (bytes (stylesheet .encode ()))
5258Gtk .StyleContext .add_provider_for_screen (
5359 Gdk .Screen .get_default (), style_provider ,
5460 Gtk .STYLE_PROVIDER_PRIORITY_APPLICATION
5561)
5662
63+ '''Defining our application infos'''
5764app .application_id = cn .App .application_id
5865app .flags = Gio .ApplicationFlags .FLAGS_NONE
5966app .program_name = cn .App .application_name
@@ -67,4 +74,5 @@ def do_activate(self):
6774app .help_url = cn .App .help_url
6875app .translate_url = cn .App .translate_url
6976
77+ '''Let's make our app roar!'''
7078app .run ("" )
0 commit comments