def _add_application_to_unity_launcher(self, transaction_details): if not self.add_to_launcher_enabled: return # mvo: use use softwarecenter.utils explicitly so that we can monkey # patch it in the test if not softwarecenter.utils.is_unity_running(): return app = Application(pkgname=transaction_details.pkgname, appname=transaction_details.appname) appdetails = app.get_details(self.db) # we only add items to the launcher that have a desktop file if not appdetails.desktop_file: return # do not add apps that have no Exec entry in their desktop file # (e.g. wine, see LP: #848437 or ubuntu-restricted-extras, # see LP: #913756) if (os.path.exists(appdetails.desktop_file) and not get_exec_line_from_desktop(appdetails.desktop_file)): return # now gather up the unity launcher info items and send the app to the # launcher service launcher_info = self._get_unity_launcher_info( app, appdetails, transaction_details.trans_id) self.unity_launcher.send_application_to_launcher( transaction_details.pkgname, launcher_info)
def _add_application_to_unity_launcher(self, transaction_details): app = Application(pkgname=transaction_details.pkgname, appname=transaction_details.appname) appdetails = app.get_details(self.db) # convert the app-install desktop file location to the actual installed # desktop file location (or in the case of a purchased item from the # agent, generate the correct installed desktop file location) installed_desktop_file_path = ( convert_desktop_file_to_installed_location(appdetails.desktop_file, app.pkgname)) # we only add items to the launcher that have a desktop file if not installed_desktop_file_path: return # do not add apps that have no Exec entry in their desktop file # (e.g. wine, see LP: #848437 or ubuntu-restricted-extras, # see LP: #913756), also, don't add the item if NoDisplay is # specified (see LP: #1006483) if (os.path.exists(installed_desktop_file_path) and (not get_exec_line_from_desktop(installed_desktop_file_path) or is_no_display_desktop_file(installed_desktop_file_path))): return # now gather up the unity launcher info items and send the app to the # launcher service launcher_info = self._get_unity_launcher_info( app, appdetails, installed_desktop_file_path, transaction_details.trans_id) self.unity_launcher.send_application_to_launcher( transaction_details.pkgname, launcher_info)
def _add_application_to_unity_launcher(self, transaction_details): if not self.add_to_launcher_enabled: return # mvo: use use softwarecenter.utils explicitly so that we can monkey # patch it in the test if not softwarecenter.utils.is_unity_running(): return app = Application(pkgname=transaction_details.pkgname, appname=transaction_details.appname) appdetails = app.get_details(self.db) # we only add items to the launcher that have a desktop file if not appdetails.desktop_file: return # do not add apps that have no Exec entry in their desktop file # (e.g. wine, see LP: #848437 or ubuntu-restricted-extras, # see LP: #913756) if (os.path.exists(appdetails.desktop_file) and not get_exec_line_from_desktop(appdetails.desktop_file)): return # now gather up the unity launcher info items and send the app to the # launcher service launcher_info = self._get_unity_launcher_info(app, appdetails, transaction_details.trans_id) self.unity_launcher.send_application_to_launcher( transaction_details.pkgname, launcher_info)
def _register_unity_launcher_transaction_started(self, backend, pkgname, appname, trans_id, trans_type): # mvo: use use softwarecenter.utils explictely so that we can monkey # patch it in the test if not softwarecenter.utils.is_unity_running(): return # add to launcher only applies in the details view currently if not self.is_app_details_view_showing(): return # we only care about getting the launcher information on an install if not trans_type == TransactionTypes.INSTALL: if pkgname in self.unity_launcher_items: self.unity_launcher_items.pop(pkgname) self.action_bar.clear() return # gather details for this transaction and create the launcher_info object app = Application(pkgname=pkgname, appname=appname) appdetails = app.get_details(self.db) (icon_size, icon_x, icon_y) = self._get_onscreen_icon_details_for_launcher_service(app) launcher_info = UnityLauncherInfo(app.name, appdetails.icon, "", # we set the icon_file_path value *after* install icon_x, icon_y, icon_size, appdetails.desktop_file, "", # we set the installed_desktop_file_path *after* install trans_id) self.unity_launcher_items[app.pkgname] = launcher_info self.show_add_to_launcher_panel(backend, pkgname, appname, app, appdetails, trans_id, trans_type)
def _register_unity_launcher_transaction_started(self, backend, pkgname, appname, trans_id, trans_type): # mvo: use use softwarecenter.utils explictely so that we can monkey # patch it in the test if not softwarecenter.utils.is_unity_running(): return # add to launcher only applies in the details view currently if not self.is_app_details_view_showing(): return # we only care about getting the launcher information on an install if not trans_type == TransactionTypes.INSTALL: if pkgname in self.unity_launcher_items: self.unity_launcher_items.pop(pkgname) self.action_bar.clear() return # gather details for this transaction and create the launcher_info object app = Application(pkgname=pkgname, appname=appname) appdetails = app.get_details(self.db) (icon_size, icon_x, icon_y) = self._get_onscreen_icon_details_for_launcher_service(app) launcher_info = UnityLauncherInfo(app.name, appdetails.icon, "", # we set the icon_file_path value *after* install icon_x, icon_y, icon_size, appdetails.desktop_file, "", # we set the installed_desktop_file_path *after* install trans_id) self.unity_launcher_items[app.pkgname] = launcher_info self.show_add_to_launcher_panel(backend, pkgname, appname, app, appdetails, trans_id, trans_type)
def _add_application_to_unity_launcher(self, transaction_details): app = Application(pkgname=transaction_details.pkgname, appname=transaction_details.appname) appdetails = app.get_details(self.db) # convert the app-install desktop file location to the actual installed # desktop file location (or in the case of a purchased item from the # agent, generate the correct installed desktop file location) installed_desktop_file_path = ( convert_desktop_file_to_installed_location(appdetails.desktop_file, app.pkgname)) # we only add items to the launcher that have a desktop file if not installed_desktop_file_path: return # do not add apps that have no Exec entry in their desktop file # (e.g. wine, see LP: #848437 or ubuntu-restricted-extras, # see LP: #913756), also, don't add the item if NoDisplay is # specified (see LP: #1006483) if (os.path.exists(installed_desktop_file_path) and (not get_exec_line_from_desktop(installed_desktop_file_path) or is_no_display_desktop_file(installed_desktop_file_path))): return # now gather up the unity launcher info items and send the app to the # launcher service launcher_info = self._get_unity_launcher_info(app, appdetails, installed_desktop_file_path, transaction_details.trans_id) self.unity_launcher.send_application_to_launcher( transaction_details.pkgname, launcher_info)
class TransactionDetails(object): """ Simple class to keep track of aptdaemon transaction details """ def __init__(self, db, pkgname, appname, trans_id, trans_type): self.db = db self.app = Application(pkgname=pkgname, appname=appname) self.trans_id = trans_id self.trans_type = trans_type self.__app_details = None self.__real_desktop = None if trans_type != TransactionTypes.INSTALL: self.guess_final_desktop_file() @property def app_details(self): if not self.__app_details: self.__app_details = self.app.get_details(self.db) return self.__app_details @property def desktop_file(self): return self.app_details.desktop_file @property def final_desktop_file(self): return self.guess_final_desktop_file() def guess_final_desktop_file(self): if self.__real_desktop: return self.__real_desktop # convert the app-install desktop file location to the actual installed # desktop file location (or in the case of a purchased item from the # agent, generate the correct installed desktop file location) desktop_file = ( convert_desktop_file_to_installed_location(self.desktop_file, self.app.pkgname)) # we only add items to the launcher that have a desktop file if not desktop_file: return # do not add apps that have no Exec entry in their desktop file # (e.g. wine, see LP: #848437 or ubuntu-restricted-extras, # see LP: #913756), also, don't add the item if NoDisplay is # specified (see LP: #1006483) if (os.path.exists(desktop_file) and (not get_exec_line_from_desktop(desktop_file) or is_no_display_desktop_file(desktop_file))): return self.__real_desktop = desktop_file return self.__real_desktop