Make postpone button optional

This commit is contained in:
Gobinath 2017-04-22 19:04:35 -04:00
parent 2326644c2e
commit cca711a449
21 changed files with 109 additions and 57 deletions

View File

@ -53,7 +53,8 @@ class BreakScreen:
logging.info("Initialize the break screen")
self.skip_button_text = language['ui_controls']['skip']
self.postpone_button_text = language['ui_controls']['postpone']
self.strict_break = config['strict_break']
self.strict_break = config.get('strict_break', False)
self.enable_postpone = config.get('allow_postpone', False)
"""
@ -133,11 +134,29 @@ class BreakScreen:
window = builder.get_object("window_main")
lbl_message = builder.get_object("lbl_message")
lbl_count = builder.get_object("lbl_count")
btn_skip = builder.get_object("btn_skip")
btn_postpone = builder.get_object("btn_postpone")
lbl_left = builder.get_object("lbl_left")
lbl_right = builder.get_object("lbl_right")
img_break = builder.get_object("img_break")
box_buttons = builder.get_object("box_buttons")
# Add the buttons
if not self.strict_break:
# Add postpone button
if self.enable_postpone:
btn_postpone = Gtk.Button(self.postpone_button_text)
btn_postpone.get_style_context().add_class('btn_postpone')
btn_postpone.connect('clicked', self.on_postpone_clicked)
btn_postpone.set_visible(True)
box_buttons.pack_start(btn_postpone, True, True, 0)
# Add the skip button
btn_skip = Gtk.Button(self.skip_button_text)
btn_skip.get_style_context().add_class('btn_skip')
btn_skip.connect('clicked', self.on_skip_clicked)
btn_skip.set_visible(True)
box_buttons.pack_start(btn_skip, True, True, 0)
# Set values
if image_path:
@ -145,12 +164,6 @@ class BreakScreen:
lbl_message.set_label(message)
lbl_left.set_markup(plugins_data['left']);
lbl_right.set_markup(plugins_data['right']);
btn_skip.set_label(self.skip_button_text)
btn_postpone.set_label(self.postpone_button_text)
# Set the visibility of buttons
btn_postpone.set_visible(not self.strict_break)
btn_skip.set_visible(not self.strict_break)
self.windows.append(window)
self.count_labels.append(lbl_count)

View File

@ -44,6 +44,7 @@ class SettingsDialog:
self.spin_idle_time_to_pause = builder.get_object('spin_idle_time_to_pause')
self.spin_postpone_duration = builder.get_object('spin_postpone_duration')
self.switch_strict_break = builder.get_object('switch_strict_break')
self.switch_postpone = builder.get_object('switch_postpone')
self.switch_audible_alert = builder.get_object('switch_audible_alert')
self.cmb_language = builder.get_object('cmb_language')
self.switch_screen_lock = builder.get_object('switch_screen_lock')
@ -57,6 +58,7 @@ class SettingsDialog:
builder.get_object('lbl_time_to_prepare').set_label(language['ui_controls']['time_to_prepare_for_break'])
builder.get_object('lbl_idle_time_to_pause').set_label(language['ui_controls']['idle_time'])
builder.get_object('lbl_postpone_duration').set_label(language['ui_controls']['postpone_duration'])
builder.get_object('lbl_allow_postpone').set_label(language['ui_controls']['allow_postpone'])
builder.get_object('lbl_strict_break').set_label(language['ui_controls']['strict_break'])
builder.get_object('lbl_audible_alert').set_label(language['ui_controls']['audible_alert'])
builder.get_object('lbl_language').set_label(language['ui_controls']['language'])
@ -79,10 +81,15 @@ class SettingsDialog:
# Enable idle_time_to_pause only if xprintidle is available
self.spin_idle_time_to_pause.set_sensitive(Utility.command_exist('xprintidle'))
self.switch_screen_lock.set_sensitive(able_to_lock_screen)
self.switch_screen_lock.set_active(able_to_lock_screen and config['enable_screen_lock'])
self.switch_postpone.set_active(config['allow_postpone'] and not config['strict_break'])
# Update relative states
self.on_switch_strict_break_activate(self.switch_strict_break, self.switch_strict_break.get_active())
self.on_switch_screen_lock_activate(self.switch_screen_lock, self.switch_screen_lock.get_active())
self.on_switch_postpone_activate(self.switch_postpone, self.switch_postpone.get_active())
# Initialize the language combobox
language_list_store = Gtk.ListStore(GObject.TYPE_STRING)
@ -126,6 +133,23 @@ class SettingsDialog:
self.spin_time_to_screen_lock.set_sensitive(self.switch_screen_lock.get_active())
def on_switch_strict_break_activate(self, switch, state):
"""
Event handler to the state change of the postpone switch.
Enable or disable the self.spin_postpone_duration based on the state of the postpone switch.
"""
strict_break_enable = state #self.switch_strict_break.get_active()
self.switch_postpone.set_sensitive(not strict_break_enable)
if strict_break_enable:
self.switch_postpone.set_active(False)
def on_switch_postpone_activate(self, switch, state):
"""
Event handler to the state change of the postpone switch.
Enable or disable the self.spin_postpone_duration based on the state of the postpone switch.
"""
self.spin_postpone_duration.set_sensitive(self.switch_postpone.get_active())
def on_window_delete(self, *args):
"""
Event handler for Settings dialog close action.
@ -149,6 +173,7 @@ class SettingsDialog:
self.config['language'] = self.languages[self.cmb_language.get_active()]
self.config['time_to_screen_lock'] = self.spin_time_to_screen_lock.get_value_as_int()
self.config['enable_screen_lock'] = self.switch_screen_lock.get_active()
self.config['allow_postpone'] = self.switch_postpone.get_active()
self.on_save_settings(self.config) # Call the provided save method
self.window.destroy() # Close the settings window

