diff options
author | Shaun McCance <shaunm@gnome.org> | 2009-11-25 01:26:45 +0800 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2009-11-25 05:24:11 +0800 |
commit | 9ec54fdc072173c6676ec2d8ea0b8eabe6936cef (patch) | |
tree | 032ca5dddc61eb696a17701e11275da94ed0be94 | |
parent | 89bc747b15ff519b81b8b153bcf94c8cd19245b1 (diff) | |
download | gsoc2013-empathy-9ec54fdc072173c6676ec2d8ea0b8eabe6936cef.tar gsoc2013-empathy-9ec54fdc072173c6676ec2d8ea0b8eabe6936cef.tar.gz gsoc2013-empathy-9ec54fdc072173c6676ec2d8ea0b8eabe6936cef.tar.bz2 gsoc2013-empathy-9ec54fdc072173c6676ec2d8ea0b8eabe6936cef.tar.lz gsoc2013-empathy-9ec54fdc072173c6676ec2d8ea0b8eabe6936cef.tar.xz gsoc2013-empathy-9ec54fdc072173c6676ec2d8ea0b8eabe6936cef.tar.zst gsoc2013-empathy-9ec54fdc072173c6676ec2d8ea0b8eabe6936cef.zip |
Some improvements to file drag-and-drop based on comments on #595226
-rw-r--r-- | src/empathy-chat-window.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 0aea2a7c7..fb04e7c3e 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -1339,7 +1339,7 @@ chat_window_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y, - guint time, + guint time_, EmpathyChatWindow *window) { GdkAtom target; @@ -1362,16 +1362,21 @@ chat_window_drag_motion (GtkWidget *widget, priv = GET_PRIV (window); contact = empathy_chat_get_remote_contact (priv->current_chat); - if (!empathy_contact_is_online (contact)) { - gdk_drag_status (context, 0, time); + /* contact is NULL for multi-user chats. We don't do + * file transfers to MUCs. We also don't send files + * to offline contacts or contacts that don't support + * file transfer. + */ + if ((contact == NULL) || !empathy_contact_is_online (contact)) { + gdk_drag_status (context, 0, time_); return FALSE; } if (!(empathy_contact_get_capabilities (contact) & EMPATHY_CAPABILITIES_FT)) { - gdk_drag_status (context, 0, time); + gdk_drag_status (context, 0, time_); return FALSE; } - gdk_drag_status (context, GDK_ACTION_COPY, time); + gdk_drag_status (context, GDK_ACTION_COPY, time_); return TRUE; } @@ -1382,12 +1387,12 @@ chat_window_drag_motion (GtkWidget *widget, Otherwise, it opens a chat. Should we use a different drag type for invites? Should we allow ASK? */ - gdk_drag_status (context, GDK_ACTION_COPY, time); + gdk_drag_status (context, GDK_ACTION_COPY, time_); return TRUE; } /* Otherwise, it must be a notebook tab drag. Set to MOVE. */ - gdk_drag_status (context, GDK_ACTION_MOVE, time); + gdk_drag_status (context, GDK_ACTION_MOVE, time_); return TRUE; } @@ -1481,15 +1486,18 @@ chat_window_drag_data_received (GtkWidget *widget, priv = GET_PRIV (window); contact = empathy_chat_get_remote_contact (priv->current_chat); - if (!EMPATHY_IS_CONTACT (contact)) { - gtk_drag_finish (context, TRUE, FALSE, time); + /* contact is NULL when current_chat is a multi-user chat. + * We don't do file transfers to MUCs, so just cancel the drag. + */ + if (contact == NULL) { + gtk_drag_finish (context, TRUE, FALSE, time_); return; } data = (const gchar *) gtk_selection_data_get_data (selection); empathy_send_file_from_uri_list (contact, data); - gtk_drag_finish (context, TRUE, FALSE, time); + gtk_drag_finish (context, TRUE, FALSE, time_); } else if (info == DND_DRAG_TYPE_TAB) { EmpathyChat **chat; |