Merge lp:~didrocks/unity-lens-applications/aboutconfig into lp:unity-lens-applications

Proposed by Didier Roche on 2011-03-17
Status: Merged
Merged at revision: 178
Proposed branch: lp:~didrocks/unity-lens-applications/aboutconfig
Merge into: lp:unity-lens-applications
Diff against target: 173 lines (+69/-15)
1 file modified
src/runner.vala (+69/-15)
To merge this branch: bzr merge lp:~didrocks/unity-lens-applications/aboutconfig
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) 2011-03-17 Approve on 2011-03-17
Review via email: mp+53793@code.launchpad.net

Description of the change

about:config will launch and store in history ccsm -p unityshell (LP: #736765)

To post a comment you must log in.

I agree that it could be nice with an about: namespace that can trigger certain built in actions.

However, before I merge this i'd rather see a more generic implementation where we can easily add/remove stuff under about:. Having a specific hack only for about:config seems well... a hack :-)

Fx. like adding a

private class AboutEntry {
  public string name;
  public string exec;
  public Icon icon;
}

Store them in a list or map and then in get_icon_uri_and_mimetype() check all registered AboutEntries or something...

review: Needs Fixing
180. By Didier Roche on 2011-03-17

enable later extension creating a map of AboutEntry

Didier Roche (didrocks) wrote :

repropose with a map and some extensions :)

review: Approve

Merged with a pedantic nullity-fix:

- AboutEntry entry = null;
+ AboutEntry? entry = null;

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/runner.vala'
2--- src/runner.vala 2011-03-11 18:03:48 +0000
3+++ src/runner.vala 2011-03-17 12:43:32 +0000
4@@ -23,6 +23,19 @@
5
6 namespace Unity.ApplicationsPlace {
7
8+ private class AboutEntry {
9+ public string name;
10+ public string exec;
11+ public Icon icon;
12+
13+ public AboutEntry (string name, string exec, Icon icon)
14+ {
15+ this.name = name;
16+ this.exec = exec;
17+ this.icon = icon;
18+ }
19+ }
20+
21 public class Runner: GLib.Object
22 {
23
24@@ -41,6 +54,7 @@
25 * incremental filtering of the result models */
26 private PlaceSearch? previous_search;
27
28+ private Gee.HashMap<string,AboutEntry> about_entries;
29 private Gee.List<string> executables;
30 private Gee.List<string> history;
31
32@@ -64,6 +78,10 @@
33
34 previous_search = null;
35
36+ /* create the private about entries */
37+ about_entries = new Gee.HashMap<string,AboutEntry> ();
38+ load_about_entries ();
39+
40 executables = new Gee.ArrayList<string> ();
41 find_system_executables.begin ();
42
43@@ -111,15 +129,15 @@
44 string uri;
45 Icon icon;
46 string mimetype;
47+ string display_name;
48 var group_id = RunnerGroup.HISTORY;
49
50 foreach (var command in this.history)
51 {
52- uri = @"unity-runner://$(command)";
53- get_icon_and_mimetype (command, out icon, out mimetype);
54+ display_name = get_icon_uri_and_mimetype (command, out icon, out uri, out mimetype);
55 model.append (uri, icon.to_string (),
56 group_id, mimetype,
57- command,
58+ display_name,
59 null);
60 }
61
62@@ -231,11 +249,10 @@
63
64 // populate results
65 // 1. enable launching the exact search string
66- uri = @"unity-runner://$(search_string)";
67- get_icon_and_mimetype (search_string, out icon, out mimetype);
68+ display_name = get_icon_uri_and_mimetype (search_string, out icon, out uri, out mimetype);
69 model.append (uri, icon.to_string (),
70 group_id, mimetype,
71- search_string,
72+ display_name,
73 null);
74
75 // 2. add possible directories (we don't store them)
76@@ -255,11 +272,11 @@
77 {
78 // TODO: try to match to a desktop file for the icon
79 uri = @"unity-runner://$(final_exec)";
80- get_icon_and_mimetype (final_exec, out icon, out mimetype);
81+ display_name = get_icon_uri_and_mimetype (final_exec, out icon, out uri, out mimetype);
82
83 model.append (uri, icon.to_string (),
84 group_id, mimetype,
85- final_exec,
86+ display_name,
87 null);
88 }
89
90@@ -316,19 +333,30 @@
91 }
92 }
93
94- private void get_icon_and_mimetype (string exec_string, out Icon? icon, out string? mimetype)
95+ private string get_icon_uri_and_mimetype (string exec_string, out Icon? icon, out string? uri, out string? mimetype)
96 {
97-
98+
99+ AboutEntry entry = null;
100+
101+ mimetype = "application/x-unity-run";
102+ entry = about_entries[exec_string];
103+ if (entry != null)
104+ {
105+ uri = @"unity-runner://$(entry.exec)";
106+ icon = entry.icon;
107+ return entry.name;
108+ }
109+
110+ uri = @"unity-runner://$(exec_string)";
111+
112+
113 // if it's a folder, show… a folder icone! + right exec
114 if (FileUtils.test (exec_string, FileTest.IS_DIR))
115 {
116 mimetype = "inode/directory";
117 icon = ContentType.get_icon (mimetype);
118- return;
119+ return exec_string;
120 }
121-
122- mimetype = "application/x-unity-run";
123-
124
125 var s = exec_string.delimit ("-", '_').split (" ", 0)[0];
126 var appresults = this.daemon.appsearcher.search (@"type:Application AND exec:$s", 0,
127@@ -342,12 +370,13 @@
128
129 // pick the first one
130 icon = this.daemon.find_pkg_icon (pkginfo);
131- return;
132+ return exec_string;
133
134 }
135
136 // if no result, default icon
137 icon = new ThemedIcon ("gtk-execute");
138+ return exec_string;
139
140 }
141
142@@ -451,6 +480,31 @@
143 warning ("Can't access to the history: %s", e.message);
144 }
145 }
146+
147+ private void load_about_entries ()
148+ {
149+ AboutEntry entry;
150+ string name;
151+ string exec;
152+ Icon icon;
153+
154+ // first about:config
155+ name = "about:config";
156+ exec = "ccsm -p unityshell";
157+ try {
158+ icon = Icon.new_for_string (@"$(Config.PREFIX)/share/ccsm/icons/hicolor/64x64/apps/plugin-unityshell.png");
159+ }
160+ catch (Error err) {
161+ warning ("Can't find unityshell icon: %s", err.message);
162+ icon = new ThemedIcon ("gtk-execute");
163+ }
164+ entry = new AboutEntry (name, exec, icon);
165+
166+ about_entries[name] = entry;
167+ about_entries[exec] = entry;
168+
169+ }
170+
171 }
172
173 }

Subscribers

People subscribed via source and target branches