def test_eq(self): info1 = gio.app_info_get_all()[0] info2 = info1.dup() self.assert_(info1 is not info2) self.assertEquals(info1, info2) self.assertNotEqual(gio.app_info_get_all()[0], gio.app_info_get_all()[1])
def get_items(self): # If we set proper desktop environment # We get exactly the apps shown in the menu, # as well as the preference panes desktop_type = __kupfer_settings__["desktop_type"] desktop_app_info_set_desktop_env(desktop_type) # Add this to the default whitelist = set([ # if you set/reset default handler for folders it is useful "nautilus-folder-handler.desktop", # we think that these are useful to show "eog.desktop", "evince.desktop", "gnome-about.desktop", "gstreamer-properties.desktop", "notification-properties.desktop", ]) blacklist = set([ "nautilus-home.desktop", ]) for item in app_info_get_all(): id_ = item.get_id() if id_ in whitelist or (item.should_show() and not id_ in blacklist): yield AppLeaf(item)
def setup_treeview(self): model = gtk.ListStore(gobject.GObject, gtk.gdk.Pixbuf, gobject.TYPE_STRING) self.app_view.set_model(model) self.app_view.set_headers_visible(False) column = gtk.TreeViewColumn() renderer = gtk.CellRendererPixbuf() column.pack_start(renderer, False) column.set_attributes(renderer, pixbuf = TYPE_ADD_APPLOGO) renderer = gtk.CellRendererText() column.pack_start(renderer, False) column.set_attributes(renderer, text = TYPE_ADD_APPNAME) column.set_sort_column_id(TYPE_DESCRIPTION) self.app_view.append_column(column) for appinfo in gio.app_info_get_all(): if appinfo.supports_files() or appinfo.supports_uris(): applogo = get_icon_with_app(appinfo, 24) appname = appinfo.get_name() iter = model.append() model.set(iter, TYPE_ADD_APPINFO, appinfo, TYPE_ADD_APPLOGO, applogo, TYPE_ADD_APPNAME, appname)
def setup_treeview(self): model = gtk.ListStore(gobject.GObject, gtk.gdk.Pixbuf, gobject.TYPE_STRING) self.app_view.set_model(model) self.app_view.set_headers_visible(False) column = gtk.TreeViewColumn() renderer = gtk.CellRendererPixbuf() column.pack_start(renderer, False) column.set_attributes(renderer, pixbuf=TYPE_ADD_APPLOGO) renderer = gtk.CellRendererText() column.pack_start(renderer, False) column.set_attributes(renderer, text=TYPE_ADD_APPNAME) column.set_sort_column_id(TYPE_DESCRIPTION) self.app_view.append_column(column) for appinfo in gio.app_info_get_all(): if appinfo.supports_files() or appinfo.supports_uris(): applogo = icon.get_from_app(appinfo) appname = appinfo.get_name() iter = model.append() model.set(iter, TYPE_ADD_APPINFO, appinfo, TYPE_ADD_APPLOGO, applogo, TYPE_ADD_APPNAME, appname)
def _load_applications(self): treestore = self.treeviewApplications.get_model() treestore.clear() self.added_applications = [] #self.interfacetype = 'text/xml' app_list = gio.app_info_get_default_for_type(self.interfacetype, False) row = self._load_application_group(_('Default application'), '', [app_list], treestore) app_list = gio.app_info_get_all_for_type(self.interfacetype) self._load_application_group(_('Recommended applications'), '', app_list, treestore) app_list = gio.app_info_get_all() self._load_application_group(_('Other applications'), '', app_list, treestore) self.treeviewApplications.set_model(treestore) #self.treeviewApplications.expand_all() try: self.treeviewApplications.expand_row((0,), False) except: pass
def __desktop_entry(self): import gio app_infos = gio.app_info_get_all() for app_info in app_infos: if app_info.get_name() == blaconst.APPNAME: return blautil.toss_extension(app_info.get_id()) return ""
def __init__(self, sink, path): DockManagerItem.__init__(self, sink, path) self.monitor = None self.recent = [] self.most = [] self.ids = {} self.has_uri = True self.uri = self.iface.Get(DOCKITEM_IFACE, "Uri", dbus_interface="org.freedesktop.DBus.Properties") if not self.uri: self.has_uri = False self.uri = self.iface.Get(DOCKITEM_IFACE, "DesktopFile", dbus_interface="org.freedesktop.DBus.Properties") self.uri = 'application://%s' % self.uri[self.uri.rfind('/')+1:] self.app_info = None app_uri = self.iface.Get(DOCKITEM_IFACE, "DesktopFile", dbus_interface="org.freedesktop.DBus.Properties") apps = gio.app_info_get_all() app = None t_app = app_uri.split("/")[-1].replace(".desktop", "") if t_app: for app in apps: if t_app in app.get_executable(): self.app_info = app break self.update_entries()
def __init__(self, filetype, apps=False): gtk.TreeView.__init__(self) self.set_rules_hint(True) #self.set_grid_lines(False) self.get_selection().set_mode(gtk.SELECTION_BROWSE) if apps: self.Apps_list = [i for i in gio.app_info_get_all_for_type(filetype) if i != gio.app_info_get_default_for_type(filetype, False)] else: self.Apps_list = [i for i in gio.app_info_get_all() if i != gio.app_info_get_default_for_type(filetype, False)]
def get_gio_application_by_id(self, id): """Get GIO AppInfo object for specified Id""" result = None for app_info in gio.app_info_get_all(): if app_info.get_id() == id: result = app_info break return result
def get_pkg_desktop_info(self, desktops): app_infos = [] all_app_infos = gio.app_info_get_all() for desktop in desktops: app_info = gio.unix.desktop_app_info_new_from_filename(desktop) if app_info: for item in all_app_infos: if app_info.get_commandline() == item.get_commandline(): app_infos.append(app_info) return app_infos
def initialize(self): try: import gio except: sys.path.append("/usr/lib/python2.7/dist-packages") try: import gio except: logger.error("Could not import gio") return tokenizer = EnglishTokenizer() for app in gio.app_info_get_all(): name = app.get_name().lower() entry = [app] tokenized_name = tokenizer.tokenize(name)[0] if name in self.appmap: self.appmap[name] += entry else: self.appmap[name] = entry self.register_vocabulary(name, "Application") if name != tokenized_name: self.register_vocabulary(tokenized_name, "Application") if tokenized_name in self.appmap: self.appmap[tokenized_name] += entry else: self.appmap[tokenized_name] = entry launch_intent = IntentBuilder( "LaunchDesktopApplicationIntent").require("LaunchKeyword").require( "Application").build() self.register_intent(launch_intent, self.handle_launch_desktop_app) close_intent = IntentBuilder( "CloseDesktopApplicationIntent").require("CloseKeyword").require( "Application").build() self.register_intent(close_intent, self.handle_close_desktop_app) launch_website_intent = IntentBuilder( "LaunchWebsiteIntent").require("LaunchKeyword").require( "Website").build() self.register_intent(launch_website_intent, self.handle_launch_website) search_website = IntentBuilder("SearchWebsiteIntent").require( "SearchKeyword").require("Website").require( "SearchTerms").build() self.register_intent(search_website, self.handle_search_website) launch_playlist_intent = IntentBuilder( "LaunchPlaylistIntent").require("LaunchKeyword").require( "Playlist").build() self.register_intent(launch_playlist_intent, self.handle_launch_playlist)
def set_default_application_for_type(self, mime_type, application_id): """Set default application for specified type""" result = False for app_info in gio.app_info_get_all(): if application_id == app_info.get_id(): app_info.set_as_default_for_type(mime_type) result = True break return result
def get_items(self): # If we set proper desktop environment # We get exactly the apps shown in the menu, # as well as the preference panes desktop_type = __kupfer_settings__["desktop_type"] desktop_app_info_set_desktop_env(desktop_type) # Add this to the default whitelist = [] for item in app_info_get_all(): if item.should_show() or item.get_id() in whitelist: yield AppLeaf(item)
def __init__(self): self.all_apps = gio.app_info_get_all() self.connections = [] self.screen = wnck.screen_get_default() while gtk.events_pending(): gtk.main_iteration() id_ = self.screen.connect("window-opened", self.on_window_change) self.connections.append(id_) id_ = self.screen.connect("window-closed", self.on_window_change) self.connections.append(id_) self.items = []
def get_items(self): # If we set proper desktop environment # We get exactly the apps shown in the menu, # as well as the preference panes desktop_type = __kupfer_settings__["desktop_type"] desktop_app_info_set_desktop_env(desktop_type) # Add this to the default # if you set/reset default handler for folders it is useful whitelist = set(["nautilus-folder-handler.desktop"]) for item in app_info_get_all(): if item.should_show() or item.get_id() in whitelist: yield AppLeaf(item)
def initialize(self): try: import gio except: sys.path.append("/usr/lib/python2.7/dist-packages") try: import gio except: logger.error("Could not import gio") return vocab_dir = os.path.join(os.path.dirname(__file__), 'vocab', 'en-us') self.load_vocab_files(vocab_dir) tokenizer = EnglishTokenizer() for app in gio.app_info_get_all(): name = app.get_name().lower() entry = [app] tokenized_name = tokenizer.tokenize(name)[0] if name in self.appmap: self.appmap[name] += entry else: self.appmap[name] = entry self.register_vocabulary(name, "Application") if name != tokenized_name: self.register_vocabulary(tokenized_name, "Application") if tokenized_name in self.appmap: self.appmap[tokenized_name] += entry else: self.appmap[tokenized_name] = entry self.register_regex("for (?P<SearchTerms>.*)") self.register_regex("for (?P<SearchTerms>.*) on") self.register_regex("(?P<SearchTerms>.*) on") launch_intent = IntentBuilder( "LaunchDesktopApplication").require("LaunchKeyword").require( "Application").build() self.register_intent(launch_intent, self.handle_launch_desktop_app) launch_website_intent = IntentBuilder( "LaunchWebsiteIntent").require("LaunchKeyword").require( "Website").build() self.register_intent(launch_website_intent, self.handle_launch_website) search_website = IntentBuilder("SearchWebsiteIntent").require( "SearchKeyword").require("Website").require( "SearchTerms").build() self.register_intent(search_website, self.handle_search_website)
def load(self): items = [] for appinfo in gio.app_info_get_all(): item = { 'type': 'application', 'id': appinfo.get_id(), 'name': appinfo.get_name(), 'command': appinfo.get_executable(), 'comment': appinfo.get_description(), 'icon': self.gicon_to_path(appinfo.get_icon()) } items.append(item) return items
def __init__(self): gobject.GObject.__init__ (self) if not os.path.isdir(Globals.AutoStartDirectory): os.system('mkdir %s' % Globals.AutoStartDirectory) self.notifier = utils.Notifier() self.menuparser = MenuParser.MenuParser() self.menuparser.connect('menu-changed',self.MenuChanged) self.AppsFile = None self.SetFile = None self.menucache = {} self.nonMenuitems = '<Bookmarks>','<AuxiliaryFunctions>','<RecentItems>','<RecentApps>','<WebBookmarks>','<Favorites>','<Shutdown>' if Globals.OnlyShowFavs: self.BaseMenu = '<Favorites>' self.menuparser.CacheApplications = None self.menuparser.CacheSettings = None elif Globals.OnlyShowRecentApps: self.BaseMenu = '<RecentApps>' self.menuparser.CacheApplications = None self.menuparser.CacheSettings = None else: self.menuparser.ParseMenus() self.BaseMenu = self.menuparser.CacheApplications if isgio: self.monitor=gio.volume_monitor_get() self.monitor.connect("drive-changed",self.on_drive_changed) self.allgio = gio.app_info_get_all() else:self.allgio = None self.Launcher = Launcher.Launcher() self.recent_manager = gtk.recent_manager_get_default() self.recent_manager.connect("changed", self.onRecentChanged) self.recents_changed = True self.recents = None self.ItemComments = {} self.Menu = self.BaseMenu self.PrevMenu = [] self.searchresults = 0 ##### Load IconFactory################################## self.IconFactory = IconFactory.IconFactory() ##### Load webbookmarks################################## try: self.webbookmarker = bookmarks.BookmarksMenu().getBookmarks() except: self.webbookmarker = None ##### Construct the menu########################### self.menuitems = 'settings','places','auxiliary','recent','recentapps','webbookmarks','favorites','shutdown','all' for item in self.menuitems: #print 'Loading item to memory: ',item self.Restart(item) gc.collect()
def __init__(self, filetype, apps=False): gtk.TreeView.__init__(self) self.set_rules_hint(True) #self.set_grid_lines(False) self.get_selection().set_mode(gtk.SELECTION_BROWSE) if apps: self.Apps_list = [ i for i in gio.app_info_get_all_for_type(filetype) if i != gio.app_info_get_default_for_type(filetype, False) ] else: self.Apps_list = [ i for i in gio.app_info_get_all() if i != gio.app_info_get_default_for_type(filetype, False) ]
def get_all(self): """Return list of all applications""" result = [] for app_info in gio.app_info_get_all(): application = ApplicationInfo( id=app_info.get_id(), name=app_info.get_name(), description=app_info.get_description(), executable=app_info.get_executable(), command_line=app_info.get_commandline(), icon=self.__get_icon(app_info.get_icon())) result.append(application) return result
def old(): sealert_app_info = None desktop_icon_dict = {} for desktop_app_info in gio.app_info_get_all(): exe = fullpath(desktop_app_info.get_executable()) rpmver = get_rpm_nvr_by_file_path(exe) if rpmver: if rpmver in desktop_icon_dict: desktop_icon_dict[rpmver].append(desktop_app_info) else: desktop_icon_dict[rpmver] = [ desktop_app_info ] basename = os.path.basename(exe) if basename in desktop_icon_dict: desktop_icon_dict[basename].append(desktop_app_info) else: desktop_icon_dict[basename] = [ desktop_app_info ]
def old(): sealert_app_info = None desktop_icon_dict = {} for desktop_app_info in gio.app_info_get_all(): exe = fullpath(desktop_app_info.get_executable()) rpmver = get_rpm_nvr_by_file_path(exe) if rpmver: if rpmver in desktop_icon_dict: desktop_icon_dict[rpmver].append(desktop_app_info) else: desktop_icon_dict[rpmver] = [desktop_app_info] basename = os.path.basename(exe) if basename in desktop_icon_dict: desktop_icon_dict[basename].append(desktop_app_info) else: desktop_icon_dict[basename] = [desktop_app_info]
def get_all(self): """Return list of all applications""" result = [] for app_info in gio.app_info_get_all(): application = ApplicationInfo( id = app_info.get_id(), name = app_info.get_name(), description = app_info.get_description(), executable = app_info.get_executable(), command_line = app_info.get_commandline(), icon = self.__get_icon(app_info.get_icon()) ) result.append(application) return result
def initialize(self): tokenizer = EnglishTokenizer() for app in gio.app_info_get_all(): name = app.get_name().lower() entry = [app] tokenized_name = tokenizer.tokenize(name)[0] if name in self.appmap: self.appmap[name] += entry else: self.appmap[name] = entry self.register_vocabulary(name, "Application") if name != tokenized_name: self.register_vocabulary(tokenized_name, "Application") if tokenized_name in self.appmap: self.appmap[tokenized_name] += entry else: self.appmap[tokenized_name] = entry launch_intent = IntentBuilder( "LaunchDesktopApplicationIntent").require("LaunchKeyword").require( "Application").build() self.register_intent(launch_intent, self.handle_launch_desktop_app) close_intent = IntentBuilder( "CloseDesktopApplicationIntent").require("CloseKeyword").require( "Application").build() self.register_intent(close_intent, self.handle_close_desktop_app) launch_website_intent = IntentBuilder( "LaunchWebsiteIntent").require("LaunchKeyword").require( "Website").build() self.register_intent(launch_website_intent, self.handle_launch_website) search_website = IntentBuilder("SearchWebsiteIntent").require( "SearchKeyword").require("Website").require( "SearchTerms").build() self.register_intent(search_website, self.handle_search_website)
def info(filter): app_names=[] Apps = [] for app in Gio.app_info_get_all(): show=True if app.should_show()==False: show=False if show==True: app_info = {} app_info["name"] = app.get_name() app_names.append(app.get_name()) app_info["exec"] = str(app.get_commandline()) if '%' in app_info["exec"]: num = app_info["exec"].index("%") stuff = app_info["exec"][num:] app_info["exec"] = app_info["exec"].replace(stuff,'') ##icon desk_file = app.get_id() desk_path = "/usr/share/applications/"+str(desk_file) if os.path.isfile(desk_path): f = open(desk_path,'r') for line in f.readlines(): if 'Icon=' in line: icon_name = line.replace('Icon=','').replace('\n','') app_info["icon"]=str(icon_name) Apps.append(app_info) ##set sorted sorted_apps=[] for name in sorted(app_names): for a in Apps: if a['name']==name: if filter!='' and filter.lower() in a["name"].lower(): sorted_apps.append(a) elif filter=='': sorted_apps.append(a) else:pass return sorted_apps
#!/usr/bin/python2 #text command icon subtext import subprocess, gio, sys apps = gio.app_info_get_all() for i in range(1, len(sys.argv)): try: k = subprocess.check_output( "ps -A -o pid -o %cpu -o comm | grep -i [^/]" + sys.argv[i] + "[^/]*$", shell=True) except: sys.exit() for j in k.splitlines(): result_s = j.split(' ') result = [] for result_tmp in result_s: if result_tmp != '': result.append(result_tmp) print '[' + result[2] + ']' print 'command=kill -9 ' + result[0] icon = "" for app in apps: if app.get_executable() == result[2]: try: icon = app.get_icon().to_string() except: icon = "" if icon == "": icon = "/usr/share/icons/gnome/48x48/mimetypes/application-x-executable.png" print "icon=" + icon
win = Gtk.Window(title="fooswitcher") box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) win.add(box) entry = Gtk.Entry() box.pack_start(entry, False, False, 0) store = Gtk.ListStore(str,int,str,str) for con in i3.filter(type=4): if con['name'] in VETO_NAMES: continue store.append(["Workspace: " + con['name'], con['id'], "","gtk-home"]) for con in i3.filter(type=2,nodes=[]): if con['name'] in VETO_NAMES: continue store.append([con['name'], con['id'], "","gtk-fullscreen"]) apps = dict(map(lambda o: (o.get_id(), o), app_info_get_all())) for app_id, app in apps.items(): store.append([app.get_name(), -1, app_id, "gtk-execute"]) filterStore = Gtk.TreeModelFilter(child_model=store) tree = Gtk.TreeView(filterStore) tree.set_enable_search(False) tree.set_headers_visible(False) tree.append_column(Gtk.TreeViewColumn("", Gtk.CellRendererPixbuf(), stock_id=3)) tree.append_column(Gtk.TreeViewColumn("", Gtk.CellRendererText(), text=0)) box.pack_start(Gtk.ScrolledWindow(child=tree), True, True, 0) store.set_sort_func(0, sort_func, None)
def initialize(self): self.all_apps = gio.app_info_get_all()
#!/usr/bin/python2 #text command icon subtext import subprocess, gio, sys apps = gio.app_info_get_all() for i in range(1, len(sys.argv)): try: k = subprocess.check_output("ps -A -o pid -o %cpu -o comm | grep -i [^/]" + sys.argv[i] + "[^/]*$", shell = True) except: sys.exit() for j in k.splitlines(): result_s = j.split(' ') result = [] for result_tmp in result_s: if result_tmp != '': result.append(result_tmp) print '[' + result[2] + ']' print 'command=kill -9 ' + result[0] icon = "" for app in apps: if app.get_executable() == result[2]: try: icon = app.get_icon().to_string() except: icon = "" if icon == "": icon = "/usr/share/icons/gnome/48x48/mimetypes/application-x-executable.png" print "icon=" + icon try: temp = subprocess.check_output("which " + result[2], shell=True) print "subtext=" + result[1] + '% CPU @ ' + temp
def reload(self, event=None, data=None): # Remove all old groupbuttons from container. for child in self.container.get_children(): self.container.remove(child) if self.windows: # Removes windows and unpinned group buttons for win in self.screen.get_windows(): self.on_window_closed(None, win) if self.groups is not None: # Removes pinned group buttons for group in self.groups: group.hide_list() group.icon_factory.remove() del self.groups del self.windows if self.theme: self.theme.remove() gc.collect() print "Dockbarx reload" self.groups = GroupList() self.windows = {} # Get the monitor on which dockbarx is. gdk_screen = gtk.gdk.screen_get_default() win = self.container.window if win is not None: self.monitor = gdk_screen.get_monitor_at_window(win) #--- Generate Gio apps self.apps_by_id = {} self.app_ids_by_exec = {} self.app_ids_by_name = {} self.app_ids_by_longname = {} self.wine_app_ids_by_program = {} for app in gio.app_info_get_all(): id = app.get_id() id = id[:id.rfind('.')].lower() name = u""+app.get_name().lower() exe = app.get_executable() if exe: self.apps_by_id[id] = app if id[:5] == 'wine-': try: cmd = u""+app.get_commandline().lower() except AttributeError: # Older versions of gio doesn't have get_comandline. cmd = u"" if cmd.find('.exe') > 0: program = cmd[:cmd.rfind('.exe')+4] program = program[program.rfind('\\')+1:] self.wine_app_ids_by_program[program] = id if name.find(' ')>-1: self.app_ids_by_longname[name] = id else: self.app_ids_by_name[name] = id if exe not in ('sudo','gksudo', 'java','mono', 'ruby','python'): if exe[0] == '/': exe = exe[exe.rfind('/')+1:] self.app_ids_by_exec[exe] = id else: self.app_ids_by_exec[exe] = id try: if self.theme is None: self.theme = Theme() else: self.theme.on_theme_changed() except NoThemesError, details: print details sys.exit(1)
def get_applications(): logging.info("open-command: Loading application shortcuts") # Add this to the default whitelist = set([ # if you set/reset default handler for folders it is useful "nautilus-folder-handler.desktop", # we think that these are useful to show "eog.desktop", "evince.desktop", "gnome-about.desktop", "gstreamer-properties.desktop", "notification-properties.desktop", ]) blacklist = set([ "nautilus-home.desktop", ]) result = [] if DESKTOP_ENVIRONMENT: desktop_app_info_set_desktop_env(DESKTOP_ENVIRONMENT) isabs = os.path.isabs isfile = os.path.isfile islink = os.path.islink with gtk_lock: for item in app_info_get_all(): id_ = item.get_id() if id_ in whitelist or (item.should_show() and id_ not in blacklist): name = item.get_name().lower() filepath = item.get_executable() shortcut_filename = None try: shortcut_filename = item.props.filename except: try: shortcut_filename = item.get_property("filename") except: try: shortcut_filename = item.get_filename() except: pass #print filepath,";",item.get_commandline(),";",item.get_description() # Need to check for existence of the file, as sometimes the app does not disappear from the list if not ptoperly uninstalled if filepath and filepath.strip() != "": if isabs(filepath): if not (isfile(filepath) or islink(filepath)): continue else: if not find_executable(filepath): continue applications_dict[name] = item s_type = shortcuts.SHORTCUT_TYPE_EXECUTABLE # get_shortcut_type(filepath) shortcut = shortcuts.Shortcut( name, s_type, filepath.strip(), shortcut_filename=shortcut_filename, category=SHORTCUT_CATEGORY) result.append(shortcut) #print "\n".join(sorted(str(s) for s in result)) logging.info("open-command: Loaded %d application shortcuts" % len(result)) return result