From f0555970a6dd57a4494c295f1e29e42d8aafec2d Mon Sep 17 00:00:00 2001 From: Olivier Le Thanh Duong Date: Thu, 4 Mar 2010 22:57:43 +0100 Subject: chat_window_drag_motion : search in all the drop targets Use gtk_drag_dest_find_target to search in all the drop targets instead of only the first one. --- src/empathy-chat-window.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 2e2f5c003..8a5d50356 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -1563,14 +1563,11 @@ chat_window_drag_motion (GtkWidget *widget, { GdkAtom target; EmpathyChatWindowPriv *priv; - GdkAtom dest_target; priv = GET_PRIV (window); - target = gtk_drag_dest_find_target (widget, context, NULL); - - dest_target = gdk_atom_intern_static_string ("text/uri-list"); - if (target == dest_target) { + target = gtk_drag_dest_find_target (widget, context, priv->file_targets); + if (target != GDK_NONE) { /* This is a file drag. Ensure the contact is online and set the drag type to COPY. Note that it's possible that the tab will be switched by GTK+ after a timeout from drag_motion without @@ -1599,8 +1596,8 @@ chat_window_drag_motion (GtkWidget *widget, return TRUE; } - dest_target = gdk_atom_intern_static_string ("text/contact-id"); - if (target == dest_target) { + target = gtk_drag_dest_find_target (widget, context, priv->contact_targets); + if (target != GDK_NONE) { /* This is a drag of a contact from a contact list. Set to COPY. FIXME: If this drag is to a MUC window, it invites the user. Otherwise, it opens a chat. Should we use a different drag -- cgit From c7085dce8076c1e98049adc7dbcb593b16ac5df8 Mon Sep 17 00:00:00 2001 From: Olivier Le Thanh Duong Date: Fri, 5 Mar 2010 00:45:01 +0100 Subject: DnD: add a new text/path-list target in chat window add a new text/path-list drop target to the chat window, it act like the text/uri-list target but is prioritized over it. This is mainly to circumvent Tomboy returning note:// uri in its uri-list. --- src/empathy-chat-window.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 8a5d50356..7419a720b 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -119,6 +119,7 @@ static const GtkTargetEntry drag_types_dest[] = { { "text/contact-id", 0, DND_DRAG_TYPE_CONTACT_ID }, { "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, DND_DRAG_TYPE_TAB }, { "text/uri-list", 0, DND_DRAG_TYPE_URI_LIST }, + { "text/path-list", 0, DND_DRAG_TYPE_URI_LIST }, }; static const GtkTargetEntry drag_types_dest_contact[] = { @@ -126,6 +127,9 @@ static const GtkTargetEntry drag_types_dest_contact[] = { }; static const GtkTargetEntry drag_types_dest_file[] = { + /* must be first to be prioritized, in order to receive the + * note's file path from Tomboy instead of an URI */ + { "text/path-list", 0, DND_DRAG_TYPE_URI_LIST }, { "text/uri-list", 0, DND_DRAG_TYPE_URI_LIST }, }; @@ -1537,15 +1541,18 @@ chat_window_drag_drop (GtkWidget *widget, int x, int y, guint time_, - gpointer user_data) + EmpathyChatWindow *window) { - GdkAtom target, uri_target, contact_target; + GdkAtom target; + EmpathyChatWindowPriv *priv; - target = gtk_drag_dest_find_target (widget, context, NULL); - uri_target = gdk_atom_intern_static_string ("text/uri-list"); - contact_target = gdk_atom_intern_static_string ("text/contact-id"); + priv = GET_PRIV (window); - if (target == uri_target || target == contact_target) { + target = gtk_drag_dest_find_target (widget, context, priv->file_targets); + if (target == GDK_NONE) + target = gtk_drag_dest_find_target (widget, context, priv->contact_targets); + + if (target != GDK_NONE) { gtk_drag_get_data (widget, context, target, time_); return TRUE; } -- cgit From b27315f5de4084fff748ac12f54b6d23ee7260a7 Mon Sep 17 00:00:00 2001 From: Olivier Le Thanh Duong Date: Mon, 15 Mar 2010 17:47:00 +0100 Subject: DnD: add a text/path-list target to contact list windows too --- libempathy-gtk/empathy-contact-list-view.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 0ed24bdf8..e8fddf0ac 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -94,6 +94,7 @@ enum DndDragType { }; static const GtkTargetEntry drag_types_dest[] = { + { "text/path-list", 0, DND_DRAG_TYPE_URI_LIST }, { "text/uri-list", 0, DND_DRAG_TYPE_URI_LIST }, { "text/contact-id", 0, DND_DRAG_TYPE_CONTACT_ID }, { "text/plain", 0, DND_DRAG_TYPE_STRING }, @@ -101,6 +102,7 @@ static const GtkTargetEntry drag_types_dest[] = { }; static const GtkTargetEntry drag_types_dest_file[] = { + { "text/path-list", 0, DND_DRAG_TYPE_URI_LIST }, { "text/uri-list", 0, DND_DRAG_TYPE_URI_LIST }, }; -- cgit