Merge lp:~njpatel/unity/lens-ordering into lp:unity

Proposed by Neil J. Patel
Status: Merged
Approved by: Mirco Müller
Approved revision: no longer in the source branch.
Merged at revision: 1516
Proposed branch: lp:~njpatel/unity/lens-ordering
Merge into: lp:unity
Diff against target: 40 lines (+21/-1)
1 file modified
UnityCore/FilesystemLenses.cpp (+21/-1)
To merge this branch: bzr merge lp:~njpatel/unity/lens-ordering
Reviewer Review Type Date Requested Status
Mirco Müller (community) Approve
Review via email: mp+74522@code.launchpad.net

Description of the change

This makes sure that the apps lens is always first, and adds basic ordering to the lenses instead of them always coming in randomly. It means that we send of the lens_added signal a little later, but that shouldn't make a difference to consumers.

This is done in a way to preserve ABI/API of UnityCore and I've added FIXMEs for the couple of things that should be changed when we branch for P.

To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote :

Gee... still got get used to all that new C++ stuff, but approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityCore/FilesystemLenses.cpp'
2--- UnityCore/FilesystemLenses.cpp 2011-08-07 09:21:37 +0000
3+++ UnityCore/FilesystemLenses.cpp 2011-09-07 21:29:31 +0000
4@@ -279,7 +279,28 @@
5 // done reading the directory
6 children_waiting_to_load_--;
7 if (!children_waiting_to_load_)
8+ {
9+ //FIXME: This should be it's own function, but we're trying not to break ABI
10+ // right now.
11+ //FIXME: We don't have a strict order, but alphabetical serves us wonderfully for
12+ // Oneiric. When we have an order/policy, please replace this.
13+ auto sort_cb = [] (Lens::Ptr a, Lens::Ptr b) -> bool
14+ {
15+ if (a->id == "applications.lens")
16+ return true;
17+ else if (b->id == "applications.lens")
18+ return false;
19+ else
20+ return g_strcmp0(a->id().c_str(), b->id().c_str()) < 0;
21+ };
22+ std::sort(lenses_.begin(),
23+ lenses_.end(),
24+ sort_cb);
25+ for (Lens::Ptr& lens: lenses_)
26+ owner_->lens_added.emit(lens);
27+
28 owner_->lenses_loaded.emit();
29+ }
30 }
31
32 void FilesystemLenses::Impl::CreateLensFromKeyFileData(GFile* file,
33@@ -307,7 +328,6 @@
34 data.visible,
35 data.shortcut.Str()));
36 lenses_.push_back(lens);
37- owner_->lens_added.emit(lens);
38
39 LOG_DEBUG(logger) << "Sucessfully loaded lens file " << path;
40 }