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
1=== modified file 'lib/Items/ApplicationDockItemProvider.vala'
2--- lib/Items/ApplicationDockItemProvider.vala 2013-04-17 09:24:56 +0000
3+++ lib/Items/ApplicationDockItemProvider.vala 2013-04-29 10:04:26 +0000
4@@ -71,9 +71,6 @@
5
6 load_items ();
7 add_running_apps ();
8-#if HAVE_ZEITGEIST || HAVE_ZEITGEIST2
9- update_suggested_apps ();
10-#endif
11 update_visible_items ();
12 serialize_item_positions ();
13
14@@ -111,8 +108,13 @@
15 null, null, null, DBusSignalFlags.NONE, handle_entry_signal);
16 dbus_name_owner_changed_signal_id = connection.signal_subscribe ("org.freedesktop.DBus", "org.freedesktop.DBus",
17 "NameOwnerChanged", "/org/freedesktop/DBus", null, DBusSignalFlags.NONE, handle_name_owner_changed);
18+
19+#if HAVE_ZEITGEIST || HAVE_ZEITGEIST2
20+ Idle.add (() => {
21+ update_suggested_apps ();
22+ return false;
23+ });
24
25-#if HAVE_ZEITGEIST || HAVE_ZEITGEIST2
26 // FIXME Update suggested apps in a "proper" interval
27 Timeout.add_seconds (3600, () => {
28 update_suggested_apps ();
29@@ -312,7 +314,10 @@
30 void update_suggested_apps ()
31 {
32 Logger.verbose ("ApplicationDockItemProvider.update_suggested_apps ()");
33-
34+ var num_events = controller.position_manager.MaxItemCount / 3;
35+
36+ if (visible_items.size >= controller.position_manager.MaxItemCount - num_events)
37+ return;
38 #if HAVE_ZEITGEIST
39 var templates = new PtrArray ();
40 #else
41@@ -324,26 +329,6 @@
42 var time_range = new TimeRange (start, now);
43
44 var event = new Event ();
45-
46- // Filter-out application-uris of already available pinned applications
47- foreach (var item in internal_items) {
48- unowned ApplicationDockItem? app_item = (item as ApplicationDockItem);
49- if (app_item == null || (item is TransientDockItem))
50- continue;
51- var app_uri = app_item.get_unity_application_uri ();
52- if (app_uri == null)
53- continue;
54-#if HAVE_ZEITGEIST
55- var subject = new Subject ();
56- subject.set_uri ("!%s".printf (app_uri));
57-#else
58- var subject = new Subject.full ("!%s".printf (app_uri));
59-#endif
60- event.add_subject (subject);
61-
62- print ("filter %s\n", app_uri);
63- }
64-
65 #if HAVE_ZEITGEIST
66 var subject = new Subject ();
67 subject.set_uri ("application://*");
68@@ -353,7 +338,7 @@
69 event.add_subject (subject);
70 templates.add (event);
71
72- zglog.find_events.begin (time_range, templates, StorageState.ANY, 4,
73+ zglog.find_events.begin (time_range, templates, StorageState.ANY, num_events,
74 ResultType.MOST_POPULAR_SUBJECTS, null, (obj, res) => {
75 ResultSet events = zglog.find_events.end (res);
76 bool needs_update = false;

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: