Re: Missing "Open with" submenu in popup menu



On Fri, 2005-10-21 at 21:21 +0200, Luca Ferretti wrote: 
> Il giorno ven, 21/10/2005 alle 00.25 +0200, Christian Neumair ha
> scritto:
> > Am Donnerstag, den 20.10.2005, 15:38 +0200 schrieb Luca Ferretti:
> > > It seems disappeared after the recent change in eel and nautilus to list
> > > applications alphabetically.
> > > 
> > > The default application menu entry is still available as well as the
> > > list of registered applications for current MIME in Properties dialog.
> > > 
> > > Example: SVG files
> > > 
> > > Past
> > > 	Open with EOG
> > > 	Open with ---> Epiphany
> > > 	               Firefox
> > > 	               Inkscape
> > > 	Open with other application...
> > > 
> > > Now
> > > 	Open with EOG
> > > 	Open with other application... 
> > 
> > I cannot reproduce your problems. You may want to do some printf
> > debugging magic inside
> > libnautilus-private/nautilus-mime-actions.c:get_open_with_mime_applications.
> > 
> 
> As first stage of investigation I've applied attached changes.
> 

Doh! I forgot the diff file... 
>         
> Example2: PNG files
> 
>         ########### Nautilus - Open with ###########
>         MIME type: image/png
>         Application 1: gThumb Image Viewer
>         Application 2: F-Spot
>         Application 3: GNU Image Manipulation Program
>         Application 4: Image Viewer
>         
>         Only EOG and gthumb in menu (why 2??)

This was the result of first investigation. Added a print of
guessed_mime_type and another "for .. print list items" just before the
return. Here is the result on PNG file.
        
        ########### Nautilus - Open with ###########
        MIME type: image/jpeg
        Application 1: gThumb Image Viewer
        Application 2: F-Spot
        Application 3: GNU Image Manipulation Program
        Application 4: Image Viewer
        ### Before return ###
        Application 1: gThumb Image Viewer
        Application 2: Image Viewer


So the issue could be a) in if statement (we have to enter, so added a
g_warning to says "We are in IF statement") b) in list sorting function.
The response is b).


        ########### Nautilus - Open with ###########
        MIME type: image/jpeg
        Application 1: gThumb Image Viewer
        Application 2: F-Spot
        Application 3: GNU Image Manipulation Program
        Application 4: Image Viewer
        ### after g_list_sort ###
        Application 1: gThumb Image Viewer
        Application 2: Image Viewer
        ### Before return ###
        Application 1: gThumb Image Viewer
        Application 2: Image Viewer

I tried changing the simple g_utf8_collate to a more complex
g_utf8_collate_key ... strcmp, but this don't work too.

Of course commenting the g_list_sort () line in
get_open_with_mime_applications, all registered application will be
showed in popup menu. Now the question is: why? Could the sorting
failure be related to glib (I'm using HEAD and there was an update to
Unicode 4.1 some time ago. I'll downgrade to 2.8 and try)? Are you sure
that GnomeVFSMimeApplication->name is public?  Or you should use
gnome_vfs_mime_application_get_name (and _id)?


Oh, before I forget: now (after removal of g_list_sort) that Nautilus is
well behaving, I tried to use the Open With dialog to change TIFF viewer
from EOG to F-Spot. Result

        Open With EOG
        Open With ---> Open with F-spot
                       Open with gThumb
                       Open with F-spot
                       Open with GIMP 

A new F-Spot entry was added to list of registered applications.

Instead, using the Open with tab in properties window, the default
application is changed smoothly.
--- libnautilus-private/nautilus-mime-actions.c	2005-10-22 19:48:07.000000000 +0200
+++ ../OLD/nautilus/libnautilus-private/nautilus-mime-actions.c	2005-10-21 21:02:55.000000000 +0200
@@ -29,6 +29,8 @@
 #include "nautilus-file.h"
 #include "nautilus-metadata.h"
 #include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <glib.h>
+#include <glib/gprintf.h>
 #include <string.h>
 
 static GList*
@@ -144,12 +146,26 @@
 	char *guessed_mime_type;
 	char *mime_type, *uri;
 	GList *result;
+	int i;
 
+	g_warning("########### Nautilus - Open with ###########");
 	guessed_mime_type = nautilus_file_get_guessed_mime_type (file);
 	mime_type = nautilus_file_get_mime_type (file);
 	uri = nautilus_file_get_uri (file);
 
+	g_warning("MIME type: %s", mime_type);
+
 	result = gnome_vfs_mime_get_all_applications_for_uri (uri, mime_type);
+	
+	for (i = 0; i < g_list_length (result) ; ++i) {
+		GList *item;
+		
+		item = g_list_nth (result, i);
+			
+		g_warning ("Application %i: %s", i+1, gnome_vfs_mime_application_get_name (item->data));
+	}
+
+
 	g_list_sort (result, (GCompareFunc) application_compare_by_name);
 
 	if (strcmp (guessed_mime_type, mime_type) != 0) {
--- ../CVS/nautilus/libnautilus-private/nautilus-mime-actions.c	2005-10-19 22:13:10.000000000 +0200
+++ libnautilus-private/nautilus-mime-actions.c	2005-10-23 17:32:15.000000000 +0200
@@ -29,6 +29,8 @@
 #include "nautilus-file.h"
 #include "nautilus-metadata.h"
 #include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <glib.h>
+#include <glib/gprintf.h>
 #include <string.h>
 
 static GList*
@@ -128,7 +130,19 @@
 application_compare_by_name (const GnomeVFSMimeApplication *app_a,
 			     const GnomeVFSMimeApplication *app_b)
 {
-	return g_utf8_collate (app_a->name, app_b->name);
+	char *application_a_key;
+	char *application_b_key;
+	int i;
+
+	application_a_key = g_utf8_collate_key (app_a->name, -1);
+	application_b_key = g_utf8_collate_key (app_b->name, -1);
+
+	i = strcmp (application_a_key, application_b_key);
+
+	g_free (application_a_key);
+	g_free (application_b_key);
+
+	return i;
 }
 
 static int
@@ -144,18 +158,42 @@
 	char *guessed_mime_type;
 	char *mime_type, *uri;
 	GList *result;
+	int i;
 
+	g_warning("########### Nautilus - Open with ###########");
 	guessed_mime_type = nautilus_file_get_guessed_mime_type (file);
 	mime_type = nautilus_file_get_mime_type (file);
 	uri = nautilus_file_get_uri (file);
 
+	g_warning("MIME type: \"%s\"", mime_type);
+	g_warning("Guessed MIME type: \"%s\"", guessed_mime_type);
+
 	result = gnome_vfs_mime_get_all_applications_for_uri (uri, mime_type);
-	g_list_sort (result, (GCompareFunc) application_compare_by_name);
+	
+	for (i = 0; i < g_list_length (result) ; ++i) {
+		GList *item;
+		item = g_list_nth (result, i);
+		g_warning ("Application %i: %s", i+1, gnome_vfs_mime_application_get_name (item->data));
+	}
+
+
+	//	g_list_sort (result, (GCompareFunc) application_compare_by_name);
+	
+
+	g_warning ("### After g_list_sort ###");
+	for (i = 0; i < g_list_length (result) ; ++i) {
+		GList *item;
+		item = g_list_nth (result, i);
+		g_warning ("Application %i: %s", i+1, gnome_vfs_mime_application_get_name (item->data));
+	}
+
 
 	if (strcmp (guessed_mime_type, mime_type) != 0) {
 		GList *result_2;
 		GList *l;
 
+		g_warning ("### We are in IF statement!!! ###");
+
 		result_2 = gnome_vfs_mime_get_all_applications (guessed_mime_type);
 		for (l = result_2; l != NULL; l = l->next) {
 			if (!g_list_find_custom (result, l->data,
@@ -164,12 +202,22 @@
 							       (GCompareFunc) application_compare_by_name);
 			}
 		}
+
+
 		g_list_free (result_2);
 	}
-
+	
 	g_free (mime_type);
 	g_free (uri);
 	g_free (guessed_mime_type);
+
+	g_warning ("### Before return ###");
+	for (i = 0; i < g_list_length (result) ; ++i) {
+		GList *item;
+		item = g_list_nth (result, i);
+		g_warning ("Application %i: %s", i+1, gnome_vfs_mime_application_get_name (item->data));
+	}
+
 	
 	return result;
 }


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