[gnome-clocks] Factor out a single EmptyPlaceholer widget



commit a7a26c8b933ea20eff219f57de08baab886028ec
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Aug 18 10:46:25 2012 +0200

    Factor out a single EmptyPlaceholer widget
    
    EmptyAlarms and EmptyClocks are the same thing with different parameters

 gnomeclocks/clocks.py  |   11 ++++++++---
 gnomeclocks/widgets.py |   44 ++++++++++----------------------------------
 2 files changed, 18 insertions(+), 37 deletions(-)
---
diff --git a/gnomeclocks/clocks.py b/gnomeclocks/clocks.py
index 5d81f3f..64241c0 100644
--- a/gnomeclocks/clocks.py
+++ b/gnomeclocks/clocks.py
@@ -20,7 +20,7 @@ from gi.repository import Gtk, GObject, Gio, Gst, Notify
 from gi.repository.GdkPixbuf import Pixbuf
 
 from widgets import NewWorldClockDialog, NewAlarmDialog
-from widgets import DigitalClock, AlarmWidget, WorldEmpty, AlarmsEmpty
+from widgets import DigitalClock, AlarmWidget, EmptyPlaceholder
 from storage import worldclockstorage
 
 from timer import TimerWelcomeScreen, TimerScreen
@@ -87,7 +87,9 @@ class World(Clock):
                                                    GObject.TYPE_PYOBJECT)
         self.iconview = iconview = Gtk.IconView.new()
 
-        self.empty_view = WorldEmpty()
+        self.empty_view = EmptyPlaceholder(
+                "document-open-recent-symbolic",
+                 _("Select <b>New</b> to add a world clock"))
 
         iconview.set_model(liststore)
         iconview.set_spacing(3)
@@ -188,7 +190,10 @@ class Alarm(Clock):
                                                   GObject.TYPE_PYOBJECT)
         self.iconview = iconview = Gtk.IconView.new()
 
-        self.empty_view = AlarmsEmpty()
+        self.empty_view = EmptyPlaceholder(
+                "alarm-symbolic",
+                _("Select <b>New</b> to add an alarm"))
+
         iconview.set_model(liststore)
 
         iconview.set_spacing(3)
diff --git a/gnomeclocks/widgets.py b/gnomeclocks/widgets.py
index 316ae34..ced2026 100644
--- a/gnomeclocks/widgets.py
+++ b/gnomeclocks/widgets.py
@@ -27,10 +27,12 @@ import os
 import cairo
 import time
 
+
 # FIXME: Use real sunrise/sunset time in the future
 def get_is_day(hour):
     return (hour > 7 and hour < 19)
 
+
 class NewWorldClockDialog(Gtk.Dialog):
 
     __gsignals__ = {'add-clock': (GObject.SignalFlags.RUN_LAST,
@@ -613,44 +615,18 @@ class NewAlarmDialog(Gtk.Dialog):
             self.repeat_days.remove('SU')
 
 
-class WorldEmpty(Gtk.Box):
-    def __init__(self):
+class EmptyPlaceholder(Gtk.Box):
+    def __init__(self, icon, message):
         Gtk.Box.__init__(self)
         self.set_orientation(Gtk.Orientation.VERTICAL)
-        gicon = Gio.ThemedIcon.new_with_default_fallbacks(
-            "document-open-recent-symbolic")
+        gicon = Gio.ThemedIcon.new_with_default_fallbacks(icon)
         image = Gtk.Image.new_from_gicon(gicon, Gtk.IconSize.DIALOG)
         image.set_sensitive(False)
-        text = Gtk.Label("")
-        text.set_markup("<span color='darkgrey'>" + _(
-            "Select <b>New</b> to add a world clock") + "</span>")
-        self.pack_start(Gtk.Label(""), True, True, 0)
-        self.pack_start(image, False, False, 6)
-        self.pack_start(text, False, False, 6)
-        self.pack_start(Gtk.Label(""), True, True, 0)
-        self.button = Gtk.ToggleButton()
-        self.show_all()
-
-    def unselect_all(self):
-        pass
-
-
-class AlarmsEmpty(Gtk.Box):
-    def __init__(self):
-        Gtk.Box.__init__(self)
-        self.set_orientation(Gtk.Orientation.VERTICAL)
-        gicon = Gio.ThemedIcon.new_with_default_fallbacks("alarm-symbolic")
-        image = Gtk.Image.new_from_gicon(gicon, Gtk.IconSize.DIALOG)
-        image.set_sensitive(False)
-        text = Gtk.Label("")
-        text.set_markup("<span color='darkgrey'>" +
-            _("Select <b>New</b> to add an alarm") + "</span>")
-        self.pack_start(Gtk.Label(""), True, True, 0)
+        text = Gtk.Label()
+        text.get_style_context().add_class("dim-label")
+        text.set_markup(message)
+        self.pack_start(Gtk.Label(), True, True, 0)
         self.pack_start(image, False, False, 6)
         self.pack_start(text, False, False, 6)
-        self.pack_start(Gtk.Label(""), True, True, 0)
-        self.button = Gtk.ToggleButton()
+        self.pack_start(Gtk.Label(), True, True, 0)
         self.show_all()
-
-    def unselect_all(self):
-        pass



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