From 781b9f31f000fa1772a635b00da5abd6753c893d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
Date: Tue, 19 Feb 2013 12:23:41 -0300
Subject: [PATCH 8/8] Emit time after the hands of the clock were grabbed - SL
#1959
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
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>
---
clock.py | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/clock.py b/clock.py
index afdcc90..88fae72 100755
a
|
b
|
font_desc="Sans Bold 40">%d</span></markup>') % (i + 1) |
937 | 937 | # the clock |
938 | 938 | return self._active and not self.grab_hands_mode |
939 | 939 | |
| 940 | def _get_time_from_hands_angles(self): |
| 941 | # FIXME, this returns the PM hours, there is no way to |
| 942 | # distinguish PM and AM in the displayed clock |
| 943 | hour = 12 + int((self._hand_angles['hour'] * 12) / (math.pi * 2)) |
| 944 | minute = int((self._hand_angles['minutes'] * 60) / (math.pi * 2)) |
| 945 | # Second is not used by speech or to display time in full |
| 946 | # letters, so we avoid that calculation |
| 947 | second = 0 |
| 948 | return datetime(self._time.year, self._time.month, self._time.day, |
| 949 | hour=hour, minute=minute, second=second) |
| 950 | |
940 | 951 | def get_time(self): |
941 | | """Public access to the time member of the clock face. |
| 952 | """Public access to the time member of the clock face. In grab |
| 953 | hands mode, return the time according to the position of the |
| 954 | clock hands. |
942 | 955 | """ |
943 | | return self._time |
| 956 | if self.grab_hands_mode: |
| 957 | return self._get_time_from_hands_angles() |
| 958 | else: |
| 959 | return self._time |
944 | 960 | |
945 | 961 | def _get_active(self): |
946 | 962 | """Get the activity status of the clock. When active, the |
… |
… |
font_desc="Sans Bold 40">%d</span></markup>') % (i + 1) |
1067 | 1083 | self.queue_draw() |
1068 | 1084 | |
1069 | 1085 | def _release_cb(self, widget, event): |
1070 | | self._hand_being_grabbed = None |
| 1086 | if self._hand_being_grabbed is None: |
| 1087 | return |
| 1088 | |
| 1089 | if self._hand_being_grabbed in ['hour', 'minutes']: |
| 1090 | self.emit("time_minute") |
| 1091 | |
1071 | 1092 | self.queue_draw() |