• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python DesktopEntry.DesktopEntry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中xdg.DesktopEntry.DesktopEntry的典型用法代码示例。如果您正苦于以下问题:Python DesktopEntry类的具体用法?Python DesktopEntry怎么用?Python DesktopEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DesktopEntry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: launch_desktop

 def launch_desktop(self, request, handler, desktop):
     entry = DesktopEntry()
     entry.parse(desktop)
     exec_ = entry.getExec()
     self.launch(
         request, handler, '/bin/bash -c "%s"' % exec_.replace('"', '\\"')
     )  # Is it really necessary to call bash ?
开发者ID:JoliOS,项目名称:jolicloud-daemon,代码行数:7,代码来源:apps.py


示例2: __new__

 def __new__(cls, desk):
     desk = DesktopEntry(str(a))
     name = desk.getName()
     icon = getIconPath(desk.getIcon())
     exe = shlex.split(re.sub('%[fFuUdDnNickvm]', '', desk.getExec()))
     launch = partial(QProcess.startDetached, exe[0], exe[1:])
     return super().__new__(cls, name, icon, launch)
开发者ID:jck,项目名称:kya,代码行数:7,代码来源:applauncher.py


示例3: test_absent

 def test_absent(self):
     with io.open(self.test_file, "w", encoding='utf-8') as f:
         f.write(resources.unicode_desktop)
     
     entry = DesktopEntry(self.test_file)
     res = entry.findTryExec()
     assert res is None, repr(res)
开发者ID:takluyver,项目名称:pyxdg,代码行数:7,代码来源:test-desktop.py


示例4: test_present

 def test_present(self):
     with io.open(self.test_file, "w", encoding='utf-8') as f:
         f.write(resources.python_desktop)
     
     entry = DesktopEntry(self.test_file)
     res = entry.findTryExec()
     assert res, repr(res)
开发者ID:takluyver,项目名称:pyxdg,代码行数:7,代码来源:test-desktop.py


示例5: __init__

 def __init__(self, filename):
     DesktopEntry.__init__(self, filename)
     log.debug('NewDesktopEntry: %s' % filename)
     if self.get(self.shortcuts_key):
         self.mode = self.shortcuts_key
     else:
         self.mode = self.actions_key
开发者ID:0x7E,项目名称:ubuntu-tweak,代码行数:7,代码来源:quicklists.py


示例6: init

    def init(self, info, progress):
        """
        If needed, perform long initialisation tasks here.

        info is a dictionary with useful information.  Currently it contains
        the following values:

          "values": a dict mapping index mnemonics to index numbers

        The progress indicator can be used to report progress.
        """

        # Read the value indexes we will use
        values = info["values"]
        self.val_popcon = values.get("app-popcon", -1)

        self.indexers = [Indexer(lang, self.val_popcon, progress) for lang in [None] + list(self.langs)]
        self.entries = {}

        progress.begin("Reading .desktop files from %s" % APPINSTALLDIR)
        for f in os.listdir(APPINSTALLDIR):
            if f[0] == "." or not f.endswith(".desktop"):
                continue
            entry = DesktopEntry(os.path.join(APPINSTALLDIR, f))
            pkg = entry.get("X-AppInstall-Package")
            self.entries.setdefault(pkg, []).append((f, entry))
        progress.end()
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:27,代码来源:app-install.py


示例7: ShowAll

 def ShowAll(self):#elenca tutti i file nelle 4 cartelle di autostart
     autolist = []
     
     path = self.user_autostart
     for file_name in os.listdir(path):
         myitem = DesktopEntry(path + '/' + file_name)
         #print(path + '/' + file_name)
         a = DeskStruct()
         a.Name = myitem.getName()
         a.Exec = myitem.getExec()
         a.Icon = myitem.getIcon()
         a.Comment = myitem.getComment()
         autolist.append(a) #lista di oggetti Deskstruct
           
     
     #path=self.xdg_autostart
     #autolist.append('     XDG files')
     #for file_name in os.listdir(path):
     #    autolist.append(path+'/'+file_name)
     #
     #path=self.sys_autostart
     #autolist.append('     Sys Files')
     #for file_name in os.listdir(path):
     #    autolist.append(path+'/'+file_name)
     #path=self.gdm_autostart
     #autolist.append('     GDM files')
     #for file_name in os.listdir(path):
     #    autolist.append(path+'/'+file_name)
     return autolist
开发者ID:adrianom,项目名称:AutoStarter,代码行数:29,代码来源:AutoStart.py


示例8: __init__

class PackageInfo:
    DESKTOP_DIR = '/usr/share/app-install/desktop/'

    def __init__(self, name):
        self.name = name
        self.pkg = PACKAGE_WORKER.get_cache()[name]
        self.desktopentry = DesktopEntry(self.DESKTOP_DIR + name + '.desktop')

    def check_installed(self):
        return self.pkg.isInstalled

    def get_comment(self):
        return self.desktopentry.getComment()

    def get_name(self):
        appname = self.desktopentry.getName()
        if appname == '':
            return self.name.title()

        return appname

    def get_version(self):
        try:
            return self.pkg.versions[0].version
        except:
            return ''
开发者ID:Adriarson,项目名称:ubuntu-tweak,代码行数:26,代码来源:package.py


示例9: test_basic

 def test_basic(self):
     entry = DesktopEntry(self.test_file)
     assert entry.hasKey("Categories")
     assert not entry.hasKey("TryExec")
     
     assert entry.hasGroup("Desktop Action Window")
     assert not entry.hasGroup("Desktop Action Door")
开发者ID:flyser,项目名称:pyxdg,代码行数:7,代码来源:test-desktop.py


示例10: get_autostart

 def get_autostart(self):
     if os.path.exists(self.autostart_desktop):
         desktop_entry = DesktopEntry(self.autostart_desktop)
         return not desktop_entry.getHidden()
     elif os.path.exists(self.sys_autostart_desktop):
         desktop_entry = DesktopEntry(self.sys_autostart_desktop)
         return not desktop_entry.getHidden()
     else:
         return False
开发者ID:xianjunzhengbackup,项目名称:LinuxBackup,代码行数:9,代码来源:config.py


示例11: __init__

    def __init__(self, parent=None, **kwargs):
        super(LaunchButton, self).__init__(parent)
        self.setObjectName("LaunchButton")
        self.launcher_size = kwargs.get("launcher_size")
        self.icon_size = kwargs.get("icon_size")
        self.name, self.comment, self.icon, self.command = None, None, None, None

        # Load in details from a .desktop file, if there is one.
        if kwargs.get("desktop_file"):
            de = DesktopEntry(kwargs.get("desktop_file"))
            self.name = de.getName()
            self.comment = de.getComment()
            self.icon = de.getIcon()
            self.command = de.getExec()

        # This allows for overriding the settings in DesktopEntry
        self.name = kwargs.get("name", self.name)
        self.comment = kwargs.get("comment", self.comment)
        self.icon = kwargs.get("icon", self.icon)
        self.command =  kwargs.get("command", self.command)

        # Create the layouts and widgets to hold the information
        toplayout = QHBoxLayout()
        leftlayout = QVBoxLayout()

        # The button's title
        title = QLabel(self.name)
        title.setObjectName("LaunchButtonTitle")
        leftlayout.addWidget(title)

        # The button's descriptive comment
        comment = QLabel(self.comment)
        comment.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        comment.setWordWrap(True)
        comment.setObjectName("LaunchButtonDescription")
        leftlayout.addWidget(comment)

        # The button's icon, if there is one
        iconpane = QLabel()
        icon = (self.icon and icon_anyway_you_can(self.icon, kwargs.get("aggressive_icon_search", False))) or QIcon()
        pixmap = icon.pixmap(*self.icon_size)
        if not pixmap.isNull():
            pixmap = pixmap.scaled(*self.icon_size)
        iconpane.setPixmap(pixmap)

        # Add everything to layouts and layouts to the button
        toplayout.addWidget(iconpane)
        toplayout.addLayout(leftlayout)
        self.setLayout(toplayout)

        # Set the button's size from config.
        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.setMinimumSize(QSize(*self.launcher_size))

        # Connect the callback
        self.connect(self, SIGNAL("clicked()"), self.callback)
开发者ID:alreece45,项目名称:KiLauncher,代码行数:56,代码来源:kilauncher.py


示例12: on_edit_item

    def on_edit_item(self, widget, treeview):
        model, iter = treeview.get_selection().get_selected()

        if iter:
            path = model.get_value(iter, COLUMN_PATH)
            if path[1:4] == "etc":
                shutil.copy(path, treeview.userdir)
                path = os.path.join(treeview.userdir, os.path.basename(path))
            dialog = AutoStartDialog(DesktopEntry(path), widget.get_toplevel())
            if dialog.run() == gtk.RESPONSE_OK:
                name = dialog.pm_name.get_text()
                cmd = dialog.pm_cmd.get_text()
                if not name:
                    ErrorDialog(_("The name of the startup program cannot be empty")).launch()
                elif not cmd:
                    ErrorDialog(_("Text was empty (or contained only whitespace)")).launch()
                else:
                    desktopentry = DesktopEntry(path)
                    desktopentry.set("Name", name, locale = True)
                    desktopentry.set("Exec", cmd)
                    desktopentry.set("Comment", dialog.pm_comment.get_text(), locale = True)
                    desktopentry.write()
                    treeview.update_items(all = self.show_all_button.get_active(), comment = self.show_comment_button.get_active())
                    dialog.destroy()
                    return
            dialog.destroy()
