本文整理汇总了Python中xdg.DesktopEntry.DesktopEntry.getComment方法的典型用法代码示例。如果您正苦于以下问题:Python DesktopEntry.getComment方法的具体用法?Python DesktopEntry.getComment怎么用?Python DesktopEntry.getComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xdg.DesktopEntry.DesktopEntry
的用法示例。
在下文中一共展示了DesktopEntry.getComment方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ShowAll
# 需要导入模块: from xdg.DesktopEntry import DesktopEntry [as 别名]
# 或者: from xdg.DesktopEntry.DesktopEntry import getComment [as 别名]
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
示例2: __init__
# 需要导入模块: from xdg.DesktopEntry import DesktopEntry [as 别名]
# 或者: from xdg.DesktopEntry.DesktopEntry import getComment [as 别名]
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 ''
示例3: provide
# 需要导入模块: from xdg.DesktopEntry import DesktopEntry [as 别名]
# 或者: from xdg.DesktopEntry.DesktopEntry import getComment [as 别名]
def provide(self):
from fnmatch import fnmatch
from xdg.DesktopEntry import DesktopEntry
items = []
for app_directory in map(os.path.expanduser, self.app_directories):
for root, dirs, files in os.walk(app_directory):
for filename in files:
if fnmatch(filename, "*.desktop"):
app_entry = DesktopEntry(os.path.join(root, filename))
icon_theme = Gtk.IconTheme.get_default()
if app_entry.getNoDisplay():
continue
if app_entry.getIcon() == "":
icon = Gtk.IconTheme.load_icon(icon_theme, "image-missing", self.icon_size, 0)
elif "/" in app_entry.getIcon():
try:
unscaled_icon = GdkPixbuf.Pixbuf.new_from_file(app_entry.getIcon())
icon = unscaled_icon.scale_simple(self.icon_size, self.icon_size, GdkPixbuf.InterpType.BILINEAR)
except:
icon = Gtk.IconTheme.load_icon(icon_theme, "image-missing", self.icon_size, 0)
else:
try:
unscaled_icon = Gtk.IconTheme.load_icon(icon_theme, app_entry.getIcon(), self.icon_size, 0)
icon = unscaled_icon.scale_simple(self.icon_size, self.icon_size, GdkPixbuf.InterpType.BILINEAR)
except:
icon = Gtk.IconTheme.load_icon(icon_theme, "image-missing", self.icon_size, 0)
words = app_entry.getName().split()
# words.append(app_entry.getExec())
command = self.escape_command(app_entry.getExec())
if app_entry.getTerminal():
command = "%s '%s'" % (self.terminal_emulator_command, command)
item = {
"indexer": self,
"name": app_entry.getName(),
"description": app_entry.getComment(),
"icon": icon,
"command": command,
"words": words,
}
items.append(item)
items.sort(key=lambda i: i["name"])
return items
示例4: __init__
# 需要导入模块: from xdg.DesktopEntry import DesktopEntry [as 别名]
# 或者: from xdg.DesktopEntry.DesktopEntry import getComment [as 别名]
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)
示例5: test_values
# 需要导入模块: from xdg.DesktopEntry import DesktopEntry [as 别名]
# 或者: from xdg.DesktopEntry.DesktopEntry import getComment [as 别名]
def test_values(self):
entry = DesktopEntry(self.test_file)
self.assertEqual(entry.getName(), 'gedit')
self.assertEqual(entry.getGenericName(), 'Text Editor')
self.assertEqual(entry.getNoDisplay(), False)
self.assertEqual(entry.getComment(), 'Edit text files')
self.assertEqual(entry.getIcon(), 'accessories-text-editor')
self.assertEqual(entry.getHidden(), False)
self.assertEqual(entry.getOnlyShowIn(), [])
self.assertEqual(entry.getExec(), 'gedit %U')
self.assertEqual(entry.getTerminal(), False)
self.assertEqual(entry.getMimeTypes(), ['text/plain'])
self.assertEqual(entry.getCategories(), ['GNOME', 'GTK', 'Utility', 'TextEditor'])
self.assertEqual(entry.getTerminal(), False)
示例6: __create_model
# 需要导入模块: from xdg.DesktopEntry import DesktopEntry [as 别名]
# 或者: from xdg.DesktopEntry.DesktopEntry import getComment [as 别名]
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)
示例7: __init__
# 需要导入模块: from xdg.DesktopEntry import DesktopEntry [as 别名]
# 或者: from xdg.DesktopEntry.DesktopEntry import getComment [as 别名]
class VeraCCModule:
""" An object representing a Vera Control Center module. """
def __init__(self, module_name, module_path):
""" Initialize the object """
self.module_is_external = False
self.module_name = module_name
self.module_path = module_path
self.launcher_icon = None
self.launcher_name = None
self.launcher_comment = None
self.launcher_section = None
self.module_launcher = DesktopEntry(os.path.join(self.module_path, "%s.desktop" % self.module_name))
# Icon
self.launcher_icon = self.module_launcher.getIcon()
if not self.launcher_icon:
self.launcher_icon = "preferences-system"
#ICON_THEME.connect("changed", lambda x: self.replace_icon(icon))
# Name
self.launcher_name = self.module_launcher.getName()
# Comment
self.launcher_comment = self.module_launcher.getComment()
# Section
self.launcher_section = self.module_launcher.get("X-VeraCC-Section")
# Keywords
self.launcher_keywords = [x.lower() for x in self.module_launcher.getKeywords()]
# External?
_exec = self.module_launcher.getExec()
if _exec:
# Yeah!
self.module_is_external = True
self.module_path = _exec
示例8: __init__
# 需要导入模块: from xdg.DesktopEntry import DesktopEntry [as 别名]
# 或者: from xdg.DesktopEntry.DesktopEntry import getComment [as 别名]
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
示例9: __init__
# 需要导入模块: from xdg.DesktopEntry import DesktopEntry [as 别名]
# 或者: from xdg.DesktopEntry.DesktopEntry import getComment [as 别名]
class PackageInfo:
DESKTOP_DIR = "/usr/share/app-install/desktop/"
def __init__(self, name):
self.name = name
self.pkg = 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
示例10: parseMenu
# 需要导入模块: from xdg.DesktopEntry import DesktopEntry [as 别名]
# 或者: from xdg.DesktopEntry.DesktopEntry import getComment [as 别名]
def parseMenu(menu, menuJSON):
for submenu in menu.Entries:
if isinstance(submenu, Menu):
newmenu=parseMenu(submenu, []);
#print ("Submenu icon: "+submenu.getIcon() + " is "+theme.getIconPath(submenu.getIcon()))
iconpath=theme.getIconPath(submenu.getIcon(), None, 'Numix-Circle')
#iconpath=theme.getIconPath(submenu.getIcon(), 128, 'future-green')
#iconpath=theme.getIconPath(submenu.getIcon(), 128, 'Numix-Circle')
iconpath=give_me_png(iconpath)
if iconpath==None:
iconpath=''
print "cat icon: "+submenu.getIcon()+" is "+iconpath
menuJSON.append({"id": unicode(submenu).replace(" ", "_"), "name":submenu.getName(), "icon":iconpath, "children":newmenu});
elif isinstance(submenu, MenuEntry):
# Description at
# http://pyxdg.readthedocs.org/en/latest/_modules/xdg/DesktopEntry.html
newitem={}
filename="/usr/share/applications/"+unicode(submenu);
item=False
if (os.path.isfile(filename)):
item=DesktopEntry(filename)
else:
# is kde4- prexifed?
if (unicode(submenu)[0:5]=="kde4-"):
filename="/usr/share/applications/kde4/"+unicode(submenu)[5:];
item=DesktopEntry(filename)
#print "!!"+item;
if item is not False:
newitem["id"]=unicode(submenu).replace(" ", "_")
newitem["name"]=item.getName()
#newitem["icon"]=item.getIcon()
newitem["comment"]=item.getComment()
newitem["tryexec"]=item.getTryExec()
newitem["exec"]=item.getExec()
newitem["path"]=item.getPath()
iconpath=theme.getIconPath(item.getIcon(), 128, 'Numix-Circle')
#iconpath=theme.getIconPath(item.getIcon(), 128, 'future-green')
#iconname=item.getIcon(); # Convert png if not exists...
#iconpath=give_me_png(iconname);
iconpath=give_me_png(iconpath);
if iconpath==None:
iconpath=''
#print "icon: "+item.getIcon()+" is "+iconpath
#print ("Icon: "+item.getIcon() + " is "+iconpath)
newitem["icon"]=iconpath
#newitem["name"]=a.getName();
#newitem["id"]=unicode(submenu)
# Only Append if it's executable
#if (item.findTryExec()):
# menuJSON.append(newitem);
#if newitem["name"]!="":
menuJSON.append(newitem);
return menuJSON
示例11: __init__
# 需要导入模块: from xdg.DesktopEntry import DesktopEntry [as 别名]
# 或者: from xdg.DesktopEntry.DesktopEntry import getComment [as 别名]
def __init__(self, parent=None, **kwargs):
"""Construct a LaunchButton"""
super(LaunchButton, self).__init__(parent)
self.setObjectName("LaunchButton")
self.launcher_size = kwargs.get("launcher_size")
self.icon_size = kwargs.get("icon_size")
self.name = None
self.comment = None
self.icon = None
self.command = None
self.categories = None
# Load in details from a .desktop file, if there is one.
desktop_file = kwargs.get("desktop_file")
if desktop_file:
if os.access(desktop_file, os.R_OK):
de = DesktopEntry(desktop_file)
self.name = de.getName()
self.comment = de.getComment()
self.icon = de.getIcon()
self.command = de.getExec()
self.categories = [c.lower() for c in de.getCategories()]
else:
sys.stderr.write(
"Read access denied on manually-specified "
"desktop file {}. Button may be missing data.\n"
.format(desktop_file))
# 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.clicked.connect(self.callback)
示例12: Mapping
# 需要导入模块: from xdg.DesktopEntry import DesktopEntry [as 别名]
# 或者: from xdg.DesktopEntry.DesktopEntry import getComment [as 别名]
class Mapping(object):
"""
An object representation of a wiican mapping.
A wiican mapping must be located in a single directory containing a file
with the wminput code, a file containing the metadata (name, description,
author, version) and an optional icon file.
"""
# Mandatory filename for the metadata file
info_filename = "info.desktop"
# Mandatory filename for the wminput config file
mapping_filename = "mapping.wminput"
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)
def get_path(self):
"""Returns the absolute path where the wiican mapping it's saved.
It returns None if the mapping it's not saved yet"""
return self.__path
def get_name(self):
"""Gets the name of the mapping"""
return self.__info.getName()
def set_name(self, name):
"""Sets the name for the mapping"""
self.__info.set("Name", name)
self.__info.set("Name", name, locale=True)
def get_comment(self):
"""Gets the descriptional comment"""
return self.__info.getComment()
def set_comment(self, comment):
"""Sets the descriptional comment for the mapping"""
self.__info.set("Comment", comment)
self.__info.set("Comment", comment, locale=True)
def get_icon(self):
#.........这里部分代码省略.........