Move delete brak button to the settings dialog

This commit is contained in:
Gobinath 2018-12-31 18:26:26 -05:00
parent 110745e3d1
commit f1196bb1ea
37 changed files with 465 additions and 63 deletions

View File

@ -8,7 +8,7 @@
Protect your eyes from eye strain using this simple and beautiful, yet extensible break reminder. A Free and Open Source Linux alternative to EyeLeo.
Visit to the official site: http://slgobinath.github.io/SafeEyes/ for more details.
Visit the official site: http://slgobinath.github.io/SafeEyes/ for more details.
## Safe Eyes command-line arguements

View File

@ -155,6 +155,18 @@ msgstr "استراحات قصيرة"
msgid "Long Breaks"
msgstr "استراحات طويلة"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "استراحة"

View File

@ -153,6 +153,18 @@ msgstr ""
msgid "Long Breaks"
msgstr ""
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr ""

View File

@ -157,6 +157,18 @@ msgstr ""
msgid "Long Breaks"
msgstr ""
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr ""

View File

@ -156,6 +156,18 @@ msgstr "Krátké přestávky"
msgid "Long Breaks"
msgstr "Dlouhé přestávky"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Přestávka"

View File

@ -160,6 +160,18 @@ msgstr "Korte pauser"
msgid "Long Breaks"
msgstr "Lange pauser"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Pause"

View File

@ -156,6 +156,18 @@ msgstr "Kurze Pausen"
msgid "Long Breaks"
msgstr "Lange Pausen"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Pause"

View File

@ -157,6 +157,18 @@ msgstr "Short Breaks"
msgid "Long Breaks"
msgstr "Long Breaks"
# Settings dialog
msgid "Delete"
msgstr "Delete"
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr "Are you sure you want to delete this break?"
# Settings dialog
msgid "You can't undo this action."
msgstr "You can't undo this action."
# Settings dialog
msgid "Break"
msgstr "Break"

View File

@ -156,6 +156,18 @@ msgstr "Descansos cortos"
msgid "Long Breaks"
msgstr ""
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr ""

View File

@ -156,6 +156,18 @@ msgstr "Lühikesed pausid"
msgid "Long Breaks"
msgstr "Pikad pausid"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Paus"

View File

@ -156,6 +156,18 @@ msgstr ""
msgid "Long Breaks"
msgstr ""
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr ""

View File

@ -159,6 +159,18 @@ msgstr "Pauses courtes"
msgid "Long Breaks"
msgstr "Pauses longues"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Pause"

View File

@ -154,6 +154,18 @@ msgstr "छोटे अंतराल"
msgid "Long Breaks"
msgstr "लंबे अंतराल"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr ""

View File

@ -154,6 +154,18 @@ msgstr "Rövid Pihenők"
msgid "Long Breaks"
msgstr "Hosszú Pihenők"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Pihenő"

View File

@ -153,6 +153,18 @@ msgstr ""
msgid "Long Breaks"
msgstr ""
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr ""

View File

@ -159,6 +159,18 @@ msgstr "Pause brevi"
msgid "Long Breaks"
msgstr "Pause lunghe"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Pausa"

View File

@ -159,6 +159,18 @@ msgstr "Trumpos pertraukos"
msgid "Long Breaks"
msgstr "Ilgos pertraukos"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Pertrauka"

View File

@ -156,6 +156,18 @@ msgstr ""
msgid "Long Breaks"
msgstr ""
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr ""

View File

@ -8,8 +8,8 @@ msgstr ""
"POT-Creation-Date: \n"
"PO-Revision-Date: 2018-11-01 15:24+0000\n"
"Last-Translator: Allan Nordhøy <epost@anotheragency.no>\n"
"Language-Team: Norwegian Bokmål <https://hosted.weblate.org/projects/"
"safe-eyes/translations/nb/>\n"
"Language-Team: Norwegian Bokmål <https://hosted.weblate.org/projects/safe-"
"eyes/translations/nb/>\n"
"Language: nb\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -154,6 +154,18 @@ msgstr "Korte pauser"
msgid "Long Breaks"
msgstr "Lange pauser"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Pause"

View File

@ -159,6 +159,18 @@ msgstr "Korte pauzes"
msgid "Long Breaks"
msgstr "Lange pauzes"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Pauze"

View File

@ -157,6 +157,18 @@ msgstr "Krótkie Przerwy"
msgid "Long Breaks"
msgstr "Długie Przerwy"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Przerwa"

View File

@ -158,6 +158,18 @@ msgstr "Paradas Curtas"
msgid "Long Breaks"
msgstr "Paradas Longas"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Parada"

View File

@ -155,6 +155,18 @@ msgstr "Короткие перерывы"
msgid "Long Breaks"
msgstr "Длинные перерывы"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Перерыв"

View File

@ -142,6 +142,18 @@ msgstr ""
msgid "Long Breaks"
msgstr ""
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr ""

View File

@ -156,6 +156,18 @@ msgstr "Krátke prestávky"
msgid "Long Breaks"
msgstr "Dlhé prestávky"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Prestávka"

View File

@ -153,6 +153,18 @@ msgstr ""
msgid "Long Breaks"
msgstr ""
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr ""

View File

@ -159,6 +159,18 @@ msgstr "குறுகிய இடைவேளைகள்"
msgid "Long Breaks"
msgstr "நீண்ட இடைவேளைகள்"
# Settings dialog
msgid "Delete"
msgstr "நீக்கு"
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr "இந்த இடைவேளையை நிச்சயமாக நீக்க விரும்புகிறீர்களா?"
# Settings dialog
msgid "You can't undo this action."
msgstr "நீங்கள் பின்னர் இதை மீட்டெடுக்க முடியாது"
# Settings dialog
msgid "Break"
msgstr "இடைவேளை"

View File

@ -157,6 +157,18 @@ msgstr "Kısa Molalar"
msgid "Long Breaks"
msgstr "Uzun Molalar"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Mola"

View File

@ -153,6 +153,18 @@ msgstr ""
msgid "Long Breaks"
msgstr ""
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr ""

View File

@ -14,8 +14,8 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<="
"4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"X-Generator: Weblate 3.3-dev\n"
# Short break
@ -158,6 +158,18 @@ msgstr "Короткі перерви"
msgid "Long Breaks"
msgstr "Довгі перерви"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Перерва"

View File

@ -157,6 +157,18 @@ msgstr "Nghỉ ngơi ngắn"
msgid "Long Breaks"
msgstr "Nghỉ ngơi dài"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "Nghỉ ngơi"

View File

@ -156,6 +156,18 @@ msgstr "短休息"
msgid "Long Breaks"
msgstr "长休息"
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr "休息"

View File

@ -154,6 +154,18 @@ msgstr ""
msgid "Long Breaks"
msgstr ""
# Settings dialog
msgid "Delete"
msgstr ""
# Settings dialog
msgid "Are you sure you want to delete this break?"
msgstr ""
# Settings dialog
msgid "You can't undo this action."
msgstr ""
# Settings dialog
msgid "Break"
msgstr ""

View File

