Merge lp:~mhr3/unity-lens-applications/fix-1220717 into lp:unity-lens-applications

Proposed by Michal Hruby
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 368
Merged at revision: 367
Proposed branch: lp:~mhr3/unity-lens-applications/fix-1220717
Merge into: lp:unity-lens-applications
Diff against target: 102 lines (+23/-5)
3 files modified
configure.ac (+1/-1)
debian/control (+1/-1)
src/scopes-scope.vala (+21/-3)
To merge this branch: bzr merge lp:~mhr3/unity-lens-applications/fix-1220717
Reviewer Review Type Date Requested Status
Paweł Stołowski (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+184289@code.launchpad.net

Commit message

Do not show home scope and scopes scope in the list of dash plugins, this will ensure that you can't disable scopes without a way to re-enable them.

Description of the change

Do not show home scope and scopes scope in the list of dash plugins, this will ensure that you can't disable scopes without a way to re-enable them.

Also adds possibility for OEMs to lock some scopes (make them permanently enabled or disabled).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
368. By Michal Hruby

Bump version requirement on libunity

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Paweł Stołowski (stolowski) wrote :

46 + public HashTable<string, bool> locked_scope_ids;

A Gee.Set would be better, or even just string[], since it's a lookup we only perform on a preview.

Apart from that it looks fine.

review: Needs Fixing
Revision history for this message
Michal Hruby (mhr3) wrote :

> 46 + public HashTable<string, bool> locked_scope_ids;
>
> A Gee.Set would be better, or even just string[], since it's a lookup we only
> perform on a preview.
>
> Apart from that it looks fine.

I rather avoid Gee classes unless completely necessary, using only GLib containers wasn't easy in early versions of Vala, but we passed that time long time ago. Moreover the docs for hash table say:

A common use-case for hash tables is to store information about a set of keys, without associating any particular value with each key. GHashTable optimizes one way of doing so: If you store only key-value pairs where key == value, then GHashTable does not allocate memory to store the values, which can be a considerable space saving, if your set is large.

Still, I don't think this use-case falls into the "if set is large" category, plus having pretty much constant lookup time is always nice (as opposed to linear with string[]).

Revision history for this message
Paweł Stołowski (stolowski) wrote :

Ok then.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'configure.ac'
--- configure.ac 2013-08-29 11:01:54 +0000
+++ configure.ac 2013-09-06 15:12:10 +0000
@@ -78,7 +78,7 @@
78 dee-1.0 >= 0.5.1678 dee-1.0 >= 0.5.16
79 zeitgeist-1.0 >= 0.3.879 zeitgeist-1.0 >= 0.3.8
80 libcolumbus >= 1.0.080 libcolumbus >= 1.0.0
81 unity >= 7.1.081 unity >= 7.1.1
82 unity-protocol-private82 unity-protocol-private
83 libgnome-menu-3.0 >= 3.6.0)83 libgnome-menu-3.0 >= 3.6.0)
8484
8585
=== modified file 'debian/control'
--- debian/control 2013-08-29 11:01:54 +0000
+++ debian/control 2013-09-06 15:12:10 +0000
@@ -11,7 +11,7 @@
11 libgee-dev,11 libgee-dev,
12 libdee-dev (>= 0.5.16),12 libdee-dev (>= 0.5.16),
13 libzeitgeist-dev (>= 0.3.8),13 libzeitgeist-dev (>= 0.3.8),
14 libunity-dev (>= 7.1.0),14 libunity-dev (>= 7.1.1),
15 libgnome-menu-3-dev,15 libgnome-menu-3-dev,
16 dh-autoreconf,16 dh-autoreconf,
17 libxapian-dev,17 libxapian-dev,
1818
=== modified file 'src/scopes-scope.vala'
--- src/scopes-scope.vala 2013-08-28 11:43:15 +0000
+++ src/scopes-scope.vala 2013-09-06 15:12:10 +0000
@@ -20,6 +20,11 @@
2020
21namespace Unity.ApplicationsLens {21namespace Unity.ApplicationsLens {
22 const string GENERIC_SCOPE_ICON = ICON_PATH + "service-generic.svg";22 const string GENERIC_SCOPE_ICON = ICON_PATH + "service-generic.svg";
23 const string[] invisible_scope_ids =
24 {
25 "home.scope",
26 "applications-scopes.scope",
27 };
2328
24 private class ScopesScope : Unity.AbstractScope29 private class ScopesScope : Unity.AbstractScope
25 {30 {
@@ -30,6 +35,8 @@
30 public Dee.Index scopes_index;35 public Dee.Index scopes_index;
31 public Dee.Analyzer analyzer;36 public Dee.Analyzer analyzer;
3237
38 public HashTable<string, bool> locked_scope_ids;
39
33 public ScopesScope (ApplicationsScope appscope)40 public ScopesScope (ApplicationsScope appscope)
34 {41 {
35 this.appscope = appscope;42 this.appscope = appscope;
@@ -52,6 +59,13 @@
52 var pref_man = PreferencesManager.get_default ();59 var pref_man = PreferencesManager.get_default ();
53 pref_man.notify["disabled-scopes"].connect (update_disabled_scopes_hash);60 pref_man.notify["disabled-scopes"].connect (update_disabled_scopes_hash);
5461
62 locked_scope_ids = new HashTable<string, bool> (str_hash, str_equal);
63 var settings = new Settings (LIBUNITY_SCHEMA);
64 foreach (unowned string scope_id in settings.get_strv ("locked-scopes"))
65 {
66 locked_scope_ids[scope_id] = true;
67 }
68
55 build_scope_index.begin ();69 build_scope_index.begin ();
56 }70 }
5771
@@ -188,6 +202,7 @@
188202
189 public override Unity.ActivationResponse? activate (Unity.ScopeResult result, Unity.SearchMetadata metadata, string? action_id)203 public override Unity.ActivationResponse? activate (Unity.ScopeResult result, Unity.SearchMetadata metadata, string? action_id)
190 {204 {
205 // uris are "scope://scope_id.scope"
191 var scope_id = result.uri.substring (8);206 var scope_id = result.uri.substring (8);
192 if (action_id == "enable-scope")207 if (action_id == "enable-scope")
193 {208 {
@@ -301,6 +316,9 @@
301 if (info.is_master_scope)316 if (info.is_master_scope)
302 continue;317 continue;
303318
319 if (info.desktop_file in invisible_scope_ids)
320 continue;
321
304 bool is_disabled = info.desktop_file in scope.disabled_scope_ids;322 bool is_disabled = info.desktop_file in scope.disabled_scope_ids;
305 var result = Unity.ScopeResult ();323 var result = Unity.ScopeResult ();
306 result.uri = @"scope://$(info.desktop_file)";324 result.uri = @"scope://$(info.desktop_file)";
@@ -386,6 +404,7 @@
386 private async Unity.AbstractPreview? make_preview ()404 private async Unity.AbstractPreview? make_preview ()
387 {405 {
388 Unity.ApplicationPreview? preview = null;406 Unity.ApplicationPreview? preview = null;
407 // uris are "scope://scope_id.scope"
389 var scope_id = result.uri.substring (8);408 var scope_id = result.uri.substring (8);
390 bool scope_disabled = scope_id in scope.disabled_scope_ids;409 bool scope_disabled = scope_id in scope.disabled_scope_ids;
391410
@@ -482,9 +501,8 @@
482 icon,501 icon,
483 screenshot);502 screenshot);
484 }503 }
485 if (preview != null && scope_id != "home.scope" &&504 if (preview != null && !(scope_id in invisible_scope_ids)
486 scope_id != "applications/applications.scope" &&505 && !(scope_id in scope.locked_scope_ids))
487 scope_id != "applications/scopes.scope")
488 {506 {
489 PreviewAction action;507 PreviewAction action;
490 preview.set_rating(-1.0f, 0);508 preview.set_rating(-1.0f, 0);

Subscribers

People subscribed via source and target branches