[gnome-clocks] Clock: Clean up the UI freeze
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Clock: Clean up the UI freeze
- Date: Sat, 2 Feb 2013 12:22:57 +0000 (UTC)
commit 44b7e802dd49bebd5486c2abc447ed0a5fd1b9e6
Author: Volker Sobek <reklov live com>
Date: Sun Jan 20 20:43:37 2013 +0100
Clock: Clean up the UI freeze
Move the functionality from the Clock class to the appropriate
widgets. The Clock class wasn't a good place for it, as clocks are now
notebooks.
gnomeclocks/clocks.py | 18 ------------------
gnomeclocks/stopwatch.py | 6 ++++--
gnomeclocks/timer.py | 14 ++++++++------
3 files changed, 12 insertions(+), 26 deletions(-)
---
diff --git a/gnomeclocks/clocks.py b/gnomeclocks/clocks.py
index f43dd61..90020fe 100644
--- a/gnomeclocks/clocks.py
+++ b/gnomeclocks/clocks.py
@@ -27,9 +27,6 @@ class Clock(Gtk.Notebook):
self._embed = embed
self._toolbar = toolbar
- self.connect('map', self._ui_thaw)
- self.connect('unmap', self._ui_freeze)
-
def insert_page(self, page, page_number):
page.show_all()
Gtk.Notebook.insert_page(self, page, None, page_number)
@@ -44,18 +41,3 @@ class Clock(Gtk.Notebook):
def update_toolbar(self):
"""Updates the toolbar depending on the current clock page."""
raise NotImplementedError
-
- def _ui_freeze(self, widget):
- """Called when the Clock widget is unmapped.
-
- Derived classes can implement this method to remove timeouts
- in order to save CPU time while the Clock widget is not
- visible."""
- pass
-
- def _ui_thaw(self, widget):
- """Called when the clock widget is mapped.
-
- Derived Clock classes can implement this method to re-add
- timeouts when the Clock widget becomes visible again."""
- pass
diff --git a/gnomeclocks/stopwatch.py b/gnomeclocks/stopwatch.py
index 34bd675..be1cc43 100644
--- a/gnomeclocks/stopwatch.py
+++ b/gnomeclocks/stopwatch.py
@@ -50,6 +50,8 @@ class Stopwatch(Clock):
self.lap_time_diff = 0
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
+ vbox.connect("map", self._on_stopwatch_mapped)
+ vbox.connect("unmap", self._on_stopwatch_unmapped)
grid = Gtk.Grid()
grid.set_margin_top(36)
@@ -215,11 +217,11 @@ class Stopwatch(Clock):
self._toolbar.clear()
self._toolbar.set_mode(Toolbar.Mode.NORMAL)
- def _ui_freeze(self, widget):
+ def _on_stopwatch_unmapped(self, widget):
if self.state == Stopwatch.State.RUNNING:
self._remove_timeout()
- def _ui_thaw(self, widget):
+ def _on_stopwatch_mapped(self, widget):
if self.state == Stopwatch.State.RUNNING:
self.count()
self._add_timeout()
diff --git a/gnomeclocks/timer.py b/gnomeclocks/timer.py
index 0fd57a6..20e0c4f 100644
--- a/gnomeclocks/timer.py
+++ b/gnomeclocks/timer.py
@@ -161,7 +161,7 @@ class Timer(Clock):
self.state = Timer.State.STOPPED
self.timeout_id = 0
self._last_set_time = None
- self._ui_is_frozen = False
+ self._timer_screen_is_mapped = False
# force the time label and the spinner to the same size
size_group = Gtk.SizeGroup(Gtk.SizeGroupMode.VERTICAL)
@@ -171,6 +171,8 @@ class Timer(Clock):
self.timer_screen = TimerScreen(self, size_group)
self.insert_page(self.timer_screen, self.Page.TIMER)
+ self.timer_screen.connect("map", self._on_timer_screen_mapped)
+ self.timer_screen.connect("unmap", self._on_timer_screen_unmapped)
self.set_current_page(self.Page.SETUP)
@@ -226,7 +228,7 @@ class Timer(Clock):
self.timer_screen.set_time(0, 0, 0)
self.change_page(self.Page.SETUP)
return False
- elif not self._ui_is_frozen:
+ elif not self._timer_screen_is_mapped:
# math.ceil() is needed because we count backwards. It assures the
# display shows the past and not the future, e.g. show 1 s and not
# 0 s when we are at 0.3 s.
@@ -242,10 +244,10 @@ class Timer(Clock):
self._toolbar.clear()
self._toolbar.set_mode(Toolbar.Mode.NORMAL)
- def _ui_freeze(self, widget):
- self._ui_is_frozen = True
+ def _on_timer_screen_unmapped(self, widget):
+ self._timer_screen_is_mapped = True
- def _ui_thaw(self, widget):
- self._ui_is_frozen = False
+ def _on_timer_screen_mapped(self, widget):
+ self._timer_screen_is_mapped = False
if self.state == Timer.State.RUNNING:
self.count()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]