aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-chat.c5
-rw-r--r--libempathy-gtk/empathy-contact-list-view.c20
-rw-r--r--libempathy-gtk/empathy-ui-utils.c30
-rw-r--r--libempathy-gtk/empathy-ui-utils.h2
-rw-r--r--src/empathy-chat-window.c27
5 files changed, 41 insertions, 43 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);
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index a58d4f65c..2c6acf75e 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -1438,9 +1438,6 @@ chat_window_drag_data_received (GtkWidget *widget,
EmpathyChatWindowPriv *priv;
EmpathyContact *contact;
const gchar *data;
- const gchar *nl;
- gchar *uri;
- GFile *file;
priv = GET_PRIV (window);
contact = empathy_chat_get_remote_contact (priv->current_chat);
@@ -1450,29 +1447,9 @@ chat_window_drag_data_received (GtkWidget *widget,
return;
}
- /* Only handle a single file for new. 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.
- */
- data = (const gchar*) gtk_selection_data_get_data (selection);
- nl = strstr (data, "\r\n");
- if (!nl) {
- nl = strchr (data, '\n');
- }
- if (nl) {
- uri = g_strndup (data, nl - data);
- file = g_file_new_for_uri (uri);
- g_free (uri);
- }
- else {
- file = g_file_new_for_uri (data);
- }
-
- empathy_send_file (contact, file);
+ data = (const gchar *) gtk_selection_data_get_data (selection);
+ empathy_send_file_from_uri_list (contact, data);
- g_object_unref (file);
gtk_drag_finish (context, TRUE, FALSE, time);
}
else if (info == DND_DRAG_TYPE_TAB) {