Add about dialog

This commit is contained in:
Gobinath 2016-12-26 05:59:30 +05:30
parent 8fda223316
commit 177605d9bf
10 changed files with 335 additions and 68 deletions

View File

@ -0,0 +1,38 @@
# Safe Eyes is a utility to remind you to take break frequently
# to protect your eyes from eye strain.
# Copyright (C) 2016 Gobinath
# 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/>.
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GdkX11
class AboutDialog:
def __init__(self, glade_file, version):
builder = Gtk.Builder()
builder.add_from_file(glade_file)
builder.connect_signals(self)
self.window = builder.get_object("window_about")
builder.get_object("lbl_app_name").set_label("Safe Eyes " + version)
def show(self):
self.window.show_all()
def on_window_delete(self, *args):
self.window.destroy()
def on_close_clicked(self, button):
self.window.destroy()

View File

@ -28,9 +28,10 @@ active = True
APPINDICATOR_ID = 'safeeyes'
class TrayIcon:
def __init__(self, language, on_show_settings, 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")
self.on_show_settings = on_show_settings;
self.on_show_settings = on_show_settings
self.on_show_about = on_show_about
self.on_quite = on_quite
self.on_enable = on_enable
self.on_disable = on_disable
@ -58,6 +59,9 @@ class TrayIcon:
item_settings = Gtk.MenuItem(self.language['ui_controls']['settings'])
item_settings.connect('activate', self.show_settings)
item_about = Gtk.MenuItem(self.language['ui_controls']['about'])
item_about.connect('activate', self.show_about)
item_quit = Gtk.MenuItem(self.language['ui_controls']['quit'])
item_quit.connect('activate', self.quit_safe_eyes)
@ -65,6 +69,7 @@ class TrayIcon:
self.menu.append(self.item_separator)
self.menu.append(self.item_enable)
self.menu.append(item_settings)
self.menu.append(item_about)
self.menu.append(item_quit)
self.menu.show_all()
@ -82,6 +87,9 @@ class TrayIcon:
def show_settings(self, *args):
self.on_show_settings()
def show_about(self, *args):
self.on_show_about()
def next_break_time(self, dateTime):
logging.info("Update next break information")
timeStr = dateTime.strftime("%l:%M")

View File

@ -18,24 +18,25 @@
]
},
"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ázaná",
"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"
},
"ui_controls": {
"skip": "Přeskočit",
"short_break_duration": "Trvání krátké přestávky (v sekundách)",
"long_break_duration": "Trvání dlouhé přestávky (v sekundách)",
"interval_between_two_breaks": "Interval mezi dvěma přestávkami",
"no_of_short_breaks_between_two_long_breaks": "Počet krátkých přestávek mezi dvěma dlouhými přestávkami",
"time_to_prepare_for_break": "Čas k přípravě na přestávku (v sekundách)",
"strict_break": "Povinná přestávka (Skryj tlačítko přeskočení)",
"enable": "Povol Safe Eyes",
"settings": "Nastavení",
"quit": "Ukončit",
"save": "Uložit",
"cancel": "Zrušit"
"skip": "Přeskočit",
"short_break_duration": "Trvání krátké přestávky (v sekundách)",
"long_break_duration": "Trvání dlouhé přestávky (v sekundách)",
"interval_between_two_breaks": "Interval mezi dvěma přestávkami",
"no_of_short_breaks_between_two_long_breaks": "Počet krátkých přestávek mezi dvěma dlouhými přestávkami",
"time_to_prepare_for_break": "Čas k přípravě na přestávku (v sekundách)",
"strict_break": "Povinná přestávka (Skryj tlačítko přeskočení)",
"enable": "Povol Safe Eyes",
"settings": "Nastavení",
"about": "O",
"quit": "Ukončit",
"save": "Uložit",
"cancel": "Zrušit"
}
}

View File

@ -18,24 +18,25 @@
]
},
"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",
"next_break_at_noon": "Next break at {}",
"next_break_at_am": "Next break at {} AM",
"next_break_at_pm": "Next break at {} PM"
},
"ui_controls": {
"skip": "Skip",
"short_break_duration": "Short break duration (in seconds)",
"long_break_duration": "Long break duration (in seconds)",
"interval_between_two_breaks": "Interval between two breaks",
"no_of_short_breaks_between_two_long_breaks": "Number of short breaks between two long breaks",
"time_to_prepare_for_break": "Time to prepare for break (in seconds)",
"strict_break": "Strict break (Hide skip button)",
"enable": "Enable Safe Eyes",
"settings": "Settings",
"quit": "Quit",
"save": "Save",
"cancel": "Cancel"
"skip": "Skip",
"short_break_duration": "Short break duration (in seconds)",
"long_break_duration": "Long break duration (in seconds)",
"interval_between_two_breaks": "Interval between two breaks",
"no_of_short_breaks_between_two_long_breaks": "Number of short breaks between two long breaks",
"time_to_prepare_for_break": "Time to prepare for break (in seconds)",
"strict_break": "Strict break (Hide skip button)",
"enable": "Enable Safe Eyes",
"settings": "Settings",
"about": "About",
"quit": "Quit",
"save": "Save",
"cancel": "Cancel"
}
}

View File

@ -17,24 +17,25 @@
]
},
"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",
"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. {}"
},
"ui_controls": {
"skip": "Átugrás",
"short_break_duration": "Rövid szünet hossza (másodpercekben)",
"long_break_duration": "Hosszú szünet hossza (másodpercekben)",
"interval_between_two_breaks": "Két szünet közötti idő",
"no_of_short_breaks_between_two_long_breaks": "Hány rövid szünet legyen a hosszabbak között?",
"time_to_prepare_for_break": "Szünet előtti figyelmeztetés (másodperc)",
"strict_break": "Kötelezők a szünetek? (nincs átugrás gomb)",
"enable": "Safe Eyes Bekapcsolása",
"settings": "Beállítások",
"quit": "Kilépés",
"save": "Mentés",
"cancel": "Mégse"
"skip": "Átugrás",
"short_break_duration": "Rövid szünet hossza (másodpercekben)",
"long_break_duration": "Hosszú szünet hossza (másodpercekben)",
"interval_between_two_breaks": "Két szünet közötti idő",
"no_of_short_breaks_between_two_long_breaks": "Hány rövid szünet legyen a hosszabbak között?",
"time_to_prepare_for_break": "Szünet előtti figyelmeztetés (másodperc)",
"strict_break": "Kötelezők a szünetek? (nincs átugrás gomb)",
"enable": "Safe Eyes Bekapcsolása",
"settings": "Beállítások",
"about": "Ról ről",
"quit": "Kilépés",
"save": "Mentés",
"cancel": "Mégse"
}
}

View File

@ -18,24 +18,25 @@
]
},
"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",
"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"
},
"ui_controls": {
"skip": "Pular",
"short_break_duration": "Duração pausa curta (em segundos)",
"long_break_duration": "Duração pausa longa (em segundos)",
"interval_between_two_breaks": "Intervalo entre duas pausas",
"no_of_short_breaks_between_two_long_breaks": "Número de pausas curtas entre duas pausas longas",
"time_to_prepare_for_break": "Tempo para se preparar para a pausa (em segundos)",
"strict_break": "Pausa rigorosa (Esconder botão pular)",
"enable": "Habilitar Safe Eyes",
"settings": "Configuração",
"quit": "Sair",
"save": "Salvar",
"cancel": "Cancelar"
"skip": "Pular",
"short_break_duration": "Duração pausa curta (em segundos)",
"long_break_duration": "Duração pausa longa (em segundos)",
"interval_between_two_breaks": "Intervalo entre duas pausas",
"no_of_short_breaks_between_two_long_breaks": "Número de pausas curtas entre duas pausas longas",
"time_to_prepare_for_break": "Tempo para se preparar para a pausa (em segundos)",
"strict_break": "Pausa rigorosa (Esconder botão pular)",
"enable": "Habilitar Safe Eyes",
"settings": "Configuração",
"about": "Sobre",
"quit": "Sair",
"save": "Salvar",
"cancel": "Cancelar"
}
}

View File

@ -18,24 +18,25 @@
]
},
"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é",
"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"
},
"ui_controls": {
"skip": "Preskočiť",
"short_break_duration": "Trvanie krátkej prestávky (v sekundách)",
"long_break_duration": "Trvanie dlhej prestávky (v sekundách)",
"interval_between_two_breaks": "Interval medzi dvomi prestávkami",
"no_of_short_breaks_between_two_long_breaks": "Počet krátkych prestávok medzi dvomi dlhými prestávkami",
"time_to_prepare_for_break": "Čas na prípravu na prestávku (v sekundách)",
"strict_break": "Povinná prestávka (Skryje tlačitko Preskočiť)",
"enable": "Povoliť Safe Eyes",
"settings": "Nastavenia",
"quit": "Koniec",
"save": "Uložiť",
"cancel": "Zrušiť"
"skip": "Preskočiť",
"short_break_duration": "Trvanie krátkej prestávky (v sekundách)",
"long_break_duration": "Trvanie dlhej prestávky (v sekundách)",
"interval_between_two_breaks": "Interval medzi dvomi prestávkami",
"no_of_short_breaks_between_two_long_breaks": "Počet krátkych prestávok medzi dvomi dlhými prestávkami",
"time_to_prepare_for_break": "Čas na prípravu na prestávku (v sekundách)",
"strict_break": "Povinná prestávka (Skryje tlačitko Preskočiť)",
"enable": "Povoliť Safe Eyes",
"settings": "Nastavenia",
"about": "Ohľadom",
"quit": "Koniec",
"save": "Uložiť",
"cancel": "Zrušiť"
}
}

View File

@ -31,6 +31,7 @@
"long_break_duration": "நீண்ட கால இடைவேளை (விநாடிகளில்)",
"no_of_short_breaks_between_two_long_breaks": "இரண்டு நீண்ட இடைவேளைகளுக்கிடையிலான குறுகிய இடைவேளைகள்",
"quit": "நிறுத்து",
"about": "Safe Eyes குறித்த தகவல்கள்",
"save": "சேமி",
"settings": "அமைப்பு",
"short_break_duration": "குறுகிய கால இடைவேளை (விநாடிகளில்)",

View File

@ -0,0 +1,204 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!--
~ Safe Eyes is a utility to remind you to take break frequently
~ to protect your eyes from eye strain.
~ Copyright (C) 2016 Gobinath
~ 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/>.
-->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkTextBuffer" id="text_buffer_license">
<property name="text" translatable="yes">Copyright (C) 2016 Gobinath
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 &lt;http://www.gnu.org/licenses/&gt;.</property>
</object>
<object class="GtkWindow" id="window_about">
<property name="height_request">400</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Safe Eyes</property>
<property name="resizable">False</property>
<property name="window_position">center</property>
<property name="default_width">400</property>
<property name="default_height">200</property>
<property name="icon_name">safeeyes</property>
<signal name="delete-event" handler="on_window_delete" swapped="no"/>
<child>
<object class="GtkBox" id="layout_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="lbl_app_name">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_top">10</property>
<property name="margin_bottom">10</property>
<property name="label" translatable="yes">Safe Eyes 1.1.1</property>
<property name="justify">center</property>
<attributes>
<attribute name="style" value="normal"/>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_decription">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">4</property>
<property name="label" translatable="yes">Safe Eyes is an open source Linux alternative for Eye Leo to protect your eyes
from eye strain (asthenopia) by reminding you to take breaks while you're
working long hours at the computer.</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_license">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="margin_top">10</property>
<property name="label" translatable="yes">License:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkTextView" id="txt_license">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="resize_mode">queue</property>
<property name="editable">False</property>
<property name="wrap_mode">word</property>
<property name="buffer">text_buffer_license</property>
<property name="accepts_tab">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="btn_url">
<property name="label" translatable="yes">https://github.com/slgobinath/SafeEyes</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="relief">none</property>
<property name="focus_on_click">False</property>
<property name="uri">https://github.com/slgobinath/SafeEyes</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator" id="separator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButtonBox" id="buttonbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="margin_right">5</property>
<property name="spacing">10</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="btn_close">
<property name="label" translatable="yes">Close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_close_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -31,6 +31,7 @@ from dbus.mainloop.glib import DBusGMainLoop
from BreakScreen import BreakScreen
from TrayIcon import TrayIcon
from SettingsDialog import SettingsDialog
from AboutDialog import AboutDialog
from SafeEyesCore import SafeEyesCore
from Notification import Notification
@ -44,12 +45,14 @@ style_sheet_path = os.path.join(os.path.expanduser('~'), '.config/safeeyes/style
log_file_path = os.path.join(os.path.expanduser('~'), '.config/safeeyes/safeeyes.log')
break_screen_glade = os.path.join(bin_directory, "glade/break_screen.glade")
settings_dialog_glade = os.path.join(bin_directory, "glade/settings_dialog.glade")
about_dialog_glade = os.path.join(bin_directory, "glade/about_dialog.glade")
system_config_file_path = os.path.join(bin_directory, "config/safeeyes.json")
system_style_sheet_path = os.path.join(bin_directory, "config/style/safeeyes_style.css")
system_language_directory = os.path.join(bin_directory, "config/lang")
is_active = True
CONFIGURATION_VERSION = 1
SAFE_EYES_VERSION = "1.1.1"
"""
Listen to tray icon Settings action and send the signal to Settings dialog.
@ -59,6 +62,14 @@ def show_settings():
settings_dialog = SettingsDialog(config, language, save_settings, settings_dialog_glade)
settings_dialog.show()
"""
Listen to tray icon About action and send the signal to About dialog.
"""
def show_about():
logging.info("Show About dialog")
about_dialog = AboutDialog(about_dialog_glade, SAFE_EYES_VERSION)
about_dialog.show()
"""
Receive the signal from core and pass it to the Notification.
"""
@ -250,7 +261,7 @@ def main():
with open(language_file_path) as language_file:
language = json.load(language_file)
tray_icon = TrayIcon(language, show_settings, enable_safeeyes, disable_safeeyes, on_quit)
tray_icon = TrayIcon(language, show_settings, show_about, enable_safeeyes, disable_safeeyes, on_quit)
break_screen = BreakScreen(on_skipped, break_screen_glade, style_sheet_path)
break_screen.initialize(config, language)
core = SafeEyesCore(show_notification, show_alert, close_alert, on_countdown, tray_icon.next_break_time)