It's 3.30.1 release day, upload a tarball and enjoy the fixes of those pesky bugs 🐛

Commit ac886102 authored by Carlos Soriano's avatar Carlos Soriano Committed by Ernestas Kulik

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 ce61f484
Pipeline #12248 passed with stage
in 7 minutes and 32 seconds
......@@ -11,6 +11,12 @@
<value value="1" nick="double"/>
</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">
<value value="0" nick="icon-view"/>
<value value="1" nick="list-view"/>
......@@ -115,6 +121,11 @@
<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>
</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">
<default>true</default>
<summary>Show the package installer for unknown MIME types</summary>
......
......@@ -8161,6 +8161,28 @@ nautilus_file_get_file_info_error (NautilusFile *file)
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
*
......
......@@ -171,6 +171,7 @@ void nautilus_file_invalidate_attributes (Nautilu
void nautilus_file_invalidate_all_attributes (NautilusFile *file);
/* Basic attributes for file objects. */
gboolean nautilus_file_contains_text (NautilusFile *file);
char * nautilus_file_get_display_name (NautilusFile *file);
char * nautilus_file_get_edit_name (NautilusFile *file);
char * nautilus_file_get_name (NautilusFile *file);
......
......@@ -64,6 +64,7 @@
#include "nautilus-file-private.h"
#include "nautilus-file-undo-manager.h"
#include "nautilus-file-utilities.h"
#include "nautilus-file.h"
#include "nautilus-floating-bar.h"
#include "nautilus-global-preferences.h"
#include "nautilus-icon-info.h"
......@@ -1194,6 +1195,7 @@ nautilus_files_view_activate_files (NautilusFilesView *view,
NautilusFilesViewPrivate *priv;
GList *files_to_extract;
GList *files_to_activate;
char *path;
if (files == NULL)
{
......@@ -1225,12 +1227,15 @@ nautilus_files_view_activate_files (NautilusFilesView *view,
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),
priv->slot,
files_to_activate,
path,
flags,
confirm_multiple);
g_free (path);
g_list_free (files_to_extract);
g_list_free (files_to_activate);
}
......@@ -7716,6 +7721,7 @@ update_selection_menu (NautilusFilesView *view)
GList *l;
gint selection_count;
gboolean show_app;
gboolean show_run;
gboolean show_extract;
gboolean item_opens_in_view;
gchar *item_label;
......@@ -7756,7 +7762,7 @@ update_selection_menu (NautilusFilesView *view)
g_free (item_label);
/* 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)
{
NautilusFile *file;
......@@ -7773,12 +7779,17 @@ update_selection_menu (NautilusFilesView *view)
show_app = FALSE;
}
if (!nautilus_mime_file_launches (file))
{
show_run = FALSE;
}
if (!nautilus_file_opens_in_view (file))
{
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;
}
......@@ -7807,6 +7818,10 @@ update_selection_menu (NautilusFilesView *view)
g_free (escaped_app);
g_object_unref (app);
}
else if (show_run)
{
item_label = g_strdup (_("Run"));
}
else if (show_extract)
{
item_label = nautilus_files_view_supports_extract_here (view) ?
......@@ -8767,9 +8782,9 @@ nautilus_files_view_move_copy_items (NautilusFilesView *view,
target_file = nautilus_file_get_existing_by_uri (target_uri);
if (copy_action == GDK_ACTION_COPY &&
nautilus_is_file_roller_installed () &&
target_file != NULL &&
nautilus_file_is_archive (target_file))
nautilus_is_file_roller_installed () &&
target_file != NULL &&
nautilus_file_is_archive (target_file))
{
char *command, *quoted_uri, *tmp;
const GList *l;
......
......@@ -51,6 +51,9 @@ typedef enum
/* Drag and drop preferences */
#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 */
#define NAUTILUS_PREFERENCES_INSTALL_MIME_ACTIVATION "install-mime-activation"
......@@ -107,6 +110,13 @@ enum
NAUTILUS_CLICK_POLICY_DOUBLE
};
enum
{
NAUTILUS_EXECUTABLE_TEXT_LAUNCH,
NAUTILUS_EXECUTABLE_TEXT_DISPLAY,
NAUTILUS_EXECUTABLE_TEXT_ASK
};
typedef enum
{
NAUTILUS_SPEED_TRADEOFF_ALWAYS,
......@@ -158,4 +168,4 @@ extern GSettings *gnome_lockdown_preferences;
extern GSettings *gnome_background_preferences;
extern GSettings *gnome_interface_preferences;
G_END_DECLS
G_END_DECLS
\ No newline at end of file
This diff is collapsed.
......@@ -39,14 +39,16 @@ gboolean nautilus_mime_file_extracts (Nauti
gboolean nautilus_mime_file_opens_in_external_app (NautilusFile *file);
gboolean nautilus_mime_file_launches (NautilusFile *file);
void nautilus_mime_activate_files (GtkWindow *parent_window,
NautilusWindowSlot *slot,
GList *files,
NautilusWindowOpenFlags flags,
gboolean user_confirmation);
NautilusWindowSlot *slot,
GList *files,
const char *launch_directory,
NautilusWindowOpenFlags flags,
gboolean user_confirmation);
void nautilus_mime_activate_file (GtkWindow *parent_window,
NautilusWindowSlot *slot_info,
NautilusFile *file,
NautilusWindowOpenFlags flags);
NautilusWindowSlot *slot_info,
NautilusFile *file,
const char *launch_directory,
NautilusWindowOpenFlags flags);
gint nautilus_mime_types_get_number_of_groups (void);
const gchar* nautilus_mime_types_group_get_name (gint group_index);
GList* nautilus_mime_types_group_get_mimetypes (gint group_index);
GList* nautilus_mime_types_group_get_mimetypes (gint group_index);
\ No newline at end of file
......@@ -95,13 +95,16 @@ open_location_cb (NautilusPlacesView *view,
{
NautilusFile *file;
GtkWidget *window;
char *path;
path = "other-locations:///";
file = nautilus_file_get (location);
window = gtk_widget_get_toplevel (GTK_WIDGET (view));
nautilus_mime_activate_file (GTK_WINDOW (window),
NAUTILUS_WINDOW_SLOT (slot),
file,
path,
flags);
nautilus_file_unref (file);
}
......
......@@ -79,6 +79,18 @@ static const char * const click_behavior_components[] =
static const char * const click_behavior_values[] = {"single", "double", NULL};
static const char * const executable_text_components[] =
{
"scripts_execute_radiobutton", "scripts_view_radiobutton",
"scripts_confirm_radiobutton", NULL
};
static const char * const executable_text_values[] =
{
"launch", "display", "ask",
NULL
};
static const char * const recursive_search_components[] =
{
"search_recursive_only_this_computer_radiobutton", "search_recursive_all_locations_radiobutton", "search_recursive_never_radiobutton", NULL
......@@ -467,6 +479,10 @@ static void nautilus_preferences_window_setup(GtkBuilder *builder,
bind_builder_radio (
builder, nautilus_preferences, (const char **) click_behavior_components,
NAUTILUS_PREFERENCES_CLICK_POLICY, (const char **) click_behavior_values);
bind_builder_radio (builder, nautilus_preferences,
(const char **) executable_text_components,
NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
(const char **) executable_text_values);
bind_builder_radio (builder, nautilus_preferences,
(const char **) recursive_search_components,
NAUTILUS_PREFERENCES_RECURSIVE_SEARCH,
......
......@@ -593,6 +593,100 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="vbox7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Executable Text Files</property>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes>
<accessibility>
<relation type="label-for" target="vbox7"/>
</accessibility>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="scripts_view_radiobutton">
<property name="label" translatable="yes">_Display them</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">scripts_execute_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="scripts_execute_radiobutton">
<property name="label" translatable="yes">_Run them</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">scripts_view_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="scripts_confirm_radiobutton">
<property name="label" translatable="yes">_Ask what to do</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">scripts_execute_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox7-atkobject">
<property name="AtkObject::accessible-role">38</property>
</object>
</child>
<accessibility>
<relation type="labelled-by" target="label12"/>
</accessibility>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="vbox8">
<property name="visible">True</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment