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



Am Montag, den 17.10.2005, 10:20 +0200 schrieb Alexander Larsson:
> On Fri, 2005-10-14 at 16:51 +0200, Christian Neumair wrote:
> > 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.
> 
> GnomeURLError was written before gnome_vfs_show_url existed...
> 
> > 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.
> 
> The gnome-vfs patch should really modify _gnome_vfs_get_slow_mime_type()
> (it is the only used for this function) instead of copying it into the
> function.

Yes, I know. I just didnt want to change that header. You reminded me
that even private API deserves some attention. Attaching a new patch
set.

What do you propose to resolve the
gnome_vfs_get_mime_type/_gnome_vfs_get_slow_mime_type signature
inconsistency the change introduces, considering that
_gnome_vfs_get_slow_mime_type is very likely to become public one day,
if not for GnomeVFS 2.14?

-- 
Christian Neumair <chris gnome-de org>
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);
 }
Index: libgnomevfs/gnome-vfs-mime-private.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-mime-private.h,v
retrieving revision 1.10
diff -u -p -r1.10 gnome-vfs-mime-private.h
--- libgnomevfs/gnome-vfs-mime-private.h	27 Aug 2004 13:42:14 -0000	1.10
+++ libgnomevfs/gnome-vfs-mime-private.h	17 Oct 2005 19:15:40 -0000
@@ -41,7 +41,8 @@ gboolean         _gnome_vfs_file_date_tr
 void             _gnome_vfs_mime_info_mark_gnome_mime_dir_dirty  (void);
 void             _gnome_vfs_mime_info_mark_user_mime_dir_dirty   (void);
 
-char * _gnome_vfs_get_slow_mime_type (const char *text_uri);
+GnomeVFSResult _gnome_vfs_get_slow_mime_type (const char  *text_uri,
+					      char       **mime_type);
 
 
 /* Should be exported, but we're in API freeze */
Index: libgnomevfs/gnome-vfs-mime.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-mime.c,v
retrieving revision 1.59
diff -u -p -r1.59 gnome-vfs-mime.c
--- libgnomevfs/gnome-vfs-mime.c	7 Sep 2005 21:24:49 -0000	1.59
+++ libgnomevfs/gnome-vfs-mime.c	17 Oct 2005 19:15:40 -0000
@@ -829,26 +829,29 @@ gnome_vfs_get_mime_type (const char *tex
 }
 
 /* This is private due to the feature freeze, maybe it should be public */
-char *
-_gnome_vfs_get_slow_mime_type (const char *text_uri)
+GnomeVFSResult
+_gnome_vfs_get_slow_mime_type (const char  *text_uri,
+			       char       **mime_type)
 {
 	GnomeVFSFileInfo *info;
-	char *mime_type;
 	GnomeVFSResult result;
 
+	g_return_val_if_fail (text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
+	g_return_val_if_fail (mime_type != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
+
+	*mime_type = NULL;
+
 	info = gnome_vfs_file_info_new ();
 	result = gnome_vfs_get_file_info (text_uri, info,
 					  GNOME_VFS_FILE_INFO_GET_MIME_TYPE |
 					  GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE |
 					  GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
-	if (info->mime_type == NULL || result != GNOME_VFS_OK) {
-		mime_type = NULL;
-	} else {
-		mime_type = g_strdup (info->mime_type);
+	if (result == GNOME_VFS_OK) {
+		*mime_type = g_strdup (info->mime_type);
 	}
 	gnome_vfs_file_info_unref (info);
 
-	return mime_type;
+	return result;
 }
 
 void
Index: libgnomevfs/gnome-vfs-utils.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-utils.c,v
retrieving revision 1.103
diff -u -p -r1.103 gnome-vfs-utils.c
--- libgnomevfs/gnome-vfs-utils.c	17 Oct 2005 18:14:50 -0000	1.103
+++ libgnomevfs/gnome-vfs-utils.c	17 Oct 2005 19:15:41 -0000
@@ -2175,10 +2175,14 @@ gnome_vfs_url_show_with_env (const char 
 	
 	g_free (scheme);
 
-	type = _gnome_vfs_get_slow_mime_type (url);
+	result = _gnome_vfs_get_slow_mime_type (url, &type);
 
-	if (type == NULL) {
-		return GNOME_VFS_ERROR_NO_DEFAULT;
+	if (result == GNOME_VFS_OK && type == NULL) {
+		result = GNOME_VFS_ERROR_NO_DEFAULT;
+	}
+
+	if (result != GNOME_VFS_OK) {
+		return result;
 	}
 	
 	params.data = (char *) url;

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil



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