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.
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
1=== modified file 'debian/changelog'
2--- debian/changelog 2011-04-19 18:44:02 +0000
3+++ debian/changelog 2011-04-20 00:46:25 +0000
4@@ -1,3 +1,12 @@
5+software-center (3.1.26.9) UNRELEASED; urgency=low
6+
7+ * softwarecenter/view/softwarepane.py:
8+ - display the offer to add an application to the launcher
9+ for the duration of the time that the details view
10+ is showing (LP: #765389)
11+
12+ -- Gary Lasker <gary.lasker@canonical.com> Tue, 19 Apr 2011 20:32:20 -0400
13+
14 software-center (3.1.26.8) natty; urgency=low
15
16 * softwarecenter/log.py:
17
18=== modified file 'softwarecenter/view/softwarepane.py'
19--- softwarecenter/view/softwarepane.py 2011-04-16 22:54:41 +0000
20+++ softwarecenter/view/softwarepane.py 2011-04-20 00:46:25 +0000
21@@ -139,6 +139,7 @@
22 self.app_install_desktop_file_path = app_install_desktop_file_path
23 self.installed_desktop_file_path = installed_desktop_file_path
24 self.trans_id = trans_id
25+ self.add_to_launcher_requested = False
26
27 class SoftwarePane(gtk.VBox, BasePane):
28 """ Common base class for InstalledPane, AvailablePane and ChannelPane"""
29@@ -178,7 +179,7 @@
30 self.apps_category = None
31 self.apps_subcategory = None
32 self.apps_search_term = None
33- # keep track of applications that have been requested to be added
34+ # keep track of applications that are candidates to be added
35 # to the Unity launcher
36 self.unity_launcher_items = {}
37 # Create the basic frame for the common view
38@@ -373,9 +374,39 @@
39 self.navigation_bar.set_active(details_button)
40
41 def on_transaction_started(self, backend, pkgname, appname, trans_id, trans_type):
42- self.show_add_to_launcher_panel(backend, pkgname, appname, trans_id, trans_type)
43+ # add to launcher only applies in the details view currently
44+ if not self.is_app_details_view_showing():
45+ return
46+ # we only care about getting the launcher information on an install
47+ if not trans_type == TRANSACTION_TYPE_INSTALL:
48+ if pkgname in self.unity_launcher_items:
49+ self.unity_launcher_items.pop(pkgname)
50+ self.action_bar.clear()
51+ return
52+ # gather details for this transaction and create the launcher_info object
53+ app = Application(pkgname=pkgname, appname=appname)
54+ appdetails = app.get_details(self.db)
55+ (icon_size, icon_x, icon_y) = self._get_onscreen_icon_details_for_launcher_service(app)
56+ launcher_info = UnityLauncherInfo(app.name,
57+ appdetails.icon,
58+ "", # we set the icon_file_path value *after* install
59+ icon_x,
60+ icon_y,
61+ icon_size,
62+ appdetails.desktop_file,
63+ "", # we set the installed_desktop_file_path *after* install
64+ trans_id)
65+ self.unity_launcher_items[app.pkgname] = launcher_info
66+ self.show_add_to_launcher_panel(backend, pkgname, appname, app, appdetails, trans_id, trans_type)
67+
68+ def _get_onscreen_icon_details_for_launcher_service(self, app):
69+ if self.is_app_details_view_showing():
70+ return self.app_details_view.get_app_icon_details()
71+ else:
72+ # TODO: implement the app list view case once it has been specified
73+ return (0, 0, 0)
74
75- def show_add_to_launcher_panel(self, backend, pkgname, appname, trans_id, trans_type):
76+ def show_add_to_launcher_panel(self, backend, pkgname, appname, app, appdetails, trans_id, trans_type):
77 """
78 if Unity is currently running, display a panel to allow the user
79 the choose whether to add a newly-installed application to the
80@@ -392,69 +423,63 @@
81 not trans_type == TRANSACTION_TYPE_INSTALL or
82 not self.is_app_details_view_showing()):
83 return
84- app = Application(pkgname=pkgname, appname=appname)
85- appdetails = app.get_details(self.db)
86 # we only show the prompt for apps with a desktop file
87 if not appdetails.desktop_file:
88 return
89 self.action_bar.add_button(ACTION_BUTTON_CANCEL_ADD_TO_LAUNCHER,
90 _("Not Now"),
91 self.on_cancel_add_to_launcher,
92- None)
93+ pkgname)
94 self.action_bar.add_button(ACTION_BUTTON_ADD_TO_LAUNCHER,
95 _("Add to Launcher"),
96 self.on_add_to_launcher,
97+ pkgname,
98 app,
99 appdetails,
100 trans_id)
101 self.action_bar.set_label(_("Add %s to the launcher?") % app.name)
102
103- def on_add_to_launcher(self, app, appdetails, trans_id):
104+ def on_add_to_launcher(self, pkgname, app, appdetails, trans_id):
105 """
106 callback indicating the user has chosen to add the indicated application
107 to the launcher
108 """
109- LOG.debug("the application '%s' will be added to the Unity launcher when installation is complete" % app.name)
110- (icon_size, icon_x, icon_y) = self._get_onscreen_icon_details_for_launcher_service(app)
111- launcher_info = UnityLauncherInfo(app.name,
112- appdetails.icon,
113- "", # we set the icon_file_path value *after* install
114- icon_x,
115- icon_y,
116- icon_size,
117- appdetails.desktop_file,
118- "", # we set the installed_desktop_file_path *after* install
119- trans_id)
120- self.unity_launcher_items[app.pkgname] = launcher_info
121- self.action_bar.set_label(_("%s will be added to the launcher when installation completes.") % app.name)
122- self.action_bar.remove_button(ACTION_BUTTON_CANCEL_ADD_TO_LAUNCHER)
123- self.action_bar.remove_button(ACTION_BUTTON_ADD_TO_LAUNCHER)
124+ if pkgname in self.unity_launcher_items:
125+ launcher_info = self.unity_launcher_items[pkgname]
126+ if launcher_info.installed_desktop_file_path:
127+ # package install is complete, we can add to the launcher immediately
128+ self.unity_launcher_items.pop(pkgname)
129+ self.action_bar.clear()
130+ self._send_dbus_signal_to_unity_launcher(launcher_info)
131+ else:
132+ # package is not yet installed, it will be added to the launcher
133+ # once the installation is complete
134+ LOG.debug("the application '%s' will be added to the Unity launcher when installation is complete" % app.name)
135+ launcher_info.add_to_launcher_requested = True
136+ self.action_bar.set_label(_("%s will be added to the launcher when installation completes.") % app.name)
137+ self.action_bar.remove_button(ACTION_BUTTON_CANCEL_ADD_TO_LAUNCHER)
138+ self.action_bar.remove_button(ACTION_BUTTON_ADD_TO_LAUNCHER)
139
140- def _get_onscreen_icon_details_for_launcher_service(self, app):
141- if self.is_app_details_view_showing():
142- return self.app_details_view.get_app_icon_details()
143- else:
144- # TODO: implement the app list view case once it has been specified
145- return (0, 0, 0)
146-
147- def on_cancel_add_to_launcher(self, args):
148+ def on_cancel_add_to_launcher(self, pkgname):
149+ if pkgname in self.unity_launcher_items:
150+ self.unity_launcher_items.pop(pkgname)
151 self.action_bar.clear()
152
153 def on_transaction_finished(self, backend, result):
154- # if requested, add this item to the Unity launcher
155+ # add the completed transaction details to the corresponding launcher_item
156 if result.pkgname in self.unity_launcher_items:
157- launcher_info = self.unity_launcher_items.pop(result.pkgname)
158+ launcher_info = self.unity_launcher_items[result.pkgname]
159 launcher_info.icon_file_path = get_file_path_from_iconname(self.icons,
160 launcher_info.icon_name)
161 launcher_info.installed_desktop_file_path \
162 = convert_desktop_file_to_installed_location(launcher_info.app_install_desktop_file_path,
163 result.pkgname)
164- if result.success:
165- self._send_dbus_signal_to_unity_launcher(launcher_info)
166- self.action_bar.clear()
167- # if the user never selected a choice in the action bar, just clear it
168- elif self.action_bar.get_button(ACTION_BUTTON_ADD_TO_LAUNCHER):
169- self.action_bar.clear()
170+ # if the request to add to launcher has already been made, do it now
171+ if launcher_info.add_to_launcher_requested:
172+ if result.success:
173+ self._send_dbus_signal_to_unity_launcher(launcher_info)
174+ self.unity_launcher_items.pop(result.pkgname)
175+ self.action_bar.clear()
176
177 def _send_dbus_signal_to_unity_launcher(self, launcher_info):
178 LOG.debug("sending dbus signal to Unity launcher for application: ", launcher_info.name)

Subscribers

People subscribed via source and target branches