[kupfer] core: Use individual source 'toplevel' configuration
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer] core: Use individual source 'toplevel' configuration
- Date: Sun, 9 May 2010 15:56:03 +0000 (UTC)
commit f7f9fbbc15c00b3111306e81f914ca77cd60960d
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Sun May 9 16:25:25 2010 +0100
core: Use individual source 'toplevel' configuration
kupfer/core/data.py | 10 ++++++----
kupfer/core/settings.py | 27 ++++++++++++++++++++++-----
kupfer/obj/base.py | 4 ++++
3 files changed, 32 insertions(+), 9 deletions(-)
---
diff --git a/kupfer/core/data.py b/kupfer/core/data.py
index a0865d6..066e71e 100644
--- a/kupfer/core/data.py
+++ b/kupfer/core/data.py
@@ -580,11 +580,13 @@ class DataController (gobject.GObject, pretty.OutputMixin):
def _insert_sources(self, plugin_id, sources, initialize=True):
if not sources:
return
- setctl = settings.GetSettingsController()
- is_toplevel = setctl.get_plugin_is_toplevel(plugin_id)
sc = GetSourceController()
- sc.add(plugin_id, sources, toplevel=is_toplevel, initialize=initialize)
- self.source_pane.source_rebase(sc.root)
+ setctl = settings.GetSettingsController()
+ for src in sources:
+ is_toplevel = setctl.get_source_is_toplevel(plugin_id, src)
+ sc.add(plugin_id, (src, ), toplevel=is_toplevel,
+ initialize=initialize)
+ self._reload_source_root()
def _finish(self, sched):
self.output_info("Saving data...")
diff --git a/kupfer/core/settings.py b/kupfer/core/settings.py
index 6d8b24d..35f2038 100644
--- a/kupfer/core/settings.py
+++ b/kupfer/core/settings.py
@@ -228,16 +228,28 @@ class SettingsController (gobject.GObject, pretty.OutputMixin):
self.emit("plugin-enabled-changed", plugin_id, enabled)
return ret
- def get_plugin_is_toplevel(self, plugin_id):
- """Convenience: if @plugin_id items are included in toplevel"""
- return self.get_plugin_config(plugin_id, "kupfer_toplevel",
- value_type=strbool, default=True)
-
def get_plugin_is_hidden(self, plugin_id):
"""Convenience: if @plugin_id is hidden"""
return self.get_plugin_config(plugin_id, "kupfer_hidden",
value_type=strbool, default=False)
+ @classmethod
+ def _source_config_repr(self, obj):
+ name = type(obj).__name__
+ return "".join([(c if c.isalnum() else '_') for c in name])
+
+ def get_source_is_toplevel(self, plugin_id, src):
+ key = "kupfer_toplevel_" + self._source_config_repr(src)
+ default = not getattr(src, "source_prefer_sublevel", False)
+ return self.get_plugin_config(plugin_id, key,
+ value_type=strbool, default=default)
+
+ def set_source_is_toplevel(self, plugin_id, src, value):
+ key = "kupfer_toplevel_" + self._source_config_repr(src)
+ self.emit("plugin-toplevel-changed", plugin_id, value)
+ return self.set_plugin_config(plugin_id, key,
+ value, value_type=strbool)
+
def get_keybinding(self):
"""Convenience: Kupfer keybinding as string"""
return self.get_config("Kupfer", "keybinding")
@@ -384,6 +396,11 @@ gobject.signal_new("plugin-enabled-changed", SettingsController,
gobject.SIGNAL_RUN_LAST, gobject.TYPE_BOOLEAN,
(gobject.TYPE_STRING, gobject.TYPE_INT))
+# Plugin ID, Value
+gobject.signal_new("plugin-toplevel-changed", SettingsController,
+ gobject.SIGNAL_RUN_LAST, gobject.TYPE_BOOLEAN,
+ (gobject.TYPE_STRING, gobject.TYPE_INT))
+
_settings_controller = None
def GetSettingsController():
global _settings_controller
diff --git a/kupfer/obj/base.py b/kupfer/obj/base.py
index 5071c91..61f6c60 100644
--- a/kupfer/obj/base.py
+++ b/kupfer/obj/base.py
@@ -298,9 +298,13 @@ class Source (KupferObject, pretty.OutputMixin):
@source_user_reloadable if True source get "Reload" action without
debug mode.
+ @source_prefer_sublevel if True, the source by default exports
+ its contents in a subcatalog, not to the toplevel.
+ NOTE: *Almost never* use this: let the user decide, default to toplevel.
"""
fallback_icon_name = "kupfer-object-multiple"
source_user_reloadable = False
+ source_prefer_sublevel = False
def __init__(self, name):
KupferObject.__init__(self, name)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]