Merge lp:~azzar1/unity/autoselect-all-button-checkoptionfilter into lp:unity

Proposed by Andrea Azzarone
Status: Work in progress
Proposed branch: lp:~azzar1/unity/autoselect-all-button-checkoptionfilter
Merge into: lp:unity
Diff against target: 55 lines (+10/-5)
2 files modified
UnityCore/CheckOptionFilter.cpp (+9/-4)
tests/test_lens.cpp (+1/-1)
To merge this branch: bzr merge lp:~azzar1/unity/autoselect-all-button-checkoptionfilter
Reviewer Review Type Date Requested Status
John Lea (community) design review Needs Fixing
Michal Hruby (community) Approve
Sam Spilsbury (community) Approve
Review via email: mp+89614@code.launchpad.net

Description of the change

Auto select the "All" button if all checkoption buttons are selected.

There was already a test for it, so i've just updated it.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) :
review: Approve
Revision history for this message
Michal Hruby (mhr3) wrote :

Looks good.

review: Approve
Revision history for this message
Andrea Azzarone (azzar1) wrote :

Requested JonhLea's review so he can confirm the wanted behavior.

Revision history for this message
John Lea (johnlea) wrote :

Hi, many thanks for this fix. After testing this fix we would like to request one change to the originally requested functionality before this lands.

If a user selects all of the filters in a section, the 'All' button should be automatically selected. In this state clicking on the 'All' button should do nothing. If the user deselects one of the filters the 'All' button should be automatically be de-selected.

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

@John, could you re-consider, I think this would make behaviour of the filters quite inconsistent, consider this:

1) User selects a couple of options, and continues doing so until all of them are selected - at this point the All button is highlighted (and also all the options), user switches to a different lens looks at the filters and sees the All button highlighted but none of the options selected - inconsistency.

Revision history for this message
John Lea (johnlea) wrote :

mhr3; we need to balance this issue with other issues, so waiting for this branch to be available so that we can test the requested behaviour before making a final call.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityCore/CheckOptionFilter.cpp'
2--- UnityCore/CheckOptionFilter.cpp 2011-08-05 19:25:57 +0000
3+++ UnityCore/CheckOptionFilter.cpp 2012-01-23 09:50:29 +0000
4@@ -88,7 +88,9 @@
5 {
6 if (!IsValid())
7 return;
8- gboolean raw_filtering = FALSE;
9+
10+ bool raw_filtering = false;
11+ bool all_activated = true;
12
13 GVariantBuilder options;
14 g_variant_builder_init(&options, G_VARIANT_TYPE("a(sssb)"));
15@@ -100,13 +102,16 @@
16 std::string icon_hint = option->icon_hint;
17 bool active = option->active;
18
19- raw_filtering = raw_filtering ? TRUE : active;
20+ raw_filtering |= active;
21+ all_activated &= active;
22
23 g_variant_builder_add(&options, "(sssb)",
24 id.c_str(), name.c_str(),
25 icon_hint.c_str(), active ? TRUE : FALSE);
26 }
27-
28+
29+ raw_filtering = all_activated ? FALSE : raw_filtering;
30+
31 GVariantBuilder hints;
32 g_variant_builder_init(&hints, G_VARIANT_TYPE("a{sv}"));
33 g_variant_builder_add(&hints, "{sv}", "options", g_variant_builder_end(&options));
34@@ -117,7 +122,7 @@
35 g_variant_builder_end(&hints));
36 dee_model_set_value(model_, iter_,
37 FilterColumn::FILTERING,
38- g_variant_new("b", raw_filtering));
39+ g_variant_new("b", raw_filtering ? TRUE : FALSE));
40 IgnoreChanges(false);
41
42 filtering.EmitChanged(filtering);
43
44=== modified file 'tests/test_lens.cpp'
45--- tests/test_lens.cpp 2011-12-02 12:03:27 +0000
46+++ tests/test_lens.cpp 2012-01-23 09:50:29 +0000
47@@ -394,7 +394,7 @@
48 EXPECT_FALSE (options[2]->active);
49
50 options[2]->active = true;
51- EXPECT_TRUE (filter->filtering);
52+ EXPECT_FALSE (filter->filtering);
53 EXPECT_TRUE (options[0]->active);
54 EXPECT_TRUE (options[1]->active);
55 EXPECT_TRUE (options[2]->active);