开发者ID:systembugtj,项目名称:ubuntu-tweak-old,代码行数:26,代码来源:autostart.py


示例13: _get_app_list

 def _get_app_list(self, directory, user):
     for root, dirs, files in os.walk(directory):
         for name in files:
             if name.endswith(".desktop"):
               
                 app_path = root + "/" + name
                 
                 # setup desktop entry to access its elements                    
                 xgd_de = DesktopEntry(app_path)
                 
                 #                    
                 self.app_entry = Desktop_Entry(
                     name,
                     xgd_de.getName( ),
                     xgd_de.getGenericName( ),
                     xgd_de.getNoDisplay( ),
                     xgd_de.getHidden( ),
                     xgd_de.getOnlyShowIn( ),
                     xgd_de.getNotShowIn( ),
                     xgd_de.getCategories( ),
                     app_path,
                     user,
                     False
                 )   
                  
                 # Just as a note, skip no display or hidden .desktop                    
                 if not (self.app_entry.de_nodisp or self.app_entry.de_hidden):
                     self._add_entry(self.app_entry)                        
开发者ID:MikeyG,项目名称:catgor,代码行数:28,代码来源:applist.py


示例14: __init__

 def __init__(self, stage):
  self._apps = list()
  self._rdsk = re.compile(u".*\.desktop$")
  self._icon_actor_cache = dict()
  HOME = os.getenv("HOME")
  l = list()
  l += self._get_all_desktop_files(u'/usr/share/applications')
  if HOME:
   l += self._get_all_desktop_files(os.path.join(HOME, u'.local/share/applications'))
  for f in l:
   de = DesktopEntry(f)
   if de.getType() == u"Application" and not de.getHidden():
    self._apps.append(apps_entry(stage, de))
  self._apps.sort(key=lambda x: x.name)
  pass
开发者ID:gschwind,项目名称:page-launcher,代码行数:15,代码来源:main.py


示例15: _update_autostart_flag

    def _update_autostart_flag(self):
        if self._desktop == 'unknown':
            # No se puede autostartear :(
            return

        desktop_compartir = DesktopEntry(
            os.path.join(BaseDirectory.save_config_path('autostart'),
            'compartir.desktop')
        )

        if self._desktop == 'mate':
            desktop_compartir.set(
                'X-MATE-Autostart-enabled',
                'true' if self.compartir.autostart else 'false'
            )
            desktop_compartir.write()
开发者ID:nachopro,项目名称:compartir,代码行数:16,代码来源:core.py


示例16: get_desktop_entries

def get_desktop_entries():

    starts = ((os.path.expanduser('~'), 'local'), (os.sep, 'usr'))
    end = ('share', 'applications', '*.desktop')

    for start in starts:
        pattern = os.path.join(*(start + end))

        for desktop_entry in glob.iglob(pattern):
            entry = DesktopEntry(desktop_entry)
            if entry.getNoDisplay():
                continue
            if entry.getOnlyShowIn():
                continue
            if entry.getTerminal():
                continue
            yield entry
开发者ID:duganchen,项目名称:ob_xdg_app_pipe,代码行数:17,代码来源:ob_xdg_apps.py


示例17: __create_model

    def __create_model(self, all = False, comment = False):
        model = self.get_model()
        model.clear()

        allitems = []
        allitems.extend(self.useritems)
        allitems.extend(self.systemitems)

        for item in allitems:
            try:
                desktopentry = DesktopEntry(item)
            except:
                continue

            if desktopentry.get("Hidden"):
                if not all:
                    continue
            iter = model.append()
            enable = desktopentry.get("X-GNOME-Autostart-enabled")
            if enable == "false":
                enable = False
            else:
                enable = True
            
            iconname = desktopentry.get('Icon', locale = False)
            if not iconname:
               iconname = desktopentry.get('Name', locale = False)
               if not iconname:
                   iconname = desktopentry.getName()

            icon = get_icon_with_name(iconname, 32)

            try:
                name = desktopentry.getName()
            except:
                name = desktopentry.get('Name', locale=False)

            if comment:
                comment = desktopentry.getComment()
                if not comment:
                    comment = _("No description")
                description = "<b>%s</b>\n%s" % (name, comment)
            else:
                description = "<b>%s</b>" % name

            model.set(iter,
                      COLUMN_ACTIVE, enable,
                      COLUMN_ICON, icon,
                      COLUMN_PROGRAM, description,
                      COLUMN_PATH, item)
开发者ID:actiononmail,项目名称:ubuntu-tweak,代码行数:50,代码来源:autostart.py


示例18: __create_desktop_entry_if_necessary

    def __create_desktop_entry_if_necessary(self):
        # Create user autostart dir if it does not exists
        if self.user_autodir is None:
            self.user_autodir = BaseDirectory.save_config_path('autostart')

        # It it does not exists an autostart file for TGCM in userdir,
        # create a copy from the global one
        self.user_autofile = os.path.join(self.user_autodir, self.autofile_name)
        if not os.path.exists(self.user_autofile):
            autofile_path = os.path.join(self.system_autodir, self.autofile_name)
            shutil.copy(autofile_path, self.user_autofile)

            # Honor 'launch-startup' policy in regional-info.xml file
            self.desktopentry = DesktopEntry(self.user_autofile)
            is_autostart = self.config.check_policy('launch-startup')
            self.set_enabled(is_autostart)
        else:
            self.desktopentry = DesktopEntry(self.user_autofile)
开发者ID:calabozo,项目名称:tgcmlinux,代码行数:18,代码来源:Autostart.py


示例19: _populate

    def _populate(self):
        for item in self.EDITORS:
            if os.path.isfile(item):
                args = self.EDITORS[item]
                desktop_entry = DesktopEntry(item)
                command = desktop_entry.getExec()

                # For .desktop files with ' %U' or ' # %F'
                command = command.split(" ")[0]

                name = desktop_entry.getName()
                icon_name = desktop_entry.getIcon()

                self._add_item(icon_name, name, command, args)

        if len(self.get_model()):
            self.empty = False
        else:
            self.empty = True
开发者ID:aaae,项目名称:kazam,代码行数:19,代码来源:combobox.py


示例20: __init__

    def __init__(self, path=None):
        """
        Builds a mapping object.

        Parameters:
        path -  scans the path for building a mapping object if the needed files
                where found. If None it builds an empty mapping. If some of the 
                needed files wasn't found it tries to build a mapping with the 
                found info.

        The Mapping.info_filename and Mapping.mapping_filename class attributes 
        marks the requiered filenames for the metadata file and wminput config file 
        respectively.

        The Mapping.mapping_filename file must contain wminput config file code
        The Mapping.info_filename follows XDG DesktopEntry syntax.
        
        The Mapping.info_filename contains the source of the optional associated
        icon. If no icon found or no icon directive it falls back to default 
        icon.

        There are three posibilities for icon setting:

        - An absolute path where the icon it's stored
        - Icon filename if it's stored in the same dir as Mapping.info_filename
        - Theme-icon-name for auto-getting the icon from the icon theme
        """

        self.__path = path

        # Getting freedesktop definition file
        self.__info = DesktopEntry()

        if path and os.path.exists(os.path.join(path, Mapping.info_filename)):
            self.__info.parse(os.path.join(path, Mapping.info_filename))
        else:
            self.__info.new(self.info_filename)
            self.__info.set("Type", "Wiican Mapping")

        # Getting wminput mapping file
        if path and os.path.exists(os.path.join(path, Mapping.mapping_filename)):
            mapping_fp = open(os.path.join(path, Mapping.mapping_filename), "r")
            self.__mapping = mapping_fp.read()
            mapping_fp.close()
        else:
            self.__mapping = ""

        # Getting icon file path
        icon_name = self.__info.getIcon()
        if path and icon_name in os.listdir(path):  # Icon included
            self.set_icon(os.path.join(path, icon_name))
        elif getIconPath(icon_name):  # Theme icon
            self.set_icon(getIconPath(icon_name))
        else:  # Default icon
            self.set_icon(ICON_DEFAULT)
开发者ID:GNOME,项目名称:wiican,代码行数:55,代码来源:mapping.py



注:本文中的xdg.DesktopEntry.DesktopEntry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python xdg_support.get_cache_file函数代码示例发布时间:2022-05-26
下一篇:
Python xdg.BaseDirectory类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap