Merge lp:~mhr3/unity-lens-applications/use-sources into lp:unity-lens-applications
- use-sources
- Merge into trunk
Proposed by
Michal Hruby
Status: | Superseded |
---|---|
Proposed branch: | lp:~mhr3/unity-lens-applications/use-sources |
Merge into: | lp:unity-lens-applications |
Diff against target: |
336 lines (+99/-38) 3 files modified
data/com.canonical.Unity.AppsLens.gschema.xml.in.in (+3/-3) src/daemon.vala (+95/-34) src/schemas.vala (+1/-1) |
To merge this branch: | bzr merge lp:~mhr3/unity-lens-applications/use-sources |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity Team | Pending | ||
Review via email: mp+88222@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-01-12.
Commit message
Description of the change
Make the apps lens scope provide sources.
To post a comment you must log in.
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'data/com.canonical.Unity.AppsLens.gschema.xml.in.in' |
2 | --- data/com.canonical.Unity.AppsLens.gschema.xml.in.in 2011-11-15 13:41:30 +0000 |
3 | +++ data/com.canonical.Unity.AppsLens.gschema.xml.in.in 2012-01-12 10:56:28 +0000 |
4 | @@ -5,10 +5,10 @@ |
5 | <summary>Display Apps Available for Download in the Applications lens.</summary> |
6 | <description>Display Apps Available for Download in the Applications lens.</description> |
7 | </key> |
8 | - <key type="b" name="display-most-used-apps"> |
9 | + <key type="b" name="display-recent-apps"> |
10 | <default>true</default> |
11 | - <summary>Display Most Used Apps in the Applications lens.</summary> |
12 | - <description>Display Most Used Apps in the Applications lens.</description> |
13 | + <summary>Display Recently Used apps in the Applications lens.</summary> |
14 | + <description>Display Recently Used Apps in the Applications lens.</description> |
15 | </key> |
16 | </schema> |
17 | <schema path="/desktop/unity/runner/" id="com.canonical.Unity.Runner" gettext-domain="unity-lens-applications"> |
18 | |
19 | === modified file 'src/daemon.vala' |
20 | --- src/daemon.vala 2011-12-07 16:21:04 +0000 |
21 | +++ src/daemon.vala 2012-01-12 10:56:28 +0000 |
22 | @@ -32,6 +32,7 @@ |
23 | { |
24 | private Zeitgeist.Log log; |
25 | private Zeitgeist.Index zg_index; |
26 | + private Zeitgeist.Monitor monitor; |
27 | |
28 | /* The searcher for online material may be null if it fails to load |
29 | * the Xapian index from the Software Center */ |
30 | @@ -46,6 +47,10 @@ |
31 | |
32 | private Unity.ApplicationsLens.Runner runner; |
33 | |
34 | + /* Keep references to the FilterOptions for sources */ |
35 | + private FilterOption local_apps_option; |
36 | + private FilterOption usc_apps_option; |
37 | + |
38 | /* For each section we have a set filtering query we use to restrict |
39 | * Xapian queries to that type */ |
40 | private HashTable<string, string> type_queries; |
41 | @@ -53,8 +58,9 @@ |
42 | private Gee.List<string> image_extensions; |
43 | private HashTable<string,Icon> file_icon_cache; |
44 | |
45 | - /* We remember the previous search so we can figure out if we should do |
46 | - * incremental filtering of the result models */ |
47 | + /* Monitor the favorite apps in the launcher, so we can filter them |
48 | + * out of the results for Recent Apps */ |
49 | + private Unity.LauncherFavorites favorite_apps; |
50 | |
51 | private PtrArray zg_templates; |
52 | |
53 | @@ -66,10 +72,10 @@ |
54 | |
55 | private Settings gp_settings; |
56 | |
57 | - private const string DISPLAY_MOST_USED_APPS_KEY = "display-most-used-apps"; |
58 | + private const string DISPLAY_RECENT_APPS_KEY = "display-recent-apps"; |
59 | private const string DISPLAY_AVAILABLE_APPS_KEY = "display-available-apps"; |
60 | |
61 | - public bool display_most_used_apps { get; set; default = true; } |
62 | + public bool display_recent_apps { get; set; default = true; } |
63 | public bool display_available_apps { get; set; default = true; } |
64 | |
65 | construct |
66 | @@ -79,9 +85,14 @@ |
67 | |
68 | log = new Zeitgeist.Log(); |
69 | zg_index = new Zeitgeist.Index(); |
70 | + monitor = new Zeitgeist.Monitor (new Zeitgeist.TimeRange.from_now (), |
71 | + zg_templates); |
72 | + monitor.events_inserted.connect (on_zeitgeist_changed); |
73 | + monitor.events_deleted.connect (on_zeitgeist_changed); |
74 | + log.install_monitor (monitor); |
75 | |
76 | this.gp_settings = new Settings ("com.canonical.Unity.ApplicationsLens"); |
77 | - this.gp_settings.bind(DISPLAY_MOST_USED_APPS_KEY, this, "display_most_used_apps", SettingsBindFlags.GET); |
78 | + this.gp_settings.bind(DISPLAY_RECENT_APPS_KEY, this, "display_recent_apps", SettingsBindFlags.GET); |
79 | this.gp_settings.bind(DISPLAY_AVAILABLE_APPS_KEY, this, "display_available_apps", SettingsBindFlags.GET); |
80 | |
81 | pkgsearcher = new Unity.Package.Searcher (); |
82 | @@ -106,14 +117,24 @@ |
83 | image_extensions.add ("ico"); |
84 | image_extensions.add ("tif"); |
85 | image_extensions.add ("jpg"); |
86 | - |
87 | + |
88 | build_app_menu_index (); |
89 | - |
90 | + |
91 | file_icon_cache = new HashTable<string,Icon>(str_hash, str_equal); |
92 | |
93 | scope = new Unity.Scope ("/com/canonical/unity/scope/applications"); |
94 | //scope.icon = @"$(Config.PREFIX)/share/unity/themes/applications.png"; |
95 | - |
96 | + |
97 | + // TRANSLATORS: Please make sure this string is short enough to fit |
98 | + // into the filter button |
99 | + local_apps_option = scope.sources.add_option ("local", _("Local Apps")); |
100 | + if (display_available_apps) |
101 | + { |
102 | + // TRANSLATORS: Please make sure this string is short enough to fit |
103 | + // into the filter button |
104 | + usc_apps_option = scope.sources.add_option ("usc", _("Software Center")); |
105 | + } |
106 | + |
107 | scope.generate_search_key.connect ((lens_search) => |
108 | { |
109 | return lens_search.search_string.strip (); |
110 | @@ -133,6 +154,12 @@ |
111 | scope.queue_search_changed (SearchType.DEFAULT); |
112 | }); |
113 | |
114 | + /* And also if the sources change */ |
115 | + scope.active_sources_changed.connect (() => |
116 | + { |
117 | + scope.queue_search_changed (SearchType.DEFAULT); |
118 | + }); |
119 | + |
120 | scope.activate_uri.connect (activate); |
121 | |
122 | /* Listen for changes in the installed applications */ |
123 | @@ -147,11 +174,14 @@ |
124 | uri_regex = null; |
125 | critical ("Failed to compile URI regex. URL launching will be disabled"); |
126 | } |
127 | - |
128 | + |
129 | + favorite_apps = Unity.LauncherFavorites.get_default (); |
130 | + |
131 | lens = new Unity.Lens ("/com/canonical/unity/lens/applications", "applications"); |
132 | lens.search_hint = _("Search Applications"); |
133 | lens.visible = true; |
134 | lens.search_in_global = true; |
135 | + lens.sources_display_name = _("Sources"); |
136 | populate_categories (); |
137 | populate_filters(); |
138 | lens.add_local_scope (scope); |
139 | @@ -184,8 +214,8 @@ |
140 | GLib.List<Unity.Category> categories = new GLib.List<Unity.Category> (); |
141 | File icon_dir = File.new_for_path (ICON_PATH); |
142 | |
143 | - var cat = new Unity.Category (_("Most Frequently Used"), |
144 | - new FileIcon (icon_dir.get_child ("group-mostused.svg"))); |
145 | + var cat = new Unity.Category (_("Recently Used"), |
146 | + new FileIcon (icon_dir.get_child ("group-recent.svg"))); |
147 | categories.append (cat); |
148 | |
149 | cat = new Unity.Category (_("Installed"), |
150 | @@ -233,6 +263,20 @@ |
151 | |
152 | lens.filters = filters; |
153 | } |
154 | + |
155 | + private bool local_apps_active () |
156 | + { |
157 | + if (scope.sources.filtering && local_apps_option != null) |
158 | + return local_apps_option.active; |
159 | + return true; |
160 | + } |
161 | + |
162 | + private bool usc_apps_active () |
163 | + { |
164 | + if (scope.sources.filtering && usc_apps_option != null) |
165 | + return usc_apps_option.active; |
166 | + return true; |
167 | + } |
168 | |
169 | /* Load xdg menu info and build a Xapian index over it. |
170 | * Do throttled re-index if the menu changes */ |
171 | @@ -288,13 +332,18 @@ |
172 | /* Create a template that activation of applications */ |
173 | zg_templates = new PtrArray.sized(1); |
174 | var ev = new Zeitgeist.Event.full (ZG_ACCESS_EVENT, ZG_USER_ACTIVITY, "", |
175 | - new Subject.full ("application://*", |
176 | + new Subject.full ("application*", |
177 | "", //NFO_SOFTWARE, |
178 | "", |
179 | "", "", "", "")); |
180 | zg_templates.add ((ev as GLib.Object).ref()); |
181 | } |
182 | |
183 | + private void on_zeitgeist_changed () |
184 | + { |
185 | + scope.invalidate_search (SearchType.DEFAULT); |
186 | + } |
187 | + |
188 | private string prepare_zg_search_string (Unity.LensSearch? search, |
189 | string type_id="all") |
190 | { |
191 | @@ -341,27 +390,28 @@ |
192 | |
193 | var zg_search_string = prepare_zg_search_string (search, type_id); |
194 | |
195 | + var transaction = new Dee.Transaction (model); |
196 | + transaction.clear (); |
197 | + |
198 | /* Even though the Installed apps search is super fast, we wait here |
199 | * for the Most Popular search to finish, because otherwise we'll update |
200 | * the Installed category too soon and this will cause flicker |
201 | * in the Dash. (lp:868192) */ |
202 | |
203 | - if (this.display_most_used_apps) { |
204 | + if (local_apps_active () && display_recent_apps) { |
205 | try { |
206 | - debug ("SEARCH_STRING: %s", zg_search_string); |
207 | var results = yield zg_index.search (zg_search_string, |
208 | new Zeitgeist.TimeRange.anytime(), |
209 | zg_templates, |
210 | - Zeitgeist.StorageState.ANY, |
211 | + 0, |
212 | 20, |
213 | - Zeitgeist.ResultType.MOST_POPULAR_SUBJECTS, |
214 | + Zeitgeist.ResultType.MOST_RECENT_SUBJECTS, |
215 | cancellable); |
216 | |
217 | - model.clear (); |
218 | - append_events_with_category (results, model, Category.MOST_USED); |
219 | - |
220 | + append_events_with_category (results, transaction, Category.RECENT, has_search); |
221 | + |
222 | timer.stop (); |
223 | - debug ("Entry search found %u/%u Most Used apps in %fms for query '%s'", |
224 | + debug ("Entry search found %u/%u Recently Used apps in %fms for query '%s'", |
225 | results.size (), results.estimated_matches (), |
226 | timer.elapsed()*1000, zg_search_string); |
227 | |
228 | @@ -371,12 +421,11 @@ |
229 | } catch (GLib.Error e) { |
230 | warning ("Error performing search '%s': %s", |
231 | search.search_string, e.message); |
232 | - model.clear (); |
233 | } |
234 | - } else { |
235 | - model.clear (); |
236 | } |
237 | |
238 | + transaction.commit (); |
239 | + |
240 | timer.start (); |
241 | Set<string> installed_uris = new HashSet<string> (); |
242 | Set<string> available_uris = new HashSet<string> (); |
243 | @@ -385,15 +434,20 @@ |
244 | has_search ? |
245 | Unity.Package.Sort.BY_RELEVANCY : |
246 | Unity.Package.Sort.BY_NAME); |
247 | - add_pkg_search_result (appresults, installed_uris, available_uris, model, |
248 | - Category.INSTALLED); |
249 | - |
250 | + if (local_apps_active ()) |
251 | + { |
252 | + add_pkg_search_result (appresults, installed_uris, available_uris, |
253 | + model, Category.INSTALLED); |
254 | + } |
255 | + |
256 | timer.stop (); |
257 | debug ("Entry search listed %i Installed apps in %fms for query: %s", |
258 | appresults.num_hits, timer.elapsed ()*1000, pkg_search_string); |
259 | |
260 | /* If we don't have a search we display 6 random apps */ |
261 | - if (has_search && this.display_available_apps && pkgsearcher != null) |
262 | + if (usc_apps_active () && display_available_apps && pkgsearcher != null) |
263 | + { |
264 | + if (has_search) |
265 | { |
266 | timer.start (); |
267 | var pkgresults = pkgsearcher.search (pkg_search_string, 50, |
268 | @@ -405,7 +459,7 @@ |
269 | debug ("Entry search listed %i Available apps in %fms for query: %s", |
270 | pkgresults.num_hits, timer.elapsed ()*1000, pkg_search_string); |
271 | } |
272 | - else if (this.display_available_apps && pkgsearcher != null) |
273 | + else |
274 | { |
275 | timer.start (); |
276 | string? filter_query = prepare_pkg_search_string (null, type_id); |
277 | @@ -416,7 +470,8 @@ |
278 | debug ("Entry search listed %i random Available apps in %fms", |
279 | random_pkgresults.num_hits, timer.elapsed ()*1000); |
280 | } |
281 | - |
282 | + } |
283 | + |
284 | search.finished (); |
285 | } |
286 | |
287 | @@ -745,8 +800,9 @@ |
288 | /* Appends the subject URIs from a set of Zeitgeist.Events to our Dee.Model |
289 | * assuming that these events are already sorted */ |
290 | public void append_events_with_category (Zeitgeist.ResultSet events, |
291 | - Dee.Model results, |
292 | - uint category_id) |
293 | + Dee.Model results, |
294 | + uint category_id, |
295 | + bool include_favorites) |
296 | { |
297 | foreach (var ev in events) |
298 | { |
299 | @@ -761,7 +817,12 @@ |
300 | |
301 | /* Assert that we indeed have a known application as actor */ |
302 | string desktop_id = Utils.get_desktop_id_for_actor (app_uri); |
303 | - string full_path; |
304 | + |
305 | + /* Discard Recently Used apps that are in the launcher */ |
306 | + if (category_id == Category.RECENT && |
307 | + !include_favorites && |
308 | + favorite_apps.has_app_id (desktop_id)) |
309 | + continue; |
310 | |
311 | var appmanager = AppInfoManager.get_default (); |
312 | AppInfo? app = appmanager.lookup (desktop_id); |
313 | @@ -771,8 +832,8 @@ |
314 | |
315 | if (!app.should_show ()) |
316 | continue; |
317 | - |
318 | - full_path = appmanager.get_path (desktop_id); |
319 | + |
320 | + string full_path = appmanager.get_path (desktop_id); |
321 | string full_uri = full_path != null ? "file://" + full_path : app_uri; |
322 | |
323 | results.append (app_uri, app.get_icon().to_string(), category_id, |
324 | |
325 | === modified file 'src/schemas.vala' |
326 | --- src/schemas.vala 2011-08-04 07:27:33 +0000 |
327 | +++ src/schemas.vala 2012-01-12 10:56:28 +0000 |
328 | @@ -31,7 +31,7 @@ |
329 | |
330 | public enum Category |
331 | { |
332 | - MOST_USED, |
333 | + RECENT, |
334 | INSTALLED, |
335 | AVAILABLE, |
336 | EMPTY_SEARCH, |