@ -77,8 +77,8 @@
color: white;
}
.btn_properties {
border-radius: 15px;
.btn_break_controls {
border-radius: 25px;
}
.lbl_plugin_name {

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<!--
~ Safe Eyes is a utility to remind you to take break frequently
~ to protect your eyes from eye strain.
@ -21,6 +21,16 @@
-->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkImage" id="img_properties">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-properties</property>
</object>
<object class="GtkImage" id="img_delete">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-delete</property>
</object>
<object class="GtkBox" id="box">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -28,6 +38,7 @@
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="lbl_name">
<property name="visible">True</property>
@ -52,7 +63,7 @@
<property name="image">img_properties</property>
<property name="always_show_image">True</property>
<style>
<class name="btn_properties"/>
<class name="btn_break_controls"/>
</style>
</object>
<packing>
@ -61,10 +72,24 @@
<property name="position">1</property>
</packing>
</child>
</object>
<object class="GtkImage" id="img_properties">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-properties</property>
<child>
<object class="GtkButton" id="btn_delete">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="image">img_delete</property>
<property name="always_show_image">True</property>
<style>
<class name="btn_break_controls"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</interface>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<!--
~ Safe Eyes is a utility to remind you to take break frequently
~ to protect your eyes from eye strain.
@ -447,33 +447,6 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButtonBox" id="buttonbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="baseline_position">top</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="btn_remove">
<property name="label">Remove</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="remove_break" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
</object>

View File

@ -42,6 +42,7 @@ class SettingsDialog(object):
"""
Create and initialize SettingsDialog instance.
"""
def __init__(self, config, on_save_settings):
self.config = config
self.on_save_settings = on_save_settings
@ -118,16 +119,48 @@ class SettingsDialog(object):
break_config,
is_short,
self.config,
lambda: parent_box.remove(box),
lambda cfg: lbl_name.set_label(_(cfg['name'])),
lambda is_short,
break_config: self.__create_break_item(break_config, is_short)
)
)
btn_delete = builder.get_object('btn_delete')
btn_delete.connect(
'clicked',
lambda button: self.__delete_break(
break_config,
is_short,
lambda: parent_box.remove(box),
)
)
box.set_visible(True)
parent_box.pack_start(box, False, False, 0)
return box
def __delete_break(self, break_config, is_short, on_remove):
"""
Remove the break after a confirmation.
"""
def __confirmation_dialog_response(widget, response_id):
if response_id == Gtk.ResponseType.OK:
if is_short:
self.config.get('short_breaks').remove(break_config)
else:
self.config.get('long_breaks').remove(break_config)
on_remove()
widget.destroy()
messagedialog = Gtk.MessageDialog(parent=self.window,
flags=Gtk.DialogFlags.MODAL,
type=Gtk.MessageType.WARNING,
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
_("Delete"), Gtk.ResponseType.OK),
message_format=_("Are you sure you want to delete this break?"))
messagedialog.connect("response", __confirmation_dialog_response)
messagedialog.format_secondary_text(_("You can't undo this action."))
messagedialog.show()
def __create_plugin_item(self, plugin_config):
"""
Create an entry for plugin to be listed in the plugin tab.
@ -167,11 +200,11 @@ class SettingsDialog(object):
dialog = PluginSettingsDialog(plugin_config)
dialog.show()
def __show_break_properties_dialog(self, break_config, is_short, parent, on_remove, on_close, on_add):
def __show_break_properties_dialog(self, break_config, is_short, parent, on_close, on_add):
"""
Show the BreakProperties dialog
"""
dialog = BreakSettingsDialog(break_config, is_short, parent, self.plugin_map, on_remove, on_close, on_add)
dialog = BreakSettingsDialog(break_config, is_short, parent, self.plugin_map, on_close, on_add)
dialog.show()
def show(self):
@ -257,6 +290,7 @@ class PluginSettingsDialog(object):
"""
Builds a settings dialog based on the configuration of a plugin.
"""
def __init__(self, config):
self.config = config
self.property_controls = []
@ -333,11 +367,11 @@ class BreakSettingsDialog(object):
"""
Builds a settings dialog based on the configuration of a plugin.
"""
def __init__(self, break_config, is_short, parent_config, plugin_map, on_remove, on_close, on_add):
def __init__(self, break_config, is_short, parent_config, plugin_map, on_close, on_add):
self.break_config = break_config
self.parent_config = parent_config
self.plugin_check_buttons = {}
self.on_remove = on_remove
self.on_close = on_close
self.is_short = is_short
self.on_add = on_add
@ -351,9 +385,6 @@ class BreakSettingsDialog(object):
self.spin_duration = builder.get_object('spin_duration')
self.img_break = builder.get_object('img_break')
self.cmb_type = builder.get_object('cmb_type')
# User cannot remove the last break
not_last_break = (len(parent_config.get('short_breaks')) + len(parent_config.get('long_breaks'))) > 1
builder.get_object('btn_remove').set_sensitive(not_last_break)
grid_plugins = builder.get_object('grid_plugins')
list_types = builder.get_object('lst_break_types')
@ -415,8 +446,7 @@ class BreakSettingsDialog(object):
"""
Show a file chooser dialog and let the user to select an image.
"""
dialog = Gtk.FileChooserDialog(_('Please select an image'), self.window, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
dialog = Gtk.FileChooserDialog(_('Please select an image'), self.window, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
png_filter = Gtk.FileFilter()
png_filter.set_name("PNG files")
@ -435,17 +465,6 @@ class BreakSettingsDialog(object):
dialog.destroy()
def remove_break(self, button):
"""
Remove the break
"""
if self.is_short:
self.parent_config.get('short_breaks').remove(self.break_config)
else:
self.parent_config.get('long_breaks').remove(self.break_config)
self.on_remove()
self.window.destroy()
def on_window_delete(self, *args):
"""
Event handler for Properties dialog close action.
@ -493,6 +512,7 @@ class NewBreakDialog(object):
"""
Builds a new break dialog.
"""
def __init__(self, parent_config, on_add):
self.parent_config = parent_config
self.on_add = on_add