Compare commits

...

6 Commits

Author SHA1 Message Date
undefiened 7f2002c85d
Merge a54c16476e into 766e9a9795 2024-02-19 08:10:36 -07:00
Сергій 766e9a9795
Translated using Weblate (Ukrainian)
Currently translated at 100.0% (116 of 116 strings)

Translation: Safe Eyes/Translations
Translate-URL: https://hosted.weblate.org/projects/safe-eyes/translations/uk/
2024-02-15 14:01:56 +01:00
undefiened a54c16476e Removed copyright 2023-07-09 01:17:08 +02:00
undefiened bc7ae63120 Added an icon 2023-07-09 00:59:20 +02:00
undefiened 3428759a85 Fixed comment 2023-05-28 21:07:55 +02:00
undefiened bd51aed724 Added plugin for limiting the number of consecutive skips or postpones 2023-05-28 13:54:09 +02:00
7 changed files with 149 additions and 9 deletions

View File

@ -500,3 +500,19 @@ msgstr "Pause media"
# plugin/healthstats
#~ msgid "Interval to reset statistics (in hours)"
#~ msgstr "Interval to reset statistics (in hours)"
# plugin/limitconsecutiveskipping
msgid "Limit Consecutive Skipping"
msgstr "Limit Consecutive Skipping"
# plugin/limitconsecutiveskipping
msgid "How many skips or postpones are allowed in a row"
msgstr "How many skips or postpones are allowed in a row"
# plugin/limitconsecutiveskipping
msgid "Limit how many breaks can be skipped or postponed in a row"
msgstr "Limit how many breaks can be skipped or postponed in a row"
# plugin/limitconsecutiveskipping
msgid "Skipped or postponed %d/%d breaks in a row"
msgstr "Skipped or postponed %d/%d breaks in a row"

View File

@ -6,17 +6,17 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2021-08-18 00:37+0000\n"
"Last-Translator: Tymofii Lytvynenko <till.svit@gmail.com>\n"
"PO-Revision-Date: 2024-02-15 13:01+0000\n"
"Last-Translator: Сергій <sergiy.goncharuk.1@gmail.com>\n"
"Language-Team: Ukrainian <https://hosted.weblate.org/projects/safe-eyes/"
"translations/uk/>\n"
"Language: uk\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"X-Generator: Weblate 4.8-dev\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"X-Generator: Weblate 5.4-dev\n"
# Short break
msgid "Tightly close your eyes"
@ -48,7 +48,7 @@ msgstr "Випийте води"
# Long break
msgid "Walk for a while"
msgstr "Трохи походіть"
msgstr "Прогуляйтесь"
# Long break
msgid "Lean back at your seat and relax"
@ -289,7 +289,7 @@ msgstr "Нова перерва"
# Settings dialog
msgid "Remove"
msgstr "Видалити"
msgstr "Вилучити"
# Settings dialog
msgid "Discard"

View File

@ -67,6 +67,8 @@ class SafeEyesCore:
self.context = context
self.context['skipped'] = False
self.context['postponed'] = False
self.context['skip_button_disabled'] = False
self.context['postpone_button_disabled'] = False
self.context['state'] = State.WAITING
def initialize(self, config):
@ -299,6 +301,8 @@ class SafeEyesCore:
# Reset the skipped flag
self.context['skipped'] = False
self.context['skip_button_disabled'] = False
self.context['postpone_button_disabled'] = False
self.__start_next_break()
def __wait_for(self, duration):

View File

@ -0,0 +1,23 @@
{
"meta": {
"name": "Limit Consecutive Skipping",
"description": "Limit how many breaks can be skipped or postponed in a row",
"version": "0.0.1"
},
"dependencies": {
"python_modules": [],
"shell_commands": [],
"operating_systems": [],
"desktop_environments": [],
"resources": []
},
"settings": [{
"id": "number_of_allowed_skips_in_a_row",
"label": "How many skips or postpones are allowed in a row",
"type": "INT",
"default": 2,
"min": 1,
"max": 100
}],
"break_override_allowed": true
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 959 B

View File

@ -0,0 +1,94 @@
#!/usr/bin/env python
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Limit how many breaks can be skipped or postponed in a row.
"""
import logging
context = None
no_of_skipped_breaks = 0
session = None
enabled = True
def init(ctx, safeeyes_config, plugin_config):
"""
Initialize the plugin.
"""
global enabled
global context
global session
global no_of_skipped_breaks
global no_allowed_skips
logging.debug('Initialize Limit consecutive skipping plugin')
context = ctx
no_allowed_skips = plugin_config.get('number_of_allowed_skips_in_a_row', 2)
if session is None:
# Read the session
session = context['session']['plugin'].get('limitconsecutiveskipping', None)
if session is None:
session = {'no_of_skipped_breaks': 0}
context['session']['plugin']['limitconsecutiveskipping'] = session
no_of_skipped_breaks = session.get('no_of_skipped_breaks', 0)
def on_stop_break():
"""
After the break, check if it is skipped.
"""
# Check if the plugin is enabled
if not enabled:
return
global no_of_skipped_breaks
if context['skipped'] or context['postponed']:
no_of_skipped_breaks += 1
session['no_of_skipped_breaks'] = no_of_skipped_breaks
else:
no_of_skipped_breaks = 0
session['no_of_skipped_breaks'] = no_of_skipped_breaks
def on_start_break(break_obj):
logging.debug('Skipped / allowed = {} / {}'.format(no_of_skipped_breaks, no_allowed_skips))
if no_of_skipped_breaks >= no_allowed_skips:
context['postpone_button_disabled'] = True
context['skip_button_disabled'] = True
def get_widget_title(break_obj):
"""
Return the widget title.
"""
# Check if the plugin is enabled
if not enabled:
return ""
return _('Limit Consecutive Skipping')
def get_widget_content(break_obj):
"""
Return the statistics.
"""
# Check if the plugin is enabled
if not enabled:
return ""
return _('Skipped or postponed %d/%d breaks in a row') % (no_of_skipped_breaks, no_allowed_skips)

View File

@ -155,6 +155,9 @@ class BreakScreen:
no_of_monitors = screen.get_n_monitors()
logging.info("Show break screens in %d display(s)", no_of_monitors)
skip_button_disabled = self.context.get('skip_button_disabled', False)
postpone_button_disabled = self.context.get('postpone_button_disabled', False)
for monitor in range(no_of_monitors):
monitor_gemoetry = screen.get_monitor_geometry(monitor)
x = monitor_gemoetry.x
@ -186,7 +189,7 @@ class BreakScreen:
toolbar_button.show()
# Add the buttons
if self.enable_postpone:
if self.enable_postpone and not postpone_button_disabled:
# Add postpone button
btn_postpone = Gtk.Button(_('Postpone'))
btn_postpone.get_style_context().add_class('btn_postpone')
@ -194,7 +197,7 @@ class BreakScreen:
btn_postpone.set_visible(True)
box_buttons.pack_start(btn_postpone, True, True, 0)
if not self.strict_break:
if not self.strict_break and not skip_button_disabled:
# Add the skip button
btn_skip = Gtk.Button(_('Skip'))
btn_skip.get_style_context().add_class('btn_skip')