aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/calendar-component.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-01-27 20:32:09 +0800
committerMilan Crha <mcrha@src.gnome.org>2009-01-27 20:32:09 +0800
commit2e94db8a65126ffcb456bd2823cf45e5b1510b0b (patch)
tree819b3bdd1877074b1a8f55075081c2c1c9c0aa71 /calendar/gui/calendar-component.c
parent561ab42a1cd7da4bacd6b4080815156c5f95b7a5 (diff)
downloadgsoc2013-evolution-2e94db8a65126ffcb456bd2823cf45e5b1510b0b.tar
gsoc2013-evolution-2e94db8a65126ffcb456bd2823cf45e5b1510b0b.tar.gz
gsoc2013-evolution-2e94db8a65126ffcb456bd2823cf45e5b1510b0b.tar.bz2
gsoc2013-evolution-2e94db8a65126ffcb456bd2823cf45e5b1510b0b.tar.lz
gsoc2013-evolution-2e94db8a65126ffcb456bd2823cf45e5b1510b0b.tar.xz
gsoc2013-evolution-2e94db8a65126ffcb456bd2823cf45e5b1510b0b.tar.zst
gsoc2013-evolution-2e94db8a65126ffcb456bd2823cf45e5b1510b0b.zip
** Fix for bug #318003
2009-01-27 Milan Crha <mcrha@redhat.com> ** Fix for bug #318003 * gui/memos-component.c: (selector_tree_data_dropped): * gui/tasks-component.c: (selector_tree_data_dropped): * gui/calendar-component.c: (selector_tree_data_dropped), (create_component_view): * gui/comp-util.h: (cal_comp_process_source_list_drop): * gui/comp-util.c: (update_single_object), (update_objects), (cal_comp_process_source_list_drop): Support move of the event in day view when dropped over the source list. Use the same function for events/tasks/memos. * gui/e-day-view.c: (e_day_view_on_drag_data_get): Encode string data same as memos and tasks do, with a source UID. * gui/e-calendar-table.c: (e_calendar_table_copy_clipboard): * gui/e-memo-table.c: (e_memo_table_copy_clipboard): Removed inappropriate comments. svn path=/trunk/; revision=37140
Diffstat (limited to 'calendar/gui/calendar-component.c')
-rw-r--r--calendar/gui/calendar-component.c100
1 files changed, 24 insertions, 76 deletions
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c
index a3a9a8b345..a44b279f19 100644
--- a/calendar/gui/calendar-component.c
+++ b/calendar/gui/calendar-component.c
@@ -1020,94 +1020,42 @@ impl_upgradeFromVersion (PortableServer_Servant servant,
}
static gboolean
-update_single_object (ECal *client, icalcomponent *icalcomp)
-{
- char *uid;
- icalcomponent *tmp_icalcomp;
-
- uid = (char *) icalcomponent_get_uid (icalcomp);
-
- if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL))
- return e_cal_modify_object (client, icalcomp, CALOBJ_MOD_ALL, NULL);
-
- return e_cal_create_object (client, icalcomp, &uid, NULL);
-}
-
-static gboolean
-update_objects (ECal *client, icalcomponent *icalcomp)
-{
- icalcomponent *subcomp;
- icalcomponent_kind kind;
-
- kind = icalcomponent_isa (icalcomp);
- if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT)
- return update_single_object (client, icalcomp);
- else if (kind != ICAL_VCALENDAR_COMPONENT)
- return FALSE;
-
- subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT);
- while (subcomp) {
- gboolean success;
-
- kind = icalcomponent_isa (subcomp);
- if (kind == ICAL_VTIMEZONE_COMPONENT) {
- icaltimezone *zone;
-
- zone = icaltimezone_new ();
- icaltimezone_set_component (zone, subcomp);
-
- success = e_cal_add_timezone (client, zone, NULL);
- icaltimezone_free (zone, 1);
- if (!success)
- return success;
- } else if (kind == ICAL_VTODO_COMPONENT ||
- kind == ICAL_VEVENT_COMPONENT) {
- success = update_single_object (client, subcomp);
- if (!success)
- return success;
- }
-
- subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT);
- }
-
- return TRUE;
-}
-
-static gboolean
selector_tree_data_dropped (ESourceSelector *selector,
GtkSelectionData *data,
ESource *destination,
GdkDragAction action,
- guint info)
+ guint info,
+ CalendarComponent *component)
{
gboolean success = FALSE;
- icalcomponent *icalcomp = NULL;
- ECal *client = NULL;
+ ECal *client;
- icalcomp = icalparser_parse_string ((char *)data->data);
+ client = auth_new_cal_from_source (destination, E_CAL_SOURCE_TYPE_EVENT);
- if (icalcomp) {
- char * uid;
+ if (!client || !e_cal_open (client, TRUE, NULL)) {
+ if (client)
+ g_object_unref (client);
- /* FIXME deal with GDK_ACTION_ASK */
- if (action == GDK_ACTION_COPY) {
- uid = e_cal_component_gen_uid ();
- icalcomponent_set_uid (icalcomp, uid);
- }
+ return FALSE;
+ }
- client = auth_new_cal_from_source (destination,
- E_CAL_SOURCE_TYPE_EVENT);
+ if (data->data) {
+ icalcomponent *icalcomp = NULL;
+ char *comp_str; /* do not free this! */
- if (client) {
- if (e_cal_open (client, TRUE, NULL)) {
- success = TRUE;
- update_objects (client, icalcomp);
- }
+ /* data->data is "source_uid\ncomponent_string" */
+ comp_str = strchr ((char *)data->data, '\n');
+ if (comp_str) {
+ comp_str [0] = 0;
+ comp_str++;
- g_object_unref (client);
- }
+ icalcomp = icalparser_parse_string (comp_str);
- icalcomponent_free (icalcomp);
+ if (icalcomp) {
+ success = cal_comp_process_source_list_drop (client, icalcomp, action, (char *)data->data, component->priv->source_list);
+ icalcomponent_free (icalcomp);
+ }
+ }
}
return success;
@@ -1324,7 +1272,7 @@ create_component_view (CalendarComponent *calendar_component)
g_signal_connect (
component_view->source_selector, "data-dropped",
- G_CALLBACK (selector_tree_data_dropped), NULL);
+ G_CALLBACK (selector_tree_data_dropped), calendar_component);
gtk_drag_dest_set(component_view->source_selector, GTK_DEST_DEFAULT_ALL, drag_types,
num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE);