[openbox/f17: 4/7] Update xdg-menu to work with latest pyxdg (#874633)
Miroslav Lichvar
mlichvar at fedoraproject.org
Tue Nov 13 16:24:28 UTC 2012
commit 5bb02a8fbbebc1e9f0ff6ad543c46afe4ce4b143
Author: Miroslav Lichvar <mlichvar at redhat.com>
Date: Tue Nov 13 17:02:32 2012 +0100
Update xdg-menu to work with latest pyxdg (#874633)
xdg-menu | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/xdg-menu b/xdg-menu
index aefc6a4..8eef84e 100644
--- a/xdg-menu
+++ b/xdg-menu
@@ -53,7 +53,9 @@ def icon_attr(entry):
return ''
def escape_utf8(s):
- return escape(s.encode('utf-8', 'xmlcharrefreplace'))
+ if isinstance(s, unicode):
+ s = s.encode('utf-8', 'xmlcharrefreplace')
+ return escape(s)
def entry_name(entry):
return escape_utf8(entry.getName())
@@ -67,14 +69,15 @@ def walk_menu(entry):
map(walk_menu, entry.getEntries())
print '</menu>'
elif isinstance(entry, xdg.Menu.MenuEntry) and entry.Show is True:
- print ' <item label="%s"%s>' % \
- (entry_name(entry.DesktopEntry).replace('"', ''),
+ name = entry_name(entry.DesktopEntry)
+ print ' <item label="%s"%s>' % (name.replace('"', ''),
escape_utf8(icon_attr(entry.DesktopEntry)))
- command = re.sub(' -caption "%c"| -caption %c', ' -caption "%s"' % entry_name(entry.DesktopEntry), entry.DesktopEntry.getExec())
+ command = re.sub(' -caption "%c"| -caption %c',
+ ' -caption "%s"' % name,
+ escape_utf8(entry.DesktopEntry.getExec()))
command = re.sub(' [^ ]*%[fFuUdDnNickvm]', '', command)
if entry.DesktopEntry.getTerminal():
- command = 'xterm -title "%s" -e %s' % \
- (entry_name(entry.DesktopEntry), command)
+ command = 'xterm -title "%s" -e %s' % (name, command)
print ' <action name="Execute">' + \
'<command>%s</command></action>' % command
print ' </item>'
More information about the scm-commits
mailing list