コード例 #1
0
ファイル: dialogs.py プロジェクト: metalink-dev/metalinks
    def __autostart_key_changed(self, client, cnxn_id, entry, data):
        if not entry.value:
            self.autostart_checkbutton.set_active(True)
        elif entry.value.type == gconf.VALUE_BOOL:
            value = entry.value.get_bool()
            self.autostart_checkbutton.set_active(value)

            autostart_dir = os.path.expanduser(AUTOSTART_DIR)
            if value:
                try:
                    item = gnomedesktop.item_new_from_basename(DESKTOP_FILE,
                            gnomedesktop.LOAD_ONLY_IF_EXISTS)
                except gobject.GError:
                    raise ValueError("File path not a .desktop file")

                if not item:
                    raise ValueError("URI not found")

                # Looks like gnomedesktop.DesktopItem.save(str, bool) isn't
                # implemented so copying manually for now.
                if not os.path.exists(autostart_dir):
                    os.makedirs(autostart_dir)

                shutil.copy2(item.get_location().replace("file://", ""),
                        autostart_dir)
            else:
                autostart_file = os.path.join(autostart_dir, DESKTOP_FILE)
                if os.path.exists(autostart_file):
                    os.remove(autostart_file)
        else:
            self.autostart_checkbutton.set_active(True)
コード例 #2
0
    def __init__(self, uri):
        try:
            if os.path.dirname(uri):
                item = gnomedesktop.item_new_from_uri(uri, gnomedesktop.LOAD_ONLY_IF_EXISTS)
            else:
                item = gnomedesktop.item_new_from_basename(uri, gnomedesktop.LOAD_ONLY_IF_EXISTS)
        except gobject.GError:
            raise ValueError("File path not a .desktop file")

        if not item:
            raise ValueError("URI not found")

        LauncherItem.__init__(self, item.get_location())

        self.command = item.get_string(gnomedesktop.KEY_EXEC)
        if not self.command:
            raise ValueError("No Exec key in .desktop file")
        
        self.name = item.get_localestring(gnomedesktop.KEY_NAME)
        if not self.name:
            self.name = os.path.basename(uri)

        self.comment = item.get_localestring(gnomedesktop.KEY_COMMENT)
        if not self.comment:
            self.comment = item.get_localestring(gnomedesktop.KEY_GENERIC_NAME)

        self.command = item.get_string(gnomedesktop.KEY_EXEC)
        self.icon_name = item.get_string(gnomedesktop.KEY_ICON)

        catstr = item.get_string(gnomedesktop.KEY_CATEGORIES) or ""
        self.categories = catstr.split(";")
コード例 #3
0
ファイル: fs_gnomevfs.py プロジェクト: sandeep-datta/hotwire
 def add_menuitem(app):
     _logger.debug("adding app %r", app)
     if have_gnomedesktop:
         desktop = gnomedesktop.item_new_from_basename(app[0], 0)
         iconpath = desktop.get_icon(self.__itheme)
     else:
         iconpath = None
     menuitem = gtk.ImageMenuItem(_('Open with %s') % (app[1],))
     if iconpath:
         pbuf = pbcache.get(iconpath, trystock=True, stocksize=gtk.ICON_SIZE_MENU)
         img = gtk.image_new_from_pixbuf(pbuf)
         menuitem.set_property('image', img)
     menuitem.connect("activate", self.__on_appmenu_activated, app, uri, context)
     menuitems.append(menuitem) 
コード例 #4
0
 def add_menuitem(app):
     _logger.debug("adding app %r", app)
     if have_gnomedesktop:
         desktop = gnomedesktop.item_new_from_basename(app[0], 0)
         iconpath = desktop.get_icon(self.__itheme)
     else:
         iconpath = None
     menuitem = gtk.ImageMenuItem(_('Open with %s') % (app[1], ))
     if iconpath:
         pbuf = pbcache.get(iconpath,
                            trystock=True,
                            stocksize=gtk.ICON_SIZE_MENU)
         img = gtk.image_new_from_pixbuf(pbuf)
         menuitem.set_property('image', img)
     menuitem.connect("activate", self.__on_appmenu_activated, app, uri,
                      context)
     menuitems.append(menuitem)