Merge lp:~ricotz/plank/launcherentry-items into lp:plank

Proposed by Rico Tzschichholz
Status: Merged
Merged at revision: 767
Proposed branch: lp:~ricotz/plank/launcherentry-items
Merge into: lp:plank
Diff against target: 193 lines (+74/-24)
4 files modified
lib/Items/ApplicationDockItemProvider.vala (+46/-18)
lib/Items/DockItemPreferences.vala (+9/-0)
lib/Items/TransientDockItem.vala (+17/-6)
lib/libplank.symbols (+2/-0)
To merge this branch: bzr merge lp:~ricotz/plank/launcherentry-items
Reviewer Review Type Date Requested Status
Robert Dyer (community) Approve
Review via email: mp+154197@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Robert Dyer (psybers) wrote :

critical() doesnt stop execution, right? Just logs?

review: Needs Information
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

> critical() doesnt stop execution, right? Just logs?

Yes, it just logs. "error (...)" is the one which stops and triggers a crash.

Revision history for this message
Robert Dyer (psybers) wrote :

Haven't tested the functionality, but code looks clean.

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-02-27 14:22:26 +0000
3+++ lib/Items/ApplicationDockItemProvider.vala 2013-03-19 20:55:35 +0000
4@@ -249,7 +249,7 @@
5 var active_workspace = Wnck.Screen.get_default ().get_active_workspace ();
6 foreach (var item in internal_items) {
7 var transient = (item as TransientDockItem);
8- item.IsVisible = (transient == null
9+ item.IsVisible = (transient == null || transient.App == null
10 || WindowControl.has_window_on_workspace (transient.App, active_workspace));
11 }
12 } else {
13@@ -292,7 +292,8 @@
14
15 void app_closed (DockItem remove)
16 {
17- if (remove is TransientDockItem)
18+ if (remove is TransientDockItem
19+ && !(remove.ProgressVisible || remove.CountVisible))
20 remove_item (remove);
21 }
22
23@@ -503,6 +504,7 @@
24 return;
25
26 // Reset item since there is no new NameOwner
27+ TransientDockItem? transient_item = null;
28 foreach (var item in internal_items) {
29 var app_item = item as ApplicationDockItem;
30 if (app_item == null)
31@@ -512,9 +514,16 @@
32 continue;
33
34 app_item.unity_reset ();
35+ transient_item = item as TransientDockItem;
36+
37 controller.renderer.animated_draw ();
38 break;
39 }
40+
41+ // Remove item which only exists because of the presence of
42+ // this removed LauncherEntry interface
43+ if (transient_item != null && transient_item.App == null)
44+ remove_item (transient_item);
45 }
46
47 void handle_update_request (string sender_name, Variant parameters)
48@@ -533,35 +542,54 @@
49
50 Logger.verbose ("Unity.handle_update_request (processing update for %s)", app_uri);
51
52- ApplicationDockItem current_item = null;
53+ ApplicationDockItem? current_item = null;
54 foreach (var item in internal_items) {
55 var app_item = item as ApplicationDockItem;
56 if (app_item == null)
57 continue;
58
59- if (app_item.get_unity_dbusname () == sender_name) {
60+ if (app_item.get_unity_dbusname () == sender_name
61+ || app_item.get_unity_application_uri () == app_uri) {
62 current_item = app_item;
63 break;
64 }
65 }
66
67- // If don't know this app yet create a new entry
68- if (current_item == null)
69- foreach (var item in internal_items) {
70- var app_item = item as ApplicationDockItem;
71- if (app_item == null)
72- continue;
73-
74- if (app_item.get_unity_application_uri () == app_uri) {
75- current_item = app_item;
76- break;
77- }
78- }
79-
80 // Update our entry and trigger a redraw
81 if (current_item != null) {
82 current_item.unity_update (sender_name, prop_iter);
83- controller.renderer.animated_draw ();
84+
85+ // Remove item which progress-bar/badge is gone and only existed
86+ // because of the presence of this LauncherEntry interface
87+ var transient_item = current_item as TransientDockItem;
88+ if (transient_item != null && transient_item.App == null
89+ && !(transient_item.ProgressVisible || transient_item.CountVisible))
90+ remove_item (transient_item);
91+ else
92+ controller.renderer.animated_draw ();
93+ } else {
94+ // Find a matching desktop-file and create new TransientDockItem for this LauncherEntry
95+ foreach (var folder in Paths.DataDirFolders) {
96+ var applications_folder = folder.get_child ("applications");
97+ if (!applications_folder.query_exists ())
98+ continue;
99+
100+ var desktop_file = applications_folder.get_child (app_uri.replace ("application://", ""));
101+ if (!desktop_file.query_exists ())
102+ continue;
103+
104+ current_item = new TransientDockItem.with_launcher (desktop_file.get_uri ());
105+ current_item.unity_update (sender_name, prop_iter);
106+
107+ // Only add item if there is actually a visible progress-bar or badge
108+ if (current_item.ProgressVisible || current_item.CountVisible)
109+ add_item (current_item);
110+
111+ break;
112+ }
113+
114+ if (current_item == null)
115+ warning ("Matching application for '%s' not found or not installed!", app_uri);
116 }
117 }
118 }
119
120=== modified file 'lib/Items/DockItemPreferences.vala'
121--- lib/Items/DockItemPreferences.vala 2013-01-29 19:53:59 +0000
122+++ lib/Items/DockItemPreferences.vala 2013-03-19 20:55:35 +0000
123@@ -30,6 +30,15 @@
124 /**
125 * {@inheritDoc}
126 */
127+ public DockItemPreferences.with_launcher (string launcher)
128+ {
129+ base ();
130+ Launcher = launcher;
131+ }
132+
133+ /**
134+ * {@inheritDoc}
135+ */
136 public DockItemPreferences.with_file (GLib.File file)
137 {
138 base.with_file (file);
139
140=== modified file 'lib/Items/TransientDockItem.vala'
141--- lib/Items/TransientDockItem.vala 2012-05-31 09:34:52 +0000
142+++ lib/Items/TransientDockItem.vala 2013-03-19 20:55:35 +0000
143@@ -30,15 +30,26 @@
144 GLib.Object (Prefs: new DockItemPreferences (), App: app);
145 }
146
147+ public TransientDockItem.with_launcher (string launcher_uri)
148+ {
149+ GLib.Object (Prefs: new DockItemPreferences.with_launcher (launcher_uri), App: null);
150+ }
151+
152 construct
153 {
154- var launcher = App.get_desktop_file ();
155- if (launcher == null || launcher == "") {
156- Text = App.get_name ();
157- ForcePixbuf = WindowControl.get_app_icon (App);
158+ if (App != null) {
159+ var launcher = App.get_desktop_file ();
160+ if (launcher == null || launcher == "") {
161+ Text = App.get_name ();
162+ ForcePixbuf = WindowControl.get_app_icon (App);
163+ } else {
164+ Prefs.Launcher = launcher;
165+ load_from_launcher ();
166+ }
167+ } else if (Prefs.Launcher != null) {
168+ load_from_launcher ();
169 } else {
170- Prefs.Launcher = launcher;
171- load_from_launcher ();
172+ critical ("No source of information for this item available");
173 }
174 }
175
176
177=== modified file 'lib/libplank.symbols'
178--- lib/libplank.symbols 2013-03-18 13:50:05 +0000
179+++ lib/libplank.symbols 2013-03-19 20:55:35 +0000
180@@ -289,11 +289,13 @@
181 plank_items_dock_item_preferences_construct
182 plank_items_dock_item_preferences_construct_with_file
183 plank_items_dock_item_preferences_construct_with_filename
184+plank_items_dock_item_preferences_construct_with_launcher
185 plank_items_dock_item_preferences_get_Launcher
186 plank_items_dock_item_preferences_get_type
187 plank_items_dock_item_preferences_new
188 plank_items_dock_item_preferences_new_with_file
189 plank_items_dock_item_preferences_new_with_filename
190+plank_items_dock_item_preferences_new_with_launcher
191 plank_items_dock_item_preferences_set_Launcher
192 plank_items_dock_item_provider_add_item
193 plank_items_dock_item_provider_add_item_without_signaling

Subscribers

People subscribed via source and target branches

to status/vote changes: