[gnome-clocks] Move around code a bit



commit 5ddf461f22331353c1879fc26464b685b215583b
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Nov 18 11:02:58 2012 +0100

    Move around code a bit
    
    Put the "Clock" subclass last in the file also in alarms and world for
    consistency

 gnomeclocks/alarm.py |  200 +++++++++++++++++++++++++-------------------------
 gnomeclocks/world.py |  188 +++++++++++++++++++++++-----------------------
 2 files changed, 194 insertions(+), 194 deletions(-)
---
diff --git a/gnomeclocks/alarm.py b/gnomeclocks/alarm.py
index b1d060c..51e26a4 100644
--- a/gnomeclocks/alarm.py
+++ b/gnomeclocks/alarm.py
@@ -315,6 +315,106 @@ class AlarmWidget():
         return self.standalone
 
 
+class StandaloneAlarm(Gtk.EventBox):
+    def __init__(self, view, alarm, alert):
+        Gtk.EventBox.__init__(self)
+        self.get_style_context().add_class('view')
+        self.get_style_context().add_class('content-view')
+        self.view = view
+        self.alarm = alarm
+        self.alert = alert
+        self.can_edit = True
+
+        self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
+        self.add(self.vbox)
+
+        time_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
+
+        self.alarm_label = Gtk.Label()
+        self.alarm_label.set_alignment(0.5, 0.5)
+        time_box.pack_start(self.alarm_label, True, True, 0)
+
+        self.repeat_label = Gtk.Label()
+        self.repeat_label.set_alignment(0.5, 0.5)
+        time_box.pack_start(self.repeat_label, True, True, 0)
+
+        self.buttons = Gtk.Box()
+        self.left_button = Gtk.Button()
+        self.left_button.get_style_context().add_class("clocks-stop")
+        self.left_button.set_size_request(200, -1)
+        self.left_label = Gtk.Label()
+        self.left_button.add(self.left_label)
+        self.right_button = Gtk.Button()
+        self.right_button.set_size_request(200, -1)
+        self.right_label = Gtk.Label()
+        self.right_button.add(self.right_label)
+
+        self.buttons.pack_start(self.left_button, True, True, 0)
+        self.buttons.pack_start(Gtk.Box(), True, True, 24)
+        self.buttons.pack_start(self.right_button, True, True, 0)
+
+        self.left_label.set_markup("<span font_desc=\"18.0\">%s</span>" % (_("Stop")))
+        self.left_label.set_padding(6, 0)
+        self.right_label.set_markup("<span font_desc=\"18.0\">%s</span>" % (_("Snooze")))
+        self.right_label.set_padding(6, 0)
+
+        self.left_button.connect('clicked', self._on_stop_clicked)
+        self.right_button.connect('clicked', self._on_snooze_clicked)
+
+        time_box.pack_start(self.buttons, True, True, 48)
+
+        hbox = Gtk.Box()
+        hbox.set_homogeneous(False)
+
+        hbox.pack_start(Gtk.Label(), True, True, 0)
+        hbox.pack_start(time_box, False, False, 0)
+        hbox.pack_start(Gtk.Label(), True, True, 0)
+
+        self.vbox.pack_start(Gtk.Label(), True, True, 0)
+        self.vbox.pack_start(hbox, False, False, 0)
+        self.vbox.pack_start(Gtk.Label(), True, True, 0)
+
+        self.update()
+
+        self.show_all()
+        self.set_ringing(False)
+
+    def _on_stop_clicked(self, button):
+        self.alarm.stop()
+        self.alert.stop()
+
+    def _on_snooze_clicked(self, button):
+        self.alarm.snooze()
+        self.alert.stop()
+
+    def get_name(self):
+        name = self.alarm.name
+        return GLib.markup_escape_text(name)
+
+    def set_ringing(self, show):
+        self.buttons.set_visible(show)
+
+    def update(self):
+        timestr = self.alarm.get_time_as_string()
+        repeat = self.alarm.get_alarm_repeat_string()
+        self.alarm_label.set_markup(
+            "<span size='72000' color='dimgray'><b>%s</b></span>" % timestr)
+        self.repeat_label.set_markup(
+            "<span size='large' color='dimgray'><b>%s</b></span>" % repeat)
+
+    def open_edit_dialog(self):
+        window = AlarmDialog(self.get_toplevel(), self.alarm)
+        window.connect("response", self._on_dialog_response)
+        window.show_all()
+
+    def _on_dialog_response(self, dialog, response):
+        if response == 1:
+            new_alarm = dialog.get_alarm_item()
+            self.alarm = self.view.update_alarm(self.alarm, new_alarm)
+            self.update()
+        dialog.destroy()
+
+
 class Alarm(Clock):
     def __init__(self):
         # Translators: "New" refers to an alarm
