mime-actions: Drop ACTIVATION_ACTION_ASK

There is an option in Preferences which enables a dialog asking users
what they intend to do when they double-click an executable text file:
open as a text file or run as a program?

The dialog asking that question has known design problems, but they
remain unaddressed, which is not surprising because it's non-default.

Now, with the new menu item added in the last commit, the two options
("Open" and "Run as a Program") are both available by default in the
context menu, so there is no need to ask the question in a dialog.

Remove the option, the dialog, and the related code.

Closes https://bugzilla.gnome.org/show_bug.cgi?id=598671
Part of https://gitlab.gnome.org/GNOME/nautilus/-/issues/1700
This commit is contained in:
António Fernandes 2020-12-17 13:18:58 +00:00
parent 0584f6cb93
commit 64326f0331
5 changed files with 5 additions and 127 deletions

View file

@ -123,7 +123,7 @@
<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>
<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, and “display” to display them as text files.</description>
</key>
<key type="b" name="install-mime-activation">
<default>true</default>

View file

@ -111,7 +111,6 @@ enum
{
NAUTILUS_EXECUTABLE_TEXT_LAUNCH,
NAUTILUS_EXECUTABLE_TEXT_DISPLAY,
NAUTILUS_EXECUTABLE_TEXT_ASK
};
typedef enum

View file

@ -46,7 +46,6 @@
typedef enum
{
ACTIVATION_ACTION_ASK,
ACTIVATION_ACTION_LAUNCH,
ACTIVATION_ACTION_LAUNCH_IN_TERMINAL,
ACTIVATION_ACTION_OPEN_IN_VIEW,
@ -221,10 +220,6 @@ struct
/* Number of seconds until cancel dialog shows up */
#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_OPEN_LIMIT 5
@ -596,90 +591,6 @@ out:
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)
{
@ -699,10 +610,10 @@ get_default_executable_text_file_action (void)
return ACTIVATION_ACTION_OPEN_IN_APPLICATION;
}
case NAUTILUS_EXECUTABLE_TEXT_ASK:
default:
return ACTIVATION_ACTION_ASK;
return ACTIVATION_ACTION_OPEN_IN_APPLICATION;
}
}
static ActivationAction
@ -1443,15 +1354,6 @@ activate_files (ActivateParameters *parameters)
}
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)
{
@ -1490,12 +1392,6 @@ activate_files (ActivateParameters *parameters)
g_assert_not_reached ();
}
break;
case ACTIVATION_ACTION_ASK:
{
g_assert_not_reached ();
}
break;
}
}

View file

@ -82,12 +82,12 @@ 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
NULL
};
static const char * const executable_text_values[] =
{
"launch", "display", "ask",
"launch", "display",
NULL
};

View file

@ -651,23 +651,6 @@
<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="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="use_underline">True</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>
<accessibility>
<relation type="labelled-by" target="label_executable_text_files"/>
</accessibility>