[gnome-clocks] Simplify the logic of the AlarmDialog response
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Simplify the logic of the AlarmDialog response
- Date: Sun, 19 Aug 2012 17:14:02 +0000 (UTC)
commit 1c821458bb8d203e14d0276e5c3b30af72baf494
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Aug 19 19:11:38 2012 +0200
Simplify the logic of the AlarmDialog response
No need to invent a signal, we have "response" for this reason. Also
make clear that "edit" is not yet implemented
gnomeclocks/clocks.py | 16 ++++++++++++----
gnomeclocks/widgets.py | 41 +++++++++++++++--------------------------
2 files changed, 27 insertions(+), 30 deletions(-)
---
diff --git a/gnomeclocks/clocks.py b/gnomeclocks/clocks.py
index 6752b7e..46fa517 100644
--- a/gnomeclocks/clocks.py
+++ b/gnomeclocks/clocks.py
@@ -271,21 +271,29 @@ class Alarm(Clock):
alarm.get_vevent()])
widget.set_iter(self.liststore, view_iter)
- def edit_alarm(self, vevent):
- pass
+ def edit_alarm(self, alarm):
+ print "To Do!"
def open_new_dialog(self):
parent = self.get_parent().get_parent().get_parent()
window = AlarmDialog(self, parent)
- window.connect("add-alarm", lambda w, l: self.add_alarm(l))
+ window.connect("response", self.on_dialog_response, True)
window.show_all()
def open_edit_dialog(self, vevent):
parent = self.get_parent().get_parent().get_parent()
window = AlarmDialog(self, parent, vevent)
- window.connect("edit-alarm", lambda w, l: self.edit_alarm(l))
+ window.connect("response", self.on_dialog_response, False)
window.show_all()
+ def on_dialog_response(self, dialog, response, isNew):
+ if response == 1:
+ alarm = dialog.get_alarm_item()
+ if (isNew):
+ self.add_alarm(alarm)
+ else:
+ self.edit_alarm(alarm)
+ dialog.destroy()
class Stopwatch(Clock):
diff --git a/gnomeclocks/widgets.py b/gnomeclocks/widgets.py
index 4ece010..804456d 100644
--- a/gnomeclocks/widgets.py
+++ b/gnomeclocks/widgets.py
@@ -404,11 +404,6 @@ class AlarmWidget():
class AlarmDialog(Gtk.Dialog):
- __gsignals__ = {'add-alarm': (GObject.SignalFlags.RUN_LAST,
- None, (GObject.TYPE_PYOBJECT, )),
- 'edit-alarm': (GObject.SignalFlags.RUN_LAST,
- None, (GObject.TYPE_PYOBJECT, ))}
-
def __init__(self, alarm_view, parent, vevent=None):
if vevent:
Gtk.Dialog.__init__(self, _("Edit Alarm"), parent)
@@ -431,7 +426,6 @@ class AlarmDialog(Gtk.Dialog):
content_area = self.get_content_area()
content_area.pack_start(table1, True, True, 0)
self.add_buttons(_("Cancel"), 0, _("Save"), 1)
- self.connect("response", self.on_response)
if vevent:
t = vevent.dtstart.value
@@ -537,28 +531,23 @@ class AlarmDialog(Gtk.Dialog):
repeat = days.split(",")
return repeat
- def on_response(self, widget, id):
- if id == 1:
- name = self.entry.get_text()
- h = self.hourselect.get_value_as_int()
- m = self.minuteselect.get_value_as_int()
- if self.cf == "12h":
- r = self.ampm.get_active()
- if r == 0:
- p = "AM"
- else:
- p = "PM"
+ def get_alarm_item(self):
+ name = self.entry.get_text()
+ h = self.hourselect.get_value_as_int()
+ m = self.minuteselect.get_value_as_int()
+ if self.cf == "12h":
+ r = self.ampm.get_active()
+ if r == 0:
+ p = "AM"
else:
- p = None
- repeat = []
- for btn in self.day_buttons:
- if btn.get_active():
- repeat.append(btn.get_label()[:2])
- new_alarm = AlarmItem(name, repeat, h, m, p)
- self.emit('add-alarm', new_alarm)
- self.destroy()
+ p = "PM"
else:
- self.destroy()
+ p = None
+ repeat = []
+ for btn in self.day_buttons:
+ if btn.get_active():
+ repeat.append(btn.get_label()[:2])
+ return AlarmItem(name, repeat, h, m, p)
class EmptyPlaceholder(Gtk.Box):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]