From 90dc62f9e598a84a4300f06c329c288b5171e159 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Fri, 25 Apr 2003 01:57:55 +0000 Subject: Fixes #37552 2003-04-24 JP Rosevear Fixes #37552 * gui/dialogs/Makefile.am: build delete-error.[hc] * gui/e-tasks.c: wrap calls to cal_client_remove_object with delete_error_dialog * gui/e-itip-control.c: ditto * gui/e-calendar-table.c: ditto * gui/e-week-view.c: ditto * gui/e-day-view.c: ditto * gui/dialogs/delete-error.[hc]: gemerate an error message based on result svn path=/trunk/; revision=20961 --- calendar/gui/dialogs/Makefile.am | 2 + calendar/gui/dialogs/delete-error.c | 107 ++++++++++++++++++++++++++++++++++++ calendar/gui/dialogs/delete-error.h | 30 ++++++++++ calendar/gui/e-calendar-table.c | 8 +-- calendar/gui/e-day-view.c | 16 +++--- calendar/gui/e-itip-control.c | 11 +++- calendar/gui/e-tasks.c | 3 +- calendar/gui/e-week-view.c | 15 ++--- 8 files changed, 165 insertions(+), 27 deletions(-) create mode 100644 calendar/gui/dialogs/delete-error.c create mode 100644 calendar/gui/dialogs/delete-error.h (limited to 'calendar/gui') diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am index 8dc79e7fe7..4bbdd90ca5 100644 --- a/calendar/gui/dialogs/Makefile.am +++ b/calendar/gui/dialogs/Makefile.am @@ -53,6 +53,8 @@ libcal_dialogs_la_SOURCES = \ comp-editor-util.h \ delete-comp.c \ delete-comp.h \ + delete-error.c \ + delete-error.h \ e-delegate-dialog.c \ e-delegate-dialog.h \ event-editor.c \ diff --git a/calendar/gui/dialogs/delete-error.c b/calendar/gui/dialogs/delete-error.c new file mode 100644 index 0000000000..947aab1e97 --- /dev/null +++ b/calendar/gui/dialogs/delete-error.c @@ -0,0 +1,107 @@ +/* Evolution calendar - Send calendar component dialog + * + * Copyright (C) 2001 Ximian, Inc. + * + * Author: JP Rosevear + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include "delete-error.h" + + + +/** + * delete_error_dialog: + * + * Shows any applicable error messages as the result of deleting and object + * + **/ +void +delete_error_dialog (CalClientResult result, CalComponentVType vtype) +{ + GtkWidget *dialog; + const char *str; + + switch (result) { + case CAL_CLIENT_RESULT_CORBA_ERROR: + switch (vtype) { + case CAL_COMPONENT_EVENT: + str = _("The event could not be deleted due to a corba error"); + break; + case CAL_COMPONENT_TODO: + str = _("The task could not be deleted due to a corba error"); + break; + case CAL_COMPONENT_JOURNAL: + str = _("The journal entry could not be deleted due to a corba error"); + break; + default: + str = _("The item could not be deleted due to a corba error"); + break; + } + break; + case CAL_CLIENT_RESULT_PERMISSION_DENIED: + switch (vtype) { + case CAL_COMPONENT_EVENT: + str = _("The event could not be deleted because permission was denied"); + break; + case CAL_COMPONENT_TODO: + str = _("The task could not be deleted because permission was denied"); + break; + case CAL_COMPONENT_JOURNAL: + str = _("The journal entry could not be deleted because permission was denied"); + break; + default: + str = _("The item could not be deleted because permission was denied"); + break; + } + break; + case CAL_CLIENT_RESULT_INVALID_OBJECT: + switch (vtype) { + case CAL_COMPONENT_EVENT: + str = _("The event could not be deleted because it was invalid"); + break; + case CAL_COMPONENT_TODO: + str = _("The task could not be deleted because it was invalid"); + break; + case CAL_COMPONENT_JOURNAL: + str = _("The journal entry could not be deleted because it was invalid"); + break; + default: + str = _("The item could not be deleted because it was invalid"); + break; + } + break; + case CAL_CLIENT_RESULT_SUCCESS: + case CAL_CLIENT_RESULT_NOT_FOUND: + default: + /* If not found, we don't care - its gone anyhow */ + return; + } + + dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, str); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); +} diff --git a/calendar/gui/dialogs/delete-error.h b/calendar/gui/dialogs/delete-error.h new file mode 100644 index 0000000000..dcef2fa3be --- /dev/null +++ b/calendar/gui/dialogs/delete-error.h @@ -0,0 +1,30 @@ +/* Evolution calendar - Send calendar component dialog + * + * Copyright (C) 2001 Ximian, Inc. + * + * Author: JP Rosevear + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef DELETE_ERROR_H +#define DELETE_ERROR_H + +#include +#include +#include + +void delete_error_dialog (CalClientResult result, CalComponentVType vtype); + +#endif diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 41d12685b8..b3ac35e045 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -48,6 +48,7 @@ #include "calendar-model.h" #include "print.h" #include "dialogs/delete-comp.h" +#include "dialogs/delete-error.h" #include "dialogs/task-editor.h" /* Pixmaps. */ @@ -716,13 +717,10 @@ delete_selected_components (ECalendarTable *cal_table) for (l = uids; l; l = l->next) { const char *uid; - + uid = l->data; - /* We don't check the return value; FALSE can mean the object - * was not in the server anyways. - */ - cal_client_remove_object (client, uid); + delete_error_dialog (cal_client_remove_object (client, uid), CAL_COMPONENT_TODO); } calendar_model_set_status_message (e_calendar_table_get_model (cal_table), NULL); diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 2fae66475c..ed6cc4f5cb 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -54,6 +54,7 @@ #include "cal-util/timeutil.h" #include "dialogs/delete-comp.h" +#include "dialogs/delete-error.h" #include "dialogs/send-comp.h" #include "dialogs/cancel-comp.h" #include "dialogs/recur-comp.h" @@ -2821,7 +2822,7 @@ e_day_view_cut_clipboard (EDayView *day_view) e_day_view_copy_clipboard (day_view); cal_component_get_uid (event->comp, &uid); - cal_client_remove_object (day_view->client, uid); + delete_error_dialog (cal_client_remove_object (day_view->client, uid), CAL_COMPONENT_EVENT); e_day_view_set_status_message (day_view, NULL); } @@ -4077,10 +4078,7 @@ e_day_view_delete_event_internal (EDayView *day_view, EDayViewEvent *event) cal_component_get_uid (event->comp, &uid); - /* We don't check the return value; FALSE can mean the object - * was not in the server anyways. - */ - cal_client_remove_object (day_view->client, uid); + delete_error_dialog (cal_client_remove_object (day_view->client, uid), CAL_COMPONENT_EVENT); } } @@ -4141,9 +4139,9 @@ e_day_view_delete_occurrence_internal (EDayView *day_view, EDayViewEvent *event) 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!"); - + + delete_error_dialog (cal_client_remove_object_with_mod (day_view->client, uid, CALOBJ_MOD_THIS), + CAL_COMPONENT_EVENT); return; } @@ -4215,7 +4213,7 @@ e_day_view_on_cut (GtkWidget *widget, gpointer data) itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, event->comp, day_view->client, NULL); cal_component_get_uid (event->comp, &uid); - cal_client_remove_object (day_view->client, uid); + delete_error_dialog (cal_client_remove_object (day_view->client, uid), CAL_COMPONENT_EVENT); } static void diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index b751015d6e..89434d02c8 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -51,6 +51,7 @@ #include #include #include +#include "dialogs/delete-error.h" #include "calendar-config.h" #include "itip-utils.h" #include "e-itip-control.h" @@ -2036,7 +2037,8 @@ remove_item (EItipControl *itip) CalComponentVType type; const char *uid; GtkWidget *dialog; - + CalClientResult result; + priv = itip->priv; type = cal_component_get_vtype (priv->comp); @@ -2049,10 +2051,13 @@ remove_item (EItipControl *itip) return; cal_component_get_uid (priv->comp, &uid); - if (cal_client_remove_object (client, uid) == CAL_CLIENT_RESULT_SUCCESS) { + result = cal_client_remove_object (client, uid); + if (result == CAL_CLIENT_RESULT_SUCCESS || result == CAL_CLIENT_RESULT_NOT_FOUND) { dialog = gnome_ok_dialog (_("Removal Complete")); gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); - } + } else { + delete_error_dialog (result, type); + } } static void diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c index cc247c2d85..38035400da 100644 --- a/calendar/gui/e-tasks.c +++ b/calendar/gui/e-tasks.c @@ -32,6 +32,7 @@ #include "e-util/e-url.h" #include "widgets/menus/gal-view-menus.h" +#include "dialogs/delete-error.h" #include "dialogs/task-editor.h" #include "cal-search-bar.h" #include "calendar-config.h" @@ -604,7 +605,7 @@ query_obj_updated_cb (CalQuery *query, const char *uid, tasks = E_TASKS (data); priv = tasks->priv; - cal_client_remove_object (priv->client, uid); + delete_error_dialog (cal_client_remove_object (priv->client, uid), CAL_COMPONENT_TODO); } /* Callback used when an evaluation error occurs when running a query */ diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 8ab0b44b1c..406a3876d1 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -51,6 +51,7 @@ #include #include #include "dialogs/delete-comp.h" +#include "dialogs/delete-error.h" #include "dialogs/send-comp.h" #include "dialogs/cancel-comp.h" #include "dialogs/recur-comp.h" @@ -1914,7 +1915,7 @@ e_week_view_cut_clipboard (EWeekView *week_view) e_week_view_copy_clipboard (week_view); cal_component_get_uid (event->comp, &uid); - cal_client_remove_object (week_view->client, uid); + delete_error_dialog (cal_client_remove_object (week_view->client, uid), CAL_COMPONENT_EVENT); e_week_view_set_status_message (week_view, NULL); } @@ -3924,10 +3925,7 @@ e_week_view_delete_event_internal (EWeekView *week_view, gint event_num) cal_component_get_uid (event->comp, &uid); - /* We don't check the return value; FALSE can mean the object - * was not in the server anyways. - */ - cal_client_remove_object (week_view->client, uid); + delete_error_dialog (cal_client_remove_object (week_view->client, uid), CAL_COMPONENT_EVENT); } } @@ -3973,9 +3971,8 @@ e_week_view_delete_occurrence_internal (EWeekView *week_view, gint event_num) 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!"); - + delete_error_dialog (cal_client_remove_object_with_mod (week_view->client, uid, CALOBJ_MOD_THIS), + CAL_COMPONENT_EVENT); return; } @@ -4037,7 +4034,7 @@ e_week_view_on_cut (GtkWidget *widget, gpointer data) itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, event->comp, week_view->client, NULL); cal_component_get_uid (event->comp, &uid); - cal_client_remove_object (week_view->client, uid); + delete_error_dialog (cal_client_remove_object (week_view->client, uid), CAL_COMPONENT_EVENT); } static void -- cgit