diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2000-11-05 01:26:49 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2000-11-05 01:26:49 +0800 |
commit | 39c634e9c2374cbcd26a4f37f201dcf6c3870b5d (patch) | |
tree | b3d5af3758f33944e85e0de0184a38f564e3f574 /calendar/gui | |
parent | 82e85fded028e36ac0df6a5619364a57fa956f83 (diff) | |
download | gsoc2013-evolution-39c634e9c2374cbcd26a4f37f201dcf6c3870b5d.tar.gz gsoc2013-evolution-39c634e9c2374cbcd26a4f37f201dcf6c3870b5d.tar.zst gsoc2013-evolution-39c634e9c2374cbcd26a4f37f201dcf6c3870b5d.zip |
Block signals from the toggle button. (date_changed_cb): Merged
2000-11-03 Federico Mena Quintero <federico@helixcode.com>
* gui/event-editor.c (check_all_day): Block signals from the
toggle button.
(date_changed_cb): Merged check_dates() and check_times() into
this function; provide better behavior as well.
(check_dates): Removed function.
(check_times): Removed function.
(init_widgets): Connect to the "changed" signal on the start_time
and end_time widgets.
(check_all_day): Use a better test.
2000-11-03 Federico Mena Quintero <federico@helixcode.com>
* gui/component/select-names/Makefile.am: Clean the idl-generated
files properly.
svn path=/trunk/; revision=6396
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/event-editor.c | 131 |
1 files changed, 45 insertions, 86 deletions
diff --git a/calendar/gui/event-editor.c b/calendar/gui/event-editor.c index 19a170a90f..d5e687ccbc 100644 --- a/calendar/gui/event-editor.c +++ b/calendar/gui/event-editor.c @@ -157,8 +157,7 @@ static void append_exception (EventEditor *ee, time_t t); static void check_all_day (EventEditor *ee); static void set_all_day (GtkWidget *toggle, EventEditor *ee); static void alarm_toggle (GtkWidget *toggle, EventEditor *ee); -static void check_dates (EDateEdit *dedit, EventEditor *ee); -static void check_times (EDateEdit *dedit, EventEditor *ee); +static void date_changed_cb (EDateEdit *dedit, gpointer data); static void recurrence_exception_add_cb (GtkWidget *widget, EventEditor *ee); static void recurrence_exception_modify_cb (GtkWidget *widget, EventEditor *ee); static void recurrence_exception_delete_cb (GtkWidget *widget, EventEditor *ee); @@ -812,15 +811,10 @@ init_widgets (EventEditor *ee) /* Start and end times */ - gtk_signal_connect (GTK_OBJECT (priv->start_time), "date_changed", - GTK_SIGNAL_FUNC (check_dates), ee); - gtk_signal_connect (GTK_OBJECT (priv->start_time), "time_changed", - GTK_SIGNAL_FUNC (check_times), ee); - - gtk_signal_connect (GTK_OBJECT (priv->end_time), "date_changed", - GTK_SIGNAL_FUNC (check_dates), ee); - gtk_signal_connect (GTK_OBJECT (priv->end_time), "time_changed", - GTK_SIGNAL_FUNC (check_times), ee); + gtk_signal_connect (GTK_OBJECT (priv->start_time), "changed", + GTK_SIGNAL_FUNC (date_changed_cb), ee); + gtk_signal_connect (GTK_OBJECT (priv->end_time), "changed", + GTK_SIGNAL_FUNC (date_changed_cb), ee); gtk_signal_connect (GTK_OBJECT (priv->all_day_event), "toggled", GTK_SIGNAL_FUNC (set_all_day), ee); @@ -2210,27 +2204,40 @@ alarm_toggle (GtkWidget *toggle, EventEditor *ee) gtk_widget_set_sensitive (alarm_unit, active); } -/* - * Checks if the day range occupies all the day, and if so, check the - * box accordingly +/* Checks if the day range occupies a single whole day, and if so, check. the + * "all day event" box accordingly. */ static void check_all_day (EventEditor *ee) { EventEditorPrivate *priv; time_t ev_start, ev_end; + time_t start_begin_day, end_begin_day; + struct tm tm_start, tm_end; + gboolean all_day; priv = ee->priv; ev_start = e_date_edit_get_time (E_DATE_EDIT (priv->start_time)); ev_end = e_date_edit_get_time (E_DATE_EDIT (priv->end_time)); - /* all day event checkbox */ - if (time_day_begin (ev_start) == ev_start - && time_day_begin (ev_end) == ev_end) - e_dialog_toggle_set (priv->all_day_event, TRUE); + start_begin_day = time_day_begin (ev_start); + end_begin_day = time_day_begin (ev_end); + + tm_start = *localtime (&start_begin_day); + tm_end = *localtime (&end_begin_day); + + tm_end.tm_mday--; + if (mktime (&tm_start) == mktime (&tm_end)) + all_day = TRUE; else - e_dialog_toggle_set (priv->all_day_event, FALSE); + all_day = FALSE; + + gtk_signal_handler_block_by_data (GTK_OBJECT (priv->all_day_event), ee); + + e_dialog_toggle_set (priv->all_day_event, all_day); + + gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->all_day_event), ee); } /* @@ -2284,18 +2291,22 @@ set_all_day (GtkWidget *toggle, EventEditor *ee) e_date_edit_set_time (E_DATE_EDIT (priv->end_time), mktime (&end_tm)); } -/* - * Callback: checks that the dates are start < end +/* Callback used when the start or end date widgets change. We check that the + * start date < end date and we set the "all day event" button as appropriate. */ static void -check_dates (EDateEdit *dedit, EventEditor *ee) +date_changed_cb (EDateEdit *dedit, gpointer data) { + EventEditor *ee; EventEditorPrivate *priv; time_t start, end; struct tm tm_start, tm_end; + ee = EVENT_EDITOR (data); priv = ee->priv; + /* Ensure that start < end */ + start = e_date_edit_get_time (E_DATE_EDIT (priv->start_time)); end = e_date_edit_get_time (E_DATE_EDIT (priv->end_time)); @@ -2304,88 +2315,36 @@ check_dates (EDateEdit *dedit, EventEditor *ee) tm_end = *localtime (&end); if (GTK_WIDGET (dedit) == priv->start_time) { + /* Modify the end time */ + tm_end.tm_year = tm_start.tm_year; tm_end.tm_mon = tm_start.tm_mon; tm_end.tm_mday = tm_start.tm_mday; + tm_end.tm_hour = tm_start.tm_hour + 1; + tm_end.tm_min = tm_start.tm_min; + tm_end.tm_sec = tm_start.tm_sec; gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), ee); - e_date_edit_set_time (E_DATE_EDIT (priv->end_time), - mktime (&tm_end)); + e_date_edit_set_time (E_DATE_EDIT (priv->end_time), mktime (&tm_end)); gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), ee); } else if (GTK_WIDGET (dedit) == priv->end_time) { + /* Modify the start time */ + tm_start.tm_year = tm_end.tm_year; tm_start.tm_mon = tm_end.tm_mon; tm_start.tm_mday = tm_end.tm_mday; - -#if 0 /* FIXME: is this right? */ - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), ee); - e_date_edit_set_time (E_DATE_EDIT (priv->start_time), - mktime (&tm_start)); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), ee); -#endif - } - } -} - -/* - * Callback: checks that start_time < end_time and whether the - * selected hour range spans all of the day - */ -static void -check_times (EDateEdit *dedit, EventEditor *ee) -{ - EventEditorPrivate *priv; - time_t start, end; - struct tm tm_start, tm_end; - - priv = ee->priv; -#if 0 - gdk_pointer_ungrab (GDK_CURRENT_TIME); - gdk_flush (); -#endif - start = e_date_edit_get_time (E_DATE_EDIT (priv->start_time)); - end = e_date_edit_get_time (E_DATE_EDIT (priv->end_time)); - - if (start > end) { - tm_start = *localtime (&start); - tm_end = *localtime (&end); - - if (GTK_WIDGET (dedit) == priv->start_time) { - tm_end.tm_min = tm_start.tm_min; - tm_end.tm_sec = tm_start.tm_sec; - tm_end.tm_hour = tm_start.tm_hour + 1; - - if (tm_end.tm_hour >= 24) { - tm_end.tm_hour = 24; /* mktime() will bump the day */ - tm_end.tm_min = 0; - tm_end.tm_sec = 0; - } - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), ee); - e_date_edit_set_time (E_DATE_EDIT (priv->end_time), - mktime (&tm_end)); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), ee); - } else if (GTK_WIDGET (dedit) == priv->end_time) { + tm_start.tm_hour = tm_end.tm_hour - 1; tm_start.tm_min = tm_end.tm_min; tm_start.tm_sec = tm_end.tm_sec; - tm_start.tm_hour = tm_end.tm_hour - 1; - - if (tm_start.tm_hour < 0) { - tm_start.tm_hour = 0; - tm_start.tm_min = 0; - tm_start.tm_min = 0; - } gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), ee); - - /* will set recur start too */ e_date_edit_set_time (E_DATE_EDIT (priv->start_time), mktime (&tm_start)); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), ee); - } + } else + g_assert_not_reached (); } - /* Check whether the event spans the whole day */ + /* Set the "all day event" button as appropriate */ check_all_day (ee); } |