From 4eb33fd3daa58ffac6b945506bcd729ab71f5a9f Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 26 Apr 2012 12:56:46 +0200 Subject: Bug #668988 - Handle a "minutes" entry greater than 59 intelligently --- calendar/gui/dialogs/event-page.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index 37373dffa5..28f54be901 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -1980,6 +1980,31 @@ minute_sel_changed (GtkSpinButton *widget, hour_minute_changed (epage); } +static gboolean +minute_sel_focus_out (GtkSpinButton *widget, + GdkEvent *event, + EventPage *epage) +{ + const gchar *text; + gint hours, minutes; + + g_return_val_if_fail (widget != NULL, FALSE); + g_return_val_if_fail (epage != NULL, FALSE); + + text = gtk_entry_get_text (GTK_ENTRY (widget)); + minutes = g_strtod (text, NULL); + + if (minutes >= 60) { + hours = minutes / 60; + minutes = minutes % 60; + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (epage->priv->hour_selector), hours); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (epage->priv->minute_selector), minutes); + } + + return FALSE; +} + static void hour_minute_changed (EventPage *epage) { @@ -3354,6 +3379,10 @@ init_widgets (EventPage *epage) priv->minute_selector, "value-changed", G_CALLBACK (minute_sel_changed), epage); + g_signal_connect ( + priv->minute_selector, "focus-out-event", + G_CALLBACK (minute_sel_focus_out), epage); + /* Add the user defined time if necessary */ priv->alarm_units = e_meeting_store_get_default_reminder_units ( -- cgit v1.2.3