diff options
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/dialogs/event-page.c | 30 | ||||
-rw-r--r-- | calendar/gui/dialogs/schedule-page.c | 17 | ||||
-rw-r--r-- | calendar/gui/e-meeting-time-sel-item.c | 4 | ||||
-rw-r--r-- | calendar/gui/e-meeting-time-sel.c | 176 | ||||
-rw-r--r-- | calendar/gui/e-meeting-time-sel.h | 7 |
5 files changed, 161 insertions, 73 deletions
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index 191f87e306..ff4ec98e59 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -375,20 +375,22 @@ update_time (EventPage *epage, CalComponentDateTime *start_date, CalComponentDat /* Set the timezones, and set sync_timezones to TRUE if both timezones are the same. */ - /* FIXME: JPR - why did you add the if check here? It looks like it - won't work for floating times, where start_zone or end_zone may be - NULL. */ -#if 0 - if (start_zone && end_zone) { -#endif - e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->start_timezone), - start_zone); - e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->end_timezone), - end_zone); - priv->sync_timezones = (start_zone == end_zone) ? TRUE : FALSE; -#if 0 - } -#endif + gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_timezone), + epage); + gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_timezone), epage); + + e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->start_timezone), + start_zone); + e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->end_timezone), + end_zone); + + gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_timezone), + epage); + gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_timezone), + epage); + + priv->sync_timezones = (start_zone == end_zone) ? TRUE : FALSE; + } /* Fills the widgets with default values */ diff --git a/calendar/gui/dialogs/schedule-page.c b/calendar/gui/dialogs/schedule-page.c index 66614348df..c1397d24c1 100644 --- a/calendar/gui/dialogs/schedule-page.c +++ b/calendar/gui/dialogs/schedule-page.c @@ -86,7 +86,7 @@ static void schedule_page_fill_widgets (CompEditorPage *page, CalComponent *comp static gboolean schedule_page_fill_component (CompEditorPage *page, CalComponent *comp); static void schedule_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates); -static void time_changed_cb (GtkWidget *widget, gpointer data); +static void times_changed_cb (GtkWidget *widget, gpointer data); static CompEditorPageClass *parent_class = NULL; @@ -276,11 +276,8 @@ update_time (SchedulePage *spage, CalComponentDateTime *start_date, CalComponent } } - e_date_edit_set_show_time (E_DATE_EDIT (priv->sel->start_date_edit), - !all_day); - e_date_edit_set_show_time (E_DATE_EDIT (priv->sel->end_date_edit), - !all_day); - + e_meeting_time_selector_set_all_day (priv->sel, all_day); + e_date_edit_set_date (E_DATE_EDIT (priv->sel->start_date_edit), start_tt.year, start_tt.month, start_tt.day); e_date_edit_set_time_of_day (E_DATE_EDIT (priv->sel->start_date_edit), @@ -402,10 +399,8 @@ init_widgets (SchedulePage *spage) priv = spage->priv; - gtk_signal_connect (GTK_OBJECT (priv->sel->start_date_edit), - "changed", time_changed_cb, spage); - gtk_signal_connect (GTK_OBJECT (priv->sel->end_date_edit), - "changed", time_changed_cb, spage); + gtk_signal_connect (GTK_OBJECT (priv->sel), + "changed", times_changed_cb, spage); return TRUE; @@ -484,7 +479,7 @@ schedule_page_new (EMeetingModel *emm) } static void -time_changed_cb (GtkWidget *widget, gpointer data) +times_changed_cb (GtkWidget *widget, gpointer data) { SchedulePage *spage = data; SchedulePagePrivate *priv; diff --git a/calendar/gui/e-meeting-time-sel-item.c b/calendar/gui/e-meeting-time-sel-item.c index 1cc2ac516b..a796495451 100644 --- a/calendar/gui/e-meeting-time-sel-item.c +++ b/calendar/gui/e-meeting-time-sel-item.c @@ -335,7 +335,6 @@ e_meeting_time_selector_item_draw (GnomeCanvasItem *item, GdkDrawable *drawable, row = y / mts->row_height; row_y = row * mts->row_height - y; while (row < e_meeting_model_count_actual_attendees (mts->model) && row_y < height) { - ETable *real_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (mts->etable)); gint model_row = e_meeting_model_etable_view_to_model_row (mts->model, row); ia = e_meeting_model_find_attendee_at_row (mts->model, model_row); @@ -857,7 +856,7 @@ e_meeting_time_selector_item_button_press (EMeetingTimeSelectorItem *mts_item, /* Find the nearest half-hour or hour interval, depending on whether zoomed_out is set. */ - if (e_date_edit_get_show_time (E_DATE_EDIT (mts->end_date_edit))) { + if (!mts->all_day) { if (mts->zoomed_out) { start_time.minute = 0; end_time = start_time; @@ -871,6 +870,7 @@ e_meeting_time_selector_item_button_press (EMeetingTimeSelectorItem *mts_item, start_time.hour = 0; start_time.minute = 0; end_time = start_time; + g_date_add_days (&end_time.date, 1); } /* Fix any overflows. */ diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c index f5f16bdc9c..a8becd47bc 100644 --- a/calendar/gui/e-meeting-time-sel.c +++ b/calendar/gui/e-meeting-time-sel.c @@ -92,6 +92,14 @@ const gchar *EMeetingTimeSelectorHours12[24] = { /* This is the maximum scrolling speed. */ #define E_MEETING_TIME_SELECTOR_MAX_SCROLL_SPEED 4 +/* Signals */ +enum { + CHANGED, + LAST_SIGNAL +}; + + +static gint mts_signals [LAST_SIGNAL] = { 0 }; static void e_meeting_time_selector_class_init (EMeetingTimeSelectorClass * klass); static void e_meeting_time_selector_init (EMeetingTimeSelector * mts); @@ -238,10 +246,20 @@ e_meeting_time_selector_class_init (EMeetingTimeSelectorClass * klass) GtkWidgetClass *widget_class; parent_class = gtk_type_class (gtk_table_get_type()); - object_class = (GtkObjectClass *) klass; widget_class = (GtkWidgetClass *) klass; + mts_signals [CHANGED] = + gtk_signal_new ("changed", GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EMeetingTimeSelectorClass, + changed), + gtk_signal_default_marshaller, + GTK_TYPE_NONE, 0); + + gtk_object_class_add_signals (object_class, mts_signals, + LAST_SIGNAL); + object_class->destroy = e_meeting_time_selector_destroy; widget_class->realize = e_meeting_time_selector_realize; @@ -691,8 +709,10 @@ e_meeting_time_selector_construct (EMeetingTimeSelector * mts, EMeetingModel *em e_meeting_time_selector_recalc_grid (mts); e_meeting_time_selector_ensure_meeting_time_shown (mts); e_meeting_time_selector_update_start_date_edit (mts); - e_meeting_time_selector_update_end_date_edit (mts); + e_meeting_time_selector_update_end_date_edit (mts); e_meeting_time_selector_update_date_popup_menus (mts); + + gtk_signal_emit (GTK_OBJECT (mts), mts_signals [CHANGED]); } @@ -1092,13 +1112,37 @@ e_meeting_time_selector_set_meeting_time (EMeetingTimeSelector *mts, gtk_widget_queue_draw (mts->display_top); gtk_widget_queue_draw (mts->display_main); - /* Set the times in the GnomeDateEdit widgets. */ + /* Set the times in the EDateEdit widgets. */ e_meeting_time_selector_update_start_date_edit (mts); e_meeting_time_selector_update_end_date_edit (mts); + gtk_signal_emit (GTK_OBJECT (mts), mts_signals [CHANGED]); + return TRUE; } +void +e_meeting_time_selector_set_all_day (EMeetingTimeSelector *mts, + gboolean all_day) +{ + EMeetingTime saved_time; + + mts->all_day = all_day; + + e_date_edit_set_show_time (E_DATE_EDIT (mts->start_date_edit), + !all_day); + e_date_edit_set_show_time (E_DATE_EDIT (mts->end_date_edit), + !all_day); + + e_meeting_time_selector_save_position (mts, &saved_time); + e_meeting_time_selector_recalc_grid (mts); + e_meeting_time_selector_restore_position (mts, &saved_time); + + gtk_widget_queue_draw (mts->display_top); + gtk_widget_queue_draw (mts->display_main); + e_meeting_time_selector_update_date_popup_menus (mts); +} + void e_meeting_time_selector_set_working_hours_only (EMeetingTimeSelector *mts, @@ -1484,7 +1528,7 @@ e_meeting_time_selector_autopick (EMeetingTimeSelector *mts, /* Get the current meeting duration in days + hours + minutes. */ e_meeting_time_selector_calculate_time_difference (&mts->meeting_start_time, &mts->meeting_end_time, &duration_days, &duration_hours, &duration_minutes); - + /* Find the first appropriate start time. */ start_time = mts->meeting_start_time; if (forward) @@ -1575,9 +1619,12 @@ e_meeting_time_selector_autopick (EMeetingTimeSelector *mts, /* Make sure the time is shown. */ e_meeting_time_selector_ensure_meeting_time_shown (mts); - /* Set the times in the GnomeDateEdit widgets. */ + /* Set the times in the EDateEdit widgets. */ e_meeting_time_selector_update_start_date_edit (mts); e_meeting_time_selector_update_end_date_edit (mts); + + gtk_signal_emit (GTK_OBJECT (mts), mts_signals [CHANGED]); + return; } @@ -1622,15 +1669,21 @@ e_meeting_time_selector_find_nearest_interval (EMeetingTimeSelector *mts, gint minutes_shown; gboolean set_to_start_of_working_day = FALSE; - if (mts->zoomed_out) { - start_time->hour++; - start_time->minute = 0; + if (!mts->all_day) { + if (mts->zoomed_out) { + start_time->hour++; + start_time->minute = 0; + } else { + start_time->minute += 30; + start_time->minute -= start_time->minute % 30; + } } else { - start_time->minute += 30; - start_time->minute -= start_time->minute % 30; + g_date_add_days (&start_time->date, 1); + start_time->hour = 0; + start_time->minute = 0; } e_meeting_time_selector_fix_time_overflows (start_time); - + *end_time = *start_time; e_meeting_time_selector_adjust_time (end_time, days, hours, mins); @@ -1673,6 +1726,7 @@ e_meeting_time_selector_find_nearest_interval (EMeetingTimeSelector *mts, start_time->minute += 29; start_time->minute -= start_time->minute % 30; } + e_meeting_time_selector_fix_time_overflows (start_time); *end_time = *start_time; @@ -1692,25 +1746,31 @@ e_meeting_time_selector_find_nearest_interval_backward (EMeetingTimeSelector *mt gint new_hour, minutes_shown; gboolean set_to_end_of_working_day = FALSE; - new_hour = start_time->hour; - if (mts->zoomed_out) { - if (start_time->minute == 0) - new_hour--; - start_time->minute = 0; - } else { - if (start_time->minute == 0) { - start_time->minute = 30; - new_hour--; - } else if (start_time->minute <= 30) + if (!mts->all_day) { + new_hour = start_time->hour; + if (mts->zoomed_out) { + if (start_time->minute == 0) + new_hour--; start_time->minute = 0; - else - start_time->minute = 30; - } - if (new_hour < 0) { - new_hour += 24; + } else { + if (start_time->minute == 0) { + start_time->minute = 30; + new_hour--; + } else if (start_time->minute <= 30) + start_time->minute = 0; + else + start_time->minute = 30; + } + if (new_hour < 0) { + new_hour += 24; + g_date_subtract_days (&start_time->date, 1); + } + start_time->hour = new_hour; + } else { g_date_subtract_days (&start_time->date, 1); + start_time->hour = 0; + start_time->minute = 0; } - start_time->hour = new_hour; *end_time = *start_time; e_meeting_time_selector_adjust_time (end_time, days, hours, mins); @@ -1753,7 +1813,7 @@ e_meeting_time_selector_find_nearest_interval_backward (EMeetingTimeSelector *mt } else { start_time->minute -= start_time->minute % 30; } - + *end_time = *start_time; e_meeting_time_selector_adjust_time (end_time, days, hours, mins); } @@ -2136,7 +2196,7 @@ e_meeting_time_selector_on_end_time_changed (GtkWidget *widget, newtime = e_date_edit_get_time (E_DATE_EDIT (mts->end_date_edit)); g_date_clear (&mtstime.date, 1); g_date_set_time (&mtstime.date, newtime); - if (!e_date_edit_get_show_time (E_DATE_EDIT (mts->end_date_edit))) + if (mts->all_day) g_date_add_days (&mtstime.date, 1); /* Time */ @@ -2280,7 +2340,7 @@ e_meeting_time_selector_drag_meeting_time (EMeetingTimeSelector *mts, /* Calculate the nearest half-hour or hour, depending on whether zoomed_out is set. */ - if (e_date_edit_get_show_time (E_DATE_EDIT (mts->end_date_edit))) { + if (!mts->all_day) { if (mts->zoomed_out) { if (drag_time.minute > 30) drag_time.hour++; @@ -2295,7 +2355,6 @@ e_meeting_time_selector_drag_meeting_time (EMeetingTimeSelector *mts, drag_time.hour = 0; drag_time.minute = 0; } - e_meeting_time_selector_fix_time_overflows (&drag_time); /* Now make sure we are between first_time & last_time. */ @@ -2314,11 +2373,21 @@ e_meeting_time_selector_drag_meeting_time (EMeetingTimeSelector *mts, if (e_meeting_time_selector_compare_times (time_to_set, &drag_time) == 0) return; + /* Don't let an empty occur for all day events */ + if (mts->all_day + && mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_START + && e_meeting_time_selector_compare_times (&mts->meeting_end_time, &drag_time) == 0) + return; + else if (mts->all_day + && mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_END + && e_meeting_time_selector_compare_times (&mts->meeting_start_time, &drag_time) == 0) + return; + *time_to_set = drag_time; /* Check if the start time and end time need to be switched. */ if (e_meeting_time_selector_compare_times (&mts->meeting_start_time, - &mts->meeting_end_time) > 0) { + &mts->meeting_end_time) > 0) { drag_time = mts->meeting_start_time; mts->meeting_start_time = mts->meeting_end_time; mts->meeting_end_time = drag_time; @@ -2330,6 +2399,7 @@ e_meeting_time_selector_drag_meeting_time (EMeetingTimeSelector *mts, set_both_times = TRUE; } + /* Mark the calculated positions as invalid. */ mts->meeting_positions_valid = FALSE; @@ -2346,6 +2416,11 @@ e_meeting_time_selector_drag_meeting_time (EMeetingTimeSelector *mts, if (set_both_times || mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_END) e_meeting_time_selector_update_end_date_edit (mts); + + if (set_both_times + || mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_END + || mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_START) + gtk_signal_emit (GTK_OBJECT (mts), mts_signals [CHANGED]); } @@ -2460,6 +2535,11 @@ e_meeting_time_selector_timeout_handler (gpointer data) || mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_END) e_meeting_time_selector_update_end_date_edit (mts); + if (set_both_times + || mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_END + || mts->dragging_position == E_MEETING_TIME_SELECTOR_POS_START) + gtk_signal_emit (GTK_OBJECT (mts), mts_signals [CHANGED]); + /* Redraw the canvases. We freeze and thaw the layouts so that they get redrawn completely. Otherwise the pixels get scrolled left or right which is not good for us (since our vertical bars have been @@ -2493,13 +2573,12 @@ e_meeting_time_selector_remove_timeout (EMeetingTimeSelector *mts) static void e_meeting_time_selector_update_start_date_edit (EMeetingTimeSelector *mts) { - e_date_edit_set_date (E_DATE_EDIT (mts->start_date_edit), - mts->meeting_start_time.date.year, - mts->meeting_start_time.date.month, - mts->meeting_start_time.date.day); - e_date_edit_set_time_of_day (E_DATE_EDIT (mts->start_date_edit), - mts->meeting_start_time.hour, - mts->meeting_start_time.minute); + e_date_edit_set_date_and_time_of_day (E_DATE_EDIT (mts->start_date_edit), + g_date_year (&mts->meeting_start_time.date), + g_date_month (&mts->meeting_start_time.date), + g_date_day (&mts->meeting_start_time.date), + mts->meeting_start_time.hour, + mts->meeting_start_time.minute); } @@ -2507,13 +2586,18 @@ e_meeting_time_selector_update_start_date_edit (EMeetingTimeSelector *mts) static void e_meeting_time_selector_update_end_date_edit (EMeetingTimeSelector *mts) { - e_date_edit_set_date (E_DATE_EDIT (mts->end_date_edit), - mts->meeting_end_time.date.year, - mts->meeting_end_time.date.month, - mts->meeting_end_time.date.day); - e_date_edit_set_time_of_day (E_DATE_EDIT (mts->end_date_edit), - mts->meeting_end_time.hour, - mts->meeting_end_time.minute); + GDate date; + + date = mts->meeting_end_time.date; + if (mts->all_day) + g_date_subtract_days (&date, 1); + + e_date_edit_set_date_and_time_of_day (E_DATE_EDIT (mts->end_date_edit), + g_date_year (&date), + g_date_month (&date), + g_date_day (&date), + mts->meeting_end_time.hour, + mts->meeting_end_time.minute); } diff --git a/calendar/gui/e-meeting-time-sel.h b/calendar/gui/e-meeting-time-sel.h index eb66c523e2..30c1abefa7 100644 --- a/calendar/gui/e-meeting-time-sel.h +++ b/calendar/gui/e-meeting-time-sel.h @@ -183,6 +183,9 @@ struct _EMeetingTimeSelector * Option Settings. */ + /* True if we are selecting all day events */ + gboolean all_day; + /* If this is TRUE we only show hours between day_start_hour and day_end_hour, defaults to TRUE (9am-6pm). */ gboolean working_hours_only; @@ -252,6 +255,8 @@ struct _EMeetingTimeSelector struct _EMeetingTimeSelectorClass { GtkTableClass parent_class; + + void (* changed) (EMeetingTimeSelector *mts); }; @@ -293,6 +298,8 @@ gboolean e_meeting_time_selector_set_meeting_time (EMeetingTimeSelector *mts, gint end_hour, gint end_minute); +void e_meeting_time_selector_set_all_day (EMeetingTimeSelector *mts, + gboolean all_day); void e_meeting_time_selector_set_working_hours_only (EMeetingTimeSelector *mts, gboolean working_hours_only); void e_meeting_time_selector_set_working_hours (EMeetingTimeSelector *mts, |