Add next break time to system tray

This commit is contained in:
Gobinath 2017-05-16 12:54:33 -04:00
parent 44590202e0
commit c03033f33d
21 changed files with 75 additions and 17 deletions

View File

@ -43,6 +43,7 @@ class SettingsDialog:
self.spin_time_to_prepare = builder.get_object('spin_time_to_prepare')
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_show_time_in_tray = builder.get_object('switch_show_time_in_tray')
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')
@ -59,6 +60,7 @@ class SettingsDialog:
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_show_time_in_tray').set_label(language['ui_controls']['show_time_in_tray'])
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'])
@ -75,6 +77,7 @@ class SettingsDialog:
self.spin_time_to_prepare.set_value(config['pre_break_warning_time'])
self.spin_idle_time_to_pause.set_value(config['idle_time'])
self.spin_postpone_duration.set_value(config['postpone_duration'])
self.switch_show_time_in_tray.set_active(config['show_time_in_tray'])
self.switch_strict_break.set_active(config['strict_break'])
self.switch_audible_alert.set_active(config['audible_alert'])
self.spin_time_to_screen_lock.set_value(config['time_to_screen_lock'])
@ -173,6 +176,7 @@ class SettingsDialog:
self.config['pre_break_warning_time'] = self.spin_time_to_prepare.get_value_as_int()
self.config['idle_time'] = self.spin_idle_time_to_pause.get_value_as_int()
self.config['postpone_duration'] = self.spin_postpone_duration.get_value_as_int()
self.config['show_time_in_tray'] = self.switch_show_time_in_tray.get_active()
self.config['strict_break'] = self.switch_strict_break.get_active()
self.config['audible_alert'] = self.switch_audible_alert.get_active()
self.config['language'] = self.languages[self.cmb_language.get_active()]

View File

@ -48,6 +48,8 @@ class TrayIcon:
APPINDICATOR_ID, "safeeyes_enabled", appindicator.IndicatorCategory.APPLICATION_STATUS)
self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
self.initialize(config)
# Construct the context menu
self.menu = Gtk.Menu()
@ -130,6 +132,9 @@ class TrayIcon:
self.indicator.set_menu(self.menu)
def initialize(self, config):
self.config = config
def set_labels(self, language):
self.language = language
for entry in self.sub_menu_items:
@ -181,7 +186,8 @@ class TrayIcon:
def __set_next_break_info(self):
formatted_time = Utility.format_time(self.dateTime)
message = self.language['messages']['next_break_at'].format(formatted_time)
if self.config.get('show_time_in_tray', False):
self.indicator.set_label(formatted_time, '')
Utility.execute_main_thread(self.item_info.set_label, message)
def on_enable_clicked(self, *args):

View File

@ -167,7 +167,7 @@ def save_settings(config):
# Reload the language translation
language = Utility.load_language(config['language'])
tray_icon.initialize(config)
tray_icon.set_labels(language)
logging.info("Initialize SafeEyesCore with modified settings")

View File

@ -47,6 +47,7 @@
"save": "Uložit",
"settings": "Nastavení",
"short_break_duration": "Trvání krátké přestávky (v sekundách)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "Přeskočit",
"strict_break": "Povinná přestávka (skrýt tlačítko pro přeskočení)",
"system_language": "Systémový jazyk",

View File

@ -47,6 +47,7 @@
"save": "Speichern",
"settings": "Einstellungen",
"short_break_duration": "Kleine-Pause-Intervall (in Sekunden)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "Überspringen",
"strict_break": "Strikte Pause (Überspringen nicht möglich)",
"system_language": "Systemsprache",

View File

@ -47,6 +47,7 @@
"save": "Save",
"settings": "Settings",
"short_break_duration": "Short break duration (in seconds)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "Skip",
"strict_break": "Strict break (Hide skip button)",
"system_language": "System Language",

View File

@ -47,6 +47,7 @@
"save": "Guardar",
"settings": "Preferencias",
"short_break_duration": "Duración de una pausa corta (en segundos)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "Saltar",
"strict_break": "Pausa estricta (No hay botón Saltar)",
"system_language": "Idioma del sistema",

View File

@ -47,6 +47,7 @@
"save": "Enregistrer",
"settings": "Paramètres",
"short_break_duration": "Durée d'une pause courte (en secondes)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "Ignorer",
"strict_break": "Pause stricte (cacher le bouton Ignorer)",
"system_language": "Langue du système ",

View File

@ -47,6 +47,7 @@
"save": "დამახსოვრება",
"settings": "პარამეტრები",
"short_break_duration": "მცირე შესვენების ხანგრძლივობა (წამებში)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "გამოტოვება",
"strict_break": "აუცილებელი შესვენება (დავმალოთ ღილაკი 'გამოტოვება')",
"system_language": "System Language",

View File

@ -47,6 +47,7 @@
"save": "रखें",
"settings": "सेटिंग्स",
"short_break_duration": "छोटे आराम की अवधि (पलों में)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "अभी नहीं",
"strict_break": "जरूरी आराम (रोक नहीं सकते)",
"system_language": "System Language",

