def __init__(self, serverid, name): try: obj = gio.unix.DesktopAppInfo("gvim.desktop") except RuntimeError: obj = gio.AppInfo(VIM) Leaf.__init__(self, obj, name) self.serverid = serverid
def get_app_info(self, commandline, application_name=None, flags=gio.APP_INFO_CREATE_NONE): try: return gio.AppInfo(commandline, application_name, flags) except: print "get app info failed"
def set_app_from_file(self, file): ''' Установка в буфер приложения для ассоциации на основе файла ''' dirpath = os.path.dirname(file) in_path = False for i in os.getenv('PATH').split(':'): if i == dirpath: in_path = True break if in_path: file = os.path.basename(file) self.__set_new_app__(gio.AppInfo(file, os.path.basename(file)))
def on_add_button_clicked(self, widget): dialog = AddAppDialog(self.types[0], widget.get_toplevel()) if dialog.run() == gtk.RESPONSE_ACCEPT: if dialog.get_command_runable(): we = dialog.get_command_or_appinfo() if type(we) == gio.unix.DesktopAppInfo: app = we else: app = gio.AppInfo(we) for filetype in self.types: app.set_as_default_for_type(filetype) self.update_model() self.emit('update', self.types) else: ErrorDialog(_('Could not find %s') % dialog.get_command_or_appinfo(), title=_('Could not find application')).launch() dialog.destroy()
def setUp(self): self.appinfo = gio.AppInfo("does-not-exist")
def menu_pressed(self, menu_id): gio.AppInfo(self.items[self.id_map[menu_id]]).launch()