diff options
author | Shaun McCance <Shaun McCance> | 2009-10-06 03:22:32 +0800 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2009-11-25 05:14:51 +0800 |
commit | f167ec2d92a526d19f1faf8320d9ff975ae1e502 (patch) | |
tree | 3c2c3888e3a77efd8d23a9a0a909f7608cacd33e /libempathy-gtk | |
parent | cfb4283d66005aa2f12b15ce0d5aefde965d815a (diff) | |
download | gsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.tar gsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.tar.gz gsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.tar.bz2 gsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.tar.lz gsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.tar.xz gsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.tar.zst gsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.zip |
Utilitiy function to send files from a URI list, for dnd implementations
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 5 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-list-view.c | 20 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.c | 30 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.h | 2 |
4 files changed, 39 insertions, 18 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index c83649a04..52806e07c 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -2007,6 +2007,11 @@ chat_create_ui (EmpathyChat *chat) /* Add message view. */ chat->view = empathy_theme_manager_create_view (empathy_theme_manager_get ()); + /* If this is a GtkTextView, it's set as a drag destination for text/plain + and other types, even though it's non-editable and doesn't accept any + drags. This steals drag motion for anything inside the scrollbars, + making drag destinations on chat windows far less useful. + */ gtk_drag_dest_unset (GTK_WIDGET (chat->view)); g_signal_connect (chat->view, "focus_in_event", G_CALLBACK (chat_text_view_focus_in_event_cb), diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 24793b457..3e1464654 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -332,9 +332,6 @@ contact_list_view_file_drag_received (GtkWidget *view, { GtkTreeIter iter; const gchar *sel_data; - const gchar *nl; - gchar *uri; - GFile *file; EmpathyContact *contact; sel_data = (const gchar *) gtk_selection_data_get_data (selection); @@ -347,22 +344,9 @@ contact_list_view_file_drag_received (GtkWidget *view, return FALSE; } - nl = strstr (sel_data, "\r\n"); - if (!nl) { - nl = strchr (sel_data, '\n'); - } - if (nl) { - uri = g_strndup (sel_data, nl - sel_data); - file = g_file_new_for_uri (uri); - g_free (uri); - } - else { - file = g_file_new_for_uri (sel_data); - } - - empathy_send_file (contact, file); + empathy_send_file_from_uri_list (contact, sel_data); - g_object_unref (file); + g_object_unref (contact); return TRUE; } diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index 411a76640..9f4182ce1 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -1473,6 +1473,36 @@ empathy_send_file (EmpathyContact *contact, GFile *file) g_object_unref (factory); } +void +empathy_send_file_from_uri_list (EmpathyContact *contact, const gchar *uri_list) +{ + const gchar *nl; + GFile *file; + + /* Only handle a single file for now. It would be wicked cool to be + able to do multiple files, offering to zip them or whatever like + nautilus-sendto does. Note that text/uri-list is defined to have + each line terminated by \r\n, but we can be tolerant of applications + that only use \n or don't terminate single-line entries. + */ + nl = strstr (uri_list, "\r\n"); + if (!nl) { + nl = strchr (uri_list, '\n'); + } + if (nl) { + gchar *uri = g_strndup (uri_list, nl - uri_list); + file = g_file_new_for_uri (uri); + g_free (uri); + } + else { + file = g_file_new_for_uri (uri_list); + } + + empathy_send_file (contact, file); + + g_object_unref (file); +} + static void file_manager_send_file_response_cb (GtkDialog *widget, gint response_id, diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h index 0f453ddbc..e0c0904b0 100644 --- a/libempathy-gtk/empathy-ui-utils.h +++ b/libempathy-gtk/empathy-ui-utils.h @@ -112,6 +112,8 @@ GtkWidget * empathy_link_button_new (const gchar *url, void empathy_send_file (EmpathyContact *contact, GFile *file); +void empathy_send_file_from_uri_list (EmpathyContact *contact, + const gchar *uri_list); void empathy_send_file_with_file_chooser (EmpathyContact *contact); void empathy_receive_file_with_file_chooser (EmpathyFTHandler *handler); |