Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ indent_size = 4

[*.{py}]
trim_trailing_whitespace = true

[*.glade]
indent_style = space
indent_size = 2
13 changes: 9 additions & 4 deletions safeeyes/config/locale/safeeyes.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down Expand Up @@ -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 ""
10 changes: 10 additions & 0 deletions safeeyes/config/style/safeeyes_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
color: black;
}

.btn_skip:disabled {
color: grey;
border-color: grey;
}

.btn_postpone {
color: white;
font-size: 10pt;
Expand All @@ -62,6 +67,11 @@
color: black;
}

.btn_postpone:disabled {
color: grey;
border-color: grey;
}

.lbl_message {
font-size: 22pt;
color: white;
Expand Down
2 changes: 1 addition & 1 deletion safeeyes/glade/settings_dialog.glade
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@
<object class="GtkLabel" id="lbl_shortcuts">
<property name="visible">1</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Keyboard shortcuts disabled period (in seconds)</property>
<property name="label" translatable="yes">Skipping/postponing disabled period (in seconds)</property>
</object>
</child>
<child>
Expand Down
22 changes: 20 additions & 2 deletions safeeyes/ui/break_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
self.shortcut_disable_time = 2
self.strict_break = False
self.windows = []
self.button_widgets = []
self.show_skip_button = False
self.show_postpone_button = False

Expand All @@ -82,6 +83,8 @@
)
)

# TODO: shortcut_disable_time should be renamed
# it used to be just about keyboard shortcuts - now it also controls whether the buttons are locked

Check failure on line 87 in safeeyes/ui/break_screen.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

safeeyes/ui/break_screen.py:87:89: E501 Line too long (107 > 88)
self.shortcut_disable_time = config.get("shortcut_disable_time", 2)
self.strict_break = config.get("strict_break", False)

Expand All @@ -105,16 +108,21 @@
self.close()

def on_skip_clicked(self, button):
"""Skip button press event handler."""

Check failure on line 111 in safeeyes/ui/break_screen.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (D202)

safeeyes/ui/break_screen.py:111:9: D202 No blank lines allowed after function docstring (found 1)
self.skip_break()

if self.enable_shortcut:
self.skip_break()

def on_postpone_clicked(self, button):
"""Postpone button press event handler."""

Check failure on line 117 in safeeyes/ui/break_screen.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (D202)

safeeyes/ui/break_screen.py:117:9: D202 No blank lines allowed after function docstring (found 1)
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))
Expand All @@ -139,6 +147,11 @@
# 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.

Expand Down Expand Up @@ -215,15 +228,19 @@
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
btn_skip = Gtk.Button.new_with_label(_("Skip"))
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:
Expand Down Expand Up @@ -354,3 +371,4 @@
win.destroy()
del self.windows[:]
del self.count_labels[:]
del self.button_widgets[:]
Loading