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
=== modified file 'UnityCore/FilesystemLenses.cpp'
--- UnityCore/FilesystemLenses.cpp 2011-08-07 09:21:37 +0000
+++ UnityCore/FilesystemLenses.cpp 2011-09-07 21:29:31 +0000
@@ -279,7 +279,28 @@
279 // done reading the directory279 // done reading the directory
280 children_waiting_to_load_--;280 children_waiting_to_load_--;
281 if (!children_waiting_to_load_)281 if (!children_waiting_to_load_)
282 {
283 //FIXME: This should be it's own function, but we're trying not to break ABI
284 // right now.
285 //FIXME: We don't have a strict order, but alphabetical serves us wonderfully for
286 // Oneiric. When we have an order/policy, please replace this.
287 auto sort_cb = [] (Lens::Ptr a, Lens::Ptr b) -> bool
288 {
289 if (a->id == "applications.lens")
290 return true;
291 else if (b->id == "applications.lens")
292 return false;
293 else
294 return g_strcmp0(a->id().c_str(), b->id().c_str()) < 0;
295 };
296 std::sort(lenses_.begin(),
297 lenses_.end(),
298 sort_cb);
299 for (Lens::Ptr& lens: lenses_)
300 owner_->lens_added.emit(lens);
301
282 owner_->lenses_loaded.emit();302 owner_->lenses_loaded.emit();
303 }
283}304}
284305
285void FilesystemLenses::Impl::CreateLensFromKeyFileData(GFile* file,306void FilesystemLenses::Impl::CreateLensFromKeyFileData(GFile* file,
@@ -307,7 +328,6 @@
307 data.visible,328 data.visible,
308 data.shortcut.Str()));329 data.shortcut.Str()));
309 lenses_.push_back(lens);330 lenses_.push_back(lens);
310 owner_->lens_added.emit(lens);
311331
312 LOG_DEBUG(logger) << "Sucessfully loaded lens file " << path;332 LOG_DEBUG(logger) << "Sucessfully loaded lens file " << path;
313 }333 }