Merge lp:~jeremy-munsch/synapse-project/add-script-execute into lp:synapse-project

Proposed by Jeremy Munsch on 2015-11-14
Status: Merged
Merged at revision: 616
Proposed branch: lp:~jeremy-munsch/synapse-project/add-script-execute
Merge into: lp:synapse-project
Diff against target: 85 lines (+57/-0)
1 file modified
src/core/common-actions.vala (+57/-0)
To merge this branch: bzr merge lp:~jeremy-munsch/synapse-project/add-script-execute
Reviewer Review Type Date Requested Status
Rico Tzschichholz 2015-11-14 Approve on 2015-11-14
Review via email: mp+277502@code.launchpad.net

Description of the change

fixes https://bugs.launchpad.net/synapse-project/+bug/695437

Add Runner and TerminalRunner for UriMatch

To post a comment you must log in.
Jeremy Munsch (jeremy-munsch) wrote :

This is also linked to https://code.launchpad.net/~jeremy-munsch/synapse-project/add-script-execute/+merge/277502
which if is approved and merged (the linked PR) would be need to be applied on this PR.

Rico Tzschichholz (ricotz) wrote :

Your are referencing this very same merge-proposal in your preview comment.

Apply this clean up https://paste.debian.net/plain/332685

Use "bzr commit --fixes lp:695437" -m "core: Handle UriMatches pointing to executable files"

review: Needs Fixing
616. By Jeremy Munsch on 2015-11-14

core: Handle UriMatches pointing to executable files

Jeremy Munsch (jeremy-munsch) wrote :

Well i meant lp:~jeremy-munsch/synapse-project/fix-ssh-terminal into lp:synapse-project sorry about that.

Fixing done thanks for reviewing

Rico Tzschichholz (ricotz) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/core/common-actions.vala'
2--- src/core/common-actions.vala 2014-07-10 13:45:44 +0000
3+++ src/core/common-actions.vala 2015-11-14 19:25:26 +0000
4@@ -92,6 +92,25 @@
5 {
6 ((Action) match).do_execute (match, target);
7 }
8+ else if (match is UriMatch)
9+ {
10+ try
11+ {
12+ unowned string uri = ((UriMatch) match).uri;
13+ if (uri.has_prefix ("file:"))
14+ {
15+ File file = File.new_for_uri (uri);
16+ AppInfo app = AppInfo.create_from_commandline (
17+ file.get_path (), file.get_basename (),
18+ AppInfoCreateFlags.NONE);
19+ app.launch (null, Gdk.Display.get_default ().get_app_launch_context ());
20+ }
21+ }
22+ catch (Error err)
23+ {
24+ warning ("%s", err.message);
25+ }
26+ }
27 else
28 {
29 warning ("'%s' is not be handled here", match.title);
30@@ -100,6 +119,16 @@
31
32 public override bool valid_for_match (Match match)
33 {
34+ if (match is UriMatch)
35+ {
36+ unowned string uri = ((UriMatch) match).uri;
37+ if (uri.has_prefix ("file:"))
38+ {
39+ string path = File.new_for_uri (uri).get_path ();
40+ return FileUtils.test (path, FileTest.IS_EXECUTABLE);
41+ }
42+ }
43+
44 return (match is Action ||
45 match is ActionMatch ||
46 (match is ApplicationMatch && !(((ApplicationMatch) match).needs_terminal)));
47@@ -138,10 +167,38 @@
48 warning ("%s", err.message);
49 }
50 }
51+ else if (match is UriMatch)
52+ {
53+ try
54+ {
55+ unowned string uri = ((UriMatch) match).uri;
56+ if (uri.has_prefix ("file:"))
57+ {
58+ File file = File.new_for_uri (uri);
59+ AppInfo app = AppInfo.create_from_commandline (
60+ file.get_path (), file.get_basename (),
61+ AppInfoCreateFlags.NEEDS_TERMINAL);
62+ app.launch (null, Gdk.Display.get_default ().get_app_launch_context ());
63+ }
64+ }
65+ catch (Error err)
66+ {
67+ warning ("%s", err.message);
68+ }
69+ }
70 }
71
72 public override bool valid_for_match (Match match)
73 {
74+ if (match is UriMatch)
75+ {
76+ unowned string uri = ((UriMatch) match).uri;
77+ if (uri.has_prefix ("file:"))
78+ {
79+ string path = File.new_for_uri (uri).get_path ();
80+ return FileUtils.test (path, FileTest.IS_EXECUTABLE);
81+ }
82+ }
83 return (match is ApplicationMatch);
84 }
85 }