Merge lp:~stolowski/unity-scope-home/filters-no-empty-masters into lp:unity-scope-home

Proposed by Paweł Stołowski on 2013-08-20
Status: Merged
Approved by: Michal Hruby on 2013-08-26
Approved revision: 148
Merged at revision: 148
Proposed branch: lp:~stolowski/unity-scope-home/filters-no-empty-masters
Merge into: lp:unity-scope-home
Diff against target: 44 lines (+13/-2)
2 files modified
src/meta-scope-registry.vala (+7/-0)
src/scope.vala (+6/-2)
To merge this branch: bzr merge lp:~stolowski/unity-scope-home/filters-no-empty-masters
Reviewer Review Type Date Requested Status
Michal Hruby (community) 2013-08-20 Approve on 2013-08-26
PS Jenkins bot continuous-integration Approve on 2013-08-26
Review via email: mp+181074@code.launchpad.net

Commit message

Don't add master scope to Categories filter if it has no scopes.

Description of the change

Don't add master scope to Categories filter if it has no scopes.

To post a comment you must log in.
Michal Hruby (mhr3) wrote :

Needs to handle remote scopes too...

review: Needs Fixing
147. By Paweł Stołowski on 2013-08-21

Fix formatting.

Michal Hruby (mhr3) wrote :

Is there a simple way to add a test for this?

9 + public bool has_scopes (string master_scope_id)

Would be more expressive as "has_subscopes()".

review: Needs Information
148. By Paweł Stołowski on 2013-08-26

Renamed has_scopes to has_subscopes.

Paweł Stołowski (stolowski) wrote :

> Is there a simple way to add a test for this?
Simple - not. It would require changing populate_filters() implementation a bit to make it independent of HS, so that it's not necessary to create HS instance... And then mocking some stuff.

> 9 + public bool has_scopes (string master_scope_id)
>
> Would be more expressive as "has_subscopes()".
Renamed.

Michal Hruby (mhr3) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/meta-scope-registry.vala'
2--- src/meta-scope-registry.vala 2013-05-02 22:00:15 +0000
3+++ src/meta-scope-registry.vala 2013-08-26 09:39:29 +0000
4@@ -80,5 +80,12 @@
5 return null;
6 return scopes[master_scope_id];
7 }
8+
9+ public bool has_subscopes (string master_scope_id)
10+ {
11+ if (!scopes.has_key (master_scope_id))
12+ return false;
13+ return scopes[master_scope_id].size > 0;
14+ }
15 }
16 }
17
18=== modified file 'src/scope.vala'
19--- src/scope.vala 2013-07-24 16:35:40 +0000
20+++ src/scope.vala 2013-08-26 09:39:29 +0000
21@@ -33,7 +33,6 @@
22 const int CATEGORY_REORDER_TIME_MS = 1500;
23 const uint FLUSH_DELAY_MS = 1500;
24 const string[] ALWAYS_REORDER_SCOPE_IDS = {"applications.scope", "files.scope"};
25-
26 public class HomeScope : Unity.AggregatorScope
27 {
28 private ScopeManager scope_mgr = new ScopeManager ();
29@@ -299,9 +298,14 @@
30
31 var src_filter = new Unity.CheckOptionFilter ("sources", _("Sources"));
32 src_filter.sort_type = Unity.OptionsFilter.SortType.DISPLAY_NAME;
33+
34+ var meta_reg = MetaScopeRegistry.instance ();
35+
36 foreach (var node in reg.scopes)
37 {
38- if (node.scope_info.visible)
39+ // display master scope in Category filter only if it has subscopes
40+ if (node.scope_info.visible && (
41+ node.scope_info.is_master == false || meta_reg.has_subscopes (node.scope_info.id)))
42 {
43 debug ("Category filter add: %s", node.scope_info.id);
44 cat_filter.add_option (node.scope_info.id, node.scope_info.name); //add master scope id to 'Categories'

Subscribers

People subscribed via source and target branches

to all changes: