Browse Source

Don't process desktop entries if they won't show

If for any reason the desktop entry won't be shown (for example if
NoDisplay is set), then don't process the desktop entry any further as
there is no need to. Should make processing a tiny bit faster.
pull/5/head
George Vlahavas 9 years ago
parent
commit
8c5f07f011
  1. 38
      src/xdgmenumaker

38
src/xdgmenumaker

@ -232,6 +232,21 @@ def icon_full_path(icon):
def get_entry_info(desktopfile):
show = True
de = dentry.DesktopEntry(filename=desktopfile)
# skip processing the rest of the desktop entry if the item is to not be
# displayed anyway
onlyshowin = de.getOnlyShowIn()
notshowin = de.getNotShowIn()
hidden = de.getHidden()
nodisplay = de.getNoDisplay()
# none of the freedesktop registered environments are supported by
# OnlyShowIn anyway:
# http://standards.freedesktop.org/menu-spec/latest/apb.html
# So if OnlyShowIn is set, it certainly isn't for any of the WMs
# xdgmenumaker supports.
if (onlyshowin != []) or (desktop in notshowin) or hidden or nodisplay:
return None
name = de.getName().encode('utf-8')
if seticon:
@ -241,12 +256,6 @@ def get_entry_info(desktopfile):
else:
icon = None
hidden = de.getHidden()
if hidden:
show = False
nodisplay = de.getNoDisplay()
if nodisplay:
show = False
# removing any %U or %F from the exec line
command = de.getExec().partition('%')[0]
@ -289,20 +298,9 @@ def get_entry_info(desktopfile):
else:
category = other
onlyshowin = de.getOnlyShowIn()
notshowin = de.getNotShowIn()
# none of the freedesktop registered environments are supported by this anyway
# http://standards.freedesktop.org/menu-spec/latest/apb.html
if onlyshowin != []:
show = False
if desktop in notshowin:
show = False
if show:
app = App(name, icon, command, path)
mentry = MenuEntry(category, app)
return mentry
else:
return None
app = App(name, icon, command, path)
mentry = MenuEntry(category, app)
return mentry
def sortedcategories(applist):

Loading…
Cancel
Save