Merge lp:~jeremywootten/pantheon-files/fix-1669996-execute-edit-script-choice into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Rejected
Rejected by: Danielle Foré
Proposed branch: lp:~jeremywootten/pantheon-files/fix-1669996-execute-edit-script-choice
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 137 lines (+91/-2)
4 files modified
libcore/gof-file.c (+1/-1)
src/CMakeLists.txt (+2/-0)
src/Dialogs/ConfirmExecuteDialog.vala (+79/-0)
src/View/AbstractDirectoryView.vala (+9/-1)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-1669996-execute-edit-script-choice
Reviewer Review Type Date Requested Status
Danielle Foré Disapprove
Review via email: mp+319640@code.launchpad.net

Commit message

Confirm execution of script or other executable when clicked on.

Description of the change

This branch shows a dialog if an executable script (or x-application) is clicked on, asking to confirm execution of the file and, if a default application is available, giving the option to open it with the default application instead.

The dialog does not appear if "Run" is deliberately chosen from the context menu.

To post a comment you must log in.
Revision history for this message
David Hewitt (davidmhewitt) wrote :

Code looks good, haven't tested yet. One minor comment about the wording. Does it make more sense to say "This file may be run as a program..." or maybe even "application" instead of "program" instead of "This file may be executed as a program"?

I feel as though run would be more widely understood than execute.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

The wording is provisional and needs UX team approval really. I do not think "application" is necessarily correct - the file is likely to be a script which is not an application in the normal sense. Indeed, strictly speaking, it is not definitely a program is it? - it is a file with the attribute of being executable. I used the plainer word "Run" in the main message and the more technical word "execute" in the detailed message, but I am open to using the same word everywhere.

Revision history for this message
Danielle Foré (danrabbit) wrote :

I'm kind of -1 on this branch. Throwing a dialog doesn't make it faster for people who want to run the script. It's still two clicks, but now there's an annoying dialog in the way whenever I want to edit a script. And I'm a bit of the position that I'm going to be executing scripts from Terminal anyways because I want the output.

review: Disapprove

Unmerged revisions

2522. By Jeremy Wootten

