@@ -51,32 +51,54 @@ system_language_directory = os.path.join(bin_directory, "config/lang")
51
51
is_active = True
52
52
CONFIGURATION_VERSION = 1
53
53
54
+ """
55
+ Listen to tray icon Settings action and send the signal to Settings dialog.
56
+ """
54
57
def show_settings ():
55
58
logging .info ("Show Settings dialog" )
56
59
settings_dialog = SettingsDialog (config , language , save_settings , settings_dialog_glade )
57
60
settings_dialog .show ()
58
61
62
+ """
63
+ Receive the signal from core and pass it to the Notification.
64
+ """
59
65
def show_notification ():
60
66
notification .show (config ['pre_break_warning_time' ])
61
67
68
+ """
69
+ Receive the break signal from core and pass it to the break screen.
70
+ """
62
71
def show_alert (message ):
63
72
logging .info ("Show the break screen" )
64
73
notification .close ()
65
74
break_screen .show_message (message )
66
75
76
+ """
77
+ Receive the stop break signal from core and pass it to the break screen.
78
+ """
67
79
def close_alert ():
68
80
logging .info ("Close the break screen" )
69
81
break_screen .close ()
70
82
83
+ """
84
+ Receive the count from core and pass it to the break screen.
85
+ """
71
86
def on_countdown (count ):
72
87
break_screen .show_count_down (count )
73
88
89
+ """
90
+ Listen to the tray menu quit action and stop the core, notification and the app itself.
91
+ """
74
92
def on_quit ():
75
93
logging .info ("Quit Safe Eyes" )
76
94
core .stop ()
77
95
notification .quite ();
78
96
Gtk .main_quit ()
79
97
98
+ """
99
+ If the system goes to sleep, Safe Eyes stop the core if it is already active.
100
+ If it was active, Safe Eyes will become active after wake up.
101
+ """
80
102
def handle_suspend_callback (sleeping ):
81
103
if sleeping :
82
104
# Sleeping / suspending
@@ -89,15 +111,24 @@ def handle_suspend_callback(sleeping):
89
111
core .start ()
90
112
logging .info ("Resumed Safe Eyes after system wakeup" )
91
113
114
+ """
115
+ Setup system suspend listener.
116
+ """
92
117
def handle_system_suspend ():
93
118
DBusGMainLoop (set_as_default = True )
94
119
bus = dbus .SystemBus ()
95
120
bus .add_signal_receiver (handle_suspend_callback , 'PrepareForSleep' , 'org.freedesktop.login1.Manager' , 'org.freedesktop.login1' )
96
121
122
+ """
123
+ Listen to break screen Skip action and send the signal to core.
124
+ """
97
125
def on_skipped ():
98
126
logging .info ("User skipped the break" )
99
127
core .skip_break ()
100
128
129
+ """
130
+ Listen to Settings dialog Save action and write to the config file.
131
+ """
101
132
def save_settings (config ):
102
133
logging .info ("Saving settings to safeeyes.json" )
103
134
if is_active :
@@ -114,14 +145,23 @@ def save_settings(config):
114
145
# 1 sec delay is required to give enough time for core to be stopped
115
146
Timer (1.0 , core .start ).start ()
116
147
148
+ """
149
+ Listen to tray icon enable action and send the signal to core.
150
+ """
117
151
def enable_safeeyes ():
118
152
is_active = True
119
153
core .toggle_active_state ()
120
154
155
+ """
156
+ Listen to tray icon disable action and send the signal to core.
157
+ """
121
158
def disable_safeeyes ():
122
159
is_active = False
123
160
core .toggle_active_state ()
124
161
162
+ """
163
+ Initialize the configuration directory and copy the files to ~/.config directory.
164
+ """
125
165
def initialize_config ():
126
166
global config
127
167
config_dir_path = os .path .join (os .path .expanduser ('~' ), '.config/safeeyes/style' )
0 commit comments