Re: [Nautilus-list] XALF patch
- From: Rémi Cohen-Scali <Remi Cohen-Scali com>
- To: Darin Adler <darin bentspoon com>, Nautilus Mailling List <nautilus-list lists eazel com>
- Subject: Re: [Nautilus-list] XALF patch
- Date: Mon, 28 Jan 2002 22:43:10 +0100
Darin Adler wrote:
On 1/28/02 12:10 PM, "Rémi Cohen-Scali" <Remi Cohen-Scali com> wrote:
My goal is to have launch feedback when a desktop icon is clicked and a
'command:' URL from a .desktop file is about to be executed.
On the nautilus-gnome-1 branch I'am testing it is one of the last xalf
interaction that is missing if the NAUTILUS_USE_XALF environment
variable is set.
OK. I see.
What about when the "command:URL" is not from a ".desktop" file? Your code
requires that it be a desktop file, and I think it might break things like
gmc URLs. Note that the code just talks in term of "activation URI". It
never says that it works only for desktop files. So you need to make the new
code you add only run when it's known to be a desktop file. Maybe you can
just assume it's a desktop file, but then look at the return value from
nautilus_desktop_file_load, and use some other approach when it fails.
-- Darin
Ok. This could be a crash maker ...
But there is a little problem with the desktop file loader.
It only reports errors about file loading (which I will also check).
The hashing (what make that we could know that the file is a
desktop file) of its contents returns nothing.
So if a non desktop file is used, I have to try to get a value from it.
So here are the proposed patches (I merged both).
--
-o)
Remi Cohen-Scali /\\
<Remi Cohen-Scali com> <rcoscali rcsnet net> _\_v
----
diff -u -p -r1.4797.2.29 ChangeLog
--- nautilus/ChangeLog 2002/01/22 20:53:34 1.4797.2.29
+++ nautilus/ChangeLog 2002/01/28 21:52:20
@@ -1,3 +1,24 @@
+2002-01-28 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.
+
+ * 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.
+
+ * libnautilus-private/nautilus-desktop-file-loader.c
+ (nautilus_desktop_file_launch):
+ Add the locale name taken from the desktop file to display it
+ through xalf (launch feedback).
+
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
@@ -105,7 +105,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 +117,7 @@
static void addition_free (NautilusDesktopFileAddition *addition);
-static NautilusDesktopFile*
+NautilusDesktopFile*
nautilus_desktop_file_new (void)
{
NautilusDesktopFile *df;
@@ -1160,6 +1159,7 @@
char *url;
char *exec;
char *subst;
+ char *name;
@@ -1187,11 +1187,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,
subst,
NULL,
in_terminal);
+ 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
@@ -40,6 +40,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.4 fm-directory-view.c
--- nautilus/src/file-manager/fm-directory-view.c 2001/12/12 18:14:47 1.473.2.4
+++ nautilus/src/file-manager/fm-directory-view.c 2002/01/28 21:23:46
@@ -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>
@@ -4600,6 +4601,7 @@
char *uri, *command, *executable_path, *quoted_path, *name;
GnomeVFSMimeApplication *application;
ActivationAction action;
+ NautilusDesktopFile *df;
parameters = callback_data;
@@ -4631,13 +4633,42 @@
fm_directory_view_get_containing_window (view));
action = ACTIVATION_ACTION_DO_NOTHING;
} else {
- /* As an additional precaution, only execute
- * commands without any parameters, which is
- * enforced by using a call that uses
- * fork/execlp instead of system.
+ name = nautilus_file_get_uri (file);
+ df = nautilus_desktop_file_new ();
+
+ /* As desktop file loader only test gnome vfs result, we have
+ * to also test for a valid desktop file by querying the hash
*/
- command = uri + strlen (NAUTILUS_COMMAND_SPECIFIER);
- eel_gnome_shell_execute (command);
+ if (df &&
+ nautilus_desktop_file_load (name, &df) == GNOME_VFS_OK &&
+ nautilus_desktop_file_get_string(df, NULL, "Exec", &command))
+ {
+ g_free (name);
+ g_free (command);
+ nautilus_desktop_file_launch (df);
+ nautilus_desktop_file_free (df);
+ }
+ else
+ {
+ /* desktop file alloc failed or not a desktop file */
+ if (df)
+ {
+ nautilus_desktop_file_free (df);
+ }
+
+ /* As an additional precaution, only execute
+ * commands without any parameters, which is
+ * enforced by using a call that uses
+ * fork/execlp instead of system.
+ * cf.: nautilus-program-choosing.c
+ */
+ command = uri + strlen (NAUTILUS_COMMAND_SPECIFIER);
+ nautilus_launch_application_from_command("",
+ command,
+ NULL, /* param */
+ FALSE);
+ g_free (name);
+ }
action = ACTIVATION_ACTION_DO_NOTHING;
}
}
diff -u -p -r1.46 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/28 21:50:07
@@ -678,16 +678,16 @@
}
xalf_prefix = get_xalf_prefix (name);
+ final_command = g_strconcat (xalf_prefix, full_command, NULL);
+ g_free (full_command);
+ g_free (xalf_prefix);
+
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);
+ eel_gnome_shell_execute (final_command);
}
g_free (final_command);
- g_free (full_command);
- g_free (xalf_prefix);
}
diff -u -p -r1.4956 ChangeLog
--- nautilus/ChangeLog 2002/01/28 07:20:10 1.4956
+++ nautilus/ChangeLog 2002/01/28 21:53:37
@@ -1,3 +1,24 @@
+2002-01-28 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.
+
+ * 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.
+
+ * libnautilus-private/nautilus-desktop-file-loader.c
+ (nautilus_desktop_file_launch):
+ Add the locale name taken from the desktop file to display it
+ through xalf (launch feedback).
+
2002-01-28 Anders Carlsson <andersca gnu org>
* libnautilus-private/nautilus-entry.c: Fix build.
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
@@ -102,7 +102,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 +114,7 @@
static void addition_free (NautilusDesktopFileAddition *addition);
-static NautilusDesktopFile*
+NautilusDesktopFile*
nautilus_desktop_file_new (void)
{
NautilusDesktopFile *df;
@@ -1099,8 +1098,7 @@
char *url;
char *exec;
char *subst;
-
-
+ char *name;
if (!nautilus_desktop_file_get_string (df, NULL, "Type", &type)) {
return;
@@ -1126,11 +1124,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,
subst,
NULL,
in_terminal);
+ 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
@@ -40,6 +40,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 -p -r1.494 fm-directory-view.c
--- nautilus/src/file-manager/fm-directory-view.c 2002/01/21 22:49:38 1.494
+++ nautilus/src/file-manager/fm-directory-view.c 2002/01/28 21:42:24
@@ -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>
@@ -4627,6 +4628,7 @@ activate_callback (NautilusFile *file, g
char *uri, *command, *executable_path, *quoted_path, *name;
GnomeVFSMimeApplication *application;
ActivationAction action;
+ NautilusDesktopFile *df;
parameters = callback_data;
@@ -4658,13 +4660,42 @@ activate_callback (NautilusFile *file, g
fm_directory_view_get_containing_window (view));
action = ACTIVATION_ACTION_DO_NOTHING;
} else {
- /* As an additional precaution, only execute
- * commands without any parameters, which is
- * enforced by using a call that uses
- * fork/execlp instead of system.
+ name = nautilus_file_get_uri (file);
+ df = nautilus_desktop_file_new ();
+
+ /* As desktop file loader only test gnome vfs result, we have
+ * to also test for a valid desktop file by querying the hash
*/
- command = uri + strlen (NAUTILUS_COMMAND_SPECIFIER);
- eel_gnome_shell_execute (command);
+ if (df &&
+ nautilus_desktop_file_load (name, &df) == GNOME_VFS_OK &&
+ nautilus_desktop_file_get_string(df, NULL, "Exec", &command))
+ {
+ g_free (name);
+ g_free (command);
+ nautilus_desktop_file_launch (df);
+ nautilus_desktop_file_free (df);
+ }
+ else
+ {
+ /* desktop file alloc failed or not a desktop file */
+ if (df)
+ {
+ nautilus_desktop_file_free (df);
+ }
+
+ /* As an additional precaution, only execute
+ * commands without any parameters, which is
+ * enforced by using a call that uses
+ * fork/execlp instead of system.
+ * cf.: nautilus-program-choosing.c
+ */
+ command = uri + strlen (NAUTILUS_COMMAND_SPECIFIER);
+ nautilus_launch_application_from_command("",
+ command,
+ NULL, /* param */
+ FALSE);
+ g_free (name);
+ }
action = ACTIVATION_ACTION_DO_NOTHING;
}
}
diff -u -p -r1.51 nautilus-program-choosing.c
--- nautilus/libnautilus-private/nautilus-program-choosing.c 2002/01/04 13:15:14 1.51
+++ nautilus/libnautilus-private/nautilus-program-choosing.c 2002/01/28 21:49:36
@@ -674,16 +674,16 @@ nautilus_launch_application_from_command
}
xalf_prefix = get_xalf_prefix (name);
+ final_command = g_strconcat (xalf_prefix, full_command, NULL);
+ g_free (full_command);
+ g_free (xalf_prefix);
+
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);
+ eel_gnome_shell_execute (final_command);
}
g_free (final_command);
- g_free (full_command);
- g_free (xalf_prefix);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]