[evolution/gnome-2-30] Bug 621819 - Can't drag message attachments to folders



commit f0ed91cee63663f132f34c7ce02039b03a3f6b95
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Jun 22 19:46:07 2010 -0400

    Bug 621819 - Can't drag message attachments to folders

 mail/em-folder-tree.c              |    9 +------
 mail/em-utils.c                    |   12 +++++-----
 widgets/misc/e-attachment-button.c |   42 ++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 13 deletions(-)
---
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index bb948f4..bdb3605 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -1663,9 +1663,7 @@ folder_tree_drop_async__free (struct _DragDataReceivedAsync *m)
 	g_object_unref(m->context);
 	camel_object_unref(m->store);
 	g_free(m->full_name);
-
-	g_free(m->selection->data);
-	g_free(m->selection);
+	gtk_selection_data_free (m->selection);
 }
 
 static MailMsgInfo folder_tree_drop_async_info = {
@@ -1735,10 +1733,7 @@ tree_drag_data_received(GtkWidget *widget, GdkDragContext *context, gint x, gint
 	m->info = info;
 
 	/* need to copy, goes away once we exit */
-	m->selection = g_malloc0(sizeof(*m->selection));
-	m->selection->data = g_malloc(selection->length);
-	memcpy(m->selection->data, selection->data, selection->length);
-	m->selection->length = selection->length;
+	m->selection = gtk_selection_data_copy (selection);
 
 	tree_drag_data_action(m);
 }
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 340ec58..692e461 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -856,18 +856,18 @@ em_utils_selection_set_urilist(GtkSelectionData *data, CamelFolder *folder, GPtr
  * automatically cleaned up when the application quits.
  **/
 void
-em_utils_selection_get_urilist(GtkSelectionData *data, CamelFolder *folder)
+em_utils_selection_get_urilist (GtkSelectionData *selection_data,
+                                CamelFolder *folder)
 {
 	CamelStream *stream;
 	CamelURL *url;
 	gint fd, i, res = 0;
-	gchar *tmp, **uris;
+	gchar **uris;
 
 	d(printf(" * drop uri list\n"));
 
-	tmp = g_strndup((gchar *)data->data, data->length);
-	uris = g_strsplit(tmp, "\n", 0);
-	g_free(tmp);
+	uris = gtk_selection_data_get_uris (selection_data);
+
 	for (i=0;res == 0 && uris[i];i++) {
 		g_strstrip(uris[i]);
 		if (uris[i][0] == '#')
@@ -889,7 +889,7 @@ em_utils_selection_get_urilist(GtkSelectionData *data, CamelFolder *folder)
 		camel_url_free(url);
 	}
 
-	g_strfreev(uris);
+	g_strfreev (uris);
 }
 
 static void
diff --git a/widgets/misc/e-attachment-button.c b/widgets/misc/e-attachment-button.c
index d1b02c0..f20ba2d 100644
--- a/widgets/misc/e-attachment-button.c
+++ b/widgets/misc/e-attachment-button.c
@@ -247,6 +247,18 @@ attachment_button_expand_clicked_cb (EAttachmentButton *button)
 }
 
 static void
+attachment_button_expand_drag_begin_cb (EAttachmentButton *button,
+                                        GdkDragContext *context)
+{
+	EAttachmentView *view;
+
+	view = e_attachment_button_get_view (button);
+
+	attachment_button_select_path (button);
+	e_attachment_view_drag_begin (view, context);
+}
+
+static void
 attachment_button_expand_drag_data_get_cb (EAttachmentButton *button,
                                            GdkDragContext *context,
                                            GtkSelectionData *selection,
@@ -263,6 +275,17 @@ attachment_button_expand_drag_data_get_cb (EAttachmentButton *button,
 		view, context, selection, info, time);
 }
 
+static void
+attachment_button_expand_drag_end_cb (EAttachmentButton *button,
+                                      GdkDragContext *context)
+{
+	EAttachmentView *view;
+
+	view = e_attachment_button_get_view (button);
+
+	e_attachment_view_drag_end (view, context);
+}
+
 static gboolean
 attachment_button_toggle_button_press_event_cb (EAttachmentButton *button,
                                                 GdkEventButton *event)
@@ -579,20 +602,39 @@ attachment_button_init (EAttachmentButton *button)
 		G_CALLBACK (attachment_button_expand_clicked_cb), button);
 
 	g_signal_connect_swapped (
+		button->priv->expand_button, "drag-begin",
+		G_CALLBACK (attachment_button_expand_drag_begin_cb),
+		button);
+
+	g_signal_connect_swapped (
 		button->priv->expand_button, "drag-data-get",
 		G_CALLBACK (attachment_button_expand_drag_data_get_cb),
 		button);
 
 	g_signal_connect_swapped (
+		button->priv->expand_button, "drag-end",
+		G_CALLBACK (attachment_button_expand_drag_end_cb),
+		button);
+
+	g_signal_connect_swapped (
 		button->priv->toggle_button, "button-press-event",
 		G_CALLBACK (attachment_button_toggle_button_press_event_cb),
 		button);
 
 	g_signal_connect_swapped (
+		button->priv->toggle_button, "drag-begin",
+		G_CALLBACK (attachment_button_expand_drag_begin_cb),
+		button);
+
+	g_signal_connect_swapped (
 		button->priv->toggle_button, "drag-data-get",
 		G_CALLBACK (attachment_button_expand_drag_data_get_cb),
 		button);
 
+	g_signal_connect_swapped (
+		button->priv->toggle_button, "drag-end",
+		G_CALLBACK (attachment_button_expand_drag_end_cb),
+		button);
 }
 
 GType



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]