View File

@ -43,7 +43,7 @@ system_config_file_path = os.path.join(Utility.bin_directory, "config/safeeyes.j
system_style_sheet_path = os.path.join(Utility.bin_directory, "config/style/safeeyes_style.css")
is_active = True
CONFIGURATION_VERSION = 4
CONFIGURATION_VERSION = 5
SAFE_EYES_VERSION = "1.2.0a9"
"""

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "O aplikaci",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "Zvukové upozornění na konec přestávky",
"cancel": "Zrušit",
"disable": "Pozastavit Safe Eyes",

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "About",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "Akustisches Signal am Ende der Pause",
"cancel": "Abbrechen",
"disable": "Safe Eyes deaktivieren",

View File

@ -5,7 +5,7 @@
},
"exercises": {
"short_break_close_eyes": "Tightly close your eyes",
"short_break_roll_eyes": "Roll your eyes",
"short_break_roll_eyes": "Roll your eyes a few times to each side",
"short_break_rotate_clockwise": "Rotate your eyes in clockwise direction",
"short_break_rotate_counter_clockwise": "Rotate your eyes in counterclockwise direction",
"short_break_blink": "Blink your eyes",
@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "About",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "Audible alert at the end of break",
"cancel": "Cancel",
"disable": "Disable Safe Eyes",

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "Acerca de",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "Alerta sonora al final de cada pausa",
"cancel": "Cancelar",
"disable": "Desactivar Safe Eyes",

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "À propos",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "Alerte sonore en fin d'une pause",
"cancel": "Annuler",
"disable": "Désactiver Safe Eyes",

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "პროგრამის შესახებ",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "ხმოვანი შეტყობინება შესვენების დამთავრებისას",
"cancel": "უარყოფა",
"disable": "Safe Eyes გამორთვა",

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "हमारे बारे में",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "आराम के ख़तम के ख़तम होने पर आवाज़",
"cancel": "रखना नहीं",
"disable": "सेफ आईज बंद",

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "Ról ről",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "Audible alert at the end of break",
"cancel": "Mégse",
"disable": "Disable Safe Eyes",

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "Tentang",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "Peringatan bersuara saat istirahat berakhir",
"cancel": "Batal",
"disable": "Matikan Safe Eyes",

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "O programie",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "Powiadomienie dźwiękowe na koniec przerwy",
"cancel": "Anuluj",
"disable": "Zatrzymaj Safe Eyes",

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "Sobre",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "Alerta sonoro no fim da pausa",
"cancel": "Cancelar",
"disable": "Desativar Safe Eyes",

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "О программе",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "Звуковой сигнал в конце перерыва",
"cancel": "Отменить",
"disable": "Отключить Safe Eyes",

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "Ohľadom",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "Zvukový signál na konci prestávky",
"cancel": "Zrušiť",
"disable": "Zakázať Safe Eyes",

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "Safe Eyes குறித்த தகவல்கள்",
"allow_postpone": "ஒத்திவைக்க அனுமதிக்கவும்",
"audible_alert": "இடைவேளையின் இறுதியில் ஒலி சமிக்கை",
"cancel": "ரத்து",
"disable": "Safe Eyes ஐ நிறுத்துக",

View File

@ -22,6 +22,7 @@
},
"ui_controls": {
"about": "Hakkında",
"allow_postpone": "Allow postponing the breaks",
"audible_alert": "Mola sonunda sesli uyarı",
"cancel": "İptal",
"disable": "Safe Eyes'ı devre dışı bırak",

View File

@ -2,8 +2,9 @@
"meta": {
"config_version": 5
},
"allow_postpone": false,
"break_interval": 15,
"enable_screen_lock": true,
"enable_screen_lock": false,
"enable_statistic": false,
"long_break_duration": 60,
"no_of_short_breaks_per_long_break": 5,

View File

@ -117,40 +117,10 @@
<property name="spacing">50</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton" id="btn_postpone">
<property name="label" translatable="yes">Postpone</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<signal name="clicked" handler="on_postpone_clicked" swapped="no"/>
<style>
<class name="btn_postpone"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="btn_skip">
<property name="label" translatable="yes">Skip</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="valign">center</property>
<signal name="clicked" handler="on_skip_clicked" swapped="no"/>
<style>
<class name="btn_skip"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
<placeholder/>
</child>
</object>
<packing>

View File

@ -189,7 +189,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
<property name="top_attach">8</property>
</packing>
</child>
<child>
@ -202,7 +202,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
@ -333,7 +333,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">6</property>
<property name="top_attach">8</property>
</packing>
</child>
<child>
@ -342,10 +342,12 @@
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<signal name="activate" handler="on_switch_strict_break_activate" swapped="no"/>
<signal name="state-set" handler="on_switch_strict_break_activate" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">7</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
@ -357,7 +359,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">8</property>
<property name="top_attach">9</property>
</packing>
</child>
<child>
@ -370,7 +372,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">8</property>
<property name="top_attach">9</property>
</packing>
</child>
<child>
@ -380,7 +382,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">11</property>
<property name="top_attach">12</property>
</packing>
</child>
<child>
@ -393,7 +395,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">11</property>
<property name="top_attach">12</property>
</packing>
</child>
<child>
@ -406,7 +408,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">9</property>
<property name="top_attach">10</property>
</packing>
</child>
<child>
@ -419,7 +421,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">9</property>
<property name="top_attach">10</property>
</packing>
</child>
<child>
@ -432,7 +434,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">10</property>
<property name="top_attach">11</property>
</packing>
</child>
<child>
@ -451,7 +453,33 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">10</property>
<property name="top_attach">11</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_allow_postpone">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Allow postponing the breaks</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="switch_postpone">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<signal name="activate" handler="on_switch_postpone_activate" swapped="no"/>
<signal name="state-set" handler="on_switch_postpone_activate" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">7</property>
</packing>
</child>
</object>