Commit ce73de0c authored by Carlos Soriano's avatar Carlos Soriano

general: Revert to allow running binaries and scripts

Recently we removed the ability to launch binaries and scripts in
commit 3a22ed5b.

A few cases appeared that we need to support, specially for enterprise
and content creators. Specifically, cases similar to #434

This also shows that is hard to predict cases like these, as some
complex setups might be needed for specific workflows.

This commits allow to run binaries and scripts as before, and further
investigation in these cases need to be done if we ever want to tweak
the workflow of running binaries.

More discussion about improving binaries/script handling is being
proposed and discussed in #443
parent 93fb7954
Pipeline #11982 passed with stages
in 8 minutes and 30 seconds
...@@ -11,6 +11,12 @@ ...@@ -11,6 +11,12 @@
<value value="1" nick="double"/> <value value="1" nick="double"/>
</enum> </enum>
<enum id="org.gnome.nautilus.ActivationChoice">
<value value="0" nick="launch"/>
<value value="1" nick="display"/>
<value value="2" nick="ask"/>
</enum>
<enum id="org.gnome.nautilus.FolderView"> <enum id="org.gnome.nautilus.FolderView">
<value value="0" nick="icon-view"/> <value value="0" nick="icon-view"/>
<value value="1" nick="list-view"/> <value value="1" nick="list-view"/>
...@@ -115,6 +121,11 @@ ...@@ -115,6 +121,11 @@
<summary>Type of click used to launch/open files</summary> <summary>Type of click used to launch/open files</summary>
<description>Possible values are “single” to launch files on a single click, or “double” to launch them on a double click.</description> <description>Possible values are “single” to launch files on a single click, or “double” to launch them on a double click.</description>
</key> </key>
<key name="executable-text-activation" enum="org.gnome.nautilus.ActivationChoice">
<default>'display'</default>
<summary>What to do with executable text files when activated</summary>
<description>What to do with executable text files when they are activated (single or double clicked). Possible values are “launch” to launch them as programs, “ask” to ask what to do via a dialog, and “display” to display them as text files.</description>
</key>
<key type="b" name="install-mime-activation"> <key type="b" name="install-mime-activation">
<default>true</default> <default>true</default>
<summary>Show the package installer for unknown MIME types</summary> <summary>Show the package installer for unknown MIME types</summary>
......
...@@ -513,6 +513,15 @@ nautilus_drag_default_drop_action_for_icons (GdkDragContext *context, ...@@ -513,6 +513,15 @@ nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
nautilus_file_unref (target_file); nautilus_file_unref (target_file);
return; return;
} }
else if (dropped_file != NULL && nautilus_file_is_launcher (dropped_file))
{
if (actions & GDK_ACTION_MOVE)
{
*action = GDK_ACTION_MOVE;
}
nautilus_file_unref (target_file);
return;
}
else if (target_file != NULL && nautilus_file_is_archive (target_file)) else if (target_file != NULL && nautilus_file_is_archive (target_file))
{ {
*action = GDK_ACTION_COPY; *action = GDK_ACTION_COPY;
......
...@@ -169,6 +169,7 @@ struct NautilusFileDetails ...@@ -169,6 +169,7 @@ struct NautilusFileDetails
eel_boolean_bit is_thumbnailing : 1; eel_boolean_bit is_thumbnailing : 1;
eel_boolean_bit is_launcher : 1;
eel_boolean_bit is_symlink : 1; eel_boolean_bit is_symlink : 1;
eel_boolean_bit is_mountpoint : 1; eel_boolean_bit is_mountpoint : 1;
eel_boolean_bit is_hidden : 1; eel_boolean_bit is_hidden : 1;
......
...@@ -4491,6 +4491,12 @@ nautilus_file_monitor_remove (NautilusFile *file, ...@@ -4491,6 +4491,12 @@ nautilus_file_monitor_remove (NautilusFile *file,
NAUTILUS_FILE_CLASS (G_OBJECT_GET_CLASS (file))->monitor_remove (file, client); NAUTILUS_FILE_CLASS (G_OBJECT_GET_CLASS (file))->monitor_remove (file, client);
} }
gboolean
nautilus_file_is_launcher (NautilusFile *file)
{
return file->details->is_launcher;
}
gboolean gboolean
nautilus_file_has_activation_uri (NautilusFile *file) nautilus_file_has_activation_uri (NautilusFile *file)
{ {
...@@ -8161,6 +8167,28 @@ nautilus_file_get_file_info_error (NautilusFile *file) ...@@ -8161,6 +8167,28 @@ nautilus_file_get_file_info_error (NautilusFile *file)
return file->details->get_info_error; return file->details->get_info_error;
} }
/**
* nautilus_file_contains_text
*
* Check if this file contains text.
* This is private and is used to decide whether or not to read the top left text.
* @file: NautilusFile representing the file in question.
*
* Returns: TRUE if @file has a text MIME type.
*
**/
gboolean
nautilus_file_contains_text (NautilusFile *file)
{
if (file == NULL)
{
return FALSE;
}
/* All text files inherit from text/plain */
return nautilus_file_is_mime_type (file, "text/plain");
}
/** /**
* nautilus_file_is_executable * nautilus_file_is_executable
* *
...@@ -9272,6 +9300,12 @@ nautilus_drag_can_accept_files (NautilusFile *drop_target_item) ...@@ -9272,6 +9300,12 @@ nautilus_drag_can_accept_files (NautilusFile *drop_target_item)
return res; return res;
} }
/* Launchers are an acceptable drop target */
if (nautilus_file_is_launcher (drop_target_item))
{
return TRUE;
}
if (nautilus_is_file_roller_installed () && if (nautilus_is_file_roller_installed () &&
nautilus_file_is_archive (drop_target_item)) nautilus_file_is_archive (drop_target_item))
{ {
......
...@@ -171,6 +171,7 @@ void nautilus_file_invalidate_attributes (Nautilu ...@@ -171,6 +171,7 @@ void nautilus_file_invalidate_attributes (Nautilu
void nautilus_file_invalidate_all_attributes (NautilusFile *file); void nautilus_file_invalidate_all_attributes (NautilusFile *file);
/* Basic attributes for file objects. */ /* Basic attributes for file objects. */
gboolean nautilus_file_contains_text (NautilusFile *file);
char * nautilus_file_get_display_name (NautilusFile *file); char * nautilus_file_get_display_name (NautilusFile *file);
char * nautilus_file_get_edit_name (NautilusFile *file); char * nautilus_file_get_edit_name (NautilusFile *file);
char * nautilus_file_get_name (NautilusFile *file); char * nautilus_file_get_name (NautilusFile *file);
...@@ -453,6 +454,7 @@ GList *nautilus_file_list_filter_hidden (GList ...@@ -453,6 +454,7 @@ GList *nautilus_file_list_filter_hidden (GList
/* Get the URI that's used when activating the file. /* Get the URI that's used when activating the file.
* Getting this can require reading the contents of the file. * Getting this can require reading the contents of the file.
*/ */
gboolean nautilus_file_is_launcher (NautilusFile *file);
gboolean nautilus_file_has_activation_uri (NautilusFile *file); gboolean nautilus_file_has_activation_uri (NautilusFile *file);
char * nautilus_file_get_activation_uri (NautilusFile *file); char * nautilus_file_get_activation_uri (NautilusFile *file);
GFile * nautilus_file_get_activation_location (NautilusFile *file); GFile * nautilus_file_get_activation_location (NautilusFile *file);
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#include "nautilus-file-private.h" #include "nautilus-file-private.h"
#include "nautilus-file-undo-manager.h" #include "nautilus-file-undo-manager.h"
#include "nautilus-file-utilities.h" #include "nautilus-file-utilities.h"
#include "nautilus-file.h"
#include "nautilus-floating-bar.h" #include "nautilus-floating-bar.h"
#include "nautilus-global-preferences.h" #include "nautilus-global-preferences.h"
#include "nautilus-icon-info.h" #include "nautilus-icon-info.h"
...@@ -1194,6 +1195,7 @@ nautilus_files_view_activate_files (NautilusFilesView *view, ...@@ -1194,6 +1195,7 @@ nautilus_files_view_activate_files (NautilusFilesView *view,
NautilusFilesViewPrivate *priv; NautilusFilesViewPrivate *priv;
GList *files_to_extract; GList *files_to_extract;
GList *files_to_activate; GList *files_to_activate;
char *path;
if (files == NULL) if (files == NULL)
{ {
...@@ -1225,12 +1227,15 @@ nautilus_files_view_activate_files (NautilusFilesView *view, ...@@ -1225,12 +1227,15 @@ nautilus_files_view_activate_files (NautilusFilesView *view,
extract_files_to_chosen_location (view, files_to_extract); extract_files_to_chosen_location (view, files_to_extract);
} }
path = get_view_directory (view);
nautilus_mime_activate_files (nautilus_files_view_get_containing_window (view), nautilus_mime_activate_files (nautilus_files_view_get_containing_window (view),
priv->slot, priv->slot,
files_to_activate, files_to_activate,
path,
flags, flags,
confirm_multiple); confirm_multiple);
g_free (path);
g_list_free (files_to_extract); g_list_free (files_to_extract);
g_list_free (files_to_activate); g_list_free (files_to_activate);
} }
...@@ -7716,6 +7721,7 @@ update_selection_menu (NautilusFilesView *view) ...@@ -7716,6 +7721,7 @@ update_selection_menu (NautilusFilesView *view)
GList *l; GList *l;
gint selection_count; gint selection_count;
gboolean show_app; gboolean show_app;
gboolean show_run;
gboolean show_extract; gboolean show_extract;
gboolean item_opens_in_view; gboolean item_opens_in_view;
gchar *item_label; gchar *item_label;
...@@ -7756,7 +7762,7 @@ update_selection_menu (NautilusFilesView *view) ...@@ -7756,7 +7762,7 @@ update_selection_menu (NautilusFilesView *view)
g_free (item_label); g_free (item_label);
/* Open With <App> menu item */ /* Open With <App> menu item */
show_extract = show_app = item_opens_in_view = selection_count != 0; show_extract = show_app = show_run = item_opens_in_view = selection_count != 0;
for (l = selection; l != NULL; l = l->next) for (l = selection; l != NULL; l = l->next)
{ {
NautilusFile *file; NautilusFile *file;
...@@ -7773,12 +7779,17 @@ update_selection_menu (NautilusFilesView *view) ...@@ -7773,12 +7779,17 @@ update_selection_menu (NautilusFilesView *view)
show_app = FALSE; show_app = FALSE;
} }
if (!nautilus_mime_file_launches (file))
{
show_run = FALSE;
}
if (!nautilus_file_opens_in_view (file)) if (!nautilus_file_opens_in_view (file))
{ {
item_opens_in_view = FALSE; item_opens_in_view = FALSE;
} }
if (!show_extract && !show_app && !item_opens_in_view) if (!show_extract && !show_app && !show_run && !item_opens_in_view)
{ {
break; break;
} }
...@@ -7807,6 +7818,10 @@ update_selection_menu (NautilusFilesView *view) ...@@ -7807,6 +7818,10 @@ update_selection_menu (NautilusFilesView *view)
g_free (escaped_app); g_free (escaped_app);
g_object_unref (app); g_object_unref (app);
} }
else if (show_run)
{
item_label = g_strdup (_("Run"));
}
else if (show_extract) else if (show_extract)
{ {
item_label = nautilus_files_view_supports_extract_here (view) ? item_label = nautilus_files_view_supports_extract_here (view) ?
...@@ -8766,10 +8781,20 @@ nautilus_files_view_move_copy_items (NautilusFilesView *view, ...@@ -8766,10 +8781,20 @@ nautilus_files_view_move_copy_items (NautilusFilesView *view,
NautilusFile *target_file; NautilusFile *target_file;
target_file = nautilus_file_get_existing_by_uri (target_uri); target_file = nautilus_file_get_existing_by_uri (target_uri);
if (copy_action == GDK_ACTION_COPY && /* special-case "command:" here instead of starting a move/copy */
nautilus_is_file_roller_installed () && if (target_file != NULL && nautilus_file_is_launcher (target_file))
target_file != NULL && {
nautilus_file_is_archive (target_file)) nautilus_file_unref (target_file);
nautilus_launch_desktop_file (
gtk_widget_get_screen (GTK_WIDGET (view)),
target_uri, item_uris,
nautilus_files_view_get_containing_window (view));
return;
}
else if (copy_action == GDK_ACTION_COPY &&
nautilus_is_file_roller_installed () &&
target_file != NULL &&
nautilus_file_is_archive (target_file))
{ {
char *command, *quoted_uri, *tmp; char *command, *quoted_uri, *tmp;
const GList *l; const GList *l;
......
...@@ -51,6 +51,9 @@ typedef enum ...@@ -51,6 +51,9 @@ typedef enum
/* Drag and drop preferences */ /* Drag and drop preferences */
#define NAUTILUS_PREFERENCES_OPEN_FOLDER_ON_DND_HOVER "open-folder-on-dnd-hover" #define NAUTILUS_PREFERENCES_OPEN_FOLDER_ON_DND_HOVER "open-folder-on-dnd-hover"
/* Activating executable text files */
#define NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION "executable-text-activation"
/* Installing new packages when unknown mime type activated */ /* Installing new packages when unknown mime type activated */
#define NAUTILUS_PREFERENCES_INSTALL_MIME_ACTIVATION "install-mime-activation" #define NAUTILUS_PREFERENCES_INSTALL_MIME_ACTIVATION "install-mime-activation"
...@@ -107,6 +110,13 @@ enum ...@@ -107,6 +110,13 @@ enum
NAUTILUS_CLICK_POLICY_DOUBLE NAUTILUS_CLICK_POLICY_DOUBLE
}; };
enum
{
NAUTILUS_EXECUTABLE_TEXT_LAUNCH,
NAUTILUS_EXECUTABLE_TEXT_DISPLAY,
NAUTILUS_EXECUTABLE_TEXT_ASK
};
typedef enum typedef enum
{ {
NAUTILUS_SPEED_TRADEOFF_ALWAYS, NAUTILUS_SPEED_TRADEOFF_ALWAYS,
...@@ -158,4 +168,4 @@ extern GSettings *gnome_lockdown_preferences; ...@@ -158,4 +168,4 @@ extern GSettings *gnome_lockdown_preferences;
extern GSettings *gnome_background_preferences; extern GSettings *gnome_background_preferences;
extern GSettings *gnome_interface_preferences; extern GSettings *gnome_interface_preferences;
G_END_DECLS G_END_DECLS
\ No newline at end of file
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
typedef enum typedef enum
{ {
ACTIVATION_ACTION_ASK, ACTIVATION_ACTION_ASK,
ACTIVATION_ACTION_LAUNCH,
ACTIVATION_ACTION_LAUNCH_IN_TERMINAL,
ACTIVATION_ACTION_OPEN_IN_VIEW, ACTIVATION_ACTION_OPEN_IN_VIEW,
ACTIVATION_ACTION_OPEN_IN_APPLICATION, ACTIVATION_ACTION_OPEN_IN_APPLICATION,
ACTIVATION_ACTION_EXTRACT, ACTIVATION_ACTION_EXTRACT,
...@@ -75,6 +77,7 @@ typedef struct ...@@ -75,6 +77,7 @@ typedef struct
gboolean timed_wait_active; gboolean timed_wait_active;
NautilusFileListHandle *files_handle; NautilusFileListHandle *files_handle;
gboolean tried_mounting; gboolean tried_mounting;
char *activation_directory;
gboolean user_confirmation; gboolean user_confirmation;
} ActivateParameters; } ActivateParameters;
...@@ -219,6 +222,10 @@ struct ...@@ -219,6 +222,10 @@ struct
/* Number of seconds until cancel dialog shows up */ /* Number of seconds until cancel dialog shows up */
#define DELAY_UNTIL_CANCEL_MSECS 5000 #define DELAY_UNTIL_CANCEL_MSECS 5000
#define RESPONSE_RUN 1000
#define RESPONSE_DISPLAY 1001
#define RESPONSE_RUN_IN_TERMINAL 1002
#define SILENT_WINDOW_OPEN_LIMIT 5 #define SILENT_WINDOW_OPEN_LIMIT 5
#define SILENT_OPEN_LIMIT 5 #define SILENT_OPEN_LIMIT 5
...@@ -589,6 +596,115 @@ out: ...@@ -589,6 +596,115 @@ out:
g_free (detail); g_free (detail);
} }
static ActivationAction
get_executable_text_file_action (GtkWindow *parent_window,
NautilusFile *file)
{
GtkDialog *dialog;
char *file_name;
char *prompt;
char *detail;
int preferences_value;
int response;
g_assert (nautilus_file_contains_text (file));
preferences_value = g_settings_get_enum (nautilus_preferences,
NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION);
switch (preferences_value)
{
case NAUTILUS_EXECUTABLE_TEXT_LAUNCH:
{
return ACTIVATION_ACTION_LAUNCH;
}
case NAUTILUS_EXECUTABLE_TEXT_DISPLAY:
{
return ACTIVATION_ACTION_OPEN_IN_APPLICATION;
}
case NAUTILUS_EXECUTABLE_TEXT_ASK:
{
}
break;
default:
/* Complain non-fatally, since preference data can't be trusted */
g_warning ("Unknown value %d for NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION",
preferences_value);
}
file_name = nautilus_file_get_display_name (file);
prompt = g_strdup_printf (_("Do you want to run “%s”, or display its contents?"),
file_name);
detail = g_strdup_printf (_("“%s” is an executable text file."),
file_name);
g_free (file_name);
dialog = eel_create_question_dialog (prompt,
detail,
_("Run in _Terminal"), RESPONSE_RUN_IN_TERMINAL,
_("_Display"), RESPONSE_DISPLAY,
parent_window);
gtk_dialog_add_button (dialog, _("_Cancel"), GTK_RESPONSE_CANCEL);
gtk_dialog_add_button (dialog, _("_Run"), RESPONSE_RUN);
gtk_dialog_set_default_response (dialog, GTK_RESPONSE_CANCEL);
gtk_widget_show (GTK_WIDGET (dialog));
g_free (prompt);
g_free (detail);
response = gtk_dialog_run (dialog);
gtk_widget_destroy (GTK_WIDGET (dialog));
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_OPEN_IN_APPLICATION;
}
default:
return ACTIVATION_ACTION_DO_NOTHING;
}
}
static ActivationAction
get_default_executable_text_file_action (void)
{
int preferences_value;
preferences_value = g_settings_get_enum (nautilus_preferences,
NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION);
switch (preferences_value)
{
case NAUTILUS_EXECUTABLE_TEXT_LAUNCH:
{
return ACTIVATION_ACTION_LAUNCH;
}
case NAUTILUS_EXECUTABLE_TEXT_DISPLAY:
{
return ACTIVATION_ACTION_OPEN_IN_APPLICATION;
}
case NAUTILUS_EXECUTABLE_TEXT_ASK:
default:
return ACTIVATION_ACTION_ASK;
}
}
static ActivationAction static ActivationAction
get_activation_action (NautilusFile *file) get_activation_action (NautilusFile *file)
{ {
...@@ -615,13 +731,35 @@ get_activation_action (NautilusFile *file) ...@@ -615,13 +731,35 @@ get_activation_action (NautilusFile *file)
activation_uri = nautilus_file_get_uri (file); activation_uri = nautilus_file_get_uri (file);
} }
if (nautilus_file_opens_in_view (file)) action = ACTIVATION_ACTION_DO_NOTHING;
if (nautilus_file_is_launchable (file))
{ {
action = ACTIVATION_ACTION_OPEN_IN_VIEW; char *executable_path;
action = ACTIVATION_ACTION_LAUNCH;
executable_path = g_filename_from_uri (activation_uri, NULL, NULL);
if (!executable_path)
{
action = ACTIVATION_ACTION_DO_NOTHING;
}
else if (nautilus_file_contains_text (file))
{
action = get_default_executable_text_file_action ();
}
g_free (executable_path);
} }
else
if (action == ACTIVATION_ACTION_DO_NOTHING)
{ {
action = ACTIVATION_ACTION_OPEN_IN_APPLICATION; if (nautilus_file_opens_in_view (file))
{
action = ACTIVATION_ACTION_OPEN_IN_VIEW;
}
else
{
action = ACTIVATION_ACTION_OPEN_IN_APPLICATION;
}
} }
g_free (activation_uri); g_free (activation_uri);
...@@ -634,6 +772,16 @@ nautilus_mime_file_extracts (NautilusFile *file) ...@@ -634,6 +772,16 @@ nautilus_mime_file_extracts (NautilusFile *file)
return get_activation_action (file) == ACTIVATION_ACTION_EXTRACT; return get_activation_action (file) == ACTIVATION_ACTION_EXTRACT;
} }
gboolean
nautilus_mime_file_launches (NautilusFile *file)
{
ActivationAction activation_action;
activation_action = get_activation_action (file);
return (activation_action == ACTIVATION_ACTION_LAUNCH);
}
gboolean gboolean
nautilus_mime_file_opens_in_external_app (NautilusFile *file) nautilus_mime_file_opens_in_external_app (NautilusFile *file)
{ {
...@@ -689,6 +837,7 @@ activation_parameters_free (ActivateParameters *parameters) ...@@ -689,6 +837,7 @@ activation_parameters_free (ActivateParameters *parameters)
nautilus_file_list_free (parameters->mountables); nautilus_file_list_free (parameters->mountables);
nautilus_file_list_free (parameters->start_mountables); nautilus_file_list_free (parameters->start_mountables);
nautilus_file_list_free (parameters->not_mounted); nautilus_file_list_free (parameters->not_mounted);
g_free (parameters->activation_directory);
g_free (parameters->timed_wait_prompt); g_free (parameters->timed_wait_prompt);
g_assert (parameters->files_handle == NULL); g_assert (parameters->files_handle == NULL);
g_free (parameters); g_free (parameters);
...@@ -816,6 +965,7 @@ typedef struct ...@@ -816,6 +965,7 @@ typedef struct
NautilusFile *file; NautilusFile *file;
GList *files; GList *files;
NautilusWindowOpenFlags flags; NautilusWindowOpenFlags flags;
char *activation_directory;
gboolean user_confirmation; gboolean user_confirmation;
char *uri; char *uri;
GDBusProxy *proxy; GDBusProxy *proxy;
...@@ -841,6 +991,7 @@ activate_parameters_install_free (ActivateParametersInstall *parameters_install) ...@@ -841,6 +991,7 @@ activate_parameters_install_free (ActivateParametersInstall *parameters_install)
nautilus_file_unref (parameters_install->file); nautilus_file_unref (parameters_install->file);
nautilus_file_list_free (parameters_install->files); nautilus_file_list_free (parameters_install->files);
g_free (parameters_install->activation_directory);
g_free (parameters_install->uri); g_free (parameters_install->uri);
g_free (parameters_install); g_free (parameters_install);
} }
...@@ -1044,6 +1195,7 @@ search_for_application_dbus_call_notify_cb (GDBusProxy *proxy, ...@@ -1044,6 +1195,7 @@ search_for_application_dbus_call_notify_cb (GDBusProxy *proxy,
nautilus_mime_activate_files (parameters_install->parent_window, nautilus_mime_activate_files (parameters_install->parent_window,
parameters_install->slot, parameters_install->slot,
parameters_install->files, parameters_install->files,
parameters_install->activation_directory,
parameters_install->flags, parameters_install->flags,
parameters_install->user_confirmation); parameters_install->user_confirmation);
...@@ -1192,6 +1344,7 @@ application_unhandled_uri (ActivateParameters *parameters, ...@@ -1192,6 +1344,7 @@ application_unhandled_uri (ActivateParameters *parameters,
parameters_install->parent_window = parameters->parent_window; parameters_install->parent_window = parameters->parent_window;
g_object_add_weak_pointer (G_OBJECT (parameters_install->parent_window), (gpointer *) &parameters_install->parent_window); g_object_add_weak_pointer (G_OBJECT (parameters_install->parent_window), (gpointer *) &parameters_install->parent_window);
} }
parameters_install->activation_directory = g_strdup (parameters->activation_directory);
parameters_install->file = file; parameters_install->file = file;
parameters_install->files = get_file_list_for_launch_locations (parameters->locations); parameters_install->files = get_file_list_for_launch_locations (parameters->locations);
parameters_install->flags = parameters->flags; parameters_install->flags = parameters->flags;
...@@ -1298,12 +1451,17 @@ activate_files (ActivateParameters *parameters) ...@@ -1298,12 +1451,17 @@ activate_files (ActivateParameters *parameters)
NautilusWindowOpenFlags flags; NautilusWindowOpenFlags flags;
int count; int count;
g_autofree char *old_working_dir = NULL; g_autofree char *old_working_dir = NULL;
GdkScreen *screen;
gboolean closed_window; gboolean closed_window;
g_autoptr (GQueue) launch_files = NULL;
g_autoptr (GQueue) launch_in_terminal_files = NULL;
g_autoptr (GQueue) open_in_app_uris = NULL; g_autoptr (GQueue) open_in_app_uris = NULL;
g_autoptr (GQueue) open_in_view_files = NULL; g_autoptr (GQueue) open_in_view_files = NULL;
GList *l; GList *l;
ActivationAction action; ActivationAction action;
launch_files = g_queue_new ();
launch_in_terminal_files = g_queue_new ();
open_in_view_files = g_queue_new (); open_in_view_files = g_queue_new ();
open_in_app_uris = g_queue_new (); open_in_app_uris = g_queue_new ();
...@@ -1320,8 +1478,30 @@ activate_files (ActivateParameters *parameters) ...@@ -1320,8 +1478,30 @@ activate_files (ActivateParameters *parameters)
} }
action = get_activation_action (file); action = get_activation_action (file);
if (action == ACTIVATION_ACTION_ASK)
{
/* Special case for executable text files, since it might be
* dangerous & unexpected to launch these.
*/
pause_activation_timed_cancel (parameters);
action = get_executable_text_file_action (parameters->parent_window, file);
unpause_activation_timed_cancel (parameters);
}
switch (action) switch (action)
{ {
case ACTIVATION_ACTION_LAUNCH:
{
g_queue_push_tail (launch_files, file);
}
break;
case ACTIVATION_ACTION_LAUNCH_IN_TERMINAL:
{
g_queue_push_tail (launch_in_terminal_files, file);
}
break;
case ACTIVATION_ACTION_OPEN_IN_VIEW: case ACTIVATION_ACTION_OPEN_IN_VIEW:
{ {
g_queue_push_tail (open_in_view_files, file); g_queue_push_tail (open_in_view_files, file);
...@@ -1346,7 +1526,7 @@ activate_files (ActivateParameters *parameters) ...@@ -1346,7 +1526,7 @@ activate_files (ActivateParameters *parameters)
} }
break; break;
default: case ACTIVATION_ACTION_ASK:
{ {
g_assert_not_reached (); g_assert_not_reached ();
} }
...@@ -1354,6 +1534,54 @@ activate_files (ActivateParameters *parameters) ...@@ -1354,6 +1534,54 @@ activate_files (ActivateParameters *parameters)
} }
} }
if (parameters->activation_directory &&
(!g_queue_is_empty (launch_files) ||
!g_queue_is_empty (launch_in_terminal_files)))
{
old_working_dir = g_get_current_dir ();
g_chdir (parameters->activation_directory);
}
screen = gtk_widget_get_screen (GTK_WIDGET (parameters->parent_window));
for (l = g_queue_peek_head_link (launch_files); l != NULL; l = l->next)
{
g_autofree char *uri = NULL;
g_autofree char *executable_path = NULL;
g_autofree char *quoted_path = NULL;
file = NAUTILUS_FILE (l->data);
</