[gnome-clocks] Relax stopwatch timeout to 100ms
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Relax stopwatch timeout to 100ms
- Date: Thu, 30 Aug 2012 20:26:14 +0000 (UTC)
commit 6ede5540d22ae702e462ba41a56ab41ba6a84abc
Author: Paolo Borelli <pborelli gnome org>
Date: Thu Aug 30 22:24:07 2012 +0200
Relax stopwatch timeout to 100ms
We only display seconds for now, so let's use less CPU
gnomeclocks/stopwatch.py | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/gnomeclocks/stopwatch.py b/gnomeclocks/stopwatch.py
index fef7de3..87bc133 100644
--- a/gnomeclocks/stopwatch.py
+++ b/gnomeclocks/stopwatch.py
@@ -78,16 +78,15 @@ class Stopwatch(Clock):
self.start()
self.leftLabel.set_markup(Stopwatch.BUTTON_MARKUP % (_("Stop")))
self.leftButton.get_style_context().add_class("clocks-stop")
- self.rightButton.set_sensitive(True)
+ self.rightButton.set_sensitive(False)
elif self.state == Stopwatch.State.RUNNING:
self.state = Stopwatch.State.STOPPED
self.stop()
- self.leftLabel.set_markup(Stopwatch.BUTTON_MARKUP %
- (_("Continue")))
- self.rightLabel.set_markup(Stopwatch.BUTTON_MARKUP %
- (_("Reset")))
+ self.leftLabel.set_markup(Stopwatch.BUTTON_MARKUP % (_("Continue")))
+ self.rightLabel.set_markup(Stopwatch.BUTTON_MARKUP % (_("Reset")))
self.leftButton.get_style_context().remove_class("clocks-stop")
self.leftButton.get_style_context().add_class("clocks-go")
+ self.rightButton.set_sensitive(True)
def _on_right_button_clicked(self, widget):
if self.state == Stopwatch.State.RUNNING:
@@ -104,7 +103,7 @@ class Stopwatch(Clock):
def start(self):
if self.timeout_id == 0:
self.start_time = time.time()
- self.timeout_id = GObject.timeout_add(10, self.count)
+ self.timeout_id = GObject.timeout_add(100, self.count)
def stop(self):
GObject.source_remove(self.timeout_id)
@@ -112,9 +111,9 @@ class Stopwatch(Clock):
self.time_diff = self.time_diff + (time.time() - self.start_time)
def reset(self):
- self.time_diff = 0
GObject.source_remove(self.timeout_id)
self.timeout_id = 0
+ self.time_diff = 0
def count(self):
timediff = time.time() - self.start_time + self.time_diff
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]