View File

@ -47,6 +47,7 @@
"save": "Mentés",
"settings": "Beállítások",
"short_break_duration": "Rövid szünet hossza (másodpercekben)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "Átugrás",
"strict_break": "Kötelezők a szünetek? (nincs átugrás gomb)",
"system_language": "System Language",

View File

@ -47,6 +47,7 @@
"save": "Simpan",
"settings": "Pengaturan",
"short_break_duration": "Durasi istirahat singkat (dalam detik)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "Lewati",
"strict_break": "Paksa istirahat (sembunyikan tombol Lewati)",
"system_language": "System Language",

View File

@ -47,6 +47,7 @@
"save": "Зачувај",
"settings": "Подесувања",
"short_break_duration": "Траење на кратките паузи (Во секунди)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "Skip",
"strict_break": "Строга пауза (Сокриј го „Прескокни“ копчето)",
"system_language": "Системски Јазик",

View File

@ -47,6 +47,7 @@
"save": "Zapisz",
"settings": "Ustawienia",
"short_break_duration": "Czas trwania krótkiej przerwy (w sekundach)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "Pomiń",
"strict_break": "Bezwzględna przerwa (ukryj przycisk pominięcia)",
"system_language": "Język systemu",

View File

@ -47,6 +47,7 @@
"save": "Salvar",
"settings": "Configuração",
"short_break_duration": "Duração de uma pausa curta (em segundos)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "Pular",
"strict_break": "Pausa rigorosa (Esconder botão pular)",
"system_language": "Linguagem do Sistema",

View File

@ -47,6 +47,7 @@
"save": "Сохранить",
"settings": "Настройки",
"short_break_duration": "Продолжительность короткого перерыва (в секундах)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "Пропустить",
"strict_break": "Обязательный перерыв (Скрыть кнопку 'Пропустить')",
"system_language": "System Language",

View File

@ -47,6 +47,7 @@
"save": "Uložiť",
"settings": "Nastavenia",
"short_break_duration": "Trvanie krátkej prestávky (v sekundách)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "Preskočiť",
"strict_break": "Povinná prestávka (Skryje tlačitko Preskočiť)",
"system_language": "System Language",

View File

@ -47,6 +47,7 @@
"save": "சேமி",
"settings": "அமைப்பு",
"short_break_duration": "குறுகிய கால இடைவேளை (விநாடிகளில்)",
"show_time_in_tray": "அடுத்த இடைவேளை நேரத்தை Safe Eyes சின்னத்திற்கு அருகில் காண்பிக்கவும்",
"skip": "தவிர்",
"strict_break": "கட்டாய இடைவேளை (தவிர்க்கும் பொத்தான் காண்பிக்கப்பட மாட்டாது)",
"system_language": "இயங்குதள மொழி",

View File

@ -47,6 +47,7 @@
"save": "Kaydet",
"settings": "Ayarlar",
"short_break_duration": "Kısa mola süresi (saniye)",
"show_time_in_tray": "Show the next break time in system tray",
"skip": "Geç",
"strict_break": "Kesin mola (Geç düğmesini gizler)",
"system_language": "System Language",

View File

@ -1,6 +1,6 @@
{
"meta": {
"config_version": "5.0"
"config_version": "5.0.1"
},
"allow_postpone": false,
"break_interval": 15,
@ -11,6 +11,7 @@
"short_break_duration": 15,
"idle_time": 5,
"postpone_duration": 5,
"show_time_in_tray": false,
"strict_break": false,
"audible_alert": false,
"language": "system",

View File

@ -189,7 +189,20 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">8</property>
<property name="top_attach">9</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_show_time_in_tray">
<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">Show the next break time in system tray icon</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
@ -202,7 +215,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
@ -333,11 +346,11 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">8</property>
<property name="top_attach">9</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="switch_strict_break">
<object class="GtkSwitch" id="switch_show_time_in_tray">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
@ -348,6 +361,18 @@
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="switch_strict_break">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="switch_audible_alert">
<property name="visible">True</property>
@ -357,7 +382,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">9</property>
<property name="top_attach">10</property>
</packing>
</child>
<child>
@ -370,7 +395,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">9</property>
<property name="top_attach">10</property>
</packing>
</child>
<child>
@ -380,7 +405,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">12</property>
<property name="top_attach">13</property>
</packing>
</child>
<child>
@ -393,7 +418,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">12</property>
<property name="top_attach">13</property>
</packing>
</child>
<child>
@ -406,7 +431,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">10</property>
<property name="top_attach">11</property>
</packing>
</child>
<child>
@ -417,7 +442,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">10</property>
<property name="top_attach">11</property>
</packing>
</child>
<child>
@ -430,7 +455,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">11</property>
<property name="top_attach">12</property>
</packing>
</child>
<child>
@ -449,7 +474,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">11</property>
<property name="top_attach">12</property>
</packing>
</child>
<child>
@ -462,7 +487,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
<property name="top_attach">8</property>
</packing>
</child>
<child>
@ -473,9 +498,15 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">7</property>
<property name="top_attach">8</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>