Re: [Nautilus-list] Another question: nautilus and XALF



Havoc Pennington wrote:

Darin Adler <darin bentspoon com> writes:
Oh, that's new code that the Red Hat guys added after 1.0.

I have never looked at nautilus_desktop_file_launch -- it's quite
possible that it does something different.

Havoc, can you remember who did this part?


I don't remember. It appears to use
nautilus_launch_application_from_command and do some xalf stuff
though.

Havoc

Here are the final two patches I propose to fix xalf handling for desktop icons. They are generated against branch nautilus-gnome-1. The nautilus2 patches are for HEAD & gnome2.

The first (nautilus1-desktop-file-launch.patch) changes the icon activate callback to take advantage of the NautilusDesktopFile::nautilus_desktop_file_launch method to launch the command in it. This class is made public, at least for the contructor. I changed this since my previous patch because the struct can stay hidden.

The second patch (nautilus1-desktop-file-launch-2.patch) changes the nautilus_launch_application_from_command func to use eel_gnome_shell_execute instead of system(3). The implementation seems to be close to the system(3) one and I think that it is more consistent.

I tested both and they are fine (or I made a big mistake :-).
Would you commit ?

--
                                                         -o)
                  Remi Cohen-Scali                       /\\
<Remi Cohen-Scali com>          <rcoscali rcsnet net>    _\_v
                                                        ----


diff -u -r1.4797.2.9 nautilus/ChangeLog
--- nautilus/ChangeLog	2001/11/08 05:37:33	1.4797.2.9
+++ nautilus/ChangeLog	2002/01/26 12:11:30
@@ -1,3 +1,16 @@
+2002-01-26  Remi Cohen-Scali  <remi cohen-scali com>
+
+	* src/file-manager/fm-directory-view.c (activate_callback): 
+	Now use newly public NautilusDesktopFile class & nautilus_desktop_file_launch
+	to launch the corresponding command.
+
+	* libnautilus-private/nautilus-desktop-file-loader.c: 
+	* libnautilus-private/nautilus-desktop-file-loader.h: 
+	Made the NautilusDesktopFile class public. The struct has been moved
+	from the source to the header. The nautilus_desktop_file_new method
+	is not static any more.
+	
+
 2002-01-22  Darin Adler  <darin bentspoon com>
 
 	* libnautilus-private/nautilus-icon-container.c:
diff -u -r1.2 nautilus/libnautilus-private/nautilus-desktop-file-loader.c
--- nautilus/libnautilus-private/nautilus-desktop-file-loader.c	2001/09/26 16:37:15	1.2
+++ nautilus/libnautilus-private/nautilus-desktop-file-loader.c	2002/01/26 12:03:07
@@ -41,7 +41,6 @@
 #include <iconv.h>
 #include <langinfo.h>
 
-typedef struct NautilusDesktopFileSection NautilusDesktopFileSection;
 typedef struct NautilusDesktopFileAddition NautilusDesktopFileAddition;
 typedef struct NautilusDesktopFileForeachData NautilusDesktopFileForeachData;
 
@@ -50,18 +49,6 @@
 						 gpointer        data);
 
 
-struct NautilusDesktopFile {
-        char **lines;
-  
-        /* hash of section names, from pointer to start of name (just after
-         * bracket) to NautilusDesktopFileSection structs
-         */  
-        GHashTable *section_hash;
-	GList *addition_list;
-
-        NautilusDesktopFileSection *main_section;
-};
-
 struct NautilusDesktopFileSection {
         /* pointer into a line of df->lines for start of name */
         const char *name;
@@ -105,7 +92,6 @@
 								    NautilusDesktopFileForeachFunc   func,
 								    gpointer                         user_data);
 
-static NautilusDesktopFile *        nautilus_desktop_file_new             (void);
 static void                         hash_lines                            (NautilusDesktopFile             *df);
 static NautilusDesktopFileSection*  section_new                           (const char                      *name,
 									   char                           **start_line);
@@ -118,7 +104,7 @@
 static void                         addition_free                         (NautilusDesktopFileAddition     *addition);
 
 
-static NautilusDesktopFile*
+NautilusDesktopFile*
 nautilus_desktop_file_new (void)
 {
         NautilusDesktopFile *df;
@@ -1160,8 +1146,7 @@
 	char *url;
 	char *exec;
 	char *subst;
-		
-		
+	char *name;
 
 	if (!nautilus_desktop_file_get_string (df, NULL, "Type", &type)) {
 		return;
@@ -1187,11 +1172,13 @@
 
 			in_terminal = FALSE;
 			nautilus_desktop_file_get_boolean (df, NULL, "Terminal", &in_terminal);
+			nautilus_desktop_file_get_locale_string (df, NULL, "Name", &name);
 
-			nautilus_launch_application_from_command ("",
+			nautilus_launch_application_from_command (name ? name : "",
 								  subst,
 								  NULL,
 								  in_terminal);
+			if (name) g_free (name);
 			g_free (subst);
 		}
 

diff -u -r1.2 nautilus/libnautilus-private/nautilus-desktop-file-loader.h
--- nautilus/libnautilus-private/nautilus-desktop-file-loader.h	2001/09/26 16:37:15	1.2
+++ nautilus/libnautilus-private/nautilus-desktop-file-loader.h	2002/01/26 12:03:07
@@ -30,6 +30,21 @@
 #include <glib.h>
 #include <libgnomevfs/gnome-vfs-result.h>
 
+struct NautilusDesktopFileSection;
+typedef struct NautilusDesktopFileSection NautilusDesktopFileSection;
+
+struct NautilusDesktopFile {
+        char **lines;
+  
+        /* hash of section names, from pointer to start of name (just after
+         * bracket) to NautilusDesktopFileSection structs
+         */  
+        GHashTable *section_hash;
+	GList *addition_list;
+
+        NautilusDesktopFileSection *main_section;
+};
+
 typedef struct NautilusDesktopFile NautilusDesktopFile;
 
 /* This is a quick-hack to read and modify .desktop files.
@@ -40,6 +55,7 @@
  * and put it in another library for use by the panel, nautilus etc.
  */
 
+NautilusDesktopFile *nautilus_desktop_file_new             (void);
 GnomeVFSResult       nautilus_desktop_file_load            (const char                      *uri,
 							    NautilusDesktopFile            **desktop_file);
 NautilusDesktopFile *nautilus_desktop_file_from_string     (const char                      *data);

diff -u -r1.473.2.3 nautilus/src/file-manager/fm-directory-view.c
--- nautilus/src/file-manager/fm-directory-view.c	2001/10/26 01:06:47	1.473.2.3
+++ nautilus/src/file-manager/fm-directory-view.c	2002/01/26 12:05:09
@@ -75,6 +75,7 @@
 #include <libnautilus-private/nautilus-trash-directory.h>
 #include <libnautilus-private/nautilus-trash-monitor.h>
 #include <libnautilus-private/nautilus-view-identifier.h>
+#include <libnautilus-private/nautilus-desktop-file-loader.h>
 #include <libnautilus/nautilus-bonobo-ui.h>
 #include <math.h>
 
@@ -4598,8 +4599,10 @@
 	ActivateParameters *parameters;
 	FMDirectoryView *view;
 	char *uri, *command, *executable_path, *quoted_path, *name;
+	char *dfpath; 
 	GnomeVFSMimeApplication *application;
 	ActivationAction action;
+	NautilusDesktopFile *df; 
 	
 	parameters = callback_data;
 
@@ -4636,8 +4639,15 @@
 			 * enforced by using a call that uses
 			 * fork/execlp instead of system.
 			 */
-			command = uri + strlen (NAUTILUS_COMMAND_SPECIFIER);
-			eel_gnome_shell_execute (command);
+			name = nautilus_file_get_name(file); 
+			df = nautilus_desktop_file_new ();
+			dfpath = g_strdup_printf ("%s/%s",
+						  nautilus_get_desktop_directory (),
+						  name); 
+			g_free (name); 
+			nautilus_desktop_file_load (dfpath, &df);
+			nautilus_desktop_file_launch(df);
+			g_free (df);
 			action = ACTIVATION_ACTION_DO_NOTHING;
 		}
 	}
diff -u nautilus/ChangeLog.prev nautilus/ChangeLog
--- nautilus/ChangeLog.prev	Sat Jan 26 19:37:08 2002
+++ nautilus/ChangeLog	Sat Jan 26 19:12:13 2002
@@ -1,5 +1,9 @@
 2002-01-26  Remi Cohen-Scali  <remi cohen-scali com>
 
+	* libnautilus-private/nautilus-program-choosing.c 
+	(nautilus_launch_application_from_command): Changed the system(3) call to 
+	launch application from command. Instead use eel_gnome_shell_execute.
+
 	* src/file-manager/fm-directory-view.c (activate_callback): 
 	Now use newly public NautilusDesktopFile class & nautilus_desktop_file_launch
 	to launch the corresponding command.
diff -u -r1.46 nautilus/libnautilus-private/nautilus-program-choosing.c
--- nautilus/libnautilus-private/nautilus-program-choosing.c	2001/10/04 10:05:57	1.46
+++ nautilus/libnautilus-private/nautilus-program-choosing.c	2002/01/26 18:10:15
@@ -678,16 +678,15 @@
 	}
 
 	xalf_prefix = get_xalf_prefix (name);
+	final_command = g_strconcat (xalf_prefix, full_command, NULL);
 
-	if (use_terminal) {
-		final_command = g_strconcat (xalf_prefix, full_command, NULL);
-		eel_gnome_open_terminal (final_command);
-	} else {
-		final_command = g_strconcat (xalf_prefix, full_command, " &", NULL);
-		system (final_command);
-	}
-
-	g_free (final_command);
 	g_free (full_command);
 	g_free (xalf_prefix);
+
+	if (use_terminal)
+	    eel_gnome_open_terminal (final_command);
+	else
+	    eel_gnome_shell_execute (final_command);
+
+	g_free (final_command);
 }

--- nautilus/ChangeLog	2001/11/08 05:37:33
+++ nautilus/ChangeLog	2002/01/26 12:11:30
@@ -1,3 +1,16 @@
+2002-01-26  Remi Cohen-Scali  <remi cohen-scali com>
+
+	* src/file-manager/fm-directory-view.c (activate_callback): 
+	Now use newly public NautilusDesktopFile class & nautilus_desktop_file_launch
+	to launch the corresponding command.
+
+	* libnautilus-private/nautilus-desktop-file-loader.c: 
+	* libnautilus-private/nautilus-desktop-file-loader.h: 
+	Made the NautilusDesktopFile class public. The struct has been moved
+	from the source to the header. The nautilus_desktop_file_new method
+	is not static any more.
+	
+
 2002-01-25  Michael Meeks  <michael ximian com>
 
 	* libnautilus-private/nautilus-bookmark.c

diff -u nautilus-orig/libnautilus-private/nautilus-desktop-file-loader.c nautilus/libnautilus-private/nautilus-desktop-file-loader.c
--- nautilus-orig/libnautilus-private/nautilus-desktop-file-loader.c	2001/09/26 16:37:15
+++ nautilus/libnautilus-private/nautilus-desktop-file-loader.c	2002/01/26 12:03:07
@@ -38,7 +38,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-typedef struct NautilusDesktopFileSection NautilusDesktopFileSection;
 typedef struct NautilusDesktopFileAddition NautilusDesktopFileAddition;
 typedef struct NautilusDesktopFileForeachData NautilusDesktopFileForeachData;
 
@@ -47,18 +46,6 @@
 						 gpointer        data);
 
 
-struct NautilusDesktopFile {
-        char **lines;
-  
-        /* hash of section names, from pointer to start of name (just after
-         * bracket) to NautilusDesktopFileSection structs
-         */  
-        GHashTable *section_hash;
-	GList *addition_list;
-
-        NautilusDesktopFileSection *main_section;
-};
-
 struct NautilusDesktopFileSection {
         /* pointer into a line of df->lines for start of name */
         const char *name;
@@ -102,7 +89,6 @@
 								    NautilusDesktopFileForeachFunc   func,
 								    gpointer                         user_data);
 
-static NautilusDesktopFile *        nautilus_desktop_file_new             (void);
 static void                         hash_lines                            (NautilusDesktopFile             *df);
 static NautilusDesktopFileSection*  section_new                           (const char                      *name,
 									   char                           **start_line);
@@ -115,7 +101,7 @@
 static void                         addition_free                         (NautilusDesktopFileAddition     *addition);
 
 
