Merge lp:~seif/plank/zeitgeist into lp:~zeitgeist/plank/zeitgeist

Proposed by Seif Lotfy
Status: Merged
Merged at revision: 803
Proposed branch: lp:~seif/plank/zeitgeist
Merge into: lp:~zeitgeist/plank/zeitgeist
Diff against target: 76 lines (+11/-26)
1 file modified
lib/Items/ApplicationDockItemProvider.vala (+11/-26)
To merge this branch: bzr merge lp:~seif/plank/zeitgeist
Reviewer Review Type Date Requested Status
Rico Tzschichholz Approve
Review via email: mp+161389@code.launchpad.net

Description of the change

This patch respects the maximum allows items in the dock.
The ApplicationDockItemProvider (ADP) asks for the maximum number (num_events) of items the dock can show on the screen
The behaviour is as follows.
It then queries for Zeitgeist for the (num_events/3) most popular applications used within the last 60 days.
This way if x of the num_events/3 Applications are already in the dock, it displays only num_events/3 - x, thus not overpopulating the dock. So if we have all the most used apps already open or pinned in the dock, the dock does not add more stuff.

To post a comment you must log in.
Revision history for this message
Rico Tzschichholz (ricotz) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/Items/ApplicationDockItemProvider.vala'
--- lib/Items/ApplicationDockItemProvider.vala 2013-04-17 09:24:56 +0000
+++ lib/Items/ApplicationDockItemProvider.vala 2013-04-29 10:04:26 +0000
@@ -71,9 +71,6 @@
71 71
72 load_items ();72 load_items ();
73 add_running_apps ();73 add_running_apps ();
74#if HAVE_ZEITGEIST || HAVE_ZEITGEIST2
75 update_suggested_apps ();
76#endif
77 update_visible_items ();74 update_visible_items ();
78 serialize_item_positions ();75 serialize_item_positions ();
79 76
@@ -111,8 +108,13 @@
111 null, null, null, DBusSignalFlags.NONE, handle_entry_signal);108 null, null, null, DBusSignalFlags.NONE, handle_entry_signal);
112 dbus_name_owner_changed_signal_id = connection.signal_subscribe ("org.freedesktop.DBus", "org.freedesktop.DBus",109 dbus_name_owner_changed_signal_id = connection.signal_subscribe ("org.freedesktop.DBus", "org.freedesktop.DBus",
113 "NameOwnerChanged", "/org/freedesktop/DBus", null, DBusSignalFlags.NONE, handle_name_owner_changed);110 "NameOwnerChanged", "/org/freedesktop/DBus", null, DBusSignalFlags.NONE, handle_name_owner_changed);
111
112#if HAVE_ZEITGEIST || HAVE_ZEITGEIST2
113 Idle.add (() => {
114 update_suggested_apps ();
115 return false;
116 });
114 117
115#if HAVE_ZEITGEIST || HAVE_ZEITGEIST2
116 // FIXME Update suggested apps in a "proper" interval118 // FIXME Update suggested apps in a "proper" interval
117 Timeout.add_seconds (3600, () => {119 Timeout.add_seconds (3600, () => {
118 update_suggested_apps ();120 update_suggested_apps ();
@@ -312,7 +314,10 @@
312 void update_suggested_apps ()314 void update_suggested_apps ()
313 {315 {
314 Logger.verbose ("ApplicationDockItemProvider.update_suggested_apps ()");316 Logger.verbose ("ApplicationDockItemProvider.update_suggested_apps ()");
315 317 var num_events = controller.position_manager.MaxItemCount / 3;
318
319 if (visible_items.size >= controller.position_manager.MaxItemCount - num_events)
320 return;
316#if HAVE_ZEITGEIST321#if HAVE_ZEITGEIST
317 var templates = new PtrArray ();322 var templates = new PtrArray ();
318#else323#else
@@ -324,26 +329,6 @@
324 var time_range = new TimeRange (start, now);329 var time_range = new TimeRange (start, now);
325 330
326 var event = new Event ();331 var event = new Event ();
327
328 // Filter-out application-uris of already available pinned applications
329 foreach (var item in internal_items) {
330 unowned ApplicationDockItem? app_item = (item as ApplicationDockItem);
331 if (app_item == null || (item is TransientDockItem))
332 continue;
333 var app_uri = app_item.get_unity_application_uri ();
334 if (app_uri == null)
335 continue;
336#if HAVE_ZEITGEIST
337 var subject = new Subject ();
338 subject.set_uri ("!%s".printf (app_uri));
339#else
340 var subject = new Subject.full ("!%s".printf (app_uri));
341#endif
342 event.add_subject (subject);
343
344 print ("filter %s\n", app_uri);
345 }
346
347#if HAVE_ZEITGEIST332#if HAVE_ZEITGEIST
348 var subject = new Subject ();333 var subject = new Subject ();
349 subject.set_uri ("application://*");334 subject.set_uri ("application://*");
@@ -353,7 +338,7 @@
353 event.add_subject (subject);338 event.add_subject (subject);
354 templates.add (event);339 templates.add (event);
355 340
356 zglog.find_events.begin (time_range, templates, StorageState.ANY, 4,341 zglog.find_events.begin (time_range, templates, StorageState.ANY, num_events,
357 ResultType.MOST_POPULAR_SUBJECTS, null, (obj, res) => {342 ResultType.MOST_POPULAR_SUBJECTS, null, (obj, res) => {
358 ResultSet events = zglog.find_events.end (res);343 ResultSet events = zglog.find_events.end (res);
359 bool needs_update = false;344 bool needs_update = false;

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: