[kupfer] settings, data: Understand USER_DIRECTORY_DESKTOP
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] settings, data: Understand USER_DIRECTORY_DESKTOP
- Date: Wed, 25 Nov 2009 00:01:07 +0000 (UTC)
commit 2d51be3a46fdacf3c5add292c458979c2547f351
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Wed Nov 25 00:53:12 2009 +0100
settings, data: Understand USER_DIRECTORY_DESKTOP
We special-case configured directories that are specified as
USER_DIRECTORY_*, and ask glib where these are.
This is for the defautl configuration only, and will be replaced by
absolute paths if the user changes the configuration in the GUI.
Launchpad bug https://bugs.launchpad.net/kupfer/+bug/471462
kupfer/data.py | 11 +++++------
kupfer/settings.py | 17 +++++++++++++++--
2 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/kupfer/data.py b/kupfer/data.py
index 9985c22..7210f5f 100644
--- a/kupfer/data.py
+++ b/kupfer/data.py
@@ -833,21 +833,20 @@ class DataController (gobject.GObject, pretty.OutputMixin):
source_config = setctl.get_config
def dir_source(opt):
- abs = os.path.abspath(os.path.expanduser(opt))
- return objects.DirectorySource(abs)
+ return objects.DirectorySource(opt)
def file_source(opt, depth=1):
abs = os.path.abspath(os.path.expanduser(opt))
return objects.FileSource((abs,), depth)
+ for coll, level in zip((s_sources, S_sources), ("Catalog", "Direct")):
+ for item in setctl.get_directories(level):
+ coll.append(dir_source(item))
+
dir_depth = source_config("DeepDirectories", "Depth")
- for item in source_config("Directories", "Catalog"):
- s_sources.append(dir_source(item))
for item in source_config("DeepDirectories","Catalog"):
s_sources.append(file_source(item, dir_depth))
- for item in source_config("Directories", "Direct"):
- S_sources.append(dir_source(item))
for item in source_config("DeepDirectories", "Direct"):
S_sources.append(file_source(item, dir_depth))
diff --git a/kupfer/settings.py b/kupfer/settings.py
index ebd4edc..1d8ba68 100644
--- a/kupfer/settings.py
+++ b/kupfer/settings.py
@@ -4,6 +4,7 @@ import os, sys
import ConfigParser
import copy
+import glib
import gobject
from kupfer import config, pretty, scheduler
@@ -232,8 +233,20 @@ class SettingsController (gobject.GObject, pretty.OutputMixin):
"""Set config value and return success"""
return self._set_config("Kupfer", "showstatusicon", enabled)
- def get_directories(self):
- return self.get_config("Directories", "direct")
+ def get_directories(self, direct=True):
+ """Yield directories to use as directory sources"""
+
+ specialdirs = dict((k, getattr(glib, k))
+ for k in dir(glib) if k.startswith("USER_DIRECTORY_"))
+
+ def get_special_dir(opt):
+ if opt in specialdirs:
+ return glib.get_user_special_dir(specialdirs[opt])
+
+ level = "Direct" if direct else "Catalog"
+ for direc in self.get_config("Directories", level):
+ dpath = get_special_dir(direc)
+ yield dpath or os.path.abspath(os.path.expanduser(direc))
def set_directories(self, dirs):
return self._set_config("Directories", "direct", dirs)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]