diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2008-11-18 05:09:36 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-11-18 05:09:36 +0800 |
commit | 8425d8bbe6359a1baae04f569864f72d34144b5c (patch) | |
tree | 72135dc992392c07047b8b53dd9876cb8e5713e5 /addressbook/gui | |
parent | 05b8df9868e2828eadaefa1a733999faf0b8e08b (diff) | |
download | gsoc2013-evolution-8425d8bbe6359a1baae04f569864f72d34144b5c.tar gsoc2013-evolution-8425d8bbe6359a1baae04f569864f72d34144b5c.tar.gz gsoc2013-evolution-8425d8bbe6359a1baae04f569864f72d34144b5c.tar.bz2 gsoc2013-evolution-8425d8bbe6359a1baae04f569864f72d34144b5c.tar.lz gsoc2013-evolution-8425d8bbe6359a1baae04f569864f72d34144b5c.tar.xz gsoc2013-evolution-8425d8bbe6359a1baae04f569864f72d34144b5c.tar.zst gsoc2013-evolution-8425d8bbe6359a1baae04f569864f72d34144b5c.zip |
** Fixes bug #557818
2008-11-17 Matthew Barnes <mbarnes@redhat.com>
** Fixes bug #557818
* addressbook/gui/component/addressbook-view.c:
* calendar/gui/calendar-component.c:
* calendar/gui/memos-component.c:
* calendar/gui/tasks-component.c:
ESourceSelector now handles most of the drag-and-drop signals.
We just have to listen for the new "data-dropped" signal and
deal with it. Gets rid of a lot of duplicate logic.
svn path=/trunk/; revision=36793
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/component/addressbook-view.c | 146 |
1 files changed, 12 insertions, 134 deletions
diff --git a/addressbook/gui/component/addressbook-view.c b/addressbook/gui/component/addressbook-view.c index 417cb02dd4..7918770df5 100644 --- a/addressbook/gui/component/addressbook-view.c +++ b/addressbook/gui/component/addressbook-view.c @@ -997,88 +997,6 @@ popup_event_callback(ESourceSelector *selector, ESource *source, GdkEventButton return TRUE; } -static gboolean -selector_tree_drag_drop (GtkWidget *widget, - GdkDragContext *context, - int x, - int y, - guint time, - AddressbookView *view) -{ - GtkTreeViewColumn *column; - int cell_x; - int cell_y; - GtkTreePath *path; - GtkTreeModel *model; - GtkTreeIter iter; - gpointer data; - - if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), x, y, &path, &column, &cell_x, &cell_y)) - return FALSE; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) { - gtk_tree_path_free (path); - return FALSE; - } - - gtk_tree_model_get (model, &iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data)) { - g_object_unref (data); - gtk_tree_path_free (path); - return FALSE; - } - - gtk_tree_path_free (path); - return TRUE; -} - -static gboolean -selector_tree_drag_motion (GtkWidget *widget, - GdkDragContext *context, - int x, - int y) -{ - GtkTreePath *path = NULL; - gpointer data = NULL; - GtkTreeViewDropPosition pos; - GtkTreeModel *model; - GtkTreeIter iter; - GdkDragAction action = { 0, }; - - if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, y, &path, &pos)) - goto finish; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) - goto finish; - - gtk_tree_model_get (model, &iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data) || e_source_get_readonly (data)) - goto finish; - - gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), path, GTK_TREE_VIEW_DROP_INTO_OR_BEFORE); - /* Make default action move, not copy */ - if (context->actions & GDK_ACTION_MOVE) - action = GDK_ACTION_MOVE; - else - action = context->suggested_action; - - finish: - if (path) - gtk_tree_path_free (path); - if (data) - g_object_unref (data); - - gdk_drag_status (context, action, GDK_CURRENT_TIME); - return TRUE; -} - typedef struct { guint remove_from_source : 1; @@ -1153,42 +1071,19 @@ merged_contact_cb (EBook *book, EBookStatus status, const char *id, gpointer clo } static gboolean -selector_tree_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - gpointer user_data) -{ - GtkTreePath *path = NULL; - GtkTreeViewDropPosition pos; - gpointer target = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - gboolean success = FALSE; +selector_tree_data_dropped (ESourceSelector *selector, + GtkSelectionData *data, + ESource *destination, + GdkDragAction action, + guint info, + AddressbookView *view) +{ EBook *source_book, *target_book; MergeContext *merge_context = NULL; GList *contactlist; - AddressbookView *view; EABView *v; - if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, y, &path, &pos)) - goto finish; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) - goto finish; - - gtk_tree_model_get (model, &iter, 0, &target, -1); - - if (E_IS_SOURCE_GROUP (target) || e_source_get_readonly (target)) - goto finish; - - target_book = e_book_new (target, NULL); + target_book = e_book_new (destination, NULL); if (!target_book) { g_message (G_STRLOC ":Couldn't create EBook."); return FALSE; @@ -1197,7 +1092,6 @@ selector_tree_drag_data_received (GtkWidget *widget, eab_book_and_contact_list_from_string ((char *)data->data, &source_book, &contactlist); - view = (AddressbookView *) user_data; v = get_current_view (view); g_object_get (v->model, "book",&source_book, NULL); @@ -1211,32 +1105,17 @@ selector_tree_drag_data_received (GtkWidget *widget, merge_context->current_contact = contactlist->data; merge_context->remaining_contacts = g_list_delete_link (contactlist, contactlist); - merge_context->remove_from_source = context->action == GDK_ACTION_MOVE ? TRUE : FALSE; + merge_context->remove_from_source = action == GDK_ACTION_MOVE ? TRUE : FALSE; /* Start merge */ eab_merging_book_add_contact (target_book, merge_context->current_contact, merged_contact_cb, merge_context); - finish: - if (path) - gtk_tree_path_free (path); - if (target) - g_object_unref (target); - - gtk_drag_finish (context, success, merge_context->remove_from_source, time); - return TRUE; } static void -selector_tree_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, gpointer data) -{ - gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), NULL, GTK_TREE_VIEW_DROP_BEFORE); -} - - -static void destroy_callback(gpointer data, GObject *where_object_was) { AddressbookView *view = data; @@ -1338,10 +1217,9 @@ addressbook_view_init (AddressbookView *view) priv->selector = e_source_selector_new (priv->source_list); - g_signal_connect (priv->selector, "drag-motion", G_CALLBACK (selector_tree_drag_motion), view); - g_signal_connect (priv->selector, "drag-leave", G_CALLBACK (selector_tree_drag_leave), view); - g_signal_connect (priv->selector, "drag-drop", G_CALLBACK (selector_tree_drag_drop), view); - g_signal_connect (priv->selector, "drag-data-received", G_CALLBACK (selector_tree_drag_data_received), view); + g_signal_connect ( + priv->selector, "data-dropped", + G_CALLBACK (selector_tree_data_dropped), view); gtk_drag_dest_set (priv->selector, GTK_DEST_DEFAULT_ALL, drag_types, num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE); a11y = gtk_widget_get_accessible (GTK_WIDGET (priv->selector)); atk_object_set_name (a11y, _("Contact Source Selector")); |