elementaryart team mailing list archive
-
elementaryart team
-
Mailing list archive
-
Message #02089
[Merge] lp:~niels-avonds/granite/timepicker-fixes into lp:granite
Cody Garver has proposed merging lp:~niels-avonds/granite/timepicker-fixes into lp:granite.
Requested reviews:
Mario Guerriero (mefrio-g)
For more details, see:
https://code.launchpad.net/~niels-avonds/granite/timepicker-fixes/+merge/106547
Hi all,
There's an issue in Maya with the current implementation of the timepicker. The plus and minus buttons don't seem to be working.
I've fixed this bug by overriding the "input" function for the timepicker. It seems weird to me that the plus and minus buttons actually read the current value from the text. Is this a bug upstream?
The "input" function was already implemented in the timepicker a while ago, but was removed because it caused builds to fail in other projects.
Do the rest of you have problems with the plus and minus buttons as well? And, if so, does my branch (lp:~niels-avonds/granite/timepicker-fixes) fix it or do you get the old build issues again?
Kind regards,
Niels Avonds
--
https://code.launchpad.net/~niels-avonds/granite/timepicker-fixes/+merge/106547
Your team elementaryart (old) is subscribed to branch lp:granite.
=== modified file 'demo/main.vala'
--- demo/main.vala 2012-05-15 03:50:14 +0000
+++ demo/main.vala 2012-05-20 22:09:18 +0000
@@ -184,6 +184,8 @@
var date_button = new Granite.Widgets.DatePicker.with_format("%d-%m-%y");
date_button.valign = date_button.halign = Gtk.Align.CENTER;
calendar_button.add(date_button);
+ var time_button = new Granite.Widgets.TimePicker.with_format("%l:%M %p");
+ calendar_button.add(time_button);
notebook.append_page (calendar_button, new Gtk.Label ("Calendar"));
/* Contractor */
=== modified file 'lib/Widgets/TimePicker.vala'
--- lib/Widgets/TimePicker.vala 2012-04-27 13:46:40 +0000
+++ lib/Widgets/TimePicker.vala 2012-05-20 22:09:18 +0000
@@ -24,17 +24,28 @@
public string format { get; construct; default = _("%l:%M %p"); }
- public DateTime time { get; set; }
+ private DateTime _time;
+
+ public DateTime time {
+ get {return _time;}
+ set {
+ // Always round to 30
+ int minute = (value.get_minute () - (value.get_minute () % 30)) - _time.get_minute ();
+
+ _time = _time.add_full (0, 0, 0, value.get_hour() - _time.get_hour (),
+ minute, 0);
+ }
+ }
construct {
-
- time = new DateTime.now_local ();
- int starting_time = time.get_hour () * 60 + 30; // start at this hour : 30
+
+ _time = new DateTime.now_local ();
+ int starting_time = _time.get_hour () * 60 + 30; // start at this hour : 30
set_minutes (starting_time);
// SpinButton properties
can_focus = false;
- adjustment = new Adjustment (starting_time, 0, 1440, 30, 300, 0);
+ adjustment = new Adjustment (starting_time, 0, 1410, 30, 300, 0);
climb_rate = 0;
digits = 0;
numeric = false; // so the text can be set
@@ -48,18 +59,24 @@
void on_time_changed () {
text = time.format (format);
- int new_time = time.get_hour () * 60 + 30;
+ int new_time = _time.get_hour () * 60 + _time.get_minute ();
adjustment.set_value (new_time);
}
- protected override bool output () {
+ protected override bool output () {
set_minutes ((int) this.value);
return true;
}
+
+ protected override int input (out double new_value) {
+ // This is necessary to make the plus and minus button work
+ new_value = _time.get_hour () * 60 + _time.get_minute ();
+ return 1;
+ }
protected virtual void set_minutes (int minutes) {
- time = time.add_full (0, 0, 0, minutes / 60 - time.get_hour (),
+ time = _time.add_full (0, 0, 0, minutes / 60 - time.get_hour (),
minutes % 60 - time.get_minute (), 0);
}