summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinrich Wendel <h_wendel@cojobo.net>2005-08-11 11:04:43 +0000
committerHeinrich Wendel <h_wendel@cojobo.net>2005-08-11 11:04:43 +0000
commit2353e5f3998676ba768c87544eb50bb5e802652e (patch)
tree149d0afe67279ea08a1dcb4b69fc3d71d80d8251
parent2625da81be980de40292d1d50ad7607ea07332f0 (diff)
add tryexec feature
-rw-r--r--xdg/Menu.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/xdg/Menu.py b/xdg/Menu.py
index a153b82..35fc753 100644
--- a/xdg/Menu.py
+++ b/xdg/Menu.py
@@ -1,6 +1,8 @@
"""
Implementation of the XDG Menu Specification Version 1.0.draft-1
http://standards.freedesktop.org/menu-spec/
+
+TODO: TryExec / NoExec
"""
from __future__ import generators
@@ -382,7 +384,7 @@ class MenuEntry:
self.DesktopEntry = DesktopEntry(os.path.join(dir,filename))
self.setAttributes(filename, dir, prefix)
- # Can be one of Deleted/Hidden/Empty/NotShowIn or True
+ # Can be one of Deleted/Hidden/Empty/NotShowIn/NoExec or True
self.Show = True
# Semi-Private
@@ -920,7 +922,7 @@ def sort(menu):
if submenu.Name not in tmp_s:
__parse_inline(submenu, menu)
- # getHidden / NoDisplay / OnlyShowIn / NotOnlyShowIn / Deleted
+ # getHidden / NoDisplay / OnlyShowIn / NotOnlyShowIn / Deleted / NoExec
for entry in menu.Entries:
entry.Show = True
menu.Visible += 1
@@ -942,6 +944,9 @@ def sort(menu):
elif entry.DesktopEntry.getHidden() == True:
entry.Show = "Hidden"
menu.Visible -= 1
+ elif entry.DesktopEntry.getTryExec() and not __find_executable(entry.DesktopEntry.getTryExec()):
+ entry.Show = "NoExec"
+ menu.Visible -= 1
elif xdg.Config.windowmanager:
if ( entry.DesktopEntry.getOnlyShowIn() != [] and xdg.Config.windowmanager not in entry.DesktopEntry.getOnlyShowIn() ) \
or xdg.Config.windowmanager in entry.DesktopEntry.getNotShowIn():
@@ -966,6 +971,17 @@ def sort(menu):
if entry.NotInXml == True:
menu.Entries.remove(entry)
+def __find_executable(executable):
+ paths = string.split(os.environ['PATH'], os.pathsep)
+ if not os.path.isfile(executable):
+ for p in paths:
+ f = os.path.join(p, executable)
+ if os.path.isfile(f):
+ return f
+ return None
+ else:
+ return executable
+
# inline tags
def __parse_inline(submenu, menu):
if submenu.Layout.inline == "true":