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

Proposed by Jeremy Munsch
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 Approve
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.
Revision history for this message
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.

Revision history for this message
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

core: Handle UriMatches pointing to executable files

Revision history for this message
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

Revision history for this message
Rico Tzschichholz (ricotz) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/core/common-actions.vala'
--- src/core/common-actions.vala 2014-07-10 13:45:44 +0000
+++ src/core/common-actions.vala 2015-11-14 19:25:26 +0000
@@ -92,6 +92,25 @@
92 {92 {
93 ((Action) match).do_execute (match, target);93 ((Action) match).do_execute (match, target);
94 }94 }
95 else if (match is UriMatch)
96 {
97 try
98 {
99 unowned string uri = ((UriMatch) match).uri;
100 if (uri.has_prefix ("file:"))
101 {
102 File file = File.new_for_uri (uri);
103 AppInfo app = AppInfo.create_from_commandline (
104 file.get_path (), file.get_basename (),
105 AppInfoCreateFlags.NONE);
106 app.launch (null, Gdk.Display.get_default ().get_app_launch_context ());
107 }
108 }
109 catch (Error err)
110 {
111 warning ("%s", err.message);
112 }
113 }
95 else114 else
96 {115 {
97 warning ("'%s' is not be handled here", match.title);116 warning ("'%s' is not be handled here", match.title);
@@ -100,6 +119,16 @@
100119
101 public override bool valid_for_match (Match match)120 public override bool valid_for_match (Match match)
102 {121 {
122 if (match is UriMatch)
123 {
124 unowned string uri = ((UriMatch) match).uri;
125 if (uri.has_prefix ("file:"))
126 {
127 string path = File.new_for_uri (uri).get_path ();
128 return FileUtils.test (path, FileTest.IS_EXECUTABLE);
129 }
130 }
131
103 return (match is Action ||132 return (match is Action ||
104 match is ActionMatch ||133 match is ActionMatch ||
105 (match is ApplicationMatch && !(((ApplicationMatch) match).needs_terminal)));134 (match is ApplicationMatch && !(((ApplicationMatch) match).needs_terminal)));
@@ -138,10 +167,38 @@
138 warning ("%s", err.message);167 warning ("%s", err.message);
139 }168 }
140 }169 }
170 else if (match is UriMatch)
171 {
172 try
173 {
174 unowned string uri = ((UriMatch) match).uri;
175 if (uri.has_prefix ("file:"))
176 {
177 File file = File.new_for_uri (uri);
178 AppInfo app = AppInfo.create_from_commandline (
179 file.get_path (), file.get_basename (),
180 AppInfoCreateFlags.NEEDS_TERMINAL);
181 app.launch (null, Gdk.Display.get_default ().get_app_launch_context ());
182 }
183 }
184 catch (Error err)
185 {
186 warning ("%s", err.message);
187 }
188 }
141 }189 }
142190
143 public override bool valid_for_match (Match match)191 public override bool valid_for_match (Match match)
144 {192 {
193 if (match is UriMatch)
194 {
195 unowned string uri = ((UriMatch) match).uri;
196 if (uri.has_prefix ("file:"))
197 {
198 string path = File.new_for_uri (uri).get_path ();
199 return FileUtils.test (path, FileTest.IS_EXECUTABLE);
200 }
201 }
145 return (match is ApplicationMatch);202 return (match is ApplicationMatch);
146 }203 }
147 }204 }