From 79242432b23fe7def50b7119e61d8570a3558c1c Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 15 Oct 2009 20:15:31 +0200 Subject: Bug #404227 - Over-aggressive appointment editor date check --- calendar/gui/dialogs/event-page.c | 27 +++++++++++++++++++++++++-- widgets/misc/e-dateedit.c | 14 +++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index 83f783a365..35a4719a77 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -2415,6 +2415,22 @@ times_updated (EventPage *epage, gboolean adjust_end_time) notify_dates_changed (epage, &start_tt, &end_tt); } +static gboolean +safe_to_process_date_changed_signal (GtkWidget *dedit_widget) +{ + EDateEdit *dedit; + GtkWidget *entry; + + g_return_val_if_fail (dedit_widget != NULL, FALSE); + + dedit = E_DATE_EDIT (dedit_widget); + g_return_val_if_fail (dedit != NULL, FALSE); + + entry = e_date_edit_get_entry (dedit); + + return !entry || !GTK_WIDGET_HAS_FOCUS (entry); +} + /* Callback used when the start date widget change. We check that the * start date < end date and we set the "all day event" button as appropriate. */ @@ -2422,6 +2438,9 @@ static void start_date_changed_cb (GtkWidget *dedit, EventPage *epage) { + if (!safe_to_process_date_changed_signal (dedit)) + return; + hour_minute_changed (epage); times_updated (epage, TRUE); } @@ -2433,6 +2452,10 @@ static void end_date_changed_cb (GtkWidget *dedit, EventPage *epage) { + if (!safe_to_process_date_changed_signal (dedit)) { + return; + } + times_updated (epage, FALSE); } @@ -2771,9 +2794,9 @@ init_widgets (EventPage *epage) e_buffer_tagger_connect (GTK_TEXT_VIEW (priv->description)); /* Start and end times */ - g_signal_connect((priv->start_time), "changed", + g_signal_connect (priv->start_time, "changed", G_CALLBACK (start_date_changed_cb), epage); - g_signal_connect((priv->end_time), "changed", + g_signal_connect (priv->end_time, "changed", G_CALLBACK (end_date_changed_cb), epage); /* Categories */ diff --git a/widgets/misc/e-dateedit.c b/widgets/misc/e-dateedit.c index 07a9fc61c4..2b0eb8acd5 100644 --- a/widgets/misc/e-dateedit.c +++ b/widgets/misc/e-dateedit.c @@ -109,6 +109,9 @@ struct _EDateEditPrivate { GDestroyNotify time_callback_destroy; gboolean twodigit_year_can_future; + + /* set to TRUE when the date has been changed by typing to the entry */ + gboolean has_been_changed; }; enum { @@ -356,6 +359,7 @@ date_edit_init (EDateEdit *dedit) dedit->priv->time_callback_destroy = NULL; dedit->priv->twodigit_year_can_future = TRUE; + dedit->priv->has_been_changed = FALSE; create_children (dedit); @@ -1681,6 +1685,12 @@ on_date_entry_focus_out (GtkEntry *entry, return FALSE; } else if (e_date_edit_get_date (dedit,&tmp_tm.tm_year,&tmp_tm.tm_mon,&tmp_tm.tm_mday)) { e_date_edit_set_date (dedit,tmp_tm.tm_year,tmp_tm.tm_mon,tmp_tm.tm_mday); + + if (dedit->priv->has_been_changed) { + /* the previous one didn't emit changed signal, but we want it even here, thus doing itself */ + g_signal_emit (dedit, signals [CHANGED], 0); + dedit->priv->has_been_changed = FALSE; + } } else { dedit->priv->date_set_to_none = TRUE; e_date_edit_update_date_entry (dedit); @@ -1951,8 +1961,10 @@ e_date_edit_check_date_changed (EDateEdit *dedit) tmp_tm.tm_mon, tmp_tm.tm_mday); - if (date_changed) + if (date_changed) { + priv->has_been_changed = TRUE; g_signal_emit (dedit, signals[CHANGED], 0); + } } /* Parses the time, and if it is different from the current settings it -- cgit