summaryrefslogtreecommitdiff
path: root/libnautilus-extensions/nautilus-program-choosing.c
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2000-09-13 23:56:47 +0000
committerDarin Adler <darin@src.gnome.org>2000-09-13 23:56:47 +0000
commitdd1314a5364df40d0ac71bc1fe0d2539a5accc71 (patch)
tree621f29cac92d0a0814f42879a9fb8bdca5b90d32 /libnautilus-extensions/nautilus-program-choosing.c
parent9f0dc6ec8edb3d688c3de18e19a531910ba770b7 (diff)
downloadnautilus-dd1314a5364df40d0ac71bc1fe0d2539a5accc71.tar.gz
Fixed bug 1462 (File names containing spaces don't launch right)
and bug 2404 (Help uri needs to be escaped properly) by adding a function to quote for strings for shell. I chose a name an an implementation that matches the function that will be added to glib 2.0 for this purpose. * libnautilus-extensions/nautilus-glib-extensions.h: * libnautilus-extensions/nautilus-glib-extensions.c: (nautilus_shell_quote), (nautilus_self_check_glib_extensions): Add a shell_quote function and tests for it. * components/help/help-method.c: (help_uri_to_string): Call the new nautilus_shell_quote function. * libnautilus-extensions/nautilus-program-choosing.h: * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_launch_application_parented): Use a URI by default, and a path only for applications that can't use URIs. (nautilus_launch_application_from_command): Quote the parameter for the shell with the new nautilus_shell_quote function.
Diffstat (limited to 'libnautilus-extensions/nautilus-program-choosing.c')
-rw-r--r--libnautilus-extensions/nautilus-program-choosing.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/libnautilus-extensions/nautilus-program-choosing.c b/libnautilus-extensions/nautilus-program-choosing.c
index 8ae22c157..53f825fc9 100644
--- a/libnautilus-extensions/nautilus-program-choosing.c
+++ b/libnautilus-extensions/nautilus-program-choosing.c
@@ -26,6 +26,7 @@
#include <config.h>
#include "nautilus-program-choosing.h"
+#include "nautilus-glib-extensions.h"
#include "nautilus-mime-actions.h"
#include "nautilus-program-chooser.h"
#include "nautilus-stock-dialogs.h"
@@ -233,18 +234,24 @@ nautilus_launch_application_parented (GnomeVFSMimeApplication *application,
{
GnomeDialog *dialog;
char *command_string;
- char *uri_or_path;
+ char *parameter;
char *prompt;
- /* Always use local path if we can get one, even for apps that can
- * deal with uris. This is done only for convenience.
+ /* If the program can open URIs, always use a URI. This
+ * prevents any possible ambiguity for cases where a path
+ * would looks like a URI.
*/
- uri_or_path = gnome_vfs_get_local_path_from_uri (uri);
- if (uri_or_path == NULL) {
- if (!application->can_open_uris) {
- /* This application can't deal with this uri, because it
- * can only handle local files. Tell user. Some day we could offer
- * to copy it locally for the user, if we knew where to put it.
+ if (application->can_open_uris) {
+ parameter = g_strdup (uri);
+ } else {
+ parameter = gnome_vfs_get_local_path_from_uri (uri);
+ if (parameter == NULL) {
+ /* This application can't deal with this URI,
+ * because it can only handle local
+ * files. Tell user. Some day we could offer
+ * to copy it locally for the user, if we knew
+ * where to put it, and who would delete it
+ * when done.
*/
prompt = g_strdup_printf (_("Sorry, %s can only open local files, and "
"\"%s\" is remote. If you want to open it "
@@ -254,8 +261,6 @@ nautilus_launch_application_parented (GnomeVFSMimeApplication *application,
g_free (prompt);
return;
}
-
- uri_or_path = g_strdup (uri);
}
if (application->requires_terminal) {
@@ -263,10 +268,10 @@ nautilus_launch_application_parented (GnomeVFSMimeApplication *application,
} else {
command_string = g_strdup (application->command);
}
-
- nautilus_launch_application_from_command (command_string, uri_or_path);
-
- g_free (uri_or_path);
+
+ nautilus_launch_application_from_command (command_string, parameter);
+
+ g_free (parameter);
g_free (command_string);
}
@@ -285,7 +290,6 @@ nautilus_launch_application (GnomeVFSMimeApplication *application, const char *u
nautilus_launch_application_parented (application, uri, NULL);
}
-
/**
* nautilus_launch_application_from_command:
*
@@ -294,15 +298,17 @@ nautilus_launch_application (GnomeVFSMimeApplication *application, const char *u
*
* @command_string: The application to be launched, with any desired
* command-line options.
- * @uri: Passed as a parameter to the application as is.
+ * @parameter: Passed as a parameter to the application as is.
*/
void
-nautilus_launch_application_from_command (const char *command_string, const char *uri)
+nautilus_launch_application_from_command (const char *command_string, const char *parameter)
{
- char *full_command;
+ char *full_command, *quoted_parameter;
- if (uri != NULL) {
- full_command = g_strconcat (command_string, " ", uri, " &", NULL);
+ if (parameter != NULL) {
+ quoted_parameter = nautilus_shell_quote (parameter);
+ full_command = g_strconcat (command_string, " ", parameter, " &", NULL);
+ g_free (quoted_parameter);
} else {
full_command = g_strconcat (command_string, " &", NULL);
}
@@ -311,4 +317,3 @@ nautilus_launch_application_from_command (const char *command_string, const char
g_free (full_command);
}
-