diff options
author | Milan Crha <mcrha@redhat.com> | 2007-11-05 18:07:23 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2007-11-05 18:07:23 +0800 |
commit | a1a1f31ef8aa921e84f82d0e88b00ead5e92c738 (patch) | |
tree | 1ef2ab796f73424e443a8dd156963bfbd05284e6 /calendar/gui/memos-component.c | |
parent | abf34a4520db2714e688fcdc01f3e5cbb890bc73 (diff) | |
download | gsoc2013-evolution-a1a1f31ef8aa921e84f82d0e88b00ead5e92c738.tar.gz gsoc2013-evolution-a1a1f31ef8aa921e84f82d0e88b00ead5e92c738.tar.zst gsoc2013-evolution-a1a1f31ef8aa921e84f82d0e88b00ead5e92c738.zip |
** Fix for bug #315101
2007-11-05 Milan Crha <mcrha@redhat.com>
** Fix for bug #315101
* drag and drop to other source for multiselect
* gui/comp-util.h:
* gui/comp-util.c: (cal_comp_selection_set_string_list),
(cal_comp_selection_get_string_list): Two new helper functions
to set and get list of strings into GtkSelectionData.
* gui/e-tasks.c: (get_selected_components_cb),
(do_for_selected_components), (obtain_list_of_components),
(table_drag_data_get):
* gui/e-memos.c: (get_selected_components_cb),
(do_for_selected_components), (obtain_list_of_components),
(table_drag_data_get): Pass list of selected components as data
for drag and drop instead of focused component from the list.
* gui/e-tasks.c: (table_drag_data_delete):
* gui/e-memos.c: (table_drag_data_delete): Obsolete now.
* gui/tasks-component.c: (selector_tree_drag_data_received):
* gui/memos-component.c: (selector_tree_drag_data_received):
Receiving list of components, so made changes here to reflect it.
svn path=/trunk/; revision=34496
Diffstat (limited to 'calendar/gui/memos-component.c')
-rw-r--r-- | calendar/gui/memos-component.c | 94 |
1 files changed, 73 insertions, 21 deletions
diff --git a/calendar/gui/memos-component.c b/calendar/gui/memos-component.c index 5024a5f2e7..40b71cf5f5 100644 --- a/calendar/gui/memos-component.c +++ b/calendar/gui/memos-component.c @@ -758,6 +758,8 @@ selector_tree_drag_data_received (GtkWidget *widget, gboolean success = FALSE; icalcomponent *icalcomp = NULL; ECal *client = NULL; + GSList *components, *p; + MemosComponent *component = MEMOS_COMPONENT (user_data); if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), x, y, &path, &pos)) @@ -771,47 +773,97 @@ selector_tree_drag_data_received (GtkWidget *widget, gtk_tree_model_get (model, &iter, 0, &source, -1); - if (E_IS_SOURCE_GROUP (source) || e_source_get_readonly (source)) + if (E_IS_SOURCE_GROUP (source) || e_source_get_readonly (source) || !data->data) goto finish; - icalcomp = icalparser_parse_string ((char *)data->data); - - if (icalcomp) { - char * uid; + client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL); + + if (!client || !e_cal_open (client, TRUE, NULL)) + goto finish; + + components = cal_comp_selection_get_string_list (data); + for (p = components; p; p = p->next) { + const char * uid; + char *old_uid = NULL; + icalcomponent *tmp_icalcomp = NULL; + GError *error = NULL; + char *comp_str; /* do not free this! */ + + /* p->data is "source_uid\ncomponent_string" */ + comp_str = strchr (p->data, '\n'); + if (!comp_str) + continue; + + comp_str [0] = 0; + comp_str++; + icalcomp = icalparser_parse_string (comp_str); + + if (!icalcomp) + continue; /* FIXME deal with GDK_ACTION_ASK */ if (context->action == GDK_ACTION_COPY) { + old_uid = g_strdup (icalcomponent_get_uid (icalcomp)); uid = e_cal_component_gen_uid (); icalcomponent_set_uid (icalcomp, uid); } - client = auth_new_cal_from_source (source, - E_CAL_SOURCE_TYPE_JOURNAL); - - if (client) { - if (e_cal_open (client, TRUE, NULL)) { + uid = icalcomponent_get_uid (icalcomp); + if (!old_uid) + old_uid = g_strdup (uid); + + if (!e_cal_get_object (client, uid, NULL, &tmp_icalcomp, &error)) { + if ((error != NULL) && (error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND)) + g_message ("Failed to search the object in destination task list: %s",error->message); + else { + /* this will report success by last item, but we don't care */ success = update_objects (client, icalcomp); + + if (success && context->action == GDK_ACTION_MOVE) { + /* remove components rather here, because we know which has been moved */ + ESource *source_source; + ECal *source_client; + + source_source = e_source_list_peek_source_by_uid (component->priv->source_list, p->data); + + if (source_source && !E_IS_SOURCE_GROUP (source_source) && !e_source_get_readonly (source_source)) { + source_client = auth_new_cal_from_source (source_source, E_CAL_SOURCE_TYPE_JOURNAL); + + if (source_client) { + gboolean read_only = TRUE; + + e_cal_is_read_only (source_client, &read_only, NULL); + + if (!read_only && e_cal_open (source_client, TRUE, NULL)) + e_cal_remove_object (source_client, old_uid, NULL); + else if (!read_only) + g_message ("Cannot open source client to remove old memo"); + + g_object_unref (source_client); + } else + g_message ("Cannot create source client to remove old memo"); + } + } } - - g_object_unref (client); - } - + + g_clear_error (&error); + } else + icalcomponent_free (tmp_icalcomp); + + g_free (old_uid); icalcomponent_free (icalcomp); } + g_slist_foreach (components, (GFunc)g_free, NULL); + g_slist_free (components); finish: + if (client) + g_object_unref (client); if (source) g_object_unref (source); if (path) gtk_tree_path_free (path); - if (!success && context->action == GDK_ACTION_MOVE) { - /* because the delete parameter of 'gtk_drag_finish' doesn't work - as expected, then we change context->action to GDK_ACTION_COPY - to prevent from deleting data when the drag was unsuccessful. - */ - context->action = GDK_ACTION_COPY; - } gtk_drag_finish (context, success, success && context->action == GDK_ACTION_MOVE, time); } |