-static NautilusDesktopFile*
+NautilusDesktopFile*
 nautilus_desktop_file_new (void)
 {
         NautilusDesktopFile *df;
@@ -1099,8 +1085,7 @@
 	char *url;
 	char *exec;
 	char *subst;
-		
-		
+	char *name;
 
 	if (!nautilus_desktop_file_get_string (df, NULL, "Type", &type)) {
 		return;
@@ -1126,11 +1111,13 @@
 
 			in_terminal = FALSE;
 			nautilus_desktop_file_get_boolean (df, NULL, "Terminal", &in_terminal);
+			nautilus_desktop_file_get_locale_string (df, NULL, "Name", &name);
 
-			nautilus_launch_application_from_command ("",
+			nautilus_launch_application_from_command (name ? name : "",
 								  subst,
 								  NULL,
 								  in_terminal);
+			if (name) g_free (name);
 			g_free (subst);
 		}
 
diff -u nautilus-orig/libnautilus-private/nautilus-desktop-file-loader.h nautilus/libnautilus-private/nautilus-desktop-file-loader.h
--- nautilus-orig/libnautilus-private/nautilus-desktop-file-loader.h	2001/09/26 16:37:15
+++ nautilus/libnautilus-private/nautilus-desktop-file-loader.h	2002/01/26 12:03:07
@@ -30,6 +30,21 @@
 #include <glib.h>
 #include <libgnomevfs/gnome-vfs-result.h>
 
+struct NautilusDesktopFileSection;
+typedef struct NautilusDesktopFileSection NautilusDesktopFileSection;
+
+struct NautilusDesktopFile {
+        char **lines;
+  
+        /* hash of section names, from pointer to start of name (just after
+         * bracket) to NautilusDesktopFileSection structs
+         */  
+        GHashTable *section_hash;
+	GList *addition_list;
+
+        NautilusDesktopFileSection *main_section;
+};
+
 typedef struct NautilusDesktopFile NautilusDesktopFile;
 
 /* This is a quick-hack to read and modify .desktop files.
@@ -40,6 +55,7 @@
  * and put it in another library for use by the panel, nautilus etc.
  */
 
+NautilusDesktopFile *nautilus_desktop_file_new             (void);
 GnomeVFSResult       nautilus_desktop_file_load            (const char                      *uri,
 							    NautilusDesktopFile            **desktop_file);
 NautilusDesktopFile *nautilus_desktop_file_from_string     (const char                      *data);

diff -u -r1.473.2.3 nautilus/src/file-manager/fm-directory-view.c
--- nautilus/src/file-manager/fm-directory-view.c	2001/10/26 01:06:47	1.473.2.3
+++ nautilus/src/file-manager/fm-directory-view.c	2002/01/26 12:05:09
@@ -74,6 +74,7 @@
 #include <libnautilus-private/nautilus-trash-directory.h>
 #include <libnautilus-private/nautilus-trash-monitor.h>
 #include <libnautilus-private/nautilus-view-identifier.h>
+#include <libnautilus-private/nautilus-desktop-file-loader.h>
 #include <libnautilus/nautilus-bonobo-ui.h>
 #include <math.h>
 #include <unistd.h>
@@ -4625,8 +4626,10 @@
 	ActivateParameters *parameters;
 	FMDirectoryView *view;
 	char *uri, *command, *executable_path, *quoted_path, *name;
+	char *dfpath; 
 	GnomeVFSMimeApplication *application;
 	ActivationAction action;
+	NautilusDesktopFile *df; 
 	
 	parameters = callback_data;
 
@@ -4663,8 +4666,15 @@
 			 * enforced by using a call that uses
 			 * fork/execlp instead of system.
 			 */
-			command = uri + strlen (NAUTILUS_COMMAND_SPECIFIER);
-			eel_gnome_shell_execute (command);
+			name = nautilus_file_get_name(file); 
+			df = nautilus_desktop_file_new ();
+			dfpath = g_strdup_printf ("%s/%s",
+						  nautilus_get_desktop_directory (),
+						  name); 
+			g_free (name); 
+			nautilus_desktop_file_load (dfpath, &df);
+			nautilus_desktop_file_launch(df);
+			g_free (df);
 			action = ACTIVATION_ACTION_DO_NOTHING;
 		}
 	}
diff -u nautilus/ChangeLog.prev nautilus/ChangeLog
--- nautilus/ChangeLog.prev	Sat Jan 26 19:37:08 2002
+++ nautilus/ChangeLog	Sat Jan 26 19:12:13 2002
@@ -1,5 +1,9 @@
 2002-01-26  Remi Cohen-Scali  <remi cohen-scali com>
 
+	* libnautilus-private/nautilus-program-choosing.c 
+	(nautilus_launch_application_from_command): Changed the system(3) call to 
+	launch application from command. Instead use eel_gnome_shell_execute.
+
 	* src/file-manager/fm-directory-view.c (activate_callback): 
 	Now use newly public NautilusDesktopFile class & nautilus_desktop_file_launch
 	to launch the corresponding command.
--- nautilus-orig/libnautilus-private/nautilus-program-choosing.c	2001/10/04 10:05:57
+++ nautilus/libnautilus-private/nautilus-program-choosing.c	2002/01/26 18:10:15
@@ -674,16 +674,15 @@
 	}
 
 	xalf_prefix = get_xalf_prefix (name);
+	final_command = g_strconcat (xalf_prefix, full_command, NULL);
 
-	if (use_terminal) {
-		final_command = g_strconcat (xalf_prefix, full_command, NULL);
-		eel_gnome_open_terminal (final_command);
-	} else {
-		final_command = g_strconcat (xalf_prefix, full_command, " &", NULL);
-		system (final_command);
-	}
-
-	g_free (final_command);
 	g_free (full_command);
 	g_free (xalf_prefix);
+
+	if (use_terminal)
+	    eel_gnome_open_terminal (final_command);
+	else
+	    eel_gnome_shell_execute (final_command);
+
+	g_free (final_command);
 }


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