Implement ConfirmExecuteDialog

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libcore/gof-file.c'
--- libcore/gof-file.c 2017-02-26 04:50:36 +0000
+++ libcore/gof-file.c 2017-03-11 18:39:16 +0000
@@ -1477,7 +1477,7 @@
1477 /* check for .exe, .bar or .com */1477 /* check for .exe, .bar or .com */
1478 can_execute = g_content_type_can_be_executable (content_type);1478 can_execute = g_content_type_can_be_executable (content_type);
1479#else1479#else
1480 /* check if the content type is save to execute, we don't use1480 /* check if the content type is safe to execute, we don't use
1481 * g_content_type_can_be_executable() for unix because it also returns1481 * g_content_type_can_be_executable() for unix because it also returns
1482 * true for "text/plain" and we don't want that */1482 * true for "text/plain" and we don't want that */
1483 if (g_content_type_is_a (content_type, "application/x-executable")1483 if (g_content_type_is_a (content_type, "application/x-executable")
14841484
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2017-02-01 14:42:37 +0000
+++ src/CMakeLists.txt 2017-03-11 18:39:16 +0000
@@ -81,6 +81,7 @@
81 Thumbnailer.vala81 Thumbnailer.vala
82 Dialogs/AbstractPropertiesDialog.vala82 Dialogs/AbstractPropertiesDialog.vala
83 Dialogs/ChooseAppDialog.vala83 Dialogs/ChooseAppDialog.vala
84 Dialogs/ConfirmExecuteDialog.vala
84 Dialogs/PropertiesWindow.vala85 Dialogs/PropertiesWindow.vala
85 Dialogs/VolumePropertiesWindow.vala86 Dialogs/VolumePropertiesWindow.vala
86 Utils/MimeActions.vala87 Utils/MimeActions.vala
@@ -147,6 +148,7 @@
147 Thumbnailer.vala148 Thumbnailer.vala
148 Dialogs/AbstractPropertiesDialog.vala149 Dialogs/AbstractPropertiesDialog.vala
149 Dialogs/ChooseAppDialog.vala150 Dialogs/ChooseAppDialog.vala
151 Dialogs/ConfirmExecuteDialog.vala
150 Dialogs/PropertiesWindow.vala152 Dialogs/PropertiesWindow.vala
151 Dialogs/VolumePropertiesWindow.vala153 Dialogs/VolumePropertiesWindow.vala
152 Utils/MimeActions.vala154 Utils/MimeActions.vala
153155
=== added file 'src/Dialogs/ConfirmExecuteDialog.vala'
--- src/Dialogs/ConfirmExecuteDialog.vala 1970-01-01 00:00:00 +0000
+++ src/Dialogs/ConfirmExecuteDialog.vala 2017-03-11 18:39:16 +0000
@@ -0,0 +1,79 @@
1/*
2* Copyright (c) 2017 elementary LLC (http://launchpad.net/pantheon-files)
3*
4* This program is free software; you can redistribute it and/or
5* modify it under the terms of the GNU General Public
6* License as published by the Free Software Foundation, Inc.,; either
7* version 3 of the License, or (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12* General Public License for more details.
13*
14* You should have received a copy of the GNU General Public
15* License along with this program; if not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17* Boston, MA 02110-1335 USA.
18*
19* Authored by: Jeremy Wootten <jeremy@elementaryos.org>
20*/
21
22public class PF.ConfirmExecuteDialog : Object {
23 public enum Response {
24 CANCEL,
25 EXECUTE,
26 OPEN
27 }
28
29 private Gtk.MessageDialog dialog;
30 public GOF.File file {get; construct;}
31 public GLib.AppInfo? default_app {get; construct;}
32 public Gtk.Window? parent {get; construct;}
33
34 public ConfirmExecuteDialog (GOF.File _file, GLib.AppInfo? _default_app, Gtk.Window? _parent) {
35 Object (file: _file,
36 default_app: _default_app,
37 parent: _parent
38 );
39 }
40
41 construct {
42 string primary_text, secondary_text;
43
44 if (default_app != null) {
45 primary_text = _("Run or Open this File?").printf (file.basename);
46 secondary_text = _("This file may be executed as a program or opened with the default application (%s).\n\nOnly execute files that you know to be safe").printf (default_app.get_name ());
47 } else {
48 primary_text = _("Run this File?").printf (file.basename);
49 secondary_text = _("This file may be executed as a program.\n\nOnly execute files that you know to be safe").printf (default_app.get_name ());
50 }
51
52 dialog = new Gtk.MessageDialog (parent,
53 Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
54 Gtk.MessageType.QUESTION,
55 Gtk.ButtonsType.NONE,
56 primary_text);
57
58 dialog.secondary_text = secondary_text;
59
60 dialog.add_button (_("Execute"), Response.EXECUTE);
61 dialog.add_button (_("Cancel"), Response.CANCEL);
62
63 /* Set safer option to be the default */
64 if (default_app != null) {
65 dialog.add_button (_("Open"), Response.OPEN);
66 dialog.set_default_response (Response.OPEN);
67 } else {
68 dialog.set_default_response (Response.CANCEL);
69 }
70
71 dialog.show_all ();
72 }
73
74 public Response run () {
75 var res = dialog.run ();
76 dialog.destroy ();
77 return (Response)res;
78 }
79}
080
=== modified file 'src/View/AbstractDirectoryView.vala'
--- src/View/AbstractDirectoryView.vala 2017-02-15 18:54:50 +0000
+++ src/View/AbstractDirectoryView.vala 2017-03-11 18:39:16 +0000
@@ -795,7 +795,15 @@
795 if (file.is_root_network_folder ()) {795 if (file.is_root_network_folder ()) {
796 load_location (location);796 load_location (location);
797 } else if (file.is_executable ()) {797 } else if (file.is_executable ()) {
798 file.execute (screen, null, null);798 var dialog = new PF.ConfirmExecuteDialog (file, default_app, window);
799 switch (dialog.run ()) { /* dialog destroys itself */
800 case PF.ConfirmExecuteDialog.Response.EXECUTE:
801 file.execute (screen, null, null);
802 break;
803 case PF.ConfirmExecuteDialog.Response.OPEN:
804 open_file (file, screen, default_app);
805 break;
806 }
799 } else {807 } else {
800 open_file (file, screen, default_app);808 open_file (file, screen, default_app);
801 }809 }

Subscribers

People subscribed via source and target branches

to all changes: