Merge lp:~donadigo/slingshot/fix-plug-launching into lp:~elementary-pantheon/slingshot/trunk

Proposed by Adam Bieńkowski on 2016-12-28
Status: Merged
Approved by: Corentin Noël on 2016-12-28
Approved revision: 712
Merged at revision: 711
Proposed branch: lp:~donadigo/slingshot/fix-plug-launching
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 94 lines (+26/-19)
2 files modified
lib/synapse-plugins/switchboard-plugin.vala (+17/-15)
src/Widgets/SearchView.vala (+9/-4)
To merge this branch: bzr merge lp:~donadigo/slingshot/fix-plug-launching
Reviewer Review Type Date Requested Status
elementary Pantheon team 2016-12-28 Pending
Review via email: mp+313901@code.launchpad.net

Commit message

* Fix switchboard plugs not launching

Description of the change

This branch fixes bug #1643014: "Switchboard plugs doesn't start from slingshot".

The implementation uses the first key from the supported_settings TreeMap, if the map is null, or there are no items in it, slingshot won't show it.

Note that some plugs won't be shown / supported until they implement supported settings properly.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/synapse-plugins/switchboard-plugin.vala'
2--- lib/synapse-plugins/switchboard-plugin.vala 2015-06-03 19:10:24 +0000
3+++ lib/synapse-plugins/switchboard-plugin.vala 2016-12-28 16:23:18 +0000
4@@ -36,7 +36,7 @@
5
6 }
7
8- public class SwitchboardObject: Object, Match, ApplicationMatch {
9+ public class SwitchboardObject: Object, Match {
10 // for Match interface
11 public string title { get; construct set; }
12 public string description { get; set; default = ""; }
13@@ -45,22 +45,16 @@
14 public string thumbnail_path { get; construct set; }
15 public MatchType match_type { get; construct set; }
16
17- // for ApplicationMatch
18- public AppInfo? app_info { get; set; default = null; }
19- public bool needs_terminal { get; set; default = false; }
20- public string? filename { get; construct set; default = null; }
21 public string plug { get; construct set; }
22+ public string uri { get; construct set; }
23
24 public SwitchboardObject (PlugInfo plug_info) {
25 Object (title: plug_info.title, description: _ ("Open %s settings").printf (plug_info.title),
26- plug: plug_info.code_name, icon_name: plug_info.icon, match_type: MatchType.APPLICATION);
27+ plug: plug_info.code_name, icon_name: plug_info.icon, match_type: MatchType.APPLICATION, uri: plug_info.uri);
28+ }
29
30- try {
31- var cmd = "/usr/bin/switchboard -o %s".printf (plug_info.code_name);
32- app_info = AppInfo.create_from_commandline (cmd, null, 0);
33- } catch (Error err) {
34- warning ("%s", err.message);
35- }
36+ public void execute (Match? match) {
37+ Gtk.show_uri (null, "settings://%s".printf (uri), Gdk.CURRENT_TIME);
38 }
39 }
40
41@@ -88,9 +82,10 @@
42 public string title { get; construct set; }
43 public string code_name { get; construct set; }
44 public string icon { get; construct set; }
45+ public string uri { get; construct set; }
46
47- public PlugInfo (string plug_title, string code_name, string icon) {
48- Object (title: plug_title, code_name: code_name, icon: icon);
49+ public PlugInfo (string plug_title, string code_name, string icon, string uri) {
50+ Object (title: plug_title, code_name: code_name, icon: icon, uri: uri);
51 }
52 }
53
54@@ -103,8 +98,15 @@
55 yield;
56
57 foreach (var plug in Switchboard.PlugsManager.get_default ().get_plugs ()) {
58- plugs.add (new PlugInfo (plug.display_name, plug.code_name, plug.icon));
59+ var settings = plug.supported_settings;
60+ if (settings == null || settings.size <= 0) {
61+ continue;
62+ }
63+
64+ string uri = settings.keys.to_array ()[0];
65+ plugs.add (new PlugInfo (plug.display_name, plug.code_name, plug.icon, uri));
66 }
67+
68 loading_in_progress = false;
69 load_complete ();
70 }
71
72=== modified file 'src/Widgets/SearchView.vala'
73--- src/Widgets/SearchView.vala 2016-07-05 20:18:20 +0000
74+++ src/Widgets/SearchView.vala 2016-12-28 16:23:18 +0000
75@@ -53,10 +53,15 @@
76 list_box.row_activated.connect ((row) => {
77 var search_item = row as SearchItem;
78 if (!dragging) {
79- if (search_item.result_type == SearchItem.ResultType.APP_ACTIONS || search_item.result_type == SearchItem.ResultType.LINK) {
80- search_item.app.match.execute (null);
81- } else {
82- search_item.app.launch ();
83+ switch (search_item.result_type) {
84+ case SearchItem.ResultType.APP_ACTIONS:
85+ case SearchItem.ResultType.LINK:
86+ case SearchItem.ResultType.SETTINGS:
87+ search_item.app.match.execute (null);
88+ break;
89+ default:
90+ search_item.app.launch ();
91+ break;
92 }
93
94 app_launched ();

Subscribers

People subscribed via source and target branches