171
168
self.scroll_categories = Gtk.ScrolledWindow()
172
169
self.scroll_categories.set_policy(Gtk.PolicyType.AUTOMATIC,
173
170
Gtk.PolicyType.AUTOMATIC)
174
with ExecutionTime("create LobbyViewGtk"):
175
self.cat_view = LobbyViewGtk(self.datadir, APP_INSTALL_PATH,
171
with ExecutionTime("create LobbyView"):
172
self.cat_view = LobbyView(
173
self.cache, self.db, self.icons, self.apps_filter)
180
174
self.scroll_categories.add(self.cat_view)
181
175
self.notebook.append_page(self.scroll_categories,
182
176
Gtk.Label(label="categories"))
184
178
# sub-categories view
185
with ExecutionTime("create SubCategoryViewGtk"):
186
self.subcategories_view = SubCategoryViewGtk(self.datadir,
192
root_category=self.cat_view.categories[0])
179
with ExecutionTime("create SubCategoryView"):
180
self.subcategories_view = SubCategoryView(
181
self.cache, self.db, self.icons, self.apps_filter,
182
root_category=self.cat_view.categories[0])
193
183
self.subcategories_view.connect(
194
184
"category-selected", self.on_subcategory_activated)
195
185
self.subcategories_view.connect(
196
"application-activated", self.on_application_activated)
197
self.subcategories_view.connect(
198
186
"show-category-applist", self.on_show_category_applist)
199
# FIXME: why do we have two application-{selected,activated] ?!?
200
self.subcategories_view.connect(
201
"application-selected", self.on_application_selected)
202
187
self.subcategories_view.connect(
203
188
"application-activated", self.on_application_activated)
204
189
self.scroll_subcategories = Gtk.ScrolledWindow()
403
384
if self._is_custom_list_search(self.state.search_term):
404
385
self._update_action_bar()
405
# add app to unity launcher on the first sign of progress
406
# and remove from the pending queue once that is done
407
for pkgname in pending_transactions:
408
if pkgname in self.unity_launcher_transaction_queue:
409
transaction_details = (
410
self.unity_launcher_transaction_queue.pop(pkgname))
411
self._add_application_to_unity_launcher(transaction_details)
413
387
def on_transaction_complete(self, backend, result):
388
""" handle a transaction that has completed successfully
390
if result.pkgname in self.unity_launcher_transaction_queue:
391
transaction_details = (
392
self.unity_launcher_transaction_queue.pop(result.pkgname))
393
self._add_application_to_unity_launcher(transaction_details)
395
def on_transaction_cancelled(self, backend, result):
396
""" handle a transaction that has been cancelled
414
398
if result.pkgname in self.unity_launcher_transaction_queue:
415
399
self.unity_launcher_transaction_queue.pop(result.pkgname)
401
def _register_unity_launcher_transaction_started(self, pkgname, appname,
402
trans_id, trans_type):
403
# at the start of the transaction, we gather details for use later
404
# when it is time to add the installed app to the Unity launcher,
405
# (see #972710). we only care about installs for the launcher
406
# mvo: use softwarecenter.utils explicitly here so that we can monkey
407
# patch it in the test
408
config = get_config()
409
if (trans_type == TransactionTypes.INSTALL and
410
config.add_to_unity_launcher and
411
softwarecenter.utils.is_unity_running()):
412
transaction_details = TransactionDetails(
413
pkgname, appname, trans_id, trans_type)
414
self.unity_launcher_transaction_queue[pkgname] = (
417
417
def _add_application_to_unity_launcher(self, transaction_details):
418
if not self.add_to_launcher_enabled:
420
# mvo: use use softwarecenter.utils explicitly so that we can monkey
421
# patch it in the test
422
if not softwarecenter.utils.is_unity_running():
425
418
app = Application(pkgname=transaction_details.pkgname,
426
419
appname=transaction_details.appname)
427
420
appdetails = app.get_details(self.db)
421
# convert the app-install desktop file location to the actual installed
422
# desktop file location (or in the case of a purchased item from the
423
# agent, generate the correct installed desktop file location)
424
installed_desktop_file_path = (
425
convert_desktop_file_to_installed_location(appdetails.desktop_file,
428
427
# we only add items to the launcher that have a desktop file
429
if not appdetails.desktop_file:
428
if not installed_desktop_file_path:
431
430
# do not add apps that have no Exec entry in their desktop file
432
431
# (e.g. wine, see LP: #848437 or ubuntu-restricted-extras,
434
if (os.path.exists(appdetails.desktop_file) and
435
not get_exec_line_from_desktop(appdetails.desktop_file)):
432
# see LP: #913756), also, don't add the item if NoDisplay is
433
# specified (see LP: #1006483)
434
if (os.path.exists(installed_desktop_file_path) and
435
(not get_exec_line_from_desktop(installed_desktop_file_path) or
436
is_no_display_desktop_file(installed_desktop_file_path))):
438
439
# now gather up the unity launcher info items and send the app to the
439
440
# launcher service
440
441
launcher_info = self._get_unity_launcher_info(app, appdetails,
442
installed_desktop_file_path,
441
443
transaction_details.trans_id)
442
444
self.unity_launcher.send_application_to_launcher(
443
445
transaction_details.pkgname,
446
def _get_unity_launcher_info(self, app, appdetails, trans_id):
448
def _get_unity_launcher_info(
449
self, app, appdetails, installed_desktop_file_path, trans_id):
447
450
(icon_size, icon_x, icon_y) = (
448
451
self._get_onscreen_icon_details_for_launcher_service(app))
449
452
icon_path = get_file_path_from_iconname(
451
iconname=appdetails.icon_file_name)
454
iconname=appdetails.icon)
455
# Note that the transaction ID is not specified because we are firing
456
# the dbus signal at the very end of the installation now, and the
457
# corresponding fix in Unity is expecting this value to be empty (it
458
# would not be useful to the Unity launcher at this point anyway,
459
# as the corresponding transaction would be complete).
460
# Please see bug LP: #925014 and corresponding Unity branch for
462
# TODO: If and when we re-implement firing the dbus signal at the
463
# start of the transaction, at that time we will need to replace
464
# the empty string below with the trans_id value.
452
465
launcher_info = UnityLauncherInfo(app.name,
458
appdetails.desktop_file,
471
installed_desktop_file_path,
460
473
return launcher_info
462
475
def _get_onscreen_icon_details_for_launcher_service(self, app):