Merge lp:~sgpthomas/granite/timepicker into lp:~elementary-pantheon/granite/granite

Proposed by Sam Thomas
Status: Merged
Approved by: Danielle Foré
Approved revision: 966
Merged at revision: 973
Proposed branch: lp:~sgpthomas/granite/timepicker
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 59 lines (+22/-2)
1 file modified
lib/Widgets/TimePicker.vala (+22/-2)
To merge this branch: bzr merge lp:~sgpthomas/granite/timepicker
Reviewer Review Type Date Requested Status
Adam Bieńkowski (community) code / testing Approve
Review via email: mp+300403@code.launchpad.net

Commit message

TimePicker:
* Minutes below 10 have a 0 in front
* Don't show AM/PM switch for 24hr time

Description of the change

Changed the formatting of the minute hand so that minutes below 10 have a 0 appended to the front. For example, '6' becomes '06'. This change makes the timepicker more consistent with how time is usually presented.

Also fixed a bug regarding switching between 12h and 24h time in the timepicker. Previously, if the widget existed, and the time was changed from 12h to 24h, the AM, PM toggle would remain and the hour spinner would remain between 1-12. My changes in this branch fix this problem.

To post a comment you must log in.
Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Thanks for reworking the branch, it looks much better now!
However there is one UI issue here:

Set the modebutton to be on "AM" and then set the hour to be on 12: you can't click "PM" anymore, the time changes but the "PM" button doesn't get higlighted.

I wrote some inline comments, only some minor code-style issues.

Also, not related to the branch itself: when you create a new follow up branch, you shouldn't remove the previous one: the comments and it's history gets completely removed. Just mark the old one as rejected and comment that there is new branch with a link to it.

review: Needs Fixing (code / testing)
lp:~sgpthomas/granite/timepicker updated
966. By Sam Thomas

fixed issue with PM not working and fixed some small code style changes

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Looks good to me!

review: Approve (code / testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Widgets/TimePicker.vala'
2--- lib/Widgets/TimePicker.vala 2016-02-09 02:09:56 +0000
3+++ lib/Widgets/TimePicker.vala 2016-07-25 19:15:30 +0000
4@@ -61,9 +61,9 @@
5 changing_time = true;
6
7 if (_time.get_hour () >= 12) {
8- am_pm_modebutton.selected = 1;
9+ am_pm_modebutton.set_active (1);
10 } else {
11- am_pm_modebutton.selected = 0;
12+ am_pm_modebutton.set_active (0);
13 }
14
15 update_text (true);
16@@ -133,6 +133,18 @@
17 minutes_spinbutton.orientation = Gtk.Orientation.VERTICAL;
18 minutes_spinbutton.wrap = true;
19 minutes_spinbutton.value_changed.connect (() => update_time (false));
20+
21+ // If the spinbutton value is less than 10, append zero in front of value. '6' becomes '06'
22+ minutes_spinbutton.output.connect (() => {
23+ var val = minutes_spinbutton.get_value ();
24+ if (val < 10) {
25+ minutes_spinbutton.set_text ("0" + val.to_string ());
26+ return true;
27+ }
28+
29+ return false;
30+ });
31+
32 /// TRANSLATORS: separates hours from minutes.
33 var separation_label = new Gtk.Label (_(":"));
34
35@@ -216,6 +228,8 @@
36 }
37
38 private void on_icon_press (Gtk.EntryIconPosition position, Gdk.Event event) {
39+ // If the mode is changed from 12h to 24h or visa versa, the entry updates on icon press
40+ update_text ();
41 changing_time = true;
42
43 if (Granite.DateTime.is_clock_format_12h () && time.get_hour () > 12)
44@@ -234,9 +248,15 @@
45 } else {
46 hours_spinbutton.set_value (time.get_hour ());
47 }
48+
49+ // Make sure that bounds are set correctly
50+ hours_spinbutton.set_range (1, 12);
51 } else {
52+ am_pm_modebutton.no_show_all = true;
53 am_pm_modebutton.hide ();
54 hours_spinbutton.set_value (time.get_hour ());
55+
56+ hours_spinbutton.set_range (0, 23);
57 }
58
59 minutes_spinbutton.set_value (time.get_minute ());

Subscribers

People subscribed via source and target branches