[kupfer] plugin.templates: Ask GLib for the user's Template dir
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] plugin.templates: Ask GLib for the user's Template dir
- Date: Wed, 11 Nov 2009 23:01:21 +0000 (UTC)
commit 7b5f8c09053623130e0e4cb2662697ba210c5311
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Wed Nov 11 23:59:00 2009 +0100
plugin.templates: Ask GLib for the user's Template dir
Since pygobject 2.18, we have glib.get_user_special_dir available.
With the right configuration, this can return the paths to the user's
special directories if set up. We use this to find the template dir or
use ~/Templates as fallback.
kupfer/plugin/templates.py | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/kupfer/plugin/templates.py b/kupfer/plugin/templates.py
index cafddff..93878bd 100644
--- a/kupfer/plugin/templates.py
+++ b/kupfer/plugin/templates.py
@@ -88,9 +88,11 @@ class TemplatesSource (Source, PicklingHelperMixin, FilesystemWatchMixin):
self.unpickle_finish()
def unpickle_finish(self):
- """Set up change callback"""
- tmpl_var = os.getenv("XDG_TEMPLATES_DIR", DEFAULT_TMPL_DIR)
- self.tmpl_dir = os.path.expanduser(tmpl_var)
+ # Set up change callback
+ tmpl_dir = glib.get_user_special_dir(glib.USER_DIRECTORY_TEMPLATES)
+ if not tmpl_dir:
+ tmpl_var = os.path.expanduser(DEFAULT_TMPL_DIR)
+ self.tmpl_dir = tmpl_var
self.monitor_token = self.monitor_directories(self.tmpl_dir)
def get_items(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]