[gnome-clocks] Same semplification for the new world clock



commit 78b880236e23ddf66c5c20e4df38aa0eb6ec33d1
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Aug 19 19:19:18 2012 +0200

    Same semplification for the new world clock

 gnomeclocks/clocks.py  |   15 ++++++---------
 gnomeclocks/widgets.py |   16 ++++------------
 2 files changed, 10 insertions(+), 21 deletions(-)
---
diff --git a/gnomeclocks/clocks.py b/gnomeclocks/clocks.py
index 46fa517..a1a44dc 100644
--- a/gnomeclocks/clocks.py
+++ b/gnomeclocks/clocks.py
@@ -70,9 +70,6 @@ class Clock(Gtk.EventBox):
     def open_new_dialog(self):
         pass
 
-    def close_new_dialog(self):
-        pass
-
     def add_new_clock(self):
         pass
 
@@ -176,14 +173,14 @@ class World(Clock):
     def open_new_dialog(self):
         parent = self.get_parent().get_parent().get_parent()
         window = NewWorldClockDialog(parent)
-        #window.get_children()[0].pack_start(widget, False, False, 0)
-        window.connect("add-clock", lambda w, l: self.add_clock(l))
+        window.connect("response", self.on_dialog_response)
         window.show_all()
 
-    def close_new_dialog(self):
-        self.notebook.set_current_page(0)
-        self.addButton.set_sensitive(False)
-        self.emit('show-requested')
+    def on_dialog_response(self, dialog, response):
+        if response == 1:
+            l = dialog.get_location()
+            self.add_clock(l)
+        dialog.destroy()
 
 
 class Alarm(Clock):
diff --git a/gnomeclocks/widgets.py b/gnomeclocks/widgets.py
index 804456d..d48f9e2 100644
--- a/gnomeclocks/widgets.py
+++ b/gnomeclocks/widgets.py
@@ -34,10 +34,6 @@ def get_is_day(hour):
 
 
 class NewWorldClockDialog(Gtk.Dialog):
-
-    __gsignals__ = {'add-clock': (GObject.SignalFlags.RUN_LAST,
-                    None, (GObject.TYPE_PYOBJECT, ))}
-
     def __init__(self, parent):
         Gtk.Dialog.__init__(self, _("Add a New World Clock"), parent)
         self.set_transient_for(parent)
@@ -73,16 +69,12 @@ class NewWorldClockDialog(Gtk.Dialog):
         self.searchEntry.connect("activate", self._set_city)
         self.searchEntry.connect("changed", self._set_city)
         self.searchEntry.connect("icon-release", self._icon_released)
-        self.connect("response", self._on_response_clicked)
         self.location = None
         self.show_all()
 
-    def _on_response_clicked(self, widget, response_id):
-        if response_id == 1:
-            location = self.searchEntry.get_location()
-            location = Location(location)
-            self.emit("add-clock", location)
-        self.destroy()
+    def get_location(self):
+        location = self.searchEntry.get_location()
+        return Location(location)
 
     def _set_city(self, widget):
         location = self.searchEntry.get_location()
@@ -108,6 +100,7 @@ class NewWorldClockDialog(Gtk.Dialog):
               Gtk.EntryIconPosition.SECONDARY, self.find_gicon)
             self.set_response_sensitive(1, False)
 
+
 class DigitalClock():
     def __init__(self, location):
         self.location = location.location
@@ -403,7 +396,6 @@ class AlarmWidget():
 
 
 class AlarmDialog(Gtk.Dialog):
-
     def __init__(self, alarm_view, parent, vevent=None):
         if vevent:
             Gtk.Dialog.__init__(self, _("Edit Alarm"), parent)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]