diff --git a/.editorconfig b/.editorconfig index 8b079ee4..9cd88eed 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,3 +11,7 @@ indent_size = 4 [*.{py}] trim_trailing_whitespace = true + +[*.glade] +indent_style = space +indent_size = 2 diff --git a/safeeyes/config/locale/safeeyes.pot b/safeeyes/config/locale/safeeyes.pot index f7e00a69..6f14420a 100644 --- a/safeeyes/config/locale/safeeyes.pot +++ b/safeeyes/config/locale/safeeyes.pot @@ -118,10 +118,6 @@ msgstr "" msgid "Time to prepare for a break (in seconds)" msgstr "" -# Settings dialog -msgid "Keyboard shortcuts disabled period (in seconds)" -msgstr "" - # Settings dialog msgid "Postponement duration (in minutes)" msgstr "" @@ -564,3 +560,12 @@ msgstr "" msgid "Customizing the postpone and skip shortcuts does not work on Wayland." msgstr "" + +msgid "Safe Eyes - Error" +msgstr "" + +msgid "A required plugin is missing dependencies!" +msgstr "" + +msgid "Skipping/postponing disabled period (in seconds)" +msgstr "" diff --git a/safeeyes/config/style/safeeyes_style.css b/safeeyes/config/style/safeeyes_style.css index f2b62555..610c4a0e 100644 --- a/safeeyes/config/style/safeeyes_style.css +++ b/safeeyes/config/style/safeeyes_style.css @@ -43,6 +43,11 @@ color: black; } +.btn_skip:disabled { + color: grey; + border-color: grey; +} + .btn_postpone { color: white; font-size: 10pt; @@ -62,6 +67,11 @@ color: black; } +.btn_postpone:disabled { + color: grey; + border-color: grey; +} + .lbl_message { font-size: 22pt; color: white; diff --git a/safeeyes/glade/settings_dialog.glade b/safeeyes/glade/settings_dialog.glade index 43ab9a55..1147f908 100644 --- a/safeeyes/glade/settings_dialog.glade +++ b/safeeyes/glade/settings_dialog.glade @@ -447,7 +447,7 @@ 1 start - Keyboard shortcuts disabled period (in seconds) + Skipping/postponing disabled period (in seconds) diff --git a/safeeyes/ui/break_screen.py b/safeeyes/ui/break_screen.py index aeacff15..31fd95c2 100644 --- a/safeeyes/ui/break_screen.py +++ b/safeeyes/ui/break_screen.py @@ -59,6 +59,7 @@ def __init__(self, application, context, on_skipped, on_postponed): self.shortcut_disable_time = 2 self.strict_break = False self.windows = [] + self.button_widgets = [] self.show_skip_button = False self.show_postpone_button = False @@ -82,6 +83,8 @@ def initialize(self, config): ) ) + # TODO: shortcut_disable_time should be renamed + # it used to be just about keyboard shortcuts - now it also controls whether the buttons are locked self.shortcut_disable_time = config.get("shortcut_disable_time", 2) self.strict_break = config.get("strict_break", False) @@ -106,15 +109,20 @@ def on_window_delete(self, *args): def on_skip_clicked(self, button): """Skip button press event handler.""" - self.skip_break() + + if self.enable_shortcut: + self.skip_break() def on_postpone_clicked(self, button): """Postpone button press event handler.""" - self.postpone_break() + + if self.enable_shortcut: + self.postpone_break() def show_count_down(self, countdown, seconds): """Show/update the count down on all screens.""" self.enable_shortcut = self.shortcut_disable_time <= seconds + GLib.idle_add(lambda: self.__set_button_widgets_sensitive()) mins, secs = divmod(countdown, 60) timeformat = "{:02d}:{:02d}".format(mins, secs) GLib.idle_add(lambda: self.__update_count_down(timeformat)) @@ -139,6 +147,11 @@ def close(self): # Destroy other windows if exists GLib.idle_add(lambda: self.__destroy_all_screens()) + def __set_button_widgets_sensitive(self) -> None: + for button in self.button_widgets: + if button.get_sensitive() != self.enable_shortcut: + button.set_sensitive(self.enable_shortcut) + def __tray_action(self, button, tray_action): """Tray action handler. @@ -215,7 +228,9 @@ def __show_break_screen(self, message, image_path, widget, tray_actions): btn_postpone.get_style_context().add_class("btn_postpone") btn_postpone.connect("clicked", self.on_postpone_clicked) btn_postpone.set_visible(True) + btn_postpone.set_sensitive(self.enable_shortcut) box_buttons.append(btn_postpone) + self.button_widgets.append(btn_postpone) if self.show_skip_button: # Add the skip button @@ -223,7 +238,9 @@ def __show_break_screen(self, message, image_path, widget, tray_actions): btn_skip.get_style_context().add_class("btn_skip") btn_skip.connect("clicked", self.on_skip_clicked) btn_skip.set_visible(True) + btn_postpone.set_sensitive(self.enable_shortcut) box_buttons.append(btn_skip) + self.button_widgets.append(btn_skip) # Set values if image_path: @@ -354,3 +371,4 @@ def __destroy_all_screens(self): win.destroy() del self.windows[:] del self.count_labels[:] + del self.button_widgets[:]