Re: PATCH: use local path when dropping files onto icons
- From: Frank Worsley <fworsley shaw ca>
- To: Alexander Larsson <alexl redhat com>
- Cc: nautilus-list gnome org
- Subject: Re: PATCH: use local path when dropping files onto icons
- Date: Mon, 24 Jun 2002 13:52:28 -0700
> Yeah, i know this, but after you changed it to not use _is_local it would
> work. Anyway, it's not important, i was just wondering if there was
> something i missed.
Nah, it still wont work because of escaped characters. A path with
spaces would become 'a%20path%20with%20spaces'.
Here's the revised patch. Did a bunch of work on the previous stuff and
the treeview now also works for viewing/launching files.
- Frank
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-desktop/ChangeLog,v
retrieving revision 1.447
diff -u -p -r1.447 ChangeLog
--- ChangeLog 21 Jun 2002 05:10:43 -0000 1.447
+++ ChangeLog 24 Jun 2002 20:56:11 -0000
@@ -1,3 +1,18 @@
+2002-06-17 Frank Worsley <fworsley shaw ca>
+
+ * libgnome-desktop/gnome-desktop-item.c:
+ (stringify_files):
+ correctly determine local path for %f and %F parameters
+ in Exec field
+
+ (ditem_execute), (gnome_desktop_item_launch):
+ support new launch options
+
+ * libgnome-desktop/gnome-desktop-item.h:
+ added new GNOME_DESKTOP_ITEM_LAUNCH_APPEND_URIS option
+ to always append command line parameters even if no
+ Exec field parameters are present
+
2002-06-21 Mark McLoughlin <mark skynet ie>
* configure.in: enable compile warnings.
Index: libgnome-desktop/gnome-desktop-item.c
===================================================================
RCS file: /cvs/gnome/gnome-desktop/libgnome-desktop/gnome-desktop-item.c,v
retrieving revision 1.105
diff -u -p -r1.105 gnome-desktop-item.c
--- libgnome-desktop/gnome-desktop-item.c 21 Jun 2002 05:25:24 -0000 1.105
+++ libgnome-desktop/gnome-desktop-item.c 24 Jun 2002 20:56:11 -0000
@@ -1079,18 +1079,28 @@ stringify_files (GSList *args,
for (li = args; li != NULL; li = li->next) {
GnomeVFSURI *uri = li->data;
- if (gnome_vfs_uri_is_local (uri)) {
- const char *path;
+ if (!strcmp (gnome_vfs_uri_get_scheme (uri), "file")) {
+ char *path, *local_path;
char *escaped;
- path = gnome_vfs_uri_get_path (uri);
- g_string_append (str, sep);
-
- escaped = escape_single_quotes (path,
- in_single_quotes,
- in_double_quotes);
- g_string_append (str, escaped);
- g_free (escaped);
-
+
+ path = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
+ local_path = gnome_vfs_get_local_path_from_uri (path);
+
+ if (local_path != NULL) {
+ /* should never be null since we check for scheme
+ * above, but you never know ...
+ */
+ g_string_append (str, sep);
+
+ escaped = escape_single_quotes (local_path,
+ in_single_quotes,
+ in_double_quotes);
+ g_string_append (str, escaped);
+ g_free (escaped);
+ g_free (local_path);
+ }
+
+ g_free (path);
sep = " ";
}
@@ -1451,6 +1461,7 @@ ditem_execute (const GnomeDesktopItem *i
char **envp,
gboolean launch_only_one,
gboolean use_current_dir,
+ gboolean append_uris,
GError **error)
{
char **real_argv;
@@ -1463,7 +1474,7 @@ ditem_execute (const GnomeDesktopItem *i
const char *working_dir = NULL;
char **temp_argv = NULL;
int temp_argc = 0;
- char *new_exec;
+ char *new_exec, *uris, *temp;
int launched = 0;
g_return_val_if_fail (item, -1);
@@ -1495,6 +1506,15 @@ ditem_execute (const GnomeDesktopItem *i
exec,
args, &arg_ptr, &added_status);
+ if (launched == 0 && added_status == ADDED_NONE && append_uris) {
+ uris = stringify_uris (args, FALSE, FALSE);
+ temp = g_strconcat (new_exec, " ", uris, NULL);
+ g_free (uris);
+ g_free (new_exec);
+ new_exec = temp;
+ added_status = ADDED_ALL;
+ }
+
if (launched > 0 && added_status == ADDED_NONE) {
g_free (new_exec);
break;
@@ -1698,6 +1718,7 @@ gnome_desktop_item_launch_with_env (cons
ret = ditem_execute (item, the_exec, file_list, envp,
(flags & GNOME_DESKTOP_ITEM_LAUNCH_ONLY_ONE),
(flags & GNOME_DESKTOP_ITEM_LAUNCH_USE_CURRENT_DIR),
+ (flags & GNOME_DESKTOP_ITEM_LAUNCH_APPEND_URIS),
error);
return ret;
Index: libgnome-desktop/gnome-desktop-item.h
===================================================================
RCS file: /cvs/gnome/gnome-desktop/libgnome-desktop/gnome-desktop-item.h,v
retrieving revision 1.42
diff -u -p -r1.42 gnome-desktop-item.h
--- libgnome-desktop/gnome-desktop-item.h 21 Jun 2002 05:25:24 -0000 1.42
+++ libgnome-desktop/gnome-desktop-item.h 24 Jun 2002 20:56:12 -0000
@@ -114,7 +114,11 @@ typedef enum {
* handle one file and we have passed many */
GNOME_DESKTOP_ITEM_LAUNCH_ONLY_ONE = 1<<0,
/* Use current directory instead of home directory */
- GNOME_DESKTOP_ITEM_LAUNCH_USE_CURRENT_DIR = 1<<1
+ GNOME_DESKTOP_ITEM_LAUNCH_USE_CURRENT_DIR = 1<<1,
+ /* Append the list of URIs to the command if no Exec
+ * parameter is specified, instead of launching the
+ * app without parameters. */
+ GNOME_DESKTOP_ITEM_LAUNCH_APPEND_URIS = 1<<2
} GnomeDesktopItemLaunchFlags;
typedef enum {
Index: components/tree/nautilus-tree-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/tree/nautilus-tree-view.c,v
retrieving revision 1.131
diff -u -p -r1.131 nautilus-tree-view.c
--- components/tree/nautilus-tree-view.c 27 May 2002 12:05:09 -0000 1.131
+++ components/tree/nautilus-tree-view.c 24 Jun 2002 20:49:30 -0000
@@ -42,8 +42,10 @@
#include <gtk/gtktreemodelsort.h>
#include <gtk/gtktreeselection.h>
#include <gtk/gtktreeview.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-private/nautilus-file-attributes.h>
#include <libnautilus-private/nautilus-global-preferences.h>
+#include <libnautilus-private/nautilus-program-choosing.h>
#define NAUTILUS_PREFERENCES_TREE_VIEW_EXPANSION_STATE "tree-sidebar-panel/expansion_state"
@@ -228,23 +230,49 @@ save_expansion_state_callback (GtkTreeVi
static void
got_activation_uri_callback (NautilusFile *file, gpointer callback_data)
{
- char *uri;
+ char *uri, *file_uri;
NautilusTreeView *view;
view = NAUTILUS_TREE_VIEW (callback_data);
g_assert (file == view->details->activation_file);
+ /* FIXME: reenable && !eel_uris_match_ignore_fragments (view->details->current_main_view_uri, uri) */
+
uri = nautilus_file_get_activation_uri (file);
if (uri != NULL
- /* FIXME: reenable && !eel_uris_match_ignore_fragments (view->details->current_main_view_uri, uri) */
- && strncmp (uri, "command:", strlen ("command:")) != 0) {
+ && eel_str_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER)) {
+
+ uri += strlen (NAUTILUS_COMMAND_SPECIFIER);
+ nautilus_launch_application_from_command (NULL, uri, NULL, FALSE);
+
+ } else if (uri != NULL
+ && eel_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
+
+ file_uri = nautilus_file_get_uri (file);
+ nautilus_launch_desktop_file (file_uri, NULL, NULL);
+ g_free (file_uri);
+
+ } else if (uri != NULL
+ && nautilus_file_is_executable (file)
+ && nautilus_file_can_execute (file)
+ && nautilus_file_is_local (file)) {
+
+ file_uri = gnome_vfs_get_local_path_from_uri (uri);
+
+ /* Non-local executables don't get launched. They act like non-executables. */
+ if (file_uri == NULL) {
+ nautilus_view_open_location_in_this_window (NAUTILUS_VIEW (view), uri);
+ } else {
+ nautilus_launch_application_from_command (NULL, file_uri, NULL, FALSE);
+ g_free (file_uri);
+ }
+
+ } else if (uri != NULL) {
nautilus_view_open_location_in_this_window (NAUTILUS_VIEW (view), uri);
}
+
g_free (uri);
-
- /* FIXME: show_file (view, file); */
-
nautilus_file_unref (view->details->activation_file);
view->details->activation_file = NULL;
}
Index: libnautilus-private/nautilus-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-dnd.c,v
retrieving revision 1.4
diff -u -p -r1.4 nautilus-dnd.c
--- libnautilus-private/nautilus-dnd.c 22 May 2002 09:51:22 -0000 1.4
+++ libnautilus-private/nautilus-dnd.c 24 Jun 2002 20:49:31 -0000
@@ -29,6 +29,7 @@
#include <config.h>
#include "nautilus-dnd.h"
+#include "nautilus-program-choosing.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
@@ -45,8 +46,6 @@
#include <stdio.h>
#include <string.h>
-#define COMMAND_SPECIFIER "command:"
-
/* a set of defines stolen from the eel-icon-dnd.c file.
* These are in microseconds.
*/
@@ -293,7 +292,8 @@ nautilus_drag_default_drop_action_for_ic
}
return;
- } else if (eel_str_has_prefix (target_uri_string, COMMAND_SPECIFIER)) {
+ } else if (eel_str_has_prefix (target_uri_string, NAUTILUS_COMMAND_SPECIFIER)
+ || eel_str_has_prefix (target_uri_string, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
if (actions & GDK_ACTION_MOVE) {
*action = GDK_ACTION_MOVE;
}
Index: libnautilus-private/nautilus-link-desktop-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link-desktop-file.c,v
retrieving revision 1.20
diff -u -p -r1.20 nautilus-link-desktop-file.c
--- libnautilus-private/nautilus-link-desktop-file.c 23 May 2002 23:13:56 -0000 1.20
+++ libnautilus-private/nautilus-link-desktop-file.c 24 Jun 2002 20:49:31 -0000
@@ -32,6 +32,7 @@
#include "nautilus-file-utilities.h"
#include "nautilus-file.h"
#include "nautilus-metadata.h"
+#include "nautilus-program-choosing.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gnome-extensions.h>
#include <eel/eel-stock-dialogs.h>
@@ -266,9 +267,7 @@ nautilus_link_desktop_file_local_get_lin
static char *
nautilus_link_desktop_file_get_link_uri_from_desktop (GnomeDesktopItem *desktop_file)
{
- char *terminal_command;
const char *launch_string;
- gboolean need_term;
const char *type;
char *retval;
@@ -284,15 +283,9 @@ nautilus_link_desktop_file_get_link_uri_
if (launch_string == NULL) {
return NULL;
}
-
- need_term = gnome_desktop_item_get_boolean (desktop_file, "Terminal");
- if (need_term) {
- terminal_command = eel_gnome_make_terminal_command (launch_string);
- retval = g_strconcat ("command:", terminal_command, NULL);
- g_free (terminal_command);
- } else {
- retval = g_strconcat ("command:", launch_string, NULL);
- }
+
+ launch_string = gnome_desktop_item_get_location (desktop_file);
+ retval = g_strconcat (NAUTILUS_DESKTOP_COMMAND_SPECIFIER, launch_string, NULL);
} else if (strcmp (type, "URL") == 0) {
/* Some old broken desktop files use this nonstandard feature, we need handle it though */
retval = g_strdup (gnome_desktop_item_get_string (desktop_file, "Exec"));
Index: libnautilus-private/nautilus-link-historical.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link-historical.c,v
retrieving revision 1.12
diff -u -p -r1.12 nautilus-link-historical.c
--- libnautilus-private/nautilus-link-historical.c 23 May 2002 15:16:08 -0000 1.12
+++ libnautilus-private/nautilus-link-historical.c 24 Jun 2002 20:49:31 -0000
@@ -32,6 +32,7 @@
#include "nautilus-file-utilities.h"
#include "nautilus-global-preferences.h"
#include "nautilus-metadata.h"
+#include "nautilus-program-choosing.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gnome-extensions.h>
#include <eel/eel-preferences.h>
@@ -406,10 +407,10 @@ nautilus_link_historical_local_create_fr
case GNOME_DESKTOP_ITEM_TYPE_APPLICATION:
if (gnome_desktop_item_get_boolean (entry, GNOME_DESKTOP_ITEM_TERMINAL)) {
terminal_command = eel_gnome_make_terminal_command (arguments);
- launch_string = g_strconcat ("command:", terminal_command, NULL);
+ launch_string = g_strconcat (NAUTILUS_COMMAND_SPECIFIER, terminal_command, NULL);
g_free (terminal_command);
} else {
- launch_string = g_strconcat ("command:", arguments, NULL);
+ launch_string = g_strconcat (NAUTILUS_COMMAND_SPECIFIER, arguments, NULL);
}
break;
case GNOME_DESKTOP_ITEM_TYPE_LINK:
Index: libnautilus-private/nautilus-program-choosing.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-program-choosing.c,v
retrieving revision 1.55
diff -u -p -r1.55 nautilus-program-choosing.c
--- libnautilus-private/nautilus-program-choosing.c 1 Mar 2002 22:57:29 -0000 1.55
+++ libnautilus-private/nautilus-program-choosing.c 24 Jun 2002 20:49:31 -0000
@@ -38,6 +38,7 @@
#include <libgnome/gnome-config.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-util.h>
+#include <libgnome/gnome-desktop-item.h>
#include <libgnomeui/gnome-uidefs.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include <libgnomevfs/gnome-vfs-utils.h>
@@ -693,4 +694,115 @@ nautilus_launch_application_from_command
}
g_free (final_command);
+}
+
+void
+nautilus_launch_desktop_file (const char *desktop_file_uri,
+ const GList *parameter_uris,
+ GtkWindow *parent_window)
+{
+ GError *error;
+ GnomeDesktopItem *ditem;
+ const char *command_string;
+ char *local_path, *message;
+ const GList *p;
+ int total, count;
+
+ /* strip the leading command specifier */
+ if (eel_str_has_prefix (desktop_file_uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
+ desktop_file_uri += strlen (NAUTILUS_DESKTOP_COMMAND_SPECIFIER);
+ }
+
+ /* Don't allow command execution from remote locations where the
+ * uri scheme isn't file:// (This is because files on for example
+ * nfs are treated as remote) to partially mitigate the security
+ * risk of executing arbitrary commands.
+ */
+ local_path = gnome_vfs_get_local_path_from_uri (desktop_file_uri);
+ if (local_path == NULL) {
+ eel_show_error_dialog
+ (_("Sorry, but you can't execute commands from "
+ "a remote site due to security considerations."),
+ _("Can't execute remote links"),
+ parent_window);
+
+ return;
+ }
+ g_free (local_path);
+
+ error = NULL;
+ ditem = gnome_desktop_item_new_from_uri (desktop_file_uri,
+ GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS,
+ &error);
+ if (error != NULL) {
+ message = g_strconcat (_("There was an error launching the application.\n\n"
+ "Details: "), error->message, NULL);
+ eel_show_error_dialog
+ (message,
+ _("Error launching application"),
+ parent_window);
+
+ g_error_free (error);
+ g_free (message);
+ return;
+ }
+
+ /* check if this app only supports local files */
+ command_string = gnome_desktop_item_get_string (ditem, GNOME_DESKTOP_ITEM_EXEC);
+ if ((strstr (command_string, "%F") || strstr (command_string, "%f"))
+ && !(strstr (command_string, "%U") || strstr (command_string, "%u"))
+ && parameter_uris != NULL) {
+
+ /* count the number of uris with local paths */
+ count = 0;
+ total = g_list_length ((GList *) parameter_uris);
+ for (p = parameter_uris; p != NULL; p = p->next) {
+ local_path = gnome_vfs_get_local_path_from_uri ((const char *) p->data);
+ if (local_path != NULL) {
+ g_free (local_path);
+ count++;
+ }
+ }
+
+ if (count == 0) {
+ /* all files are non-local */
+ eel_show_error_dialog
+ (_("This drop target only supports local files.\n\n"
+ "To open non-local files copy them to a local folder and then"
+ " drop them again."),
+ _("Drop target only supports local files"),
+ parent_window);
+
+ gnome_desktop_item_unref (ditem);
+ return;
+
+ } else if (count != total) {
+ /* some files were non-local */
+ eel_show_warning_dialog
+ (_("This drop target only supports local files.\n\n"
+ "To open non-local files copy them to a local folder and then"
+ " drop them again. The local files you dropped have already been opened."),
+ _("Drop target only supports local files"),
+ parent_window);
+ }
+ }
+
+ error = NULL;
+ gnome_desktop_item_launch (ditem, (GList *) parameter_uris,
+ GNOME_DESKTOP_ITEM_LAUNCH_APPEND_URIS,
+ &error);
+
+ if (error != NULL) {
+ message = g_strconcat (_("There was an error launching the application.\n\n"
+ "Details: "), error->message, NULL);
+ eel_show_error_dialog
+ (message,
+ _("Error launching application"),
+ parent_window);
+
+ g_error_free (error);
+ g_free (message);
+ }
+
+ gnome_desktop_item_unref (ditem);
}
Index: libnautilus-private/nautilus-program-choosing.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-program-choosing.h,v
retrieving revision 1.14
diff -u -p -r1.14 nautilus-program-choosing.h
--- libnautilus-private/nautilus-program-choosing.h 21 Feb 2002 19:26:47 -0000 1.14
+++ libnautilus-private/nautilus-program-choosing.h 24 Jun 2002 20:49:31 -0000
@@ -31,6 +31,9 @@
#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-view-identifier.h>
+#define NAUTILUS_COMMAND_SPECIFIER "command:"
+#define NAUTILUS_DESKTOP_COMMAND_SPECIFIER "desktop-file:"
+
typedef void (*NautilusApplicationChoiceCallback) (GnomeVFSMimeApplication *application,
gpointer callback_data);
typedef void (*NautilusComponentChoiceCallback) (NautilusViewIdentifier *identifier,
@@ -57,5 +60,8 @@ void nautilus_launch_application_from_co
const char *command_string,
const char *parameter,
gboolean use_terminal);
+void nautilus_launch_desktop_file (const char *desktop_file_uri,
+ const GList *parameter_uris,
+ GtkWindow *parent_window);
#endif /* NAUTILUS_PROGRAM_CHOOSING_H */
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.540
diff -u -p -r1.540 fm-directory-view.c
--- src/file-manager/fm-directory-view.c 31 May 2002 05:41:53 -0000 1.540
+++ src/file-manager/fm-directory-view.c 24 Jun 2002 20:49:32 -0000
@@ -93,10 +93,9 @@
#define DUPLICATE_HORIZONTAL_ICON_OFFSET 70
#define DUPLICATE_VERTICAL_ICON_OFFSET 30
-#define NAUTILUS_COMMAND_SPECIFIER "command:"
-
#define RESPONSE_RUN 1000
#define RESPONSE_DISPLAY 1001
+#define RESPONSE_RUN_IN_TERMINAL 1002
/* MOD2 is num lock -- I would include MOD3-5 if I was sure they were not lock keys */
#define ALL_NON_LOCK_MODIFIER_KEYS (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)
@@ -248,6 +247,7 @@ typedef enum {
typedef enum {
ACTIVATION_ACTION_LAUNCH,
+ ACTIVATION_ACTION_LAUNCH_IN_TERMINAL,
ACTIVATION_ACTION_DISPLAY,
ACTIVATION_ACTION_DO_NOTHING
} ActivationAction;
@@ -4764,8 +4764,9 @@ get_executable_text_file_action (FMDirec
dialog = eel_create_question_dialog (prompt,
_("Run or Display?"),
_("Run"), RESPONSE_RUN,
- _("Display"), RESPONSE_DISPLAY,
+ _("Run in terminal"), RESPONSE_RUN_IN_TERMINAL,
fm_directory_view_get_containing_window (view));
+ gtk_dialog_add_button (dialog, _("Display"), RESPONSE_DISPLAY);
gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gtk_widget_show (GTK_WIDGET (dialog));
@@ -4777,6 +4778,8 @@ get_executable_text_file_action (FMDirec
switch (response) {
case RESPONSE_RUN:
return ACTIVATION_ACTION_LAUNCH;
+ case RESPONSE_RUN_IN_TERMINAL:
+ return ACTIVATION_ACTION_LAUNCH_IN_TERMINAL;
case RESPONSE_DISPLAY:
return ACTIVATION_ACTION_DISPLAY;
default:
@@ -4789,11 +4792,10 @@ activate_callback (NautilusFile *file, g
{
ActivateParameters *parameters;
FMDirectoryView *view;
- char *uri, *command, *executable_path, *quoted_path, *name, *file_uri, *file_uri_scheme;
+ char *uri, *file_uri;
+ char *executable_path, *quoted_path, *name;
GnomeVFSMimeApplication *application;
ActivationAction action;
- GnomeDesktopItem *desktop_item;
- int error;
parameters = callback_data;
@@ -4812,51 +4814,19 @@ activate_callback (NautilusFile *file, g
if (nautilus_file_is_broken_symbolic_link (file)) {
report_broken_symbolic_link (view, file);
action = ACTIVATION_ACTION_DO_NOTHING;
- } else if (eel_istr_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER)) {
- /* Don't allow command execution from remote locations where the
- * uri scheme isn't file:// (This is because files on for example
- * nfs are treated as remote)
- * to partially mitigate the security risk of
- * executing arbitrary commands.
- */
- file_uri_scheme = nautilus_file_get_uri_scheme (file);
-
- if (!nautilus_file_is_local (file) && strcmp (file_uri_scheme, "file") != 0) {
- eel_show_error_dialog
- (_("Sorry, but you can't execute commands from "
- "a remote site due to security considerations."),
- _("Can't execute remote links"),
+ } else if (eel_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
+ file_uri = nautilus_file_get_uri (file);
+ nautilus_launch_desktop_file
+ (file_uri, NULL,
fm_directory_view_get_containing_window (view));
- action = ACTIVATION_ACTION_DO_NOTHING;
- } else {
- file_uri = nautilus_file_get_uri (file);
- desktop_item = gnome_desktop_item_new_from_uri (file_uri, 0, NULL);
- g_free (file_uri);
- if (desktop_item == NULL) {
- error = -1;
- } else {
- error = gnome_desktop_item_launch (desktop_item, NULL, 0, NULL);
- gnome_desktop_item_unref (desktop_item);
- }
- if (error == -1) {
- /* 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);
- }
-
- action = ACTIVATION_ACTION_DO_NOTHING;
- }
-
- g_free (file_uri_scheme);
+ g_free (file_uri);
+ action = ACTIVATION_ACTION_DO_NOTHING;
+ } else if (eel_str_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER)) {
+ uri += strlen (NAUTILUS_COMMAND_SPECIFIER);
+ nautilus_launch_application_from_command (NULL, uri, NULL, FALSE);
+ action = ACTIVATION_ACTION_DO_NOTHING;
}
+
if (action != ACTIVATION_ACTION_DO_NOTHING && file_is_launchable (file)) {
action = ACTIVATION_ACTION_LAUNCH;
@@ -4881,20 +4851,17 @@ activate_callback (NautilusFile *file, g
action = get_executable_text_file_action (view, file);
}
- if (action == ACTIVATION_ACTION_LAUNCH) {
+ if (action == ACTIVATION_ACTION_LAUNCH ||
+ action == ACTIVATION_ACTION_LAUNCH_IN_TERMINAL) {
quoted_path = g_shell_quote (executable_path);
name = nautilus_file_get_name (file);
- /* FIXME bugzilla.gnome.org 41773: This is a
- * lame way to run command-line tools, since
- * there's no terminal for the output. But if
- * we always had a terminal, that would be
- * just as bad.
- */
- nautilus_launch_application_from_command (name, quoted_path, NULL, FALSE);
+ nautilus_launch_application_from_command
+ (name, quoted_path, NULL,
+ (action == ACTIVATION_ACTION_LAUNCH_IN_TERMINAL) /* use terminal */ );
g_free (name);
g_free (quoted_path);
}
-
+
g_free (executable_path);
}
@@ -5666,9 +5633,8 @@ fm_directory_view_move_copy_items (const
int x, int y,
FMDirectoryView *view)
{
- char *command_string, *scanner;
- int length;
- const GList *p;
+ char *parameters, *temp;
+ GList *p;
g_assert (relative_item_points == NULL
|| relative_item_points->len == 0
@@ -5678,35 +5644,25 @@ fm_directory_view_move_copy_items (const
offset_drop_points (relative_item_points, x, y);
/* special-case "command:" here instead of starting a move/copy */
- if (eel_str_has_prefix (target_uri, NAUTILUS_COMMAND_SPECIFIER)) {
- /* execute command, passing it the dragged uris */
-
- /* strip the leading "command:" */
- target_uri += strlen (NAUTILUS_COMMAND_SPECIFIER);
-
- /* how long will the command string be? */
- length = strlen (target_uri) + 1;
- for (p = item_uris; p != NULL; p = p->next) {
- length += strlen ((const char *) p->data) + 1;
- }
-
- command_string = g_malloc (length);
- scanner = command_string;
-
- /* copy the command string */
- strcpy (scanner, target_uri);
- scanner += strlen (scanner);
-
- /* copy the uris */
- for (p = item_uris; p != NULL; p = p->next) {
- sprintf (scanner, " %s", (const char *) p->data);
- scanner += strlen (scanner);
+ if (eel_str_has_prefix (target_uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
+ nautilus_launch_desktop_file
+ (target_uri, item_uris,
+ fm_directory_view_get_containing_window (view));
+ return;
+ } else if (eel_str_has_prefix (target_uri, NAUTILUS_COMMAND_SPECIFIER)) {
+ parameters = NULL;
+ for (p = (GList *) item_uris; p != NULL; p = p->next) {
+ temp = g_strconcat ((char *) p->data, " ", parameters, NULL);
+ if (parameters != NULL) {
+ g_free (parameters);
+ }
+ parameters = temp;
}
+
+ target_uri += strlen (NAUTILUS_COMMAND_SPECIFIER);
+ nautilus_launch_application_from_command (NULL, target_uri, parameters, FALSE);
+ g_free (parameters);
- /* execute the command */
- eel_gnome_shell_execute (command_string);
-
- g_free (command_string);
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]