Merge lp:~stolowski/unity/expand-2nd-home-category into lp:unity

Proposed by Paweł Stołowski on 2012-09-26
Status: Rejected
Rejected by: Andrea Azzarone on 2013-01-29
Proposed branch: lp:~stolowski/unity/expand-2nd-home-category
Merge into: lp:unity
Diff against target: 161 lines (+59/-18)
4 files modified
dash/DashView.cpp (+11/-0)
dash/LensView.cpp (+30/-15)
dash/LensView.h (+1/-1)
manual-tests/Dash.txt (+17/-2)
To merge this branch: bzr merge lp:~stolowski/unity/expand-2nd-home-category
Reviewer Review Type Date Requested Status
Andrea Azzarone 2012-09-26 Disapprove on 2013-01-29
Michal Hruby (community) Needs Fixing on 2012-09-26
Neil J. Patel 2012-09-26 Pending
Review via email: mp+126453@code.launchpad.net

Commit Message

Dash Home Lens: expand 2nd category (Files & Folders by default) if search is empty.

Description of the Change

Dash Home Lens: expand 2nd category (Files & Folders by default) if search is empty.

To post a comment you must log in.
Andrea Azzarone (azzar1) wrote :

Do we really need to hardcode it? A category cannot expand itself using libunity etc.?

Andrea Azzarone (azzar1) :
review: Needs Information
Paweł Stołowski (stolowski) wrote :

Unfortunately there is no way to do this from lenses. Ideally, we should have a new expand-in-home-on-empty-search lens property in libunity Lens class, that would be passed via existing as{v} hints over DBus. I discussed this with Neil and he suggested handling it as an edge case on unity side only, as it's sanest for 12.10.

Michal Hruby (mhr3) wrote :

Can we at least do this when the search actually finishes and not arbitrarily after adding a few results?

Otherwise the category might get expanded, but as another lens finishes search and pushes more results it will again get unexpanded... Or is that what what we actually want?

> lens_->view_type == ViewType::LENS_VIEW

That doesn't look right, we should be using HOME_VIEW in home lens (if that's not the case the id check should suffice)

review: Needs Fixing
Andrea Azzarone (azzar1) wrote :

> Unfortunately there is no way to do this from lenses. Ideally, we should have
> a new expand-in-home-on-empty-search lens property in libunity Lens class,
> that would be passed via existing as{v} hints over DBus. I discussed this with
> Neil and he suggested handling it as an edge case on unity side only, as it's
> sanest for 12.10.

Got it.

2756. By Paweł Stołowski on 2012-09-27

Perform category expansion on search finished.

2757. By Paweł Stołowski on 2012-11-05

Merged trunk.

2758. By Paweł Stołowski on 2012-11-05

Added manual test for 2nd category expansion in dash home view.

Andrea Azzarone (azzar1) :
review: Disapprove

Unmerged revisions

2758. By Paweł Stołowski on 2012-11-05

Added manual test for 2nd category expansion in dash home view.

2757. By Paweł Stołowski on 2012-11-05

Merged trunk.

2756. By Paweł Stołowski on 2012-09-27

Perform category expansion on search finished.

2755. By Paweł Stołowski on 2012-09-26

Dash Home Lens: expand 2nd category (Files & Folders by default) if search is empty.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/DashView.cpp'
2--- dash/DashView.cpp 2012-10-29 09:34:54 +0000
3+++ dash/DashView.cpp 2012-11-05 10:17:23 +0000
4@@ -1013,6 +1013,17 @@
5 if (active_lens_view_ == NULL) return;
6
7 active_lens_view_->CheckNoResults(hints);
8+
9+ if (active_lens_view_ == home_view_ && active_lens_view_->lens()->last_search_string == "")
10+ {
11+ active_lens_view_->CheckCategoryExpansion(2);
12+ }
13+ else
14+ {
15+ // Check if all results so far are from one category
16+ // If so, then expand that category.
17+ active_lens_view_->CheckCategoryExpansion(1);
18+ }
19 std::string const& search_string = search_bar_->search_string;
20
21 if (active_lens_view_->search_string == search_string)
22
23=== modified file 'dash/LensView.cpp'
24--- dash/LensView.cpp 2012-10-29 09:34:54 +0000
25+++ dash/LensView.cpp 2012-11-05 10:17:23 +0000
26@@ -483,16 +483,15 @@
27 CheckNoResults(Lens::Hints());
28 }
29
30- if (!model_updated_timeout_)
31+ /* Disabled for now, enable back if needed
32+ if (!model_updated_timeout_)
33 {
34 model_updated_timeout_.reset(new glib::Idle([&] () {
35- // Check if all results so far are from one category
36- // If so, then expand that category.
37- CheckCategoryExpansion();
38 model_updated_timeout_.reset();
39 return false;
40 }, glib::Source::Priority::HIGH));
41 }
42+ */
43 } catch (std::out_of_range& oor) {
44 LOG_WARN(logger) << "Result does not have a valid category index: "
45 << boost::lexical_cast<unsigned int>(result.category_index)
46@@ -566,7 +565,9 @@
47 }
48 }
49
50-void LensView::CheckCategoryExpansion()
51+
52+/* Expand last category if number of categories with results is less than or equal to max_categories */
53+void LensView::CheckCategoryExpansion(int max_categories)
54 {
55 int number_of_displayed_categories = 0;
56
57@@ -574,23 +575,37 @@
58 // If so, collapse it for now
59 if (last_expanded_group_ != nullptr)
60 {
61- last_expanded_group_->SetExpanded(false);
62- last_expanded_group_ = nullptr;
63+ last_expanded_group_->SetExpanded(false);
64+ last_expanded_group_ = nullptr;
65 }
66
67- // Cycle through all categories
68+ const std::vector<unsigned> order(lens_->GetCategoriesOrder());
69+ unsigned last_category_index = 0;
70+
71+ // Cycle through all categories, find last category to expand based on order
72 for (auto category : categories_)
73 {
74- if (counts_[category] > 0) {
75- number_of_displayed_categories++;
76- last_expanded_group_ = category;
77+ if (counts_[category] > 0) {
78+ number_of_displayed_categories++;
79+ for (unsigned i = 0; i < order.size(); i++)
80+ {
81+ if (order[i] == category->GetCategoryIndex())
82+ {
83+ if (i >= last_category_index)
84+ {
85+ last_category_index = i;
86+ last_expanded_group_ = category;
87+ }
88+ break;
89+ }
90 }
91+ }
92 }
93-
94- if (number_of_displayed_categories == 1 && last_expanded_group_ != nullptr)
95- last_expanded_group_->SetExpanded(true);
96+
97+ if (number_of_displayed_categories <= max_categories && last_expanded_group_ != nullptr)
98+ last_expanded_group_->SetExpanded(true);
99 else
100- last_expanded_group_ = nullptr;
101+ last_expanded_group_ = nullptr;
102 }
103
104 void LensView::HideResultsMessage()
105
106=== modified file 'dash/LensView.h'
107--- dash/LensView.h 2012-10-11 01:44:15 +0000
108+++ dash/LensView.h 2012-11-05 10:17:23 +0000
109@@ -72,7 +72,7 @@
110
111 void PerformSearch(std::string const& search_query);
112 void CheckNoResults(Lens::Hints const& hints);
113- void CheckCategoryExpansion();
114+ void CheckCategoryExpansion(int max_categories);
115 void HideResultsMessage();
116
117 private:
118
119=== modified file 'manual-tests/Dash.txt'
120--- manual-tests/Dash.txt 2012-10-11 01:44:15 +0000
121+++ manual-tests/Dash.txt 2012-11-05 10:17:23 +0000
122@@ -90,7 +90,7 @@
123 * Open the dash home view
124 * Search for something on your system that returns multiple results (more than the number that can fit in a row)
125 yet all results are in one category only. This differs per system; try searching for "gnome" in the home lens, or "kde"
126- in the app lens.
127+ in the app lens.
128 * Multiple results should be returned in both the cases, but if searching for "gnome" on the home lens returns folders in addition to apps
129 or "kde" returns results from two categories in the apps lens, then keep experimenting with other search strings.
130 * When you have at least one situation in which results from only one category are returned, and the number of results are enough to overflow one single row,
131@@ -101,6 +101,21 @@
132 header expands automatically
133
134
135+Dash home category expand test
136+------------------------------
137+This tests whether the dash home expands 2nd category (Files & Folders by default) if there is no search query.
138+https://bugs.launchpad.net/unity/+bug/1052914
139+
140+Setup:
141+Make sure you've at least 6 files indexed by zeitgeist - just create some empty files in nautilus if needed.
142+
143+Actions:
144+ * Open the dash home view, make sure search query is empty.
145+
146+Expected result:
147+ * 'Files & Folders' category header is expanded.
148+
149+
150 Test the Panel does not lose track of when the Dash is opened then closed.
151 --------------------------------------------------------------------------
152 This tests shows the panel will not think the Dash is opened when it is closed.
153@@ -307,7 +322,7 @@
154 2758 ? Sl 0:00 /usr/lib/unity-lens-music/unity-music-daemon
155 2760 ? Sl 0:00 /usr/bin/python /usr/lib/unity-lens-video/unity-lens-video
156 2816 ? Sl 0:00 /usr/lib/unity-lens-music/unity-musicstore-daemon
157-
158+
159 Wrong Result:
160 #2 and #4 both produce non-empty result which means the lenses were not
161 lazy-loaded but they were running before the first dash use.