Merge pull request #57 from radek-sprta/master
Use local time representation
This commit is contained in:
commit
812914c3a7
|
@ -17,6 +17,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
|
import locale
|
||||||
import logging
|
import logging
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
gi.require_version('AppIndicator3', '0.1')
|
gi.require_version('AppIndicator3', '0.1')
|
||||||
|
@ -27,7 +28,9 @@ from gi.repository import AppIndicator3 as appindicator
|
||||||
active = True
|
active = True
|
||||||
APPINDICATOR_ID = 'safeeyes'
|
APPINDICATOR_ID = 'safeeyes'
|
||||||
|
|
||||||
|
|
||||||
class TrayIcon:
|
class TrayIcon:
|
||||||
|
|
||||||
def __init__(self, language, on_show_settings, on_show_about, on_enable, on_disable, on_quite):
|
def __init__(self, language, on_show_settings, on_show_about, on_enable, on_disable, on_quite):
|
||||||
logging.info("Initialize the tray icon")
|
logging.info("Initialize the tray icon")
|
||||||
self.on_show_settings = on_show_settings
|
self.on_show_settings = on_show_settings
|
||||||
|
@ -39,7 +42,8 @@ class TrayIcon:
|
||||||
self.dateTime = None
|
self.dateTime = None
|
||||||
|
|
||||||
# Construct the tray icon
|
# Construct the tray icon
|
||||||
self.indicator = appindicator.Indicator.new(APPINDICATOR_ID, "safeeyes_enabled", appindicator.IndicatorCategory.APPLICATION_STATUS)
|
self.indicator = appindicator.Indicator.new(
|
||||||
|
APPINDICATOR_ID, "safeeyes_enabled", appindicator.IndicatorCategory.APPLICATION_STATUS)
|
||||||
self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
|
self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
|
||||||
|
|
||||||
# Construct the context menu
|
# Construct the context menu
|
||||||
|
@ -90,17 +94,20 @@ class TrayIcon:
|
||||||
if self.dateTime:
|
if self.dateTime:
|
||||||
self.set_next_break_info(self.dateTime)
|
self.set_next_break_info(self.dateTime)
|
||||||
else:
|
else:
|
||||||
self.item_info.set_label(self.language['messages']['safe_eyes_is_disabled'])
|
self.item_info.set_label(self.language['messages'][
|
||||||
|
'safe_eyes_is_disabled'])
|
||||||
self.item_enable.set_label(self.language['ui_controls']['enable'])
|
self.item_enable.set_label(self.language['ui_controls']['enable'])
|
||||||
self.item_settings.set_label(self.language['ui_controls']['settings'])
|
self.item_settings.set_label(self.language['ui_controls']['settings'])
|
||||||
self.item_about.set_label(self.language['ui_controls']['about'])
|
self.item_about.set_label(self.language['ui_controls']['about'])
|
||||||
self.item_quit.set_label(self.language['ui_controls']['quit'])
|
self.item_quit.set_label(self.language['ui_controls']['quit'])
|
||||||
|
|
||||||
def show_icon(self):
|
def show_icon(self):
|
||||||
GLib.idle_add(lambda: self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE))
|
GLib.idle_add(lambda: self.indicator.set_status(
|
||||||
|
appindicator.IndicatorStatus.ACTIVE))
|
||||||
|
|
||||||
def hide_icon(self):
|
def hide_icon(self):
|
||||||
GLib.idle_add(lambda: self.indicator.set_status(appindicator.IndicatorStatus.PASSIVE))
|
GLib.idle_add(lambda: self.indicator.set_status(
|
||||||
|
appindicator.IndicatorStatus.PASSIVE))
|
||||||
|
|
||||||
def quit_safe_eyes(self, *args):
|
def quit_safe_eyes(self, *args):
|
||||||
self.on_quite()
|
self.on_quite()
|
||||||
|
@ -117,13 +124,9 @@ class TrayIcon:
|
||||||
self.set_next_break_info(self.dateTime)
|
self.set_next_break_info(self.dateTime)
|
||||||
|
|
||||||
def set_next_break_info(self, dateTime):
|
def set_next_break_info(self, dateTime):
|
||||||
formatted_time = dateTime.strftime("%l:%M")
|
formatted_time = dateTime.strftime(locale.nl_langinfo(locale.T_FMT))
|
||||||
if dateTime.hour == 12:
|
message = self.language['messages'][
|
||||||
message = self.language['messages']['next_break_at_noon'].format(formatted_time)
|
'next_break_at'].format(formatted_time)
|
||||||
elif dateTime.hour < 12:
|
|
||||||
message = self.language['messages']['next_break_at_am'].format(formatted_time)
|
|
||||||
else:
|
|
||||||
message = self.language['messages']['next_break_at_pm'].format(formatted_time)
|
|
||||||
|
|
||||||
GLib.idle_add(lambda: self.item_info.set_label(message))
|
GLib.idle_add(lambda: self.item_info.set_label(message))
|
||||||
|
|
||||||
|
@ -137,6 +140,7 @@ class TrayIcon:
|
||||||
else:
|
else:
|
||||||
logging.info("Disable Safe Eyes")
|
logging.info("Disable Safe Eyes")
|
||||||
self.indicator.set_icon("safeeyes_disabled")
|
self.indicator.set_icon("safeeyes_disabled")
|
||||||
self.item_info.set_label(self.language['messages']['safe_eyes_is_disabled'])
|
self.item_info.set_label(self.language['messages'][
|
||||||
|
'safe_eyes_is_disabled'])
|
||||||
self.item_info.set_sensitive(False)
|
self.item_info.set_sensitive(False)
|
||||||
self.on_disable()
|
self.on_disable()
|
||||||
|
|
|
@ -21,9 +21,7 @@
|
||||||
"messages": {
|
"messages": {
|
||||||
"ready_for_a_break": "Připravte se na přestávku za {} sekund",
|
"ready_for_a_break": "Připravte se na přestávku za {} sekund",
|
||||||
"safe_eyes_is_disabled": "Safe Eyes je zakázáno",
|
"safe_eyes_is_disabled": "Safe Eyes je zakázáno",
|
||||||
"next_break_at_noon": "Příští přestávka v {}",
|
"next_break_at": "Příští přestávka v {}"
|
||||||
"next_break_at_am": "Příští přestávka v {} dopoledne",
|
|
||||||
"next_break_at_pm": "Příští přestávka v {} odpoledne"
|
|
||||||
},
|
},
|
||||||
"ui_controls": {
|
"ui_controls": {
|
||||||
"skip": "Přeskočit",
|
"skip": "Přeskočit",
|
||||||
|
|
|
@ -21,9 +21,7 @@
|
||||||
"messages": {
|
"messages": {
|
||||||
"ready_for_a_break": "Ready for a break in {} seconds",
|
"ready_for_a_break": "Ready for a break in {} seconds",
|
||||||
"safe_eyes_is_disabled": "Safe Eyes is disabled",
|
"safe_eyes_is_disabled": "Safe Eyes is disabled",
|
||||||
"next_break_at_noon": "Next break at {}",
|
"next_break_at": "Next break at {}"
|
||||||
"next_break_at_am": "Next break at {} AM",
|
|
||||||
"next_break_at_pm": "Next break at {} PM"
|
|
||||||
},
|
},
|
||||||
"ui_controls": {
|
"ui_controls": {
|
||||||
"skip": "Skip",
|
"skip": "Skip",
|
||||||
|
|
|
@ -21,9 +21,7 @@
|
||||||
"messages": {
|
"messages": {
|
||||||
"ready_for_a_break": "Listo para una pausa en {} segundos",
|
"ready_for_a_break": "Listo para una pausa en {} segundos",
|
||||||
"safe_eyes_is_disabled": "Safe Eyes está desactivado",
|
"safe_eyes_is_disabled": "Safe Eyes está desactivado",
|
||||||
"next_break_at_noon": "Próxima pausa a las {}",
|
"next_break_at": "Próxima pausa a las {}"
|
||||||
"next_break_at_am": "Próxima pausa a las {} de la mañana",
|
|
||||||
"next_break_at_pm": "Próxima pausa a las {} de la tarde/noche"
|
|
||||||
},
|
},
|
||||||
"ui_controls": {
|
"ui_controls": {
|
||||||
"skip": "Cancelar",
|
"skip": "Cancelar",
|
||||||
|
|
|
@ -20,9 +20,7 @@
|
||||||
"messages": {
|
"messages": {
|
||||||
"ready_for_a_break": "Prêt pour une pause dans {} secondes",
|
"ready_for_a_break": "Prêt pour une pause dans {} secondes",
|
||||||
"safe_eyes_is_disabled": "Safe Eyes est désactivé",
|
"safe_eyes_is_disabled": "Safe Eyes est désactivé",
|
||||||
"next_break_at_noon": "Prochaine pause à {}",
|
"next_break_at": "Prochaine pause à {}"
|
||||||
"next_break_at_am": "Prochaine pause à {} AM",
|
|
||||||
"next_break_at_pm": "Prochaine pause à {} PM"
|
|
||||||
},
|
},
|
||||||
"ui_controls": {
|
"ui_controls": {
|
||||||
"skip": "Annuler",
|
"skip": "Annuler",
|
||||||
|
|
|
@ -19,9 +19,7 @@
|
||||||
"messages": {
|
"messages": {
|
||||||
"ready_for_a_break": "Tervezett szünet {} másodperc múlva!",
|
"ready_for_a_break": "Tervezett szünet {} másodperc múlva!",
|
||||||
"safe_eyes_is_disabled": "Safe Eyes kikapcsolva",
|
"safe_eyes_is_disabled": "Safe Eyes kikapcsolva",
|
||||||
"next_break_at_noon": "A következő szünet {}",
|
"next_break_at": "A következő szünet {}"
|
||||||
"next_break_at_am": "A következő szünet de. {}",
|
|
||||||
"next_break_at_pm": "A következő szünet du. {}"
|
|
||||||
},
|
},
|
||||||
"ui_controls": {
|
"ui_controls": {
|
||||||
"skip": "Átugrás",
|
"skip": "Átugrás",
|
||||||
|
|
|
@ -21,9 +21,7 @@
|
||||||
"messages": {
|
"messages": {
|
||||||
"ready_for_a_break": "Pronto para uma pausa em {} segundos",
|
"ready_for_a_break": "Pronto para uma pausa em {} segundos",
|
||||||
"safe_eyes_is_disabled": "Safe Eyes está desabilitado",
|
"safe_eyes_is_disabled": "Safe Eyes está desabilitado",
|
||||||
"next_break_at_noon": "Próxima pausa em {}",
|
"next_break_at": "Próxima pausa em {}"
|
||||||
"next_break_at_am": "Próxima pausa em {} AM",
|
|
||||||
"next_break_at_pm": "Próxima pausa em {} PM"
|
|
||||||
},
|
},
|
||||||
"ui_controls": {
|
"ui_controls": {
|
||||||
"skip": "Pular",
|
"skip": "Pular",
|
||||||
|
|
|
@ -21,9 +21,7 @@
|
||||||
"messages": {
|
"messages": {
|
||||||
"ready_for_a_break": "Приготовьтесь к перерыву через {} секунд",
|
"ready_for_a_break": "Приготовьтесь к перерыву через {} секунд",
|
||||||
"safe_eyes_is_disabled": "Safe Eyes отключен",
|
"safe_eyes_is_disabled": "Safe Eyes отключен",
|
||||||
"next_break_at_noon": "Следующий перерыв в {}",
|
"next_break_at": "Следующий перерыв в {}"
|
||||||
"next_break_at_am": "Следующий перерыв в {} утра",
|
|
||||||
"next_break_at_pm": "Следующий перерыв в {} вечера"
|
|
||||||
},
|
},
|
||||||
"ui_controls": {
|
"ui_controls": {
|
||||||
"skip": "Пропустить",
|
"skip": "Пропустить",
|
||||||
|
|
|
@ -20,9 +20,7 @@
|
||||||
"messages": {
|
"messages": {
|
||||||
"ready_for_a_break": "Priprav sa na prestávku o {} sekúnd",
|
"ready_for_a_break": "Priprav sa na prestávku o {} sekúnd",
|
||||||
"safe_eyes_is_disabled": "Safe Eyes sú zablokované",
|
"safe_eyes_is_disabled": "Safe Eyes sú zablokované",
|
||||||
"next_break_at_noon": "Ďalšia prestávka o {}",
|
"next_break_at": "Ďalšia prestávka o {}"
|
||||||
"next_break_at_am": "Ďalšia prestávka o {} doobeda",
|
|
||||||
"next_break_at_pm": "Ďalšia prestávka o {} poobede"
|
|
||||||
},
|
},
|
||||||
"ui_controls": {
|
"ui_controls": {
|
||||||
"skip": "Preskočiť",
|
"skip": "Preskočiť",
|
||||||
|
|
|
@ -21,9 +21,7 @@
|
||||||
"messages": {
|
"messages": {
|
||||||
"ready_for_a_break": "{} விநாடிகளில் இடைவேளைக்கு தயாராகுங்கள்",
|
"ready_for_a_break": "{} விநாடிகளில் இடைவேளைக்கு தயாராகுங்கள்",
|
||||||
"safe_eyes_is_disabled": "Safe Eyes நிறுத்தி வைக்கப்பட்டுள்ளது",
|
"safe_eyes_is_disabled": "Safe Eyes நிறுத்தி வைக்கப்பட்டுள்ளது",
|
||||||
"next_break_at_noon": "அடுத்த இடைவேளை {}",
|
"next_break_at": "அடுத்த இடைவேளை {}"
|
||||||
"next_break_at_am": "அடுத்த இடைவேளை {} முற்பகல்",
|
|
||||||
"next_break_at_pm": "அடுத்த இடைவேள {} பிற்பகல்"
|
|
||||||
},
|
},
|
||||||
"ui_controls": {
|
"ui_controls": {
|
||||||
"cancel": "ரத்து",
|
"cancel": "ரத்து",
|
||||||
|
|
Loading…
Reference in New Issue