Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2013-02-19 15:23:41 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2013-02-27 23:31:11 (GMT)
commit6c7b2ba0fe4aaa889323f7156804dc18ab73f238 (patch)
tree108dc4a51ae6ba5c52aad76b044195683c3e0c8d
parent95ed3f75deb5c9b69c04d3433a521728686a8f73 (diff)
Emit time after the hands of the clock were grabbed - SL #1959
This provokes an update in the displayed time in full letters and also speaks the time if the speech time option is toggled. One decision had to be made: which time should it output? AM or PM? Because from the analog clock both can be tell. I went for the PM because looks more intuitive for children. Signed-off-by: Manuel Quiñones <manuq@laptop.org>
-rwxr-xr-xclock.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/clock.py b/clock.py
index afdcc90..6e594a4 100755
--- a/clock.py
+++ b/clock.py
@@ -937,10 +937,26 @@ font_desc="Sans Bold 40">%d</span></markup>') % (i + 1)
# the clock
return self._active and not self.grab_hands_mode
+ def _get_time_from_hands_angles(self):
+ # FIXME, this returns the PM hours, there is no way to
+ # distinguish PM and AM in the displayed clock
+ hour = 12 + int((self._hand_angles['hour'] * 12) / (math.pi * 2))
+ minute = int((self._hand_angles['minutes'] * 60) / (math.pi * 2))
+ # Second is not used by speech or to display time in full
+ # letters, so we avoid that calculation
+ second = 0
+ return datetime(self._time.year, self._time.month, self._time.day,
+ hour=hour, minute=minute, second=second)
+
def get_time(self):
- """Public access to the time member of the clock face.
+ """Public access to the time member of the clock face. In grab
+ hands mode, return the time according to the position of the
+ clock hands.
"""
- return self._time
+ if self.grab_hands_mode:
+ return self._get_time_from_hands_angles()
+ else:
+ return self._time
def _get_active(self):
"""Get the activity status of the clock. When active, the
@@ -1067,5 +1083,11 @@ font_desc="Sans Bold 40">%d</span></markup>') % (i + 1)
self.queue_draw()
def _release_cb(self, widget, event):
+ if self._hand_being_grabbed is None:
+ return
+
+ if self._hand_being_grabbed in ['hour', 'minutes']:
+ self.emit("time_minute")
+
self._hand_being_grabbed = None
self.queue_draw()