diff options
author | Milan Crha <mcrha@redhat.com> | 2009-08-08 00:05:18 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-08-12 05:47:08 +0800 |
commit | 4846995f5ebab385dcae061cc30fa86486ac4ad4 (patch) | |
tree | 7ba50c0364ecf17af69c3a885b8a0c09bf541c5f /calendar | |
parent | e9071c9f1dc185c11b2992a2fc78330782428f58 (diff) | |
download | gsoc2013-evolution-4846995f5ebab385dcae061cc30fa86486ac4ad4.tar.gz gsoc2013-evolution-4846995f5ebab385dcae061cc30fa86486ac4ad4.tar.zst gsoc2013-evolution-4846995f5ebab385dcae061cc30fa86486ac4ad4.zip |
Bug #584030 - [Mail-To-Task] improve duplicate handling and such
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/gui/Makefile.am | 23 | ||||
-rw-r--r-- | calendar/gui/cal-editor-utils.c | 121 | ||||
-rw-r--r-- | calendar/gui/cal-editor-utils.h | 38 |
3 files changed, 172 insertions, 10 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 28fcf3dd43..780cb5db88 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -8,12 +8,13 @@ privsolib_LTLIBRARIES = libevolution-calendar.la ecalendarincludedir = $(privincludedir)/calendar/gui -ecalendarinclude_HEADERS = \ - e-attachment-handler-calendar.h \ +ecalendarinclude_HEADERS = \ + cal-editor-utils.h \ calendar-config.h \ calendar-config-keys.h \ comp-util.h \ e-alarm-list.h \ + e-attachment-handler-calendar.h \ e-cal-config.h \ e-cal-event.h \ e-cal-model-calendar.h \ @@ -83,12 +84,8 @@ etspec_DATA = \ e-memo-table.etspec libevolution_calendar_la_SOURCES = \ - e-attachment-handler-calendar.c \ - e-attachment-handler-calendar.h \ - e-calendar-view.c \ - e-calendar-view.h \ - e-calendar-table.c \ - e-calendar-table.h \ + cal-editor-utils.c \ + cal-editor-utils.h \ calendar-config.c \ calendar-config.h \ calendar-config-keys.h \ @@ -100,6 +97,8 @@ libevolution_calendar_la_SOURCES = \ comp-util.h \ e-alarm-list.c \ e-alarm-list.h \ + e-attachment-handler-calendar.c \ + e-attachment-handler-calendar.h \ e-cal-component-preview.c \ e-cal-component-preview.h \ e-cal-config.c \ @@ -122,12 +121,16 @@ libevolution_calendar_la_SOURCES = \ e-cal-model-tasks.h \ e-calendar-selector.c \ e-calendar-selector.h \ + e-calendar-table.c \ + e-calendar-table.h \ + e-calendar-view.c \ + e-calendar-view.h \ e-cell-date-edit-text.h \ e-cell-date-edit-text.c \ e-comp-editor-registry.c \ e-comp-editor-registry.h \ - e-date-time-list.c \ - e-date-time-list.h \ + e-date-time-list.c \ + e-date-time-list.h \ e-day-view-layout.c \ e-day-view-layout.h \ e-day-view-main-item.c \ diff --git a/calendar/gui/cal-editor-utils.c b/calendar/gui/cal-editor-utils.c new file mode 100644 index 0000000000..0da7ca2af9 --- /dev/null +++ b/calendar/gui/cal-editor-utils.c @@ -0,0 +1,121 @@ +/* + * 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 "e-comp-editor-registry.h" +#include "dialogs/event-editor.h" +#include "dialogs/task-editor.h" +#include "dialogs/memo-editor.h" + +extern ECompEditorRegistry *comp_editor_registry; + +/** + * 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); +} diff --git a/calendar/gui/cal-editor-utils.h b/calendar/gui/cal-editor-utils.h new file mode 100644 index 0000000000..211684eb20 --- /dev/null +++ b/calendar/gui/cal-editor-utils.h @@ -0,0 +1,38 @@ +/* + * 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) + * + */ + +#ifndef CAL_EDITOR_UTILS_H +#define CAL_EDITOR_UTILS_H + +#include <glib.h> +#include <libecal/e-cal.h> +#include <libecal/e-cal-component.h> +#include <shell/e-shell.h> + +G_BEGIN_DECLS + +void open_component_editor (EShell *shell, + ECal *client, + ECalComponent *comp, + gboolean is_new, + GError **error); + +G_END_DECLS + +#endif /* CAL_EDITOR_UTILS_H */ |