[evolution-patches] (Gal) Fix to handle double click on attachment bar



Hi,

I have attached the patch. Please review it.

-Srini.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/ChangeLog,v
retrieving revision 1.371
diff -u -p -r1.371 ChangeLog
--- ChangeLog	16 Aug 2005 05:26:17 -0000	1.371
+++ ChangeLog	17 Aug 2005 14:27:16 -0000
@@ -1,3 +1,9 @@
+2005-08-17  Srinivasa Ragavan <sragavan novell com>
+
+	* e-attachment-bar.c (eab_icon_clicked_cb) (e_attachment_bar_new): 
+	Fixed part of bug #312224. It handles double click on a attachment
+	icon and calls gnome_url_show.
+	
 2005-08-16  Srinivasa Ragavan <sragavan novell com>
 
 	* e-attachment.c (download_to_local_path) (e_attachment_edit): Fixed
Index: e-attachment-bar.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-attachment-bar.c,v
retrieving revision 1.7
diff -u -p -r1.7 e-attachment-bar.c
--- e-attachment-bar.c	16 Aug 2005 03:47:55 -0000	1.7
+++ e-attachment-bar.c	17 Aug 2005 14:27:20 -0000
@@ -34,6 +34,7 @@
 #include <gdk/gdkkeysyms.h>
 #include <libgnomevfs/gnome-vfs-mime-handlers.h>
 #include <libgnome/gnome-i18n.h>
+#include <libgnome/libgnome.h>
 
 #include "e-attachment.h"
 #include "e-attachment-bar.h"
@@ -810,6 +811,61 @@ eab_button_press_event(EAttachmentBar *b
 	return FALSE;
 }
 
+static gboolean
+eab_icon_clicked_cb (EAttachmentBar *bar, GdkEvent *event, gpointer *dummy)
+{
+	GSList *p = NULL;
+	GError *error = NULL;
+	gboolean ret = FALSE;
+
+	if (E_IS_ATTACHMENT_BAR (bar) && event->type == GDK_2BUTTON_PRESS) {
+		p = e_attachment_bar_get_selected (bar);
+		if (p && g_slist_length(p) == 1) {
+			EAttachment *attachment;
+			char *path = NULL, *url = NULL;
+
+			attachment = (EAttachment *)p->data;
+
+			/* Check if the file is stored already */
+			if (!(url = g_object_get_data ((GObject *)attachment, "e-open-url"))) {
+				char *uri = g_object_get_data ((GObject *)attachment, "e-drag-uri");
+
+				if (!uri) {
+					path = temp_save_part (attachment->body);
+					url = g_strdup_printf("file://%s", path);
+					g_object_set_data_full ((GObject *) attachment, "e-open-url", url, g_free);
+					uri = g_strdup_printf("file://%s\r\n", path);
+					g_object_set_data_full ((GObject *) attachment, "e-drag-uri", uri, g_free);
+				} else {
+					int len = strlen (uri);
+					/* Strip off the \r\n. gnome_url_show doesnt work with those */
+					url = g_strdup (uri);
+					url[len-2] = 0;
+					g_object_set_data_full ((GObject *) attachment, "e-open-url", url, g_free);
+				}
+			}
+
+			/* launch the url now */
+			gnome_url_show (url, &error);
+			if (error) {
+				g_message ("DEBUG: Launch failed: %s\n", error->message);
+				g_error_free (error);
+				error = NULL;
+			}
+
+			g_free (path);
+			ret = TRUE;
+		}
+
+		if (p) {
+			g_slist_foreach (p, (GFunc)g_object_unref, NULL);
+			g_slist_free (p);
+		}
+	}
+
+	return ret;
+}
+
 /* Initialization.  */
 
 static void
@@ -910,6 +966,7 @@ e_attachment_bar_new (GtkAdjustment *adj
 	g_signal_connect (new, "button_release_event", G_CALLBACK(eab_button_release_event), NULL);
 	g_signal_connect (new, "button_press_event", G_CALLBACK(eab_button_press_event), NULL);
 	g_signal_connect (new, "drag-data-get", G_CALLBACK(eab_drag_data_get), NULL);
+	g_signal_connect (icon_list, "event", G_CALLBACK (eab_icon_clicked_cb), NULL);
 	
 	return GTK_WIDGET (new);
 }


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