[gnome-clocks] DigitalClock: Set last_sunrise/sunset on update
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] DigitalClock: Set last_sunrise/sunset on update
- Date: Mon, 12 Nov 2012 22:24:54 +0000 (UTC)
commit b3b37d707ca9e181da0cbd3f908c30beb022d797
Author: Volker Sobek <reklov live com>
Date: Sun Nov 11 01:08:16 2012 +0100
DigitalClock: Set last_sunrise/sunset on update
This was done in the wrong place, resulting in a complete update of
every world clock, every second. This caused a pretty high
CPU usage when using a few world clocks.
Also use a new _standalone_is_new attribute for DigitalClock instances
to ensure a full DigitalClock update after a StandaloneClock has been
added. (This prevents an empty StandaloneClock until the next full
update. This wasn't necessary before, as the bug already caused the
DigitalClock to be completely updated on every update call.)
https://bugzilla.gnome.org/show_bug.cgi?id=688069
gnomeclocks/world.py | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/gnomeclocks/world.py b/gnomeclocks/world.py
index e6748d2..730cf10 100644
--- a/gnomeclocks/world.py
+++ b/gnomeclocks/world.py
@@ -148,6 +148,7 @@ class DigitalClock():
self._last_time = None
self.drawing = DigitalClockDrawing()
self.standalone = None
+ self._standalone_is_new = False
self.update()
def get_location_time(self, secs=None):
@@ -168,7 +169,8 @@ class DigitalClock():
t = t[1:]
if not t == self._last_time \
or not self.sunrise == self._last_sunrise \
- or not self.sunset == self._last_sunset:
+ or not self.sunset == self._last_sunset \
+ or self._standalone_is_new:
is_light = self.get_is_light(location_time)
if is_light:
img = os.path.join(Dirs.get_image_dir(), "cities", "day.png")
@@ -183,8 +185,11 @@ class DigitalClock():
self.list_store[self.path][1] = self.drawing.pixbuf
if self.standalone:
self.standalone.update(img, t, self.sunrise, self.sunset)
+ self._standalone_is_new = False
- self._last_time = t
+ self._last_time = t
+ self._last_sunrise = self.sunrise
+ self._last_sunset = self.sunset
def get_sunrise_sunset(self):
self.weather = GWeather.Info(location=self.location, world=gweather_world)
@@ -195,8 +200,6 @@ class DigitalClock():
# returned as the time here
ok, sunrise = weather.get_value_sunrise()
ok, sunset = weather.get_value_sunset()
- self._last_sunrise = self.sunrise
- self._last_sunset = self.sunset
self.sunrise = self.get_location_time(sunrise)
self.sunset = self.get_location_time(sunset)
self.update()
@@ -207,6 +210,7 @@ class DigitalClock():
def get_standalone_widget(self):
if not self.standalone:
self.standalone = StandaloneClock(self.location, self.sunrise, self.sunset)
+ self._standalone_is_new = True
self.update()
return self.standalone
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]