diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-02-09 03:52:18 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-02-09 07:57:24 +0800 |
commit | 67ce5f3b140525c2f5944270a9383616f9d67923 (patch) | |
tree | 167788f4efa12f87ac04c474598d61b5ca446464 /addressbook | |
parent | 9cd1f937a26363aa108f3d2b36606b167597a2eb (diff) | |
download | gsoc2013-evolution-67ce5f3b140525c2f5944270a9383616f9d67923.tar gsoc2013-evolution-67ce5f3b140525c2f5944270a9383616f9d67923.tar.gz gsoc2013-evolution-67ce5f3b140525c2f5944270a9383616f9d67923.tar.bz2 gsoc2013-evolution-67ce5f3b140525c2f5944270a9383616f9d67923.tar.lz gsoc2013-evolution-67ce5f3b140525c2f5944270a9383616f9d67923.tar.xz gsoc2013-evolution-67ce5f3b140525c2f5944270a9383616f9d67923.tar.zst gsoc2013-evolution-67ce5f3b140525c2f5944270a9383616f9d67923.zip |
Add DnD support to e-selection.c.
Avoid listing calendar and directory targets explicitly, so that
e-selection.c contains the one and only master list. Still need
to figure out how to centralize "text/x-source-vcard".
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/gui/contact-list-editor/e-contact-list-editor.c | 47 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-selector.c | 12 |
2 files changed, 19 insertions, 40 deletions
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index 0b0c71711d..23da590e72 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -25,6 +25,7 @@ #include "e-contact-list-editor.h" #include <e-util/e-util-private.h> #include <e-util/e-alert-dialog.h> +#include <e-util/e-selection.h> #include "shell/e-shell.h" #include <string.h> @@ -127,16 +128,6 @@ struct _EContactListEditorPrivate { EBook *load_book; }; -#define VCARD_TYPE "text/x-vcard" - -enum { - TARGET_TYPE_VCARD -}; - -static GtkTargetEntry targets[] = { - { (gchar *) VCARD_TYPE, 0, TARGET_TYPE_VCARD }, -}; - static gpointer parent_class; static EContactListEditor * @@ -439,24 +430,25 @@ contact_list_editor_drag_data_received_cb (GtkWidget *widget, void contact_list_editor_drag_data_received_cb (GtkWidget *widget, GdkDragContext *context, - gint x, gint y, - GtkSelectionData *selection_data, - guint info, - guint time) + gint x, gint y, + GtkSelectionData *selection_data, + guint info, + guint time) { EContactListEditor *editor; EContactListModel *model; - gchar *target_type; gboolean changed = FALSE; gboolean handled = FALSE; GList *list, *iter; + GdkAtom target; editor = contact_list_editor_extract (widget); model = E_CONTACT_LIST_MODEL (editor->priv->model); - target_type = gdk_atom_name (selection_data->target); - if (strcmp (target_type, VCARD_TYPE) != 0) + /* Sanity check the selection target. */ + target = gtk_selection_data_get_target (selection_data); + if (!e_targets_include_directory (&target, 1)) goto exit; list = eab_contact_list_from_string ((gchar *) selection_data->data); @@ -516,14 +508,8 @@ contact_list_editor_drag_drop_cb (GtkWidget *widget, for (iter = context->targets; iter != NULL; iter = iter->next) { GdkAtom target = GDK_POINTER_TO_ATOM (iter->data); - gchar *possible_type; - gboolean match; - possible_type = gdk_atom_name (target); - match = (strcmp (possible_type, VCARD_TYPE) == 0); - g_free (possible_type); - - if (match) { + if (e_targets_include_directory (&target, 1)) { gtk_drag_get_data (widget, context, target, time); return TRUE; } @@ -548,14 +534,8 @@ contact_list_editor_drag_motion_cb (GtkWidget *widget, for (iter = context->targets; iter != NULL; iter = iter->next) { GdkAtom target = GDK_POINTER_TO_ATOM (iter->data); - gchar *possible_type; - gboolean match; - - possible_type = gdk_atom_name (target); - match = (strcmp (possible_type, VCARD_TYPE) == 0); - g_free (possible_type); - if (match) { + if (e_targets_include_directory (&target, 1)) { gdk_drag_status (context, GDK_ACTION_LINK, time); return TRUE; } @@ -1318,8 +1298,9 @@ contact_list_editor_init (EContactListEditor *editor) gtk_tree_selection_set_mode ( gtk_tree_view_get_selection (view), GTK_SELECTION_MULTIPLE); - gtk_tree_view_enable_model_drag_dest ( - view, targets, G_N_ELEMENTS (targets), GDK_ACTION_LINK); + + gtk_tree_view_enable_model_drag_dest (view, NULL, 0, GDK_ACTION_LINK); + e_drag_dest_add_directory_targets (WIDGET (TREE_VIEW)); g_signal_connect ( priv->model, "row-deleted", diff --git a/addressbook/gui/widgets/e-addressbook-selector.c b/addressbook/gui/widgets/e-addressbook-selector.c index 21347e2529..d33680ac99 100644 --- a/addressbook/gui/widgets/e-addressbook-selector.c +++ b/addressbook/gui/widgets/e-addressbook-selector.c @@ -20,6 +20,8 @@ #include "e-addressbook-selector.h" +#include <e-util/e-selection.h> + #include <eab-book-util.h> #include <eab-contact-merging.h> @@ -53,14 +55,8 @@ enum { PROP_CURRENT_VIEW }; -enum { - DND_TARGET_TYPE_VCARD, - DND_TARGET_TYPE_SOURCE_VCARD -}; - static GtkTargetEntry drag_types[] = { - { (gchar *) "text/x-vcard", 0, DND_TARGET_TYPE_VCARD }, - { (gchar *) "text/x-source-vcard", 0, DND_TARGET_TYPE_SOURCE_VCARD } + { (gchar *) "text/x-source-vcard", 0, 0 } }; static gpointer parent_class; @@ -367,6 +363,8 @@ addressbook_selector_init (EAddressbookSelector *selector) GTK_WIDGET (selector), GTK_DEST_DEFAULT_ALL, drag_types, G_N_ELEMENTS (drag_types), GDK_ACTION_COPY | GDK_ACTION_MOVE); + + e_drag_dest_add_directory_targets (GTK_WIDGET (selector)); } GType |