[california] Allow reducing duration of multi-day event: Bug #744147
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california] Allow reducing duration of multi-day event: Bug #744147
- Date: Thu, 12 Feb 2015 01:59:42 +0000 (UTC)
commit ba370f762bf4d66a9acbcb315d4eb0c357e6231b
Author: Jim Nelson <jim yorba org>
Date: Wed Feb 11 17:58:54 2015 -0800
Allow reducing duration of multi-day event: Bug #744147
Time of day can be reduced but code didn't allow for date span
duration to be reduced. This provides for it.
src/event-editor/event-editor-date-time-card.vala | 25 ++++++++++++++++----
.../event-editor-date-time-widget.vala | 24 +++++++++++++++++++
2 files changed, 44 insertions(+), 5 deletions(-)
---
diff --git a/src/event-editor/event-editor-date-time-card.vala
b/src/event-editor/event-editor-date-time-card.vala
index c7882e0..ffd51c3 100644
--- a/src/event-editor/event-editor-date-time-card.vala
+++ b/src/event-editor/event-editor-date-time-card.vala
@@ -148,6 +148,9 @@ public class DateTimeCard : Gtk.Box, Toolkit.Card {
all_day_checkbutton.active = (message.exact_time_span == null);
+ from_widget.user_modified = false;
+ to_widget.user_modified = false;
+
thaw_widget_notifications();
}
@@ -207,16 +210,28 @@ public class DateTimeCard : Gtk.Box, Toolkit.Card {
private void on_date_time_changed(DateTimeWidget source, DateTimeWidget other, int duration_adjustment) {
// if From is pushed forward beyond To (or To pushed back before From), adjust the other
- // widget to maintain the user's duration
+ // widget to maintain the user's duration ... to allow for spans to be reduced, don't auto
+ // adjust if the other was manually modified by the user (but at least make sure from is
+ // earlier than to)
Calendar.ExactTime from_exact_time = from_widget.get_exact_time(Calendar.Timezone.local);
Calendar.ExactTime to_exact_time = to_widget.get_exact_time(Calendar.Timezone.local);
if (from_exact_time.compare_to(to_exact_time) >= 0) {
- Calendar.ExactTime adjusted = source.get_exact_time(Calendar.Timezone.local)
- .adjust_time(duration_adjustment, Calendar.TimeUnit.SECOND);
+ Calendar.ExactTime adjusted = source.get_exact_time(Calendar.Timezone.local);
+ if (!other.user_modified) {
+ // user hasn't touched the other widget, so maintain duration
+ adjusted = adjusted.adjust_time(duration_adjustment, Calendar.TimeUnit.SECOND);
+ }
+
+ Calendar.Date new_other_date = new Calendar.Date.from_exact_time(adjusted);
+ Calendar.WallTime new_other_wall_time = adjusted.to_wall_time();
+ // to avoid signal cycles, freeze notifications and avoid property change notifications
+ // if new values are the same
freeze_widget_notifications();
- other.date = new Calendar.Date.from_exact_time(adjusted);
- other.wall_time = adjusted.to_wall_time();
+ if (!other.date.equal_to(new_other_date))
+ other.date = new_other_date;
+ if (!other.wall_time.equal_to(new_other_wall_time))
+ other.wall_time = new_other_wall_time;
thaw_widget_notifications();
} else if (!source.in_time_edit) {
// otherwise, this is the new duration to be maintained (but only adjust if not editing
diff --git a/src/event-editor/event-editor-date-time-widget.vala
b/src/event-editor/event-editor-date-time-widget.vala
index 9849316..926206e 100644
--- a/src/event-editor/event-editor-date-time-widget.vala
+++ b/src/event-editor/event-editor-date-time-widget.vala
@@ -16,11 +16,15 @@ public class DateTimeWidget : Gtk.Box {
public const string PROP_FLOOR = "floor";
public const string PROP_CEILING = "ceiling";
public const string PROP_OUT_OF_RANGE = "out-of-range";
+ public const string PROP_USER_MODIFIED = "user-modified";
public bool enable_time { get; set; default = true; }
public bool enable_date { get; set; default = true; }
+ /**
+ * Indicates one of the time-of-day controls have focus.
+ */
public bool in_time_edit { get; protected set; default = false; }
public Calendar.Date date { get; set; default = Calendar.System.today; }
@@ -37,6 +41,13 @@ public class DateTimeWidget : Gtk.Box {
*/
public bool out_of_range { get; protected set; default = false; }
+ /**
+ * Set when the time or date is updated due to user manipulation of a widget.
+ *
+ * Can be reset any time by the owner of this widget.
+ */
+ public bool user_modified { get; set; default = false; }
+
[GtkChild]
private Gtk.Calendar calendar;
@@ -167,22 +178,32 @@ public class DateTimeWidget : Gtk.Box {
button_connector.clicked.connect(on_time_adjustment_clicked);
calendar.day_selected.connect(on_calendar_day_selected);
+ calendar.day_selected.connect(on_user_modified);
calendar.month_changed.connect(on_calendar_month_or_year_changed);
calendar.next_year.connect(on_calendar_month_or_year_changed);
calendar.prev_year.connect(on_calendar_month_or_year_changed);
hour_entry.changed.connect(on_time_entry_changed);
+ hour_entry.changed.connect(on_user_modified);
minutes_entry.changed.connect(on_time_entry_changed);
+ minutes_entry.changed.connect(on_user_modified);
}
private void disconnect_widget_signals() {
button_connector.clicked.disconnect(on_time_adjustment_clicked);
calendar.day_selected.disconnect(on_calendar_day_selected);
+ calendar.day_selected.disconnect(on_user_modified);
calendar.month_changed.disconnect(on_calendar_month_or_year_changed);
calendar.next_year.disconnect(on_calendar_month_or_year_changed);
calendar.prev_year.disconnect(on_calendar_month_or_year_changed);
hour_entry.changed.disconnect(on_time_entry_changed);
+ hour_entry.changed.disconnect(on_user_modified);
minutes_entry.changed.disconnect(on_time_entry_changed);
+ minutes_entry.changed.disconnect(on_user_modified);
+ }
+
+ private void on_user_modified() {
+ user_modified = true;
}
private bool on_time_adjustment_clicked(Toolkit.ButtonEvent details) {
@@ -224,6 +245,9 @@ public class DateTimeWidget : Gtk.Box {
thaw_notify();
}
+ // treat all valid changing events off the ButtonConnector as a user modification
+ on_user_modified();
+
return Toolkit.STOP;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]