1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) version 3.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <e-util/e-dialog-utils.h>
#include "cal-editor-utils.h"
#include "dialogs/event-editor.h"
#include "dialogs/task-editor.h"
#include "dialogs/memo-editor.h"
/**
* open_component_editor:
* @client: Already opened #ECal, where to store the component
* @comp: #ECalComponent component to be stored
* @is_new: Whether the @comp is a new component or an existing
* @error: #GError for possible error reporting
*
* Opens component editor for the event stored in the comp component.
* If such component exists in the client already (with the same UID),
* then there's opened already stored event, instead of the comp.
*
* It blocks until finished and should be called in the main thread.
**/
void
open_component_editor (EShell *shell,
ECal *client,
ECalComponent *comp,
gboolean is_new,
GError **error)
{
ECalComponentId *id;
CompEditorFlags flags = 0;
CompEditor *editor = NULL;
g_return_if_fail (E_IS_SHELL (shell));
g_return_if_fail (E_IS_CAL (client));
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
id = e_cal_component_get_id (comp);
g_return_if_fail (id != NULL);
g_return_if_fail (id->uid != NULL);
if (is_new) {
flags |= COMP_EDITOR_NEW_ITEM;
} else {
editor = comp_editor_find_instance (id->uid);
}
if (!editor) {
if (itip_organizer_is_user (comp, client))
flags |= COMP_EDITOR_USER_ORG;
switch (e_cal_component_get_vtype (comp)) {
case E_CAL_COMPONENT_EVENT:
if (e_cal_component_has_attendees (comp))
flags |= COMP_EDITOR_MEETING;
editor = event_editor_new (client, shell, flags);
if (flags & COMP_EDITOR_MEETING)
event_editor_show_meeting (EVENT_EDITOR (editor));
break;
case E_CAL_COMPONENT_TODO:
if (e_cal_component_has_attendees (comp))
flags |= COMP_EDITOR_IS_ASSIGNED;
editor = task_editor_new (client, shell, flags);
if (flags & COMP_EDITOR_IS_ASSIGNED)
task_editor_show_assignment (TASK_EDITOR (editor));
break;
case E_CAL_COMPONENT_JOURNAL:
if (e_cal_component_has_organizer (comp))
flags |= COMP_EDITOR_IS_SHARED;
editor = memo_editor_new (client, shell, flags);
break;
default:
if (error)
*error = g_error_new (E_CALENDAR_ERROR, E_CALENDAR_STATUS_INVALID_OBJECT, "%s", _("Invalid object"));
break;
}
if (editor) {
comp_editor_edit_comp (editor, comp);
/* request save for new events */
comp_editor_set_changed (editor, is_new);
}
}
if (editor)
gtk_window_present (GTK_WINDOW (editor));
e_cal_component_free_id (id);
}
|