@@ -435,103 +535,3 @@ class Alarm(Clock):
             alarm = dialog.get_alarm_item()
             self.add_alarm(alarm)
         dialog.destroy()
-
-
-class StandaloneAlarm(Gtk.EventBox):
-    def __init__(self, view, alarm, alert):
-        Gtk.EventBox.__init__(self)
-        self.get_style_context().add_class('view')
-        self.get_style_context().add_class('content-view')
-        self.view = view
-        self.alarm = alarm
-        self.alert = alert
-        self.can_edit = True
-
-        self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
-        self.add(self.vbox)
-
-        time_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
-
-        self.alarm_label = Gtk.Label()
-        self.alarm_label.set_alignment(0.5, 0.5)
-        time_box.pack_start(self.alarm_label, True, True, 0)
-
-        self.repeat_label = Gtk.Label()
-        self.repeat_label.set_alignment(0.5, 0.5)
-        time_box.pack_start(self.repeat_label, True, True, 0)
-
-        self.buttons = Gtk.Box()
-        self.left_button = Gtk.Button()
-        self.left_button.get_style_context().add_class("clocks-stop")
-        self.left_button.set_size_request(200, -1)
-        self.left_label = Gtk.Label()
-        self.left_button.add(self.left_label)
-        self.right_button = Gtk.Button()
-        self.right_button.set_size_request(200, -1)
-        self.right_label = Gtk.Label()
-        self.right_button.add(self.right_label)
-
-        self.buttons.pack_start(self.left_button, True, True, 0)
-        self.buttons.pack_start(Gtk.Box(), True, True, 24)
-        self.buttons.pack_start(self.right_button, True, True, 0)
-
-        self.left_label.set_markup("<span font_desc=\"18.0\">%s</span>" % (_("Stop")))
-        self.left_label.set_padding(6, 0)
-        self.right_label.set_markup("<span font_desc=\"18.0\">%s</span>" % (_("Snooze")))
-        self.right_label.set_padding(6, 0)
-
-        self.left_button.connect('clicked', self._on_stop_clicked)
-        self.right_button.connect('clicked', self._on_snooze_clicked)
-
-        time_box.pack_start(self.buttons, True, True, 48)
-
-        hbox = Gtk.Box()
-        hbox.set_homogeneous(False)
-
-        hbox.pack_start(Gtk.Label(), True, True, 0)
-        hbox.pack_start(time_box, False, False, 0)
-        hbox.pack_start(Gtk.Label(), True, True, 0)
-
-        self.vbox.pack_start(Gtk.Label(), True, True, 0)
-        self.vbox.pack_start(hbox, False, False, 0)
-        self.vbox.pack_start(Gtk.Label(), True, True, 0)
-
-        self.update()
-
-        self.show_all()
-        self.set_ringing(False)
-
-    def _on_stop_clicked(self, button):
-        self.alarm.stop()
-        self.alert.stop()
-
-    def _on_snooze_clicked(self, button):
-        self.alarm.snooze()
-        self.alert.stop()
-
-    def get_name(self):
-        name = self.alarm.name
-        return GLib.markup_escape_text(name)
-
-    def set_ringing(self, show):
-        self.buttons.set_visible(show)
-
-    def update(self):
-        timestr = self.alarm.get_time_as_string()
-        repeat = self.alarm.get_alarm_repeat_string()
-        self.alarm_label.set_markup(
-            "<span size='72000' color='dimgray'><b>%s</b></span>" % timestr)
-        self.repeat_label.set_markup(
-            "<span size='large' color='dimgray'><b>%s</b></span>" % repeat)
-
-    def open_edit_dialog(self):
-        window = AlarmDialog(self.get_toplevel(), self.alarm)
-        window.connect("response", self._on_dialog_response)
-        window.show_all()
-
-    def _on_dialog_response(self, dialog, response):
-        if response == 1:
-            new_alarm = dialog.get_alarm_item()
-            self.alarm = self.view.update_alarm(self.alarm, new_alarm)
-            self.update()
-        dialog.destroy()
diff --git a/gnomeclocks/world.py b/gnomeclocks/world.py
index 730cf10..71d87da 100644
--- a/gnomeclocks/world.py
+++ b/gnomeclocks/world.py
@@ -258,6 +258,100 @@ class DigitalClock():
         self.list_store = list_store
 
 
