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 <glib/gi18n.h>
30 #include "changed-comp.h"
31
32 /**
33 * changed_component_dialog:
34 * @parent: Parent window for the dialog.
35 * @comp: A calendar component
36 * @deleted: Whether the object is being deleted or updated
37 * @changed: Whether or not the user has made changes
38 *
39 * Pops up a dialog box asking the user whether changes made (if any)
40 * should be thrown away because the item has been updated elsewhere
41 *
42 * Return value: TRUE if the user clicked Yes, FALSE otherwise.
43 **/
44 gboolean
45 changed_component_dialog (GtkWindow *parent,
46 ECalComponent *comp,
47 gboolean deleted,
48 gboolean changed)
49 {
50 GtkWidget *dialog;
51 ECalComponentVType vtype;
52 gchar *str;
53 gint response;
54
55 vtype = e_cal_component_get_vtype (comp);
56
57 if (deleted) {
58 switch (vtype) {
59 case E_CAL_COMPONENT_EVENT:
60 str = _("This event has been deleted.");
61 break;
62
63 case E_CAL_COMPONENT_TODO:
64 str = _("This task has been deleted.");
65 break;
66
67 case E_CAL_COMPONENT_JOURNAL:
68 str = _("This memo has been deleted.");
69 break;
70
71 default:
72 g_message (
73 "changed_component_dialog(): "
74 "Cannot handle object of type %d", vtype);
75 return FALSE;
76 }
77 if (changed)
78 str = g_strdup_printf (_("%s You have made changes. Forget those changes and close the editor?"), str);
79 else
80 str = g_strdup_printf (_("%s You have made no changes, close the editor?"), str);
81
82 } else {
83 switch (vtype) {
84 case E_CAL_COMPONENT_EVENT:
85 str = _("This event has been changed.");
86 break;
87
88 case E_CAL_COMPONENT_TODO:
89 str = _("This task has been changed.");
90 break;
91
92 case E_CAL_COMPONENT_JOURNAL:
93 str = _("This memo has been changed.");
94 break;
95
96 default:
97 g_message (
98 "changed_component_dialog(): "
99 "Cannot handle object of type %d", vtype);
100 return FALSE;
101 }
102 if (changed)
103 str = g_strdup_printf (_("%s You have made changes. Forget those changes and update the editor?"), str);
104 else
105 str = g_strdup_printf (_("%s You have made no changes, update the editor?"), str);
106 }
107
108 dialog = gtk_message_dialog_new (
109 parent, GTK_DIALOG_MODAL,
110 GTK_MESSAGE_QUESTION,
111 GTK_BUTTONS_YES_NO, "%s", str);
112
113 gtk_window_set_icon_name (GTK_WINDOW (dialog), "x-office-calendar");
114
115 response = gtk_dialog_run (GTK_DIALOG (dialog));
116 gtk_widget_destroy (dialog);
117
118 if (response == GTK_RESPONSE_YES)
119 return TRUE;
120 else
121 return FALSE;
122 }