[kupfer: 19/67] desktop_launch: Find .desktop files in subdirectories
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer: 19/67] desktop_launch: Find .desktop files in subdirectories
- Date: Sat, 19 Mar 2011 00:59:20 +0000 (UTC)
commit 1083a7eca5f24d0aa6f3889842565c801dac48aa
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Tue Mar 15 22:52:29 2011 +0100
desktop_launch: Find .desktop files in subdirectories
kupfer/desktop_launch.py | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/kupfer/desktop_launch.py b/kupfer/desktop_launch.py
index f590be3..08eb9dd 100644
--- a/kupfer/desktop_launch.py
+++ b/kupfer/desktop_launch.py
@@ -44,13 +44,24 @@ def gtk_to_unicode(gtkstring):
return gtkstring.decode("UTF-8", "ignore")
def find_desktop_file(desk_id):
- """Find file for @desk_id or raise ResourceLookupError"""
+ """Find file for @desk_id or raise ResourceLookupError
+
+ Desktop files are found by appending /applications/ to
+ $XDG_DATA_DIRS, but if they are located in subdirs of that,
+ then additional 'subdirectory-' prefixes are used.
+ """
if not desk_id:
raise ResourceLookupError("Empty id")
try:
return next(xdg.BaseDirectory.load_data_paths("applications", desk_id))
except StopIteration:
- raise ResourceLookupError("Cannot locate '%s'" % (desk_id,))
+ if "-" in desk_id:
+ try:
+ return next(xdg.BaseDirectory.load_data_paths(
+ "applications", *desk_id.split("-", 1)))
+ except StopIteration:
+ pass
+ raise ResourceLookupError("Cannot locate '%s'" % (desk_id,))
def read_desktop_info(desktop_file):
"""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]