+class StandaloneClock(Gtk.EventBox):
+    def __init__(self, location, sunrise, sunset):
+        Gtk.EventBox.__init__(self)
+        self.get_style_context().add_class('view')
+        self.get_style_context().add_class('content-view')
+        self.location = location
+        self.can_edit = False
+        self.time_label = Gtk.Label()
+        self.sunrise = sunrise
+        self.sunset = sunset
+
+        self.clock_format = None
+
+        self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
+        self.add(self.vbox)
+
+        time_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
+        self.time_label.set_alignment(0.0, 0.5)
+        time_box.pack_start(self.time_label, True, True, 0)
+
+        self.hbox = hbox = Gtk.Box()
+        self.hbox.set_homogeneous(False)
+
+        self.hbox.pack_start(Gtk.Label(), True, True, 0)
+        self.hbox.pack_start(time_box, False, False, 0)
+        self.hbox.pack_start(Gtk.Label(), True, True, 0)
+
+        self.vbox.pack_start(Gtk.Label(), True, True, 25)
+        self.vbox.pack_start(hbox, False, False, 0)
+        self.vbox.pack_start(Gtk.Label(), True, True, 0)
+
+        sunrise_label = Gtk.Label()
+        sunrise_label.set_markup(
+            "<span size ='large' color='dimgray'>%s</span>" % (_("Sunrise")))
+        sunrise_label.set_alignment(1.0, 0.5)
+        self.sunrise_time_label = Gtk.Label()
+        self.sunrise_time_label.set_alignment(0.0, 0.5)
+        sunrise_hbox = Gtk.Box(True, 9)
+        sunrise_hbox.pack_start(sunrise_label, False, False, 0)
+        sunrise_hbox.pack_start(self.sunrise_time_label, False, False, 0)
+
+        sunset_label = Gtk.Label()
+        sunset_label.set_markup(
+            "<span size ='large' color='dimgray'>%s</span>" % (_("Sunset")))
+        sunset_label.set_alignment(1.0, 0.5)
+        self.sunset_time_label = Gtk.Label()
+        self.sunset_time_label.set_alignment(0.0, 0.5)
+        sunset_hbox = Gtk.Box(True, 9)
+        sunset_hbox.pack_start(sunset_label, False, False, 0)
+        sunset_hbox.pack_start(self.sunset_time_label, False, False, 0)
+
+        sunbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
+        sunbox.set_homogeneous(True)
+        sunbox.set_spacing(3)
+        sunbox.pack_start(sunrise_hbox, False, False, 3)
+        sunbox.pack_start(sunset_hbox, False, False, 3)
+
+        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
+        hbox.pack_start(Gtk.Label(), True, True, 0)
+        hbox.pack_start(sunbox, False, False, 0)
+        hbox.pack_start(Gtk.Label(), True, True, 0)
+        self.vbox.pack_end(hbox, False, False, 30)
+
+        self.show_all()
+
+    def get_name(self):
+        return GLib.markup_escape_text(self.location.get_city_name())
+
+    def update(self, img, text, sunrise, sunset):
+        size = 72000  # FIXME: (self.get_allocation().height / 300) * 72000
+        self.time_label.set_markup(
+            "<span size='%i' color='dimgray'><b>%s</b></span>" % (size, text))
+        clock_format = SystemSettings.get_clock_format()
+        if clock_format != self.clock_format or \
+                sunrise != self.sunrise or sunset != self.sunset:
+            self.sunrise = sunrise
+            self.sunset = sunset
+            if clock_format == "12h":
+                sunrise_str = time.strftime("%I:%M %p", sunrise)
+                sunset_str = time.strftime("%I:%M %p", sunset)
+            else:
+                sunrise_str = time.strftime("%H:%M", sunrise)
+                sunset_str = time.strftime("%H:%M", sunset)
+            if sunrise_str.startswith("0"):
+                sunrise_str = sunrise_str[1:]
+            if sunset_str.startswith("0"):
+                sunset_str = sunset_str[1:]
+            self.sunrise_time_label.set_markup(
+                "<span size ='large'>%s</span>" % sunrise_str)
+            self.sunset_time_label.set_markup(
+                "<span size ='large'>%s</span>" % sunset_str)
+        self.clock_format = clock_format
+
+
 class World(Clock):
     def __init__(self):
         # Translators: "New" refers to a world clock
@@ -360,97 +454,3 @@ class World(Clock):
             l = dialog.get_location()
             self.add_clock(l)
         dialog.destroy()
-
-
-class StandaloneClock(Gtk.EventBox):
-    def __init__(self, location, sunrise, sunset):
-        Gtk.EventBox.__init__(self)
-        self.get_style_context().add_class('view')
-        self.get_style_context().add_class('content-view')
-        self.location = location
-        self.can_edit = False
-        self.time_label = Gtk.Label()
-        self.sunrise = sunrise
-        self.sunset = sunset
-
-        self.clock_format = None
-
-        self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
-        self.add(self.vbox)
-
-        time_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
-        self.time_label.set_alignment(0.0, 0.5)
-        time_box.pack_start(self.time_label, True, True, 0)
-
-        self.hbox = hbox = Gtk.Box()
-        self.hbox.set_homogeneous(False)
-
-        self.hbox.pack_start(Gtk.Label(), True, True, 0)
-        self.hbox.pack_start(time_box, False, False, 0)
-        self.hbox.pack_start(Gtk.Label(), True, True, 0)
-
-        self.vbox.pack_start(Gtk.Label(), True, True, 25)
-        self.vbox.pack_start(hbox, False, False, 0)
-        self.vbox.pack_start(Gtk.Label(), True, True, 0)
-
-        sunrise_label = Gtk.Label()
-        sunrise_label.set_markup(
-            "<span size ='large' color='dimgray'>%s</span>" % (_("Sunrise")))
-        sunrise_label.set_alignment(1.0, 0.5)
-        self.sunrise_time_label = Gtk.Label()
-        self.sunrise_time_label.set_alignment(0.0, 0.5)
-        sunrise_hbox = Gtk.Box(True, 9)
-        sunrise_hbox.pack_start(sunrise_label, False, False, 0)
-        sunrise_hbox.pack_start(self.sunrise_time_label, False, False, 0)
-
-        sunset_label = Gtk.Label()
-        sunset_label.set_markup(
-            "<span size ='large' color='dimgray'>%s</span>" % (_("Sunset")))
-        sunset_label.set_alignment(1.0, 0.5)
-        self.sunset_time_label = Gtk.Label()
-        self.sunset_time_label.set_alignment(0.0, 0.5)
-        sunset_hbox = Gtk.Box(True, 9)
-        sunset_hbox.pack_start(sunset_label, False, False, 0)
-        sunset_hbox.pack_start(self.sunset_time_label, False, False, 0)
-
-        sunbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
-        sunbox.set_homogeneous(True)
-        sunbox.set_spacing(3)
-        sunbox.pack_start(sunrise_hbox, False, False, 3)
-        sunbox.pack_start(sunset_hbox, False, False, 3)
-
-        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
-        hbox.pack_start(Gtk.Label(), True, True, 0)
-        hbox.pack_start(sunbox, False, False, 0)
-        hbox.pack_start(Gtk.Label(), True, True, 0)
-        self.vbox.pack_end(hbox, False, False, 30)
-
-        self.show_all()
-
-    def get_name(self):
-        return GLib.markup_escape_text(self.location.get_city_name())
-
-    def update(self, img, text, sunrise, sunset):
-        size = 72000  # FIXME: (self.get_allocation().height / 300) * 72000
-        self.time_label.set_markup(
-            "<span size='%i' color='dimgray'><b>%s</b></span>" % (size, text))
-        clock_format = SystemSettings.get_clock_format()
-        if clock_format != self.clock_format or \
-                sunrise != self.sunrise or sunset != self.sunset:
-            self.sunrise = sunrise
-            self.sunset = sunset
-            if clock_format == "12h":
-                sunrise_str = time.strftime("%I:%M %p", sunrise)
-                sunset_str = time.strftime("%I:%M %p", sunset)
-            else:
-                sunrise_str = time.strftime("%H:%M", sunrise)
-                sunset_str = time.strftime("%H:%M", sunset)
-            if sunrise_str.startswith("0"):
-                sunrise_str = sunrise_str[1:]
-            if sunset_str.startswith("0"):
-                sunset_str = sunset_str[1:]
-            self.sunrise_time_label.set_markup(
-                "<span size ='large'>%s</span>" % sunrise_str)
-            self.sunset_time_label.set_markup(
-                "<span size ='large'>%s</span>" % sunset_str)
-        self.clock_format = clock_format



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