[gnome-clocks] Improve code encapsulation
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Improve code encapsulation
- Date: Mon, 20 Aug 2012 16:44:17 +0000 (UTC)
commit bd3e6fd50cc16a27be7186150024c86707751a1b
Author: Paolo Borelli <pborelli gnome org>
Date: Mon Aug 20 18:39:56 2012 +0200
Improve code encapsulation
The DigitalClock and AlarmWidget should not muck with the list store
gnomeclocks/clocks.py | 7 ++-----
gnomeclocks/widgets.py | 17 ++++-------------
2 files changed, 6 insertions(+), 18 deletions(-)
---
diff --git a/gnomeclocks/clocks.py b/gnomeclocks/clocks.py
index f9d392b..e3258dc 100644
--- a/gnomeclocks/clocks.py
+++ b/gnomeclocks/clocks.py
@@ -138,14 +138,12 @@ class World(Clock):
d = DigitalClock(location)
name = d.location.get_city_name()
view_iter = self.liststore.append([False,
- d.drawing.pixbuf,
+ d.get_pixbuf(),
"<b>" + name + "</b>",
d])
- d.set_iter(self.liststore, view_iter)
def delete_clock(self, d):
self.clocks.remove(d.location)
- self.liststore.remove(d.view_iter)
self.iconview.unselect_all()
if len(self.clocks) == 0:
self.load_empty_clocks_view()
@@ -256,11 +254,10 @@ class Alarm(Clock):
repeat = alarm.get_alarm_repeat_string()
widget = AlarmWidget(timestr, repeat)
view_iter = self.liststore.append([False,
- widget.drawing.pixbuf,
+ widget.get_pixbuf(),
"<b>" + name + "</b>",
widget,
alarm.get_vevent()])
- widget.set_iter(self.liststore, view_iter)
def edit_alarm(self, alarm):
print "To Do!"
diff --git a/gnomeclocks/widgets.py b/gnomeclocks/widgets.py
index 985bbdb..f72e1bf 100644
--- a/gnomeclocks/widgets.py
+++ b/gnomeclocks/widgets.py
@@ -109,10 +109,6 @@ class DigitalClock():
self.offset = self.timezone.get_offset() * 60
self.isDay = None
self._last_time = None
-
- self.view_iter = None
- self.list_store = None
-
self.drawing = DigitalClockDrawing()
self.standalone = DigitalClockStandalone(self.location)
self.update()
@@ -148,16 +144,12 @@ class DigitalClock():
self.drawing.render(t, img, isDay)
else:
self.drawing.render(t, img, isDay, day)
- if self.view_iter and self.list_store:
- self.list_store.set_value(
- self.view_iter, 0, self.drawing.pixbuf)
self.standalone.update(img, t, systemClockFormat)
self._last_time = t
return True
- def set_iter(self, list_store, view_iter):
- self.view_iter = view_iter
- self.list_store = list_store
+ def get_pixbuf(self):
+ return self.drawing.pixbuf
def get_standalone_widget(self):
return self.standalone
@@ -390,9 +382,8 @@ class AlarmWidget():
img = os.path.join(Dirs.get_image_dir(), "cities", "night.png")
self.drawing.render(t, img, isDay, repeat)
- def set_iter(self, list_store, view_iter):
- self.view_iter = view_iter
- self.list_store = list_store
+ def get_pixbuf(self):
+ return self.drawing.pixbuf
class AlarmDialog(Gtk.Dialog):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]