diff options
author | Rodrigo Moya <rodrigo@ximian.com> | 2003-04-23 02:06:38 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2003-04-23 02:06:38 +0800 |
commit | 95d8e5b20bdc58eb2a72a6f8f75ca99cbd6b169b (patch) | |
tree | bb270c7030c3dad20de98b0f9d68455e65fda34b /calendar | |
parent | 4167920c363eb3ff08268ffe250c4786fe72b0ac (diff) | |
download | gsoc2013-evolution-95d8e5b20bdc58eb2a72a6f8f75ca99cbd6b169b.tar.gz gsoc2013-evolution-95d8e5b20bdc58eb2a72a6f8f75ca99cbd6b169b.tar.zst gsoc2013-evolution-95d8e5b20bdc58eb2a72a6f8f75ca99cbd6b169b.zip |
Fixes #22444
2003-04-21 Rodrigo Moya <rodrigo@ximian.com>
Fixes #22444
* gui/calendar-commands.c: added new verbs for occurrence-related
menu items.
(delete_occurrence_cmd): added callback for "Delete this occurrence"
menu item. "Delete all occurrences" is just the same as "Delete".
(sensitize_calendar_commands): sensitive ocurrence-related menu items.
* gui/gnome-cal.[ch] (gnome_calendar_delete_selected_occurrence): new
function.
(gnome_calendar_get_current_view_widget): made this public.
* gui/e-week-view.[ch] (e_week_view_get_selected_event):
(e_week_view_delete_occurrence): new functions.
(e_week_view_delete_occurrence_internal): real implementation of the
'Delete Occurrence' logic.
(e_week_view_on_delete_occurrence): call delete_instance_internal.
* gui/e-day-view.[ch] (e_day_view_get_selected_event):
(e_day_view_delete_occurrence): new functions.
(e_week_view_delete_occurrence_internal): real implementation of the
'Delete Occurrence' logic.
(e_week_view_on_delete_occurrence): call delete_occurrence_internal.
svn path=/trunk/; revision=20917
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 26 | ||||
-rw-r--r-- | calendar/gui/calendar-commands.c | 47 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 118 | ||||
-rw-r--r-- | calendar/gui/e-day-view.h | 2 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 108 | ||||
-rw-r--r-- | calendar/gui/e-week-view.h | 3 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 25 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 2 |
8 files changed, 257 insertions, 74 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 238dc435dc..e3cd63eb0a 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,29 @@ +2003-04-21 Rodrigo Moya <rodrigo@ximian.com> + + Fixes #22444 + + * gui/calendar-commands.c: added new verbs for occurrence-related + menu items. + (delete_occurrence_cmd): added callback for "Delete this occurrence" + menu item. "Delete all occurrences" is just the same as "Delete". + (sensitize_calendar_commands): sensitive ocurrence-related menu items. + + * gui/gnome-cal.[ch] (gnome_calendar_delete_selected_occurrence): new + function. + (gnome_calendar_get_current_view_widget): made this public. + + * gui/e-week-view.[ch] (e_week_view_get_selected_event): + (e_week_view_delete_occurrence): new functions. + (e_week_view_delete_occurrence_internal): real implementation of the + 'Delete Occurrence' logic. + (e_week_view_on_delete_occurrence): call delete_instance_internal. + + * gui/e-day-view.[ch] (e_day_view_get_selected_event): + (e_day_view_delete_occurrence): new functions. + (e_week_view_delete_occurrence_internal): real implementation of the + 'Delete Occurrence' logic. + (e_week_view_on_delete_occurrence): call delete_occurrence_internal. + 2003-04-18 Rodrigo Moya <rodrigo@ximian.com> * gui/alarm-notify/alarm-notify.glade: removed 'heading' and diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index 23109d50a7..6dac8ec8a5 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -49,6 +49,8 @@ #include "shell/Evolution.h" #include "calendar-commands.h" #include "calendar-config.h" +#include "e-day-view.h" +#include "e-week-view.h" #include "gnome-cal.h" #include "goto.h" #include "print.h" @@ -293,6 +295,18 @@ delete_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path) } static void +delete_occurrence_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path) +{ + GnomeCalendar *gcal; + + gcal = GNOME_CALENDAR (data); + + set_clock_cursor (gcal); + gnome_calendar_delete_selected_occurrence (gcal); + set_normal_cursor (gcal); +} + +static void publish_freebusy_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path) { GnomeCalendar *gcal; @@ -505,7 +519,7 @@ sensitize_calendar_commands (GnomeCalendar *gcal, BonoboControl *control, gboole { BonoboUIComponent *uic; int n_selected; - gboolean read_only; + gboolean read_only, has_recurrences; uic = bonobo_control_get_ui_component (control); g_assert (uic != NULL); @@ -525,6 +539,33 @@ sensitize_calendar_commands (GnomeCalendar *gcal, BonoboControl *control, gboole bonobo_ui_component_set_prop (uic, "/commands/Delete", "sensitive", n_selected == 0 || read_only ? "0" : "1", NULL); + + /* occurrence-related menu items */ + has_recurrences = FALSE; + if (n_selected > 0 && !read_only) { + CalComponent *comp; + GtkWidget *view; + + view = gnome_calendar_get_current_view_widget (gcal); + if (E_IS_DAY_VIEW (view)) + comp = e_day_view_get_selected_event (E_DAY_VIEW (view)); + else if (E_IS_WEEK_VIEW (view)) + comp = e_week_view_get_selected_event (E_WEEK_VIEW (view)); + else + comp = NULL; + + if (comp) { + if (cal_component_has_recurrences (comp)) + has_recurrences = TRUE; + } + } + + bonobo_ui_component_set_prop (uic, "/commands/DeleteOccurrence", "sensitive", + has_recurrences ? "1" : "0", + NULL); + bonobo_ui_component_set_prop (uic, "/commands/DeleteAllOccurrences", "sensitive", + has_recurrences ? "1" : "0", + NULL); } /* Sensitizes the UI Component menu/toolbar tasks commands based on the number @@ -659,6 +700,8 @@ static BonoboUIVerb verbs [] = { BONOBO_UI_VERB ("Copy", copy_cmd), BONOBO_UI_VERB ("Paste", paste_cmd), BONOBO_UI_VERB ("Delete", delete_cmd), + BONOBO_UI_VERB ("DeleteOccurrence", delete_occurrence_cmd), + BONOBO_UI_VERB ("DeleteAllOccurrences", delete_cmd), BONOBO_UI_VERB ("CalendarPrev", previous_clicked), BONOBO_UI_VERB ("CalendarToday", today_clicked), @@ -681,6 +724,8 @@ static EPixmap pixmaps [] = E_PIXMAP ("/menu/EditPlaceholder/Edit/Copy", "16_copy.png"), E_PIXMAP ("/menu/EditPlaceholder/Edit/Paste", "16_paste.png"), E_PIXMAP ("/menu/EditPlaceholder/Edit/Delete", "evolution-trash-mini.png"), + E_PIXMAP ("/menu/EditPlaceholder/Edit/DeleteOccurrence", "evolution-trash-mini.png"), + E_PIXMAP ("/menu/EditPlaceholder/Edit/DeleteAllOccurrences", "evolution-trash-mini.png"), E_PIXMAP ("/menu/File/Print/Print", "print.xpm"), E_PIXMAP ("/menu/File/Print/PrintPreview", "print-preview.xpm"), E_PIXMAP ("/menu/View/ViewBegin/Goto", "goto-16.png"), diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 90e8f28069..27b512a63a 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -4077,40 +4077,6 @@ e_day_view_on_settings (GtkWidget *widget, gpointer data) } static void -e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - CalComponent *comp; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - if (cal_component_is_instance (event->comp)) { - const char *uid; - - cal_component_get_uid (event->comp, &uid); - if (cal_client_remove_object_with_mod (day_view->client, uid, CALOBJ_MOD_THIS) != CAL_CLIENT_RESULT_SUCCESS) - g_message ("e_day_view_on_delete_occurrence(): Could not update the object!"); - - return; - } - - /* We must duplicate the CalComponent, or we won't know it has changed - when we get the "update_event" callback. */ - comp = cal_component_clone (event->comp); - cal_comp_util_add_exdate (comp, event->start, day_view->zone); - - if (cal_client_update_object (day_view->client, comp) != CAL_CLIENT_RESULT_SUCCESS) - g_message ("e_day_view_on_delete_occurrence(): Could not update the object!"); - - g_object_unref (comp); -} - -static void e_day_view_delete_event_internal (EDayView *day_view, EDayViewEvent *event) { CalComponentVType vtype; @@ -4182,6 +4148,69 @@ e_day_view_delete_event (EDayView *day_view) e_day_view_delete_event_internal (day_view, event); } +static void +e_day_view_delete_occurrence_internal (EDayView *day_view, EDayViewEvent *event) +{ + CalComponent *comp; + + if (cal_component_is_instance (event->comp)) { + const char *uid; + + cal_component_get_uid (event->comp, &uid); + if (cal_client_remove_object_with_mod (day_view->client, uid, CALOBJ_MOD_THIS) != CAL_CLIENT_RESULT_SUCCESS) + g_message ("e_day_view_on_delete_occurrence(): Could not update the object!"); + + return; + } + + /* We must duplicate the CalComponent, or we won't know it has changed + when we get the "update_event" callback. */ + comp = cal_component_clone (event->comp); + cal_comp_util_add_exdate (comp, event->start, day_view->zone); + + if (cal_client_update_object (day_view->client, comp) != CAL_CLIENT_RESULT_SUCCESS) + g_message ("e_day_view_on_delete_occurrence(): Could not update the object!"); + + g_object_unref (comp); +} + +static void +e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data) +{ + EDayView *day_view; + EDayViewEvent *event; + CalComponent *comp; + + day_view = E_DAY_VIEW (data); + + event = e_day_view_get_popup_menu_event (day_view); + if (event == NULL) + return; + + e_day_view_delete_occurrence_internal (day_view, event); +} + +void +e_day_view_delete_occurrence (EDayView *day_view) +{ + EDayViewEvent *event; + + g_return_if_fail (E_IS_DAY_VIEW (day_view)); + + if (day_view->editing_event_day == -1) + return; + + if (day_view->editing_event_day == E_DAY_VIEW_LONG_EVENT) + event = &g_array_index (day_view->long_events, + EDayViewEvent, + day_view->editing_event_num); + else + event = &g_array_index (day_view->events[day_view->editing_event_day], + EDayViewEvent, + day_view->editing_event_num); + + e_day_view_delete_occurrence_internal (day_view, event); +} static void e_day_view_on_cut (GtkWidget *widget, gpointer data) @@ -7756,6 +7785,27 @@ e_day_view_get_num_events_selected (EDayView *day_view) return (day_view->editing_event_day != -1) ? 1 : 0; } +/* Returns the currently-selected event, or NULL if none */ +CalComponent * +e_day_view_get_selected_event (EDayView *day_view) +{ + EDayViewEvent *event; + + g_return_val_if_fail (E_IS_DAY_VIEW (day_view), NULL); + g_return_val_if_fail (day_view->editing_event_day != -1, NULL); + + if (day_view->editing_event_day == E_DAY_VIEW_LONG_EVENT) + event = &g_array_index (day_view->long_events, + EDayViewEvent, + day_view->editing_event_num); + else + event = &g_array_index (day_view->events[day_view->editing_event_day], + EDayViewEvent, + day_view->editing_event_num); + + return event ? event->comp : NULL; +} + /* Displays messages on the status bar. */ void e_day_view_set_status_message (EDayView *day_view, const char *message) diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h index 8743751be1..c8b719aca1 100644 --- a/calendar/gui/e-day-view.h +++ b/calendar/gui/e-day-view.h @@ -609,11 +609,13 @@ void e_day_view_copy_clipboard (EDayView *day_view); void e_day_view_paste_clipboard (EDayView *day_view); void e_day_view_delete_event (EDayView *day_view); +void e_day_view_delete_occurrence (EDayView *day_view); /* Returns the number of selected events (0 or 1 at present). */ gint e_day_view_get_num_events_selected (EDayView *day_view); +CalComponent *e_day_view_get_selected_event (EDayView *day_view); /* * Internal functions called by the associated canvas items. diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 88de72c287..649da416f9 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -3898,44 +3898,6 @@ e_week_view_on_settings (GtkWidget *widget, gpointer data) } static void -e_week_view_on_delete_occurrence (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - CalComponent *comp; - - week_view = E_WEEK_VIEW (data); - - if (week_view->popup_event_num == -1) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, - week_view->popup_event_num); - - if (cal_component_is_instance (event->comp)) { - const char *uid; - - cal_component_get_uid (event->comp, &uid); - if (cal_client_remove_object_with_mod (week_view->client, uid, CALOBJ_MOD_THIS) != CAL_CLIENT_RESULT_SUCCESS) - g_message ("e_week_view_on_delete_occurrence(): Could not update the object!"); - - return; - } - - /* We must duplicate the CalComponent, or we won't know it has changed - when we get the "update_event" callback. */ - - comp = cal_component_clone (event->comp); - cal_comp_util_add_exdate (comp, event->start, week_view->zone); - - if (cal_client_update_object (week_view->client, comp) != CAL_CLIENT_RESULT_SUCCESS) - g_message ("e_week_view_on_delete_occurrence(): Could not update the object!"); - - g_object_unref (comp); -} - - -static void e_week_view_delete_event_internal (EWeekView *week_view, gint event_num) { CalComponentVType vtype; @@ -3993,6 +3955,61 @@ e_week_view_delete_event (EWeekView *week_view) static void +e_week_view_delete_occurrence_internal (EWeekView *week_view, gint event_num) +{ + EWeekViewEvent *event; + CalComponent *comp; + + event = &g_array_index (week_view->events, EWeekViewEvent, + event_num); + + if (cal_component_is_instance (event->comp)) { + const char *uid; + + cal_component_get_uid (event->comp, &uid); + if (cal_client_remove_object_with_mod (week_view->client, uid, CALOBJ_MOD_THIS) != CAL_CLIENT_RESULT_SUCCESS) + g_message ("e_week_view_on_delete_occurrence(): Could not update the object!"); + + return; + } + + /* We must duplicate the CalComponent, or we won't know it has changed + when we get the "update_event" callback. */ + + comp = cal_component_clone (event->comp); + cal_comp_util_add_exdate (comp, event->start, week_view->zone); + + if (cal_client_update_object (week_view->client, comp) != CAL_CLIENT_RESULT_SUCCESS) + g_message ("e_week_view_on_delete_occurrence(): Could not update the object!"); + + g_object_unref (comp); +} + +static void +e_week_view_on_delete_occurrence (GtkWidget *widget, gpointer data) +{ + EWeekView *week_view; + + week_view = E_WEEK_VIEW (data); + + if (week_view->popup_event_num == -1) + return; + + e_week_view_delete_occurrence_internal (week_view, week_view->popup_event_num); +} + +void +e_week_view_delete_occurrence (EWeekView *week_view) +{ + g_return_if_fail (E_IS_WEEK_VIEW (week_view)); + + if (week_view->editing_event_num == -1) + return; + + e_week_view_delete_occurrence_internal (week_view, week_view->editing_event_num); +} + +static void e_week_view_on_cut (GtkWidget *widget, gpointer data) { EWeekView *week_view; @@ -4430,6 +4447,21 @@ e_week_view_get_num_events_selected (EWeekView *week_view) return (week_view->editing_event_num != -1) ? 1 : 0; } +/* Returns the currently-selected event, or NULL if none */ +CalComponent * +e_week_view_get_selected_event (EWeekView *week_view) +{ + EWeekViewEvent *event; + + g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), NULL); + g_return_val_if_fail (week_view->editing_event_num != -1, NULL); + + event = &g_array_index (week_view->events, EWeekViewEvent, + week_view->editing_event_num); + + return event ? event->comp : NULL; +} + /* Displays a message on the activity client. */ void e_week_view_set_status_message (EWeekView *week_view, const char *message) diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index 8723d14cf9..fc481bdc4a 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -465,10 +465,13 @@ void e_week_view_copy_clipboard (EWeekView *week_view); void e_week_view_paste_clipboard (EWeekView *week_view); void e_week_view_delete_event (EWeekView *week_view); +void e_week_view_delete_occurrence (EWeekView *week_view); /* Returns the number of selected events (0 or 1 at present). */ gint e_week_view_get_num_events_selected (EWeekView *week_view); +CalComponent *e_week_view_get_selected_event (EWeekView *week_view); + /* * Internal functions called by the associated canvas items. */ diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index be5de68b80..b56f4a1824 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -347,7 +347,7 @@ dn_query_eval_error_cb (CalQuery *query, const char *error_str, gpointer data) } /* Returns the current view widget, a EDayView or EWeekView. */ -static GtkWidget* +GtkWidget* gnome_calendar_get_current_view_widget (GnomeCalendar *gcal) { GnomeCalendarPrivate *priv; @@ -2853,6 +2853,29 @@ gnome_calendar_delete_selection (GnomeCalendar *gcal) g_assert_not_reached (); } +void +gnome_calendar_delete_selected_occurrence (GnomeCalendar *gcal) +{ + GnomeCalendarPrivate *priv; + FocusLocation location; + GtkWidget *view; + + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); + + priv = gcal->priv; + + location = get_focus_location (gcal); + + if (location == FOCUS_CALENDAR) { + + view = gnome_calendar_get_current_view_widget (gcal); + + if (E_IS_DAY_VIEW (view)) + e_day_view_delete_occurrence (E_DAY_VIEW (view)); + else + e_week_view_delete_occurrence (E_WEEK_VIEW (view)); + } +} ECalendarTable* gnome_calendar_get_task_pad (GnomeCalendar *gcal) diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 2c71eb898c..52c2cf5176 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -108,6 +108,7 @@ GnomeCalendarViewType gnome_calendar_get_view (GnomeCalendar *gcal); void gnome_calendar_set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean range_selected, gboolean grab_focus); +GtkWidget *gnome_calendar_get_current_view_widget (GnomeCalendar *gcal); void gnome_calendar_setup_view_menus (GnomeCalendar *gcal, BonoboUIComponent *uic); void gnome_calendar_discard_view_menus (GnomeCalendar *gcal); @@ -167,6 +168,7 @@ void gnome_calendar_copy_clipboard (GnomeCalendar *gcal); void gnome_calendar_paste_clipboard (GnomeCalendar *gcal); void gnome_calendar_delete_selection (GnomeCalendar *gcal); +void gnome_calendar_delete_selected_occurrence (GnomeCalendar *gcal); |