Merge lp:~gary-lasker/software-center/keep-add-to-launcher-offer-lp765389 into lp:software-center

Proposed by Gary Lasker
Status: Merged
Merged at revision: 1743
Proposed branch: lp:~gary-lasker/software-center/keep-add-to-launcher-offer-lp765389
Merge into: lp:software-center
Diff against target: 178 lines (+72/-38)
2 files modified
debian/changelog (+9/-0)
softwarecenter/view/softwarepane.py (+63/-38)
To merge this branch: bzr merge lp:~gary-lasker/software-center/keep-add-to-launcher-offer-lp765389
Reviewer Review Type Date Requested Status
Michael Vogt Pending
Review via email: mp+58414@code.launchpad.net

Description of the change

This branch keeps the offer to add an application to the launcher displayed for the full duration of the time that the details view for that application is showing. Previously, we removed the offer when the installation was complete (this was a side-effect of the earlier design, aka "plan a", but in no way is it necessary to do this). Now, if an installation has been completed, then clicking "Add to Launcher" will immediately make the dbus call to Unity and the application will appear in the launcher. If "Add to Launcher" is clicked before the installation is completed, it is simply queued and is then added after install exactly as it worked previously.

This branch continues to work for multiple simultaneous installs, queuing up launcher add requests and executing them at the end of each install, as required.

I think this fix greatly enhances the usability of the "Add to Launcher" feature, particularly in cases where an application install is extremely quick (as described in the bug report from Martin), and I think it would be very worthwhile to get this for natty. Note that I tested it pretty heavily under many different combinations of install/navigate/install another/remove/etc.

