Merge lp:~miwaxe+launchpad/synapse-project/clementine-support into lp:synapse-project
- clementine-support
- Merge into trunk
Status: | Needs review |
---|---|
Proposed branch: | lp:~miwaxe+launchpad/synapse-project/clementine-support |
Merge into: | lp:synapse-project |
Diff against target: |
497 lines (+471/-0) 3 files modified
src/plugins/Makefile.am (+1/-0) src/plugins/clementine-plugin.vala (+469/-0) src/ui/synapse-main.vala (+1/-0) |
To merge this branch: | bzr merge lp:~miwaxe+launchpad/synapse-project/clementine-support |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeremy Munsch (community) | Needs Resubmitting | ||
Michal Hruby | Needs Information | ||
Review via email: mp+195676@code.launchpad.net |
Commit message
Description of the change
I've ported the XNoise plugin to Clementine, my favourite music player. Please review it!
:-)
Jeremy Munsch (jeremy-munsch) wrote : | # |
I just wanted to try this on 15.04 but a dependency is unique-3.0 which is not available anymore.
looks like gir1.2-unique-3.0 was last available in Saucy (13.10).
Since last LTS is Trusty (14.04), this should be update with the last version of synapse in order to be tested.
Jeremy Munsch (jeremy-munsch) wrote : | # |
> I just wanted to try this on 15.04 but a dependency is unique-3.0 which is not
> available anymore.
> looks like gir1.2-unique-3.0 was last available in Saucy (13.10).
>
> Since last LTS is Trusty (14.04), this should be update with the last version
> of synapse in order to be tested.
I also tested the code in the last version of synapse, but the code is outdated right now. So it needs a great update to be used.
Jeremy Munsch (jeremy-munsch) wrote : | # |
Oups sorry i miss clicked for the resubmit.
Unmerged revisions
- 514. By Andrea Brancaleoni <email address hidden>
-
Clementine Plugin
Preview Diff
1 | === modified file 'src/plugins/Makefile.am' | |||
2 | --- src/plugins/Makefile.am 2013-07-02 23:06:40 +0000 | |||
3 | +++ src/plugins/Makefile.am 2013-11-18 21:23:46 +0000 | |||
4 | @@ -52,6 +52,7 @@ | |||
5 | 52 | selection-plugin.vala \ | 52 | selection-plugin.vala \ |
6 | 53 | test-slow-plugin.vala \ | 53 | test-slow-plugin.vala \ |
7 | 54 | xnoise-media-player-plugin.vala \ | 54 | xnoise-media-player-plugin.vala \ |
8 | 55 | clementine-plugin.vala \ | ||
9 | 55 | system-management.vala \ | 56 | system-management.vala \ |
10 | 56 | $(NULL) | 57 | $(NULL) |
11 | 57 | 58 | ||
12 | 58 | 59 | ||
13 | === added file 'src/plugins/clementine-plugin.vala' | |||
14 | --- src/plugins/clementine-plugin.vala 1970-01-01 00:00:00 +0000 | |||
15 | +++ src/plugins/clementine-plugin.vala 2013-11-18 21:23:46 +0000 | |||
16 | @@ -0,0 +1,469 @@ | |||
17 | 1 | /* | ||
18 | 2 | * Copyright (C) 2012 Jörn Magens <shuerhaaken@googlemail.com> | ||
19 | 3 | * | ||
20 | 4 | * This program is free software; you can redistribute it and/or modify | ||
21 | 5 | * it under the terms of the GNU General Public License as published by | ||
22 | 6 | * the Free Software Foundation; either version 2 of the License, or | ||
23 | 7 | * (at your option) any later version. | ||
24 | 8 | * | ||
25 | 9 | * This program is distributed in the hope that it will be useful, | ||
26 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
27 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
28 | 12 | * GNU General Public License for more details. | ||
29 | 13 | * | ||
30 | 14 | * You should have received a copy of the GNU General Public License | ||
31 | 15 | * along with this program; if not, write to the Free Software | ||
32 | 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
33 | 17 | * | ||
34 | 18 | * Authored by Jörn Magens <shuerhaaken@googlemail.com> | ||
35 | 19 | * Authored by Andrea Brancaleoni <miwaxe@gmail.com> | ||
36 | 20 | * | ||
37 | 21 | */ | ||
38 | 22 | |||
39 | 23 | namespace Synapse | ||
40 | 24 | { | ||
41 | 25 | [DBus (name = "org.mpris.MediaPlayer2.Player")] | ||
42 | 26 | private interface ClementinePlayer : Object | ||
43 | 27 | { | ||
44 | 28 | public const string UNIQUE_NAME = "org.mpris.MediaPlayer2.clementine"; | ||
45 | 29 | public const string OBJECT_PATH = "/org/mpris/MediaPlayer2"; | ||
46 | 30 | |||
47 | 31 | public abstract void next () throws IOError; | ||
48 | 32 | public abstract void previous () throws IOError; | ||
49 | 33 | public abstract void pause () throws IOError; | ||
50 | 34 | public abstract void play_pause () throws IOError; | ||
51 | 35 | public abstract void stop () throws IOError; | ||
52 | 36 | public abstract void play () throws IOError; | ||
53 | 37 | public abstract void open_uri (string uri) throws IOError; | ||
54 | 38 | } | ||
55 | 39 | |||
56 | 40 | [DBus (name = "org.mpris.MediaPlayer2")] | ||
57 | 41 | private interface ClementineEngine : Object | ||
58 | 42 | { | ||
59 | 43 | public const string UNIQUE_NAME = "org.mpris.MediaPlayer2.clementine"; | ||
60 | 44 | public const string OBJECT_PATH = "/org/mpris/MediaPlayer2"; | ||
61 | 45 | |||
62 | 46 | public abstract void quit () throws IOError; | ||
63 | 47 | public abstract void raise () throws IOError; | ||
64 | 48 | } | ||
65 | 49 | |||
66 | 50 | public class ClementineActions: Object, Activatable, ItemProvider, ActionProvider | ||
67 | 51 | { | ||
68 | 52 | public bool enabled { get; set; default = true; } | ||
69 | 53 | |||
70 | 54 | public void activate () | ||
71 | 55 | { | ||
72 | 56 | } | ||
73 | 57 | |||
74 | 58 | public void deactivate () | ||
75 | 59 | { | ||
76 | 60 | } | ||
77 | 61 | |||
78 | 62 | static void register_plugin () | ||
79 | 63 | { | ||
80 | 64 | DataSink.PluginRegistry.get_default ().register_plugin ( | ||
81 | 65 | typeof (ClementineActions), | ||
82 | 66 | "Clementine", | ||
83 | 67 | _ ("Control Clementine media player."), | ||
84 | 68 | "clementine", | ||
85 | 69 | register_plugin, | ||
86 | 70 | Environment.find_program_in_path ("clementine") != null, | ||
87 | 71 | _ ("Clementine is not installed!") | ||
88 | 72 | ); | ||
89 | 73 | } | ||
90 | 74 | |||
91 | 75 | static construct | ||
92 | 76 | { | ||
93 | 77 | register_plugin (); | ||
94 | 78 | } | ||
95 | 79 | |||
96 | 80 | private abstract class ClementineAction: Object, Match | ||
97 | 81 | { | ||
98 | 82 | // from Match interface | ||
99 | 83 | public string title { get; construct set; } | ||
100 | 84 | public string description { get; set; } | ||
101 | 85 | public string icon_name { get; construct set; } | ||
102 | 86 | public bool has_thumbnail { get; construct set; } | ||
103 | 87 | public string thumbnail_path { get; construct set; } | ||
104 | 88 | public MatchType match_type { get; construct set; } | ||
105 | 89 | public int default_relevancy { get; set; } | ||
106 | 90 | |||
107 | 91 | public abstract bool valid_for_match (Match match); | ||
108 | 92 | public abstract void execute_internal (Match? match); | ||
109 | 93 | |||
110 | 94 | public void execute (Match? match) | ||
111 | 95 | { | ||
112 | 96 | execute_internal (match); | ||
113 | 97 | } | ||
114 | 98 | |||
115 | 99 | public virtual int get_relevancy () | ||
116 | 100 | { | ||
117 | 101 | bool clementine_running = DBusService.get_default ().name_has_owner ( | ||
118 | 102 | ClementinePlayer.UNIQUE_NAME); | ||
119 | 103 | return clementine_running ? default_relevancy + Match.Score.INCREMENT_LARGE : default_relevancy; | ||
120 | 104 | } | ||
121 | 105 | } | ||
122 | 106 | |||
123 | 107 | private abstract class ClementineControlMatch: Object, Match | ||
124 | 108 | { | ||
125 | 109 | // for Match interface | ||
126 | 110 | public string title { get; construct set; } | ||
127 | 111 | public string description { get; set; default = ""; } | ||
128 | 112 | public string icon_name { get; construct set; default = ""; } | ||
129 | 113 | public bool has_thumbnail { get; construct set; default = false; } | ||
130 | 114 | public string thumbnail_path { get; construct set; } | ||
131 | 115 | public MatchType match_type { get; construct set; } | ||
132 | 116 | |||
133 | 117 | public void execute (Match? match) | ||
134 | 118 | { | ||
135 | 119 | this.do_action (); | ||
136 | 120 | } | ||
137 | 121 | |||
138 | 122 | public abstract void do_action (); | ||
139 | 123 | |||
140 | 124 | public virtual bool action_available () | ||
141 | 125 | { | ||
142 | 126 | return DBusService.get_default ().name_has_owner ( | ||
143 | 127 | ClementinePlayer.UNIQUE_NAME | ||
144 | 128 | ); | ||
145 | 129 | } | ||
146 | 130 | } | ||
147 | 131 | |||
148 | 132 | /* MATCHES of Type.ACTION */ | ||
149 | 133 | private class Quit : ClementineControlMatch | ||
150 | 134 | { | ||
151 | 135 | public Quit () | ||
152 | 136 | { | ||
153 | 137 | Object (title: _ ("Quit"), | ||
154 | 138 | description: _ ("Quit Clementine"), | ||
155 | 139 | icon_name: "gtk-close", | ||
156 | 140 | has_thumbnail: false, | ||
157 | 141 | match_type: MatchType.ACTION | ||
158 | 142 | ); | ||
159 | 143 | } | ||
160 | 144 | |||
161 | 145 | public override void do_action () | ||
162 | 146 | { | ||
163 | 147 | try { | ||
164 | 148 | ClementineEngine player = Bus.get_proxy_sync (BusType.SESSION, | ||
165 | 149 | ClementineEngine.UNIQUE_NAME, | ||
166 | 150 | ClementineEngine.OBJECT_PATH); | ||
167 | 151 | player.quit (); | ||
168 | 152 | } catch (IOError e) { | ||
169 | 153 | Utils.Logger.warning (this, "Clementine is not available.\n%s", e.message); | ||
170 | 154 | } | ||
171 | 155 | } | ||
172 | 156 | } | ||
173 | 157 | |||
174 | 158 | private class Raise : ClementineControlMatch | ||
175 | 159 | { | ||
176 | 160 | public Raise () | ||
177 | 161 | { | ||
178 | 162 | Object (title: _ ("Raise"), | ||
179 | 163 | description: _ ("Show Clementine"), | ||
180 | 164 | icon_name: "clementine", | ||
181 | 165 | has_thumbnail: false, | ||
182 | 166 | match_type: MatchType.ACTION | ||
183 | 167 | ); | ||
184 | 168 | } | ||
185 | 169 | |||
186 | 170 | public override void do_action () | ||
187 | 171 | { | ||
188 | 172 | try { | ||
189 | 173 | ClementineEngine player = Bus.get_proxy_sync (BusType.SESSION, | ||
190 | 174 | ClementineEngine.UNIQUE_NAME, | ||
191 | 175 | ClementineEngine.OBJECT_PATH); | ||
192 | 176 | player.raise (); | ||
193 | 177 | } catch (IOError e) { | ||
194 | 178 | Utils.Logger.warning (this, "Clementine is not available.\n%s", e.message); | ||
195 | 179 | } | ||
196 | 180 | } | ||
197 | 181 | } | ||
198 | 182 | |||
199 | 183 | private class Play : ClementineControlMatch | ||
200 | 184 | { | ||
201 | 185 | public Play () | ||
202 | 186 | { | ||
203 | 187 | Object (title: _ ("Play"), | ||
204 | 188 | description: _ ("Start playback in Clementine"), | ||
205 | 189 | icon_name: "media-playback-start", | ||
206 | 190 | has_thumbnail: false, | ||
207 | 191 | match_type: MatchType.ACTION | ||
208 | 192 | ); | ||
209 | 193 | } | ||
210 | 194 | |||
211 | 195 | public override void do_action () | ||
212 | 196 | { | ||
213 | 197 | try { | ||
214 | 198 | ClementinePlayer player = Bus.get_proxy_sync (BusType.SESSION, | ||
215 | 199 | ClementinePlayer.UNIQUE_NAME, | ||
216 | 200 | ClementinePlayer.OBJECT_PATH); | ||
217 | 201 | player.play (); | ||
218 | 202 | } catch (IOError e) { | ||
219 | 203 | Utils.Logger.warning (this, "Clementine is not available.\n%s", e.message); | ||
220 | 204 | } | ||
221 | 205 | } | ||
222 | 206 | } | ||
223 | 207 | |||
224 | 208 | private class TogglePlaying : ClementineControlMatch | ||
225 | 209 | { | ||
226 | 210 | public TogglePlaying () | ||
227 | 211 | { | ||
228 | 212 | Object (title: _ ("TogglePlaying"), | ||
229 | 213 | description: _ ("Start/Pause playback in Clementine"), | ||
230 | 214 | icon_name: "media-playback-pause", | ||
231 | 215 | has_thumbnail: false, | ||
232 | 216 | match_type: MatchType.ACTION | ||
233 | 217 | ); | ||
234 | 218 | } | ||
235 | 219 | |||
236 | 220 | public override void do_action () | ||
237 | 221 | { | ||
238 | 222 | try { | ||
239 | 223 | ClementinePlayer player = Bus.get_proxy_sync (BusType.SESSION, | ||
240 | 224 | ClementinePlayer.UNIQUE_NAME, | ||
241 | 225 | ClementinePlayer.OBJECT_PATH); | ||
242 | 226 | player.play_pause (); | ||
243 | 227 | } catch (IOError e) { | ||
244 | 228 | Utils.Logger.warning (this, "Clementine is not available.\n%s", e.message); | ||
245 | 229 | } | ||
246 | 230 | } | ||
247 | 231 | |||
248 | 232 | public override bool action_available () | ||
249 | 233 | { | ||
250 | 234 | return true; | ||
251 | 235 | } | ||
252 | 236 | } | ||
253 | 237 | |||
254 | 238 | private class Pause : ClementineControlMatch | ||
255 | 239 | { | ||
256 | 240 | public Pause () | ||
257 | 241 | { | ||
258 | 242 | Object (title: _ ("Pause"), | ||
259 | 243 | description: _ ("Pause playback in Clementine"), | ||
260 | 244 | icon_name: "media-playback-pause", | ||
261 | 245 | has_thumbnail: false, | ||
262 | 246 | match_type: MatchType.ACTION | ||
263 | 247 | ); | ||
264 | 248 | } | ||
265 | 249 | |||
266 | 250 | public override void do_action () | ||
267 | 251 | { | ||
268 | 252 | try { | ||
269 | 253 | ClementinePlayer player = Bus.get_proxy_sync (BusType.SESSION, | ||
270 | 254 | ClementinePlayer.UNIQUE_NAME, | ||
271 | 255 | ClementinePlayer.OBJECT_PATH); | ||
272 | 256 | player.pause (); | ||
273 | 257 | } catch (IOError e) { | ||
274 | 258 | Utils.Logger.warning (this, "Clementine is not available.\n%s", e.message); | ||
275 | 259 | } | ||
276 | 260 | } | ||
277 | 261 | } | ||
278 | 262 | |||
279 | 263 | private class Next : ClementineControlMatch | ||
280 | 264 | { | ||
281 | 265 | public Next () | ||
282 | 266 | { | ||
283 | 267 | Object (title: _ ("Next"), | ||
284 | 268 | description: _ ("Plays the next song in Clementine's playlist"), | ||
285 | 269 | icon_name: "media-skip-forward", | ||
286 | 270 | has_thumbnail: false, | ||
287 | 271 | match_type: MatchType.ACTION | ||
288 | 272 | ); | ||
289 | 273 | } | ||
290 | 274 | |||
291 | 275 | public override void do_action () | ||
292 | 276 | { | ||
293 | 277 | try { | ||
294 | 278 | ClementinePlayer player = Bus.get_proxy_sync (BusType.SESSION, | ||
295 | 279 | ClementinePlayer.UNIQUE_NAME, | ||
296 | 280 | ClementinePlayer.OBJECT_PATH); | ||
297 | 281 | |||
298 | 282 | player.next (); | ||
299 | 283 | } catch (IOError e) { | ||
300 | 284 | Utils.Logger.warning (this, "Clementine is not available.\n%s", e.message); | ||
301 | 285 | } | ||
302 | 286 | } | ||
303 | 287 | } | ||
304 | 288 | |||
305 | 289 | private class Previous : ClementineControlMatch | ||
306 | 290 | { | ||
307 | 291 | public Previous () | ||
308 | 292 | { | ||
309 | 293 | Object (title: _ ("Previous"), | ||
310 | 294 | description: _ ("Plays the previous song in Clementine's playlist"), | ||
311 | 295 | icon_name: "media-skip-backward", | ||
312 | 296 | has_thumbnail: false, | ||
313 | 297 | match_type: MatchType.ACTION | ||
314 | 298 | ); | ||
315 | 299 | } | ||
316 | 300 | |||
317 | 301 | public override void do_action () | ||
318 | 302 | { | ||
319 | 303 | try { | ||
320 | 304 | ClementinePlayer player = Bus.get_proxy_sync (BusType.SESSION, | ||
321 | 305 | ClementinePlayer.UNIQUE_NAME, | ||
322 | 306 | ClementinePlayer.OBJECT_PATH); | ||
323 | 307 | player.previous (); | ||
324 | 308 | } catch (IOError e) { | ||
325 | 309 | Utils.Logger.warning (this, "Clementine is not available.\n%s", e.message); | ||
326 | 310 | } | ||
327 | 311 | } | ||
328 | 312 | } | ||
329 | 313 | |||
330 | 314 | private class Stop : ClementineControlMatch | ||
331 | 315 | { | ||
332 | 316 | public Stop () | ||
333 | 317 | { | ||
334 | 318 | Object (title: _ ("Stop"), | ||
335 | 319 | description: _ ("Stops the playback of Clementine"), | ||
336 | 320 | icon_name: "media-playback-stop", | ||
337 | 321 | has_thumbnail: false, | ||
338 | 322 | match_type: MatchType.ACTION | ||
339 | 323 | ); | ||
340 | 324 | } | ||
341 | 325 | |||
342 | 326 | public override void do_action () | ||
343 | 327 | { | ||
344 | 328 | try { | ||
345 | 329 | ClementinePlayer player = Bus.get_proxy_sync (BusType.SESSION, | ||
346 | 330 | ClementinePlayer.UNIQUE_NAME, | ||
347 | 331 | ClementinePlayer.OBJECT_PATH); | ||
348 | 332 | player.stop (); | ||
349 | 333 | } catch (IOError e) { | ||
350 | 334 | Utils.Logger.warning (this, "Clementine is not available.\n%s", e.message); | ||
351 | 335 | } | ||
352 | 336 | } | ||
353 | 337 | } | ||
354 | 338 | |||
355 | 339 | /* ACTIONS FOR MP3s */ | ||
356 | 340 | private class OpenUri: ClementineAction | ||
357 | 341 | { | ||
358 | 342 | public OpenUri () | ||
359 | 343 | { | ||
360 | 344 | Object (title: _ ("Play in Clementine"), | ||
361 | 345 | description: _ ("Queues and plays the song"), | ||
362 | 346 | icon_name: "media-playback-start", | ||
363 | 347 | has_thumbnail: false, | ||
364 | 348 | match_type: MatchType.ACTION, | ||
365 | 349 | default_relevancy: Match.Score.ABOVE_AVERAGE | ||
366 | 350 | ); | ||
367 | 351 | } | ||
368 | 352 | |||
369 | 353 | public override void execute_internal (Match? match) | ||
370 | 354 | { | ||
371 | 355 | return_if_fail (match.match_type == MatchType.GENERIC_URI); | ||
372 | 356 | UriMatch uri = match as UriMatch; | ||
373 | 357 | return_if_fail ((uri.file_type & QueryFlags.AUDIO) != 0 || | ||
374 | 358 | (uri.file_type & QueryFlags.VIDEO) != 0); | ||
375 | 359 | try { | ||
376 | 360 | ClementinePlayer player = Bus.get_proxy_sync (BusType.SESSION, | ||
377 | 361 | ClementinePlayer.UNIQUE_NAME, | ||
378 | 362 | ClementinePlayer.OBJECT_PATH); | ||
379 | 363 | player.open_uri (uri.uri); | ||
380 | 364 | player.play (); | ||
381 | 365 | } catch (IOError e) { | ||
382 | 366 | Utils.Logger.warning (this, "Clementine is not available.\n%s", e.message); | ||
383 | 367 | } | ||
384 | 368 | } | ||
385 | 369 | |||
386 | 370 | public override bool valid_for_match (Match match) | ||
387 | 371 | { | ||
388 | 372 | switch (match.match_type) | ||
389 | 373 | { | ||
390 | 374 | case MatchType.GENERIC_URI: | ||
391 | 375 | UriMatch uri = match as UriMatch; | ||
392 | 376 | if ((uri.file_type & QueryFlags.AUDIO) != 0 || | ||
393 | 377 | (uri.file_type & QueryFlags.VIDEO) != 0) | ||
394 | 378 | return true; | ||
395 | 379 | else | ||
396 | 380 | return false; | ||
397 | 381 | default: | ||
398 | 382 | return false; | ||
399 | 383 | } | ||
400 | 384 | } | ||
401 | 385 | } | ||
402 | 386 | |||
403 | 387 | private Gee.List<ClementineAction> actions; | ||
404 | 388 | private Gee.List<ClementineControlMatch> matches; | ||
405 | 389 | |||
406 | 390 | construct | ||
407 | 391 | { | ||
408 | 392 | actions = new Gee.ArrayList<ClementineAction> (); | ||
409 | 393 | matches = new Gee.ArrayList<ClementineControlMatch> (); | ||
410 | 394 | |||
411 | 395 | actions.add (new OpenUri()); | ||
412 | 396 | |||
413 | 397 | matches.add (new Raise ()); | ||
414 | 398 | matches.add (new Quit ()); | ||
415 | 399 | |||
416 | 400 | matches.add (new Play ()); | ||
417 | 401 | matches.add (new TogglePlaying ()); | ||
418 | 402 | matches.add (new Pause ()); | ||
419 | 403 | matches.add (new Stop ()); | ||
420 | 404 | matches.add (new Previous ()); | ||
421 | 405 | matches.add (new Next ()); | ||
422 | 406 | } | ||
423 | 407 | |||
424 | 408 | public async ResultSet? search (Query q) throws SearchError | ||
425 | 409 | { | ||
426 | 410 | // we only search for actions | ||
427 | 411 | if (!(QueryFlags.ACTIONS in q.query_type)) return null; | ||
428 | 412 | |||
429 | 413 | var result = new ResultSet (); | ||
430 | 414 | |||
431 | 415 | var matchers = Query.get_matchers_for_query (q.query_string, 0, | ||
432 | 416 | RegexCompileFlags.OPTIMIZE | RegexCompileFlags.CASELESS); | ||
433 | 417 | |||
434 | 418 | foreach (var action in matches) | ||
435 | 419 | { | ||
436 | 420 | if (!action.action_available ()) continue; | ||
437 | 421 | foreach (var matcher in matchers) | ||
438 | 422 | { | ||
439 | 423 | if (matcher.key.match (action.title)) | ||
440 | 424 | { | ||
441 | 425 | result.add (action, matcher.value - Match.Score.INCREMENT_SMALL); | ||
442 | 426 | break; | ||
443 | 427 | } | ||
444 | 428 | } | ||
445 | 429 | } | ||
446 | 430 | q.check_cancellable (); | ||
447 | 431 | return result; | ||
448 | 432 | } | ||
449 | 433 | |||
450 | 434 | public ResultSet? find_for_match (ref Query query, Match match) | ||
451 | 435 | { | ||
452 | 436 | bool query_empty = query.query_string == ""; | ||
453 | 437 | var results = new ResultSet (); | ||
454 | 438 | |||
455 | 439 | if (query_empty) | ||
456 | 440 | { | ||
457 | 441 | foreach (var action in actions) | ||
458 | 442 | { | ||
459 | 443 | if (action.valid_for_match (match)) | ||
460 | 444 | { | ||
461 | 445 | results.add (action, action.get_relevancy ()); | ||
462 | 446 | } | ||
463 | 447 | } | ||
464 | 448 | } | ||
465 | 449 | else | ||
466 | 450 | { | ||
467 | 451 | var matchers = Query.get_matchers_for_query (query.query_string, 0, | ||
468 | 452 | RegexCompileFlags.OPTIMIZE | RegexCompileFlags.CASELESS); | ||
469 | 453 | foreach (var action in actions) | ||
470 | 454 | { | ||
471 | 455 | if (!action.valid_for_match (match)) continue; | ||
472 | 456 | foreach (var matcher in matchers) | ||
473 | 457 | { | ||
474 | 458 | if (matcher.key.match (action.title)) | ||
475 | 459 | { | ||
476 | 460 | results.add (action, matcher.value); | ||
477 | 461 | break; | ||
478 | 462 | } | ||
479 | 463 | } | ||
480 | 464 | } | ||
481 | 465 | } | ||
482 | 466 | return results; | ||
483 | 467 | } | ||
484 | 468 | } | ||
485 | 469 | } | ||
486 | 0 | 470 | ||
487 | === modified file 'src/ui/synapse-main.vala' | |||
488 | --- src/ui/synapse-main.vala 2013-07-20 18:34:34 +0000 | |||
489 | +++ src/ui/synapse-main.vala 2013-11-18 21:23:46 +0000 | |||
490 | @@ -177,6 +177,7 @@ | |||
491 | 177 | typeof (SelectionPlugin), | 177 | typeof (SelectionPlugin), |
492 | 178 | typeof (SshPlugin), | 178 | typeof (SshPlugin), |
493 | 179 | typeof (XnoiseActions), | 179 | typeof (XnoiseActions), |
494 | 180 | typeof (ClementineActions), | ||
495 | 180 | // typeof (FileOpPlugin), | 181 | // typeof (FileOpPlugin), |
496 | 181 | // typeof (PidginPlugin), | 182 | // typeof (PidginPlugin), |
497 | 182 | // typeof (ChatActions), | 183 | // typeof (ChatActions), |
Code-wise this looks perfectly fine, but could use testing from someone who uses clementine... Any takers?