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
=== modified file 'lib/Items/ApplicationDockItemProvider.vala'
--- lib/Items/ApplicationDockItemProvider.vala 2013-02-27 14:22:26 +0000
+++ lib/Items/ApplicationDockItemProvider.vala 2013-03-19 20:55:35 +0000
@@ -249,7 +249,7 @@
249 var active_workspace = Wnck.Screen.get_default ().get_active_workspace ();249 var active_workspace = Wnck.Screen.get_default ().get_active_workspace ();
250 foreach (var item in internal_items) {250 foreach (var item in internal_items) {
251 var transient = (item as TransientDockItem);251 var transient = (item as TransientDockItem);
252 item.IsVisible = (transient == null252 item.IsVisible = (transient == null || transient.App == null
253 || WindowControl.has_window_on_workspace (transient.App, active_workspace));253 || WindowControl.has_window_on_workspace (transient.App, active_workspace));
254 }254 }
255 } else {255 } else {
@@ -292,7 +292,8 @@
292 292
293 void app_closed (DockItem remove)293 void app_closed (DockItem remove)
294 {294 {
295 if (remove is TransientDockItem)295 if (remove is TransientDockItem
296 && !(remove.ProgressVisible || remove.CountVisible))
296 remove_item (remove);297 remove_item (remove);
297 }298 }
298 299
@@ -503,6 +504,7 @@
503 return;504 return;
504 505
505 // Reset item since there is no new NameOwner506 // Reset item since there is no new NameOwner
507 TransientDockItem? transient_item = null;
506 foreach (var item in internal_items) {508 foreach (var item in internal_items) {
507 var app_item = item as ApplicationDockItem;509 var app_item = item as ApplicationDockItem;
508 if (app_item == null)510 if (app_item == null)
@@ -512,9 +514,16 @@
512 continue;514 continue;
513 515
514 app_item.unity_reset ();516 app_item.unity_reset ();
517 transient_item = item as TransientDockItem;
518
515 controller.renderer.animated_draw ();519 controller.renderer.animated_draw ();
516 break;520 break;
517 }521 }
522
523 // Remove item which only exists because of the presence of
524 // this removed LauncherEntry interface
525 if (transient_item != null && transient_item.App == null)
526 remove_item (transient_item);
518 }527 }
519 528
520 void handle_update_request (string sender_name, Variant parameters)529 void handle_update_request (string sender_name, Variant parameters)
@@ -533,35 +542,54 @@
533 542
534 Logger.verbose ("Unity.handle_update_request (processing update for %s)", app_uri);543 Logger.verbose ("Unity.handle_update_request (processing update for %s)", app_uri);
535 544
536 ApplicationDockItem current_item = null;545 ApplicationDockItem? current_item = null;
537 foreach (var item in internal_items) {546 foreach (var item in internal_items) {
538 var app_item = item as ApplicationDockItem;547 var app_item = item as ApplicationDockItem;
539 if (app_item == null)548 if (app_item == null)
540 continue;549 continue;
541 550
542 if (app_item.get_unity_dbusname () == sender_name) {551 if (app_item.get_unity_dbusname () == sender_name
552 || app_item.get_unity_application_uri () == app_uri) {
543 current_item = app_item;553 current_item = app_item;
544 break;554 break;
545 }555 }
546 }556 }
547 557
548 // If don't know this app yet create a new entry
549 if (current_item == null)
550 foreach (var item in internal_items) {
551 var app_item = item as ApplicationDockItem;
552 if (app_item == null)
553 continue;
554
555 if (app_item.get_unity_application_uri () == app_uri) {
556 current_item = app_item;
557 break;
558 }
559 }
560
561 // Update our entry and trigger a redraw558 // Update our entry and trigger a redraw
562 if (current_item != null) {559 if (current_item != null) {
563 current_item.unity_update (sender_name, prop_iter);560 current_item.unity_update (sender_name, prop_iter);
564 controller.renderer.animated_draw ();561
562 // Remove item which progress-bar/badge is gone and only existed
563 // because of the presence of this LauncherEntry interface
564 var transient_item = current_item as TransientDockItem;
565 if (transient_item != null && transient_item.App == null
566 && !(transient_item.ProgressVisible || transient_item.CountVisible))
567 remove_item (transient_item);
568 else
569 controller.renderer.animated_draw ();
570 } else {
571 // Find a matching desktop-file and create new TransientDockItem for this LauncherEntry
572 foreach (var folder in Paths.DataDirFolders) {
573 var applications_folder = folder.get_child ("applications");
574 if (!applications_folder.query_exists ())
575 continue;
576
577 var desktop_file = applications_folder.get_child (app_uri.replace ("application://", ""));
578 if (!desktop_file.query_exists ())
579 continue;
580
581 current_item = new TransientDockItem.with_launcher (desktop_file.get_uri ());
582 current_item.unity_update (sender_name, prop_iter);
583
584 // Only add item if there is actually a visible progress-bar or badge
585 if (current_item.ProgressVisible || current_item.CountVisible)
586 add_item (current_item);
587
588 break;
589 }
590
591 if (current_item == null)
592 warning ("Matching application for '%s' not found or not installed!", app_uri);
565 }593 }
566 }594 }
567 }595 }
568596
=== modified file 'lib/Items/DockItemPreferences.vala'
--- lib/Items/DockItemPreferences.vala 2013-01-29 19:53:59 +0000
+++ lib/Items/DockItemPreferences.vala 2013-03-19 20:55:35 +0000
@@ -30,6 +30,15 @@
30 /**30 /**
31 * {@inheritDoc}31 * {@inheritDoc}
32 */32 */
33 public DockItemPreferences.with_launcher (string launcher)
34 {
35 base ();
36 Launcher = launcher;
37 }
38
39 /**
40 * {@inheritDoc}
41 */
33 public DockItemPreferences.with_file (GLib.File file)42 public DockItemPreferences.with_file (GLib.File file)
34 {43 {
35 base.with_file (file);44 base.with_file (file);
3645
=== modified file 'lib/Items/TransientDockItem.vala'
--- lib/Items/TransientDockItem.vala 2012-05-31 09:34:52 +0000
+++ lib/Items/TransientDockItem.vala 2013-03-19 20:55:35 +0000
@@ -30,15 +30,26 @@
30 GLib.Object (Prefs: new DockItemPreferences (), App: app);30 GLib.Object (Prefs: new DockItemPreferences (), App: app);
31 }31 }
32 32
33 public TransientDockItem.with_launcher (string launcher_uri)
34 {
35 GLib.Object (Prefs: new DockItemPreferences.with_launcher (launcher_uri), App: null);
36 }
37
33 construct38 construct
34 {39 {
35 var launcher = App.get_desktop_file ();40 if (App != null) {
36 if (launcher == null || launcher == "") {41 var launcher = App.get_desktop_file ();
37 Text = App.get_name ();42 if (launcher == null || launcher == "") {
38 ForcePixbuf = WindowControl.get_app_icon (App);43 Text = App.get_name ();
44 ForcePixbuf = WindowControl.get_app_icon (App);
45 } else {
46 Prefs.Launcher = launcher;
47 load_from_launcher ();
48 }
49 } else if (Prefs.Launcher != null) {
50 load_from_launcher ();
39 } else {51 } else {
40 Prefs.Launcher = launcher;52 critical ("No source of information for this item available");
41 load_from_launcher ();
42 }53 }
43 }54 }
44 55
4556
=== modified file 'lib/libplank.symbols'
--- lib/libplank.symbols 2013-03-18 13:50:05 +0000
+++ lib/libplank.symbols 2013-03-19 20:55:35 +0000
@@ -289,11 +289,13 @@
289plank_items_dock_item_preferences_construct289plank_items_dock_item_preferences_construct
290plank_items_dock_item_preferences_construct_with_file290plank_items_dock_item_preferences_construct_with_file
291plank_items_dock_item_preferences_construct_with_filename291plank_items_dock_item_preferences_construct_with_filename
292plank_items_dock_item_preferences_construct_with_launcher
292plank_items_dock_item_preferences_get_Launcher293plank_items_dock_item_preferences_get_Launcher
293plank_items_dock_item_preferences_get_type294plank_items_dock_item_preferences_get_type
294plank_items_dock_item_preferences_new295plank_items_dock_item_preferences_new
295plank_items_dock_item_preferences_new_with_file296plank_items_dock_item_preferences_new_with_file
296plank_items_dock_item_preferences_new_with_filename297plank_items_dock_item_preferences_new_with_filename
298plank_items_dock_item_preferences_new_with_launcher
297plank_items_dock_item_preferences_set_Launcher299plank_items_dock_item_preferences_set_Launcher
298plank_items_dock_item_provider_add_item300plank_items_dock_item_provider_add_item
299plank_items_dock_item_provider_add_item_without_signaling301plank_items_dock_item_provider_add_item_without_signaling

Subscribers

People subscribed via source and target branches

to status/vote changes: