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

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michal Hruby
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) Approve
PS Jenkins bot (community) continuous-integration Approve
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.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michal Hruby (mhr3) wrote :

Needs to handle remote scopes too...

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

Fix formatting.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
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

Renamed has_scopes to has_subscopes.

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 :

> 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.

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

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/meta-scope-registry.vala'
--- src/meta-scope-registry.vala 2013-05-02 22:00:15 +0000
+++ src/meta-scope-registry.vala 2013-08-26 09:39:29 +0000
@@ -80,5 +80,12 @@
80 return null;80 return null;
81 return scopes[master_scope_id];81 return scopes[master_scope_id];
82 }82 }
83
84 public bool has_subscopes (string master_scope_id)
85 {
86 if (!scopes.has_key (master_scope_id))
87 return false;
88 return scopes[master_scope_id].size > 0;
89 }
83 }90 }
84}91}
8592
=== modified file 'src/scope.vala'
--- src/scope.vala 2013-07-24 16:35:40 +0000
+++ src/scope.vala 2013-08-26 09:39:29 +0000
@@ -33,7 +33,6 @@
33const int CATEGORY_REORDER_TIME_MS = 1500;33const int CATEGORY_REORDER_TIME_MS = 1500;
34const uint FLUSH_DELAY_MS = 1500;34const uint FLUSH_DELAY_MS = 1500;
35const string[] ALWAYS_REORDER_SCOPE_IDS = {"applications.scope", "files.scope"};35const string[] ALWAYS_REORDER_SCOPE_IDS = {"applications.scope", "files.scope"};
36
37public class HomeScope : Unity.AggregatorScope36public class HomeScope : Unity.AggregatorScope
38{37{
39 private ScopeManager scope_mgr = new ScopeManager ();38 private ScopeManager scope_mgr = new ScopeManager ();
@@ -299,9 +298,14 @@
299298
300 var src_filter = new Unity.CheckOptionFilter ("sources", _("Sources"));299 var src_filter = new Unity.CheckOptionFilter ("sources", _("Sources"));
301 src_filter.sort_type = Unity.OptionsFilter.SortType.DISPLAY_NAME;300 src_filter.sort_type = Unity.OptionsFilter.SortType.DISPLAY_NAME;
301
302 var meta_reg = MetaScopeRegistry.instance ();
303
302 foreach (var node in reg.scopes)304 foreach (var node in reg.scopes)
303 {305 {
304 if (node.scope_info.visible)306 // display master scope in Category filter only if it has subscopes
307 if (node.scope_info.visible && (
308 node.scope_info.is_master == false || meta_reg.has_subscopes (node.scope_info.id)))
305 {309 {
306 debug ("Category filter add: %s", node.scope_info.id);310 debug ("Category filter add: %s", node.scope_info.id);
307 cat_filter.add_option (node.scope_info.id, node.scope_info.name); //add master scope id to 'Categories'311 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: