Merge pull request #57 from radek-sprta/master

Use local time representation
This commit is contained in:
Gobinath 2017-02-07 10:17:10 -05:00 committed by GitHub
commit 812914c3a7
10 changed files with 104 additions and 118 deletions

View File

@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import gi
import locale
import logging
gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')
@ -27,7 +28,9 @@ from gi.repository import AppIndicator3 as appindicator
active = True
APPINDICATOR_ID = 'safeeyes'
class TrayIcon:
def __init__(self, language, on_show_settings, on_show_about, on_enable, on_disable, on_quite):
logging.info("Initialize the tray icon")
self.on_show_settings = on_show_settings
@ -39,7 +42,8 @@ class TrayIcon:
self.dateTime = None
# 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)
# Construct the context menu
@ -90,17 +94,20 @@ class TrayIcon:
if self.dateTime:
self.set_next_break_info(self.dateTime)
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_settings.set_label(self.language['ui_controls']['settings'])
self.item_about.set_label(self.language['ui_controls']['about'])
self.item_quit.set_label(self.language['ui_controls']['quit'])
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):
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):
self.on_quite()
@ -117,13 +124,9 @@ class TrayIcon:
self.set_next_break_info(self.dateTime)
def set_next_break_info(self, dateTime):
formatted_time = dateTime.strftime("%l:%M")
if dateTime.hour == 12:
message = self.language['messages']['next_break_at_noon'].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)
formatted_time = dateTime.strftime(locale.nl_langinfo(locale.T_FMT))
message = self.language['messages'][
'next_break_at'].format(formatted_time)
GLib.idle_add(lambda: self.item_info.set_label(message))
@ -137,6 +140,7 @@ class TrayIcon:
else:
logging.info("Disable Safe Eyes")
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.on_disable()

View File

@ -21,9 +21,7 @@
"messages": {
"ready_for_a_break": "Připravte se na přestávku za {} sekund",
"safe_eyes_is_disabled": "Safe Eyes je zakázáno",
"next_break_at_noon": "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"
"next_break_at": "Příští přestávka v {}"
},
"ui_controls": {
"skip": "Přeskočit",

View File

@ -21,9 +21,7 @@
"messages": {
"ready_for_a_break": "Ready for a break in {} seconds",
"safe_eyes_is_disabled": "Safe Eyes is disabled",
"next_break_at_noon": "Next break at {}",
"next_break_at_am": "Next break at {} AM",
"next_break_at_pm": "Next break at {} PM"
"next_break_at": "Next break at {}"
},
"ui_controls": {
"skip": "Skip",

View File

@ -21,9 +21,7 @@
"messages": {
"ready_for_a_break": "Listo para una pausa en {} segundos",
"safe_eyes_is_disabled": "Safe Eyes está desactivado",
"next_break_at_noon": "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"
"next_break_at": "Próxima pausa a las {}"
},
"ui_controls": {
"skip": "Cancelar",

View File

@ -20,9 +20,7 @@
"messages": {
"ready_for_a_break": "Prêt pour une pause dans {} secondes",
"safe_eyes_is_disabled": "Safe Eyes est désactivé",
"next_break_at_noon": "Prochaine pause à {}",
"next_break_at_am": "Prochaine pause à {} AM",
"next_break_at_pm": "Prochaine pause à {} PM"
"next_break_at": "Prochaine pause à {}"
},
"ui_controls": {
"skip": "Annuler",

View File

@ -19,9 +19,7 @@
"messages": {
"ready_for_a_break": "Tervezett szünet {} másodperc múlva!",
"safe_eyes_is_disabled": "Safe Eyes kikapcsolva",
"next_break_at_noon": "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. {}"
"next_break_at": "A következő szünet {}"
},
"ui_controls": {
"skip": "Átugrás",

View File

@ -21,9 +21,7 @@
"messages": {
"ready_for_a_break": "Pronto para uma pausa em {} segundos",
"safe_eyes_is_disabled": "Safe Eyes está desabilitado",
"next_break_at_noon": "Próxima pausa em {}",
"next_break_at_am": "Próxima pausa em {} AM",
"next_break_at_pm": "Próxima pausa em {} PM"
"next_break_at": "Próxima pausa em {}"
},
"ui_controls": {
"skip": "Pular",

View File

@ -21,9 +21,7 @@
"messages": {
"ready_for_a_break": "Приготовьтесь к перерыву через {} секунд",
"safe_eyes_is_disabled": "Safe Eyes отключен",
"next_break_at_noon": "Следующий перерыв в {}",
"next_break_at_am": "Следующий перерыв в {} утра",
"next_break_at_pm": "Следующий перерыв в {} вечера"
"next_break_at": "Следующий перерыв в {}"
},
"ui_controls": {
"skip": "Пропустить",

View File

@ -20,9 +20,7 @@
"messages": {
"ready_for_a_break": "Priprav sa na prestávku o {} sekúnd",
"safe_eyes_is_disabled": "Safe Eyes sú zablokované",
"next_break_at_noon": "Ď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"
"next_break_at": "Ďalšia prestávka o {}"
},
"ui_controls": {
"skip": "Preskočiť",

View File

@ -21,9 +21,7 @@
"messages": {
"ready_for_a_break": "{} விநாடிகளில் இடைவேளைக்கு தயாராகுங்கள்",
"safe_eyes_is_disabled": "Safe Eyes நிறுத்தி வைக்கப்பட்டுள்ளது",
"next_break_at_noon": "அடுத்த இடைவேளை {}",
"next_break_at_am": "அடுத்த இடைவேளை {} முற்பகல்",
"next_break_at_pm": "அடுத்த இடைவேள {} பிற்பகல்"
"next_break_at": "அடுத்த இடைவேளை {}"
},
"ui_controls": {
"cancel": "ரத்து",