[PATCH] Freeze breakage: Fix URI activation cancellation for panel



The attached patches are meant to fix cancellation of URI activations
through the panel. They are against libgnome, gnome-panel and gnome-vfs,
and break string freeze, and potentially even API freeze. I wonder
whether adding an element to a public enum is consiered an API change.

Life would have been easier if GnomeURLError used negative error codes,
reserving all >= 0 for GnomeVFSResult retvals.

I've also CCed random people that often occur in recent ChangeLogs of
the affected producs and/or released tarballs. MAINTAINERS files aren't
up to date for any of these.

-- 
Christian Neumair <chris gnome-de org>
Index: libgnomevfs/gnome-vfs-utils.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-utils.c,v
retrieving revision 1.102
diff -u -p -r1.102 gnome-vfs-utils.c
--- libgnomevfs/gnome-vfs-utils.c	15 Sep 2005 11:02:53 -0000	1.102
+++ libgnomevfs/gnome-vfs-utils.c	14 Oct 2005 14:37:15 -0000
@@ -2170,10 +2178,20 @@ gnome_vfs_url_show_with_env (const char 
 	
 	g_free (scheme);
 
-	type = _gnome_vfs_get_slow_mime_type (url);
-
-	if (type == NULL) {
+	info = gnome_vfs_file_info_new ();
+	result = gnome_vfs_get_file_info (url, info,
+					  GNOME_VFS_FILE_INFO_GET_MIME_TYPE |
+					  GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE |
+					  GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
+	if (result != GNOME_VFS_OK) {
+		gnome_vfs_file_info_unref (info);
+		return result;
+	} else if (info->mime_type == NULL) {
+		gnome_vfs_file_info_unref (info);
 		return GNOME_VFS_ERROR_NO_DEFAULT;
+	} else {
+		type = g_strdup (info->mime_type);
+		gnome_vfs_file_info_unref (info);
 	}
 	
 	params.data = (char *) url;
Index: libgnome/gnome-url.c
===================================================================
RCS file: /cvs/gnome/libgnome/libgnome/gnome-url.c,v
retrieving revision 1.48
diff -u -p -r1.48 gnome-url.c
--- libgnome/gnome-url.c	28 Mar 2005 15:45:07 -0000	1.48
+++ libgnome/gnome-url.c	14 Oct 2005 14:30:32 -0000
@@ -120,7 +120,14 @@ gnome_url_show_with_env (const char  *ur
 			     GNOME_URL_ERROR_NOT_SUPPORTED,
 			     _("The default action does not support this protocol."));
 		break;
-			     
+
+	case GNOME_VFS_ERROR_CANCELLED:
+		g_set_error (error,
+		             GNOME_URL_ERROR,
+			     GNOME_URL_ERROR_CANCELLED,
+			     _("The request was cancelled."));
+		break;
+
 	default:
 		g_set_error (error,
 			     GNOME_URL_ERROR,
Index: libgnome/gnome-url.h
===================================================================
RCS file: /cvs/gnome/libgnome/libgnome/gnome-url.h,v
retrieving revision 1.19
diff -u -p -r1.19 gnome-url.h
--- libgnome/gnome-url.h	25 Apr 2003 11:20:12 -0000	1.19
+++ libgnome/gnome-url.h	14 Oct 2005 14:30:32 -0000
@@ -42,7 +42,8 @@ typedef enum {
   GNOME_URL_ERROR_URL,
   GNOME_URL_ERROR_NO_DEFAULT,
   GNOME_URL_ERROR_NOT_SUPPORTED,
-  GNOME_URL_ERROR_VFS
+  GNOME_URL_ERROR_VFS,
+  GNOME_URL_ERROR_CANCELLED
 } GnomeURLError;
 
 #define GNOME_URL_ERROR (gnome_url_error_quark ())
Index: gnome-panel/panel-menu-items.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-menu-items.c,v
retrieving revision 1.11
diff -u -p -r1.11 panel-menu-items.c
--- gnome-panel/panel-menu-items.c	9 Oct 2005 21:40:58 -0000	1.11
+++ gnome-panel/panel-menu-items.c	14 Oct 2005 14:35:50 -0000
@@ -39,6 +39,7 @@
 #include <glib/gi18n.h>
 
 #include <libgnomevfs/gnome-vfs.h>
+#include <libgnome/gnome-url.h>
 #include <libgnomeui/gnome-url.h>
 
 #include "menu.h"
@@ -102,16 +103,17 @@ activate_uri (GtkWidget *menuitem,
 						       GNOME_VFS_MAKE_URI_DIR_HOMEDIR);
 	gnome_url_show_on_screen (url, screen, &error);
 
-	if (error) {
-		escaped = g_markup_escape_text (url, -1);
-		panel_error_dialog (screen, "cannot_show_url", TRUE,
-				    _("Cannot display location '%s'"),
-				    "%s",
-				    escaped,
-				    error->message);
-
+	if (error != NULL) {
+		if (error->code != GNOME_URL_ERROR_CANCELLED) {
+			escaped = g_markup_escape_text (url, -1);
+			panel_error_dialog (screen, "cannot_show_url", TRUE,
+					    _("Cannot display location '%s'"),
+					    "%s",
+					    escaped,
+					    error->message);
+			g_free (escaped);
+		}
 		g_error_free (error);
-		g_free (escaped);
 	}
 	g_free (url);
 }

Attachment: signature.asc
Description: This is a digitally signed message part



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