Many thanks!

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for this branch. I think its a important and useful fix. However the current branch fails in test_unity_launcher_itegration.py. I look at this next.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2011-04-19 18:44:02 +0000
+++ debian/changelog 2011-04-20 00:46:25 +0000
@@ -1,3 +1,12 @@
1software-center (3.1.26.9) UNRELEASED; urgency=low
2
3 * softwarecenter/view/softwarepane.py:
4 - display the offer to add an application to the launcher
5 for the duration of the time that the details view
6 is showing (LP: #765389)
7
8 -- Gary Lasker <gary.lasker@canonical.com> Tue, 19 Apr 2011 20:32:20 -0400
9
1software-center (3.1.26.8) natty; urgency=low10software-center (3.1.26.8) natty; urgency=low
211
3 * softwarecenter/log.py:12 * softwarecenter/log.py:
413
=== modified file 'softwarecenter/view/softwarepane.py'
--- softwarecenter/view/softwarepane.py 2011-04-16 22:54:41 +0000
+++ softwarecenter/view/softwarepane.py 2011-04-20 00:46:25 +0000
@@ -139,6 +139,7 @@
139 self.app_install_desktop_file_path = app_install_desktop_file_path139 self.app_install_desktop_file_path = app_install_desktop_file_path
140 self.installed_desktop_file_path = installed_desktop_file_path140 self.installed_desktop_file_path = installed_desktop_file_path
141 self.trans_id = trans_id141 self.trans_id = trans_id
142 self.add_to_launcher_requested = False
142143
143class SoftwarePane(gtk.VBox, BasePane):144class SoftwarePane(gtk.VBox, BasePane):
144 """ Common base class for InstalledPane, AvailablePane and ChannelPane"""145 """ Common base class for InstalledPane, AvailablePane and ChannelPane"""
@@ -178,7 +179,7 @@
178 self.apps_category = None179 self.apps_category = None
179 self.apps_subcategory = None180 self.apps_subcategory = None
180 self.apps_search_term = None181 self.apps_search_term = None
181 # keep track of applications that have been requested to be added182 # keep track of applications that are candidates to be added
182 # to the Unity launcher183 # to the Unity launcher
183 self.unity_launcher_items = {}184 self.unity_launcher_items = {}
184 # Create the basic frame for the common view185 # Create the basic frame for the common view
@@ -373,9 +374,39 @@
373 self.navigation_bar.set_active(details_button)374 self.navigation_bar.set_active(details_button)
374 375
375 def on_transaction_started(self, backend, pkgname, appname, trans_id, trans_type):376 def on_transaction_started(self, backend, pkgname, appname, trans_id, trans_type):
376 self.show_add_to_launcher_panel(backend, pkgname, appname, trans_id, trans_type)377 # add to launcher only applies in the details view currently
378 if not self.is_app_details_view_showing():
379 return
380 # we only care about getting the launcher information on an install
381 if not trans_type == TRANSACTION_TYPE_INSTALL:
382 if pkgname in self.unity_launcher_items:
383 self.unity_launcher_items.pop(pkgname)
384 self.action_bar.clear()
385 return
386 # gather details for this transaction and create the launcher_info object
387 app = Application(pkgname=pkgname, appname=appname)
388 appdetails = app.get_details(self.db)
389 (icon_size, icon_x, icon_y) = self._get_onscreen_icon_details_for_launcher_service(app)
390 launcher_info = UnityLauncherInfo(app.name,
391 appdetails.icon,
392 "", # we set the icon_file_path value *after* install
393 icon_x,
394 icon_y,
395 icon_size,
396 appdetails.desktop_file,
397 "", # we set the installed_desktop_file_path *after* install
398 trans_id)
399 self.unity_launcher_items[app.pkgname] = launcher_info
400 self.show_add_to_launcher_panel(backend, pkgname, appname, app, appdetails, trans_id, trans_type)
401
402 def _get_onscreen_icon_details_for_launcher_service(self, app):
403 if self.is_app_details_view_showing():
404 return self.app_details_view.get_app_icon_details()
405 else:
406 # TODO: implement the app list view case once it has been specified
407 return (0, 0, 0)
377 408
378 def show_add_to_launcher_panel(self, backend, pkgname, appname, trans_id, trans_type):409 def show_add_to_launcher_panel(self, backend, pkgname, appname, app, appdetails, trans_id, trans_type):
379 """410 """
380 if Unity is currently running, display a panel to allow the user411 if Unity is currently running, display a panel to allow the user
381 the choose whether to add a newly-installed application to the412 the choose whether to add a newly-installed application to the
@@ -392,69 +423,63 @@
392 not trans_type == TRANSACTION_TYPE_INSTALL or423 not trans_type == TRANSACTION_TYPE_INSTALL or
393 not self.is_app_details_view_showing()):424 not self.is_app_details_view_showing()):
394 return425 return
395 app = Application(pkgname=pkgname, appname=appname)
396 appdetails = app.get_details(self.db)
397 # we only show the prompt for apps with a desktop file426 # we only show the prompt for apps with a desktop file
398 if not appdetails.desktop_file:427 if not appdetails.desktop_file:
399 return428 return
400 self.action_bar.add_button(ACTION_BUTTON_CANCEL_ADD_TO_LAUNCHER,429 self.action_bar.add_button(ACTION_BUTTON_CANCEL_ADD_TO_LAUNCHER,
401 _("Not Now"), 430 _("Not Now"),
402 self.on_cancel_add_to_launcher, 431 self.on_cancel_add_to_launcher,
403 None)432 pkgname)
404 self.action_bar.add_button(ACTION_BUTTON_ADD_TO_LAUNCHER,433 self.action_bar.add_button(ACTION_BUTTON_ADD_TO_LAUNCHER,
405 _("Add to Launcher"),434 _("Add to Launcher"),
406 self.on_add_to_launcher,435 self.on_add_to_launcher,
436 pkgname,
407 app,437 app,
408 appdetails,438 appdetails,
409 trans_id)439 trans_id)
410 self.action_bar.set_label(_("Add %s to the launcher?") % app.name)440 self.action_bar.set_label(_("Add %s to the launcher?") % app.name)
411 441
412 def on_add_to_launcher(self, app, appdetails, trans_id):442 def on_add_to_launcher(self, pkgname, app, appdetails, trans_id):
413 """443 """
414 callback indicating the user has chosen to add the indicated application444 callback indicating the user has chosen to add the indicated application
415 to the launcher445 to the launcher
416 """446 """
417 LOG.debug("the application '%s' will be added to the Unity launcher when installation is complete" % app.name)447 if pkgname in self.unity_launcher_items:
418 (icon_size, icon_x, icon_y) = self._get_onscreen_icon_details_for_launcher_service(app)448 launcher_info = self.unity_launcher_items[pkgname]
419 launcher_info = UnityLauncherInfo(app.name,449 if launcher_info.installed_desktop_file_path:
420 appdetails.icon,450 # package install is complete, we can add to the launcher immediately
421 "", # we set the icon_file_path value *after* install451 self.unity_launcher_items.pop(pkgname)
422 icon_x,452 self.action_bar.clear()
423 icon_y,453 self._send_dbus_signal_to_unity_launcher(launcher_info)
424 icon_size,454 else:
425 appdetails.desktop_file,455 # package is not yet installed, it will be added to the launcher
426 "", # we set the installed_desktop_file_path *after* install456 # once the installation is complete
427 trans_id)457 LOG.debug("the application '%s' will be added to the Unity launcher when installation is complete" % app.name)
428 self.unity_launcher_items[app.pkgname] = launcher_info458 launcher_info.add_to_launcher_requested = True
429 self.action_bar.set_label(_("%s will be added to the launcher when installation completes.") % app.name)459 self.action_bar.set_label(_("%s will be added to the launcher when installation completes.") % app.name)
430 self.action_bar.remove_button(ACTION_BUTTON_CANCEL_ADD_TO_LAUNCHER)460 self.action_bar.remove_button(ACTION_BUTTON_CANCEL_ADD_TO_LAUNCHER)
431 self.action_bar.remove_button(ACTION_BUTTON_ADD_TO_LAUNCHER)461 self.action_bar.remove_button(ACTION_BUTTON_ADD_TO_LAUNCHER)
432462
433 def _get_onscreen_icon_details_for_launcher_service(self, app):463 def on_cancel_add_to_launcher(self, pkgname):
434 if self.is_app_details_view_showing():464 if pkgname in self.unity_launcher_items:
435 return self.app_details_view.get_app_icon_details()465 self.unity_launcher_items.pop(pkgname)
436 else:
437 # TODO: implement the app list view case once it has been specified
438 return (0, 0, 0)
439
440 def on_cancel_add_to_launcher(self, args):
441 self.action_bar.clear()466 self.action_bar.clear()
442 467
443 def on_transaction_finished(self, backend, result):468 def on_transaction_finished(self, backend, result):
444 # if requested, add this item to the Unity launcher469 # add the completed transaction details to the corresponding launcher_item
445 if result.pkgname in self.unity_launcher_items:470 if result.pkgname in self.unity_launcher_items:
446 launcher_info = self.unity_launcher_items.pop(result.pkgname)471 launcher_info = self.unity_launcher_items[result.pkgname]
447 launcher_info.icon_file_path = get_file_path_from_iconname(self.icons,472 launcher_info.icon_file_path = get_file_path_from_iconname(self.icons,
448 launcher_info.icon_name)473 launcher_info.icon_name)
449 launcher_info.installed_desktop_file_path \474 launcher_info.installed_desktop_file_path \
450 = convert_desktop_file_to_installed_location(launcher_info.app_install_desktop_file_path,475 = convert_desktop_file_to_installed_location(launcher_info.app_install_desktop_file_path,
451 result.pkgname)476 result.pkgname)
452 if result.success:477 # if the request to add to launcher has already been made, do it now
453 self._send_dbus_signal_to_unity_launcher(launcher_info)478 if launcher_info.add_to_launcher_requested:
454 self.action_bar.clear()479 if result.success:
455 # if the user never selected a choice in the action bar, just clear it480 self._send_dbus_signal_to_unity_launcher(launcher_info)
456 elif self.action_bar.get_button(ACTION_BUTTON_ADD_TO_LAUNCHER):481 self.unity_launcher_items.pop(result.pkgname)
457 self.action_bar.clear()482 self.action_bar.clear()
458 483
459 def _send_dbus_signal_to_unity_launcher(self, launcher_info):484 def _send_dbus_signal_to_unity_launcher(self, launcher_info):
460 LOG.debug("sending dbus signal to Unity launcher for application: ", launcher_info.name)485 LOG.debug("sending dbus signal to Unity launcher for application: ", launcher_info.name)

Subscribers

People subscribed via source and target branches