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
1=== modified file 'configure.ac'
2--- configure.ac 2013-08-29 11:01:54 +0000
3+++ configure.ac 2013-09-06 15:12:10 +0000
4@@ -78,7 +78,7 @@
5 dee-1.0 >= 0.5.16
6 zeitgeist-1.0 >= 0.3.8
7 libcolumbus >= 1.0.0
8- unity >= 7.1.0
9+ unity >= 7.1.1
10 unity-protocol-private
11 libgnome-menu-3.0 >= 3.6.0)
12
13
14=== modified file 'debian/control'
15--- debian/control 2013-08-29 11:01:54 +0000
16+++ debian/control 2013-09-06 15:12:10 +0000
17@@ -11,7 +11,7 @@
18 libgee-dev,
19 libdee-dev (>= 0.5.16),
20 libzeitgeist-dev (>= 0.3.8),
21- libunity-dev (>= 7.1.0),
22+ libunity-dev (>= 7.1.1),
23 libgnome-menu-3-dev,
24 dh-autoreconf,
25 libxapian-dev,
26
27=== modified file 'src/scopes-scope.vala'
28--- src/scopes-scope.vala 2013-08-28 11:43:15 +0000
29+++ src/scopes-scope.vala 2013-09-06 15:12:10 +0000
30@@ -20,6 +20,11 @@
31
32 namespace Unity.ApplicationsLens {
33 const string GENERIC_SCOPE_ICON = ICON_PATH + "service-generic.svg";
34+ const string[] invisible_scope_ids =
35+ {
36+ "home.scope",
37+ "applications-scopes.scope",
38+ };
39
40 private class ScopesScope : Unity.AbstractScope
41 {
42@@ -30,6 +35,8 @@
43 public Dee.Index scopes_index;
44 public Dee.Analyzer analyzer;
45
46+ public HashTable<string, bool> locked_scope_ids;
47+
48 public ScopesScope (ApplicationsScope appscope)
49 {
50 this.appscope = appscope;
51@@ -52,6 +59,13 @@
52 var pref_man = PreferencesManager.get_default ();
53 pref_man.notify["disabled-scopes"].connect (update_disabled_scopes_hash);
54
55+ locked_scope_ids = new HashTable<string, bool> (str_hash, str_equal);
56+ var settings = new Settings (LIBUNITY_SCHEMA);
57+ foreach (unowned string scope_id in settings.get_strv ("locked-scopes"))
58+ {
59+ locked_scope_ids[scope_id] = true;
60+ }
61+
62 build_scope_index.begin ();
63 }
64
65@@ -188,6 +202,7 @@
66
67 public override Unity.ActivationResponse? activate (Unity.ScopeResult result, Unity.SearchMetadata metadata, string? action_id)
68 {
69+ // uris are "scope://scope_id.scope"
70 var scope_id = result.uri.substring (8);
71 if (action_id == "enable-scope")
72 {
73@@ -301,6 +316,9 @@
74 if (info.is_master_scope)
75 continue;
76
77+ if (info.desktop_file in invisible_scope_ids)
78+ continue;
79+
80 bool is_disabled = info.desktop_file in scope.disabled_scope_ids;
81 var result = Unity.ScopeResult ();
82 result.uri = @"scope://$(info.desktop_file)";
83@@ -386,6 +404,7 @@
84 private async Unity.AbstractPreview? make_preview ()
85 {
86 Unity.ApplicationPreview? preview = null;
87+ // uris are "scope://scope_id.scope"
88 var scope_id = result.uri.substring (8);
89 bool scope_disabled = scope_id in scope.disabled_scope_ids;
90
91@@ -482,9 +501,8 @@
92 icon,
93 screenshot);
94 }
95- if (preview != null && scope_id != "home.scope" &&
96- scope_id != "applications/applications.scope" &&
97- scope_id != "applications/scopes.scope")
98+ if (preview != null && !(scope_id in invisible_scope_ids)
99+ && !(scope_id in scope.locked_scope_ids))
100 {
101 PreviewAction action;
102 preview.set_rating(-1.0f, 0);

Subscribers

People subscribed via source and target branches