From 6c7b2ba0fe4aaa889323f7156804dc18ab73f238 Mon Sep 17 00:00:00 2001 From: Manuel QuiƱones Date: Tue, 19 Feb 2013 15:23:41 +0000 Subject: 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 --- 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') % (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') % (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() -- cgit v0.9.1