evolution-3.6.4/calendar/gui/dialogs/delete-error.c

No issues found

  1 /*
  2  * Evolution calendar - Send calendar component dialog
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2 of the License, or (at your option) version 3.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with the program; if not, see <http://www.gnu.org/licenses/>
 16  *
 17  *
 18  * Authors:
 19  *		JP Rosevear <jpr@ximian.com>
 20  *
 21  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 22  *
 23  */
 24 
 25 #ifdef HAVE_CONFIG_H
 26 #include <config.h>
 27 #endif
 28 
 29 #include <gtk/gtk.h>
 30 #include <glib/gi18n.h>
 31 #include "delete-error.h"
 32 
 33 /**
 34  * delete_error_dialog:
 35  *
 36  * Shows any applicable error messages as the result of deleting and object
 37  *
 38  **/
 39 void
 40 delete_error_dialog (const GError *error,
 41                      ECalComponentVType vtype)
 42 {
 43 	GtkWidget *dialog;
 44 	const gchar *str;
 45 	const gchar *icon_name = NULL;
 46 
 47 	if (!error || error->domain != E_CLIENT_ERROR)
 48 		return;
 49 
 50 	switch (error->code) {
 51 	case E_CLIENT_ERROR_DBUS_ERROR:
 52 		switch (vtype) {
 53 		case E_CAL_COMPONENT_EVENT:
 54 			/* Translators: The '%s' is replaced with a detailed error message */
 55 			str = _("The event could not be deleted due to a dbus error: %s");
 56 			break;
 57 		case E_CAL_COMPONENT_TODO:
 58 			/* Translators: The '%s' is replaced with a detailed error message */
 59 			str = _("The task could not be deleted due to a dbus error: %s");
 60 			break;
 61 		case E_CAL_COMPONENT_JOURNAL:
 62 			/* Translators: The '%s' is replaced with a detailed error message */
 63 			str = _("The memo could not be deleted due to a dbus error: %s");
 64 			break;
 65 		default:
 66 			/* Translators: The '%s' is replaced with a detailed error message */
 67 			str = _("The item could not be deleted due to a dbus error: %s");
 68 			break;
 69 		}
 70 		break;
 71 	case E_CLIENT_ERROR_PERMISSION_DENIED:
 72 		switch (vtype) {
 73 		case E_CAL_COMPONENT_EVENT:
 74 			str = _("The event could not be deleted because permission was denied");
 75 			break;
 76 		case E_CAL_COMPONENT_TODO:
 77 			str = _("The task could not be deleted because permission was denied");
 78 			break;
 79 		case E_CAL_COMPONENT_JOURNAL:
 80 			str = _("The memo could not be deleted because permission was denied");
 81 			break;
 82 		default:
 83 			str = _("The item could not be deleted because permission was denied");
 84 			break;
 85 		}
 86 		break;
 87 	case E_CLIENT_ERROR_OTHER_ERROR:
 88 		switch (vtype) {
 89 		case E_CAL_COMPONENT_EVENT:
 90 			/* Translators: The '%s' is replaced with a detailed error message */
 91 			str = _("The event could not be deleted due to an error: %s");
 92 			break;
 93 		case E_CAL_COMPONENT_TODO:
 94 			/* Translators: The '%s' is replaced with a detailed error message */
 95 			str = _("The task could not be deleted due to an error: %s");
 96 			break;
 97 		case E_CAL_COMPONENT_JOURNAL:
 98 			/* Translators: The '%s' is replaced with a detailed error message */
 99 			str = _("The memo could not be deleted due to an error: %s");
100 			break;
101 		default:
102 			/* Translators: The '%s' is replaced with a detailed error message */
103 			str = _("The item could not be deleted due to an error: %s");
104 			break;
105 		}
106 		break;
107 	default:
108 		/* If not found, we don't care - its gone anyhow */
109 		return;
110 	}
111 
112 	dialog = gtk_message_dialog_new (
113 		NULL, GTK_DIALOG_MODAL,
114 		GTK_MESSAGE_ERROR,
115 		GTK_BUTTONS_OK, str, error->message);
116 	if (vtype == E_CAL_COMPONENT_EVENT)
117 		icon_name = "x-office-calendar";
118 	else if (vtype == E_CAL_COMPONENT_TODO)
119 		icon_name = "stock_todo";
120 
121 	if (icon_name)
122 		gtk_window_set_icon_name (GTK_WINDOW (dialog), icon_name);
123 
124 	gtk_dialog_run (GTK_DIALOG (dialog));
125 	gtk_widget_destroy (dialog);
126 }