[kupfer] data, main, browser: Use normal singleton idiom for DataController
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] data, main, browser: Use normal singleton idiom for DataController
- Date: Thu, 20 Aug 2009 22:11:04 +0000 (UTC)
commit 83152edeb15225c35e89a2dd0be851c47590e2ce
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Thu Aug 20 20:20:00 2009 +0200
data, main, browser: Use normal singleton idiom for DataController
DataController is implemented as a singleton, and should use the
normal (kupfer) GetDataController() idiom.
kupfer/browser.py | 11 ++++++-----
kupfer/data.py | 12 +++++++-----
kupfer/main.py | 2 +-
3 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/kupfer/browser.py b/kupfer/browser.py
index 9b2349a..3eee94e 100644
--- a/kupfer/browser.py
+++ b/kupfer/browser.py
@@ -1134,13 +1134,14 @@ class WindowController (pretty.OutputMixin):
"""
"""
self.icon_name = gtk.STOCK_FIND
- self.data_controller = data.DataController()
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- self.interface = Interface(self.data_controller, self.window)
- self._setup_window()
+
+ data_controller = data.GetDataController()
+ data_controller.connect("launched-action", self.launch_callback)
+
+ self.interface = Interface(data_controller, self.window)
self.interface.connect("cancelled", self._cancelled)
- self.data_controller.connect("launched-action", self.launch_callback)
- self._keystr = ""
+ self._setup_window()
self._statusicon = None
def show_statusicon(self):
diff --git a/kupfer/data.py b/kupfer/data.py
index 7edaffd..1cf158b 100644
--- a/kupfer/data.py
+++ b/kupfer/data.py
@@ -693,9 +693,6 @@ class DataController (gobject.GObject, pretty.OutputMixin):
"""
__gtype_name__ = "DataController"
- def __call__(self):
- return self
-
def __init__(self):
super(DataController, self).__init__()
@@ -958,8 +955,13 @@ gobject.signal_new("mode-changed", DataController, gobject.SIGNAL_RUN_LAST,
gobject.signal_new("launched-action", DataController, gobject.SIGNAL_RUN_LAST,
gobject.TYPE_BOOLEAN, (gobject.TYPE_INT, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT))
-# Create singleton object shadowing main class!
-DataController = DataController()
+
+_data_controller = None
+def GetDataController():
+ global _data_controller
+ if _data_controller is None:
+ _data_controller = DataController()
+ return _data_controller
class ActionThread (threading.Thread, gobject.GObject, pretty.OutputMixin):
diff --git a/kupfer/main.py b/kupfer/main.py
index 6015157..4400dcc 100644
--- a/kupfer/main.py
+++ b/kupfer/main.py
@@ -186,7 +186,7 @@ def main():
if not S_sources and not s_sources:
print pretty.print_info(__name__, "No sources found!")
- dc = data.DataController()
+ dc = data.GetDataController()
dc.set_sources(S_sources, s_sources)
dc.register_text_sources(text_sources)
dc.register_action_decorators(action_decorators)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]