[hamster-applet] don't initiate dialog classes on startup to avoid circular dependencies
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [hamster-applet] don't initiate dialog classes on startup to avoid circular dependencies
- Date: Mon, 28 Dec 2009 02:04:29 +0000 (UTC)
commit e444cbebdf66ad05e125de9f73f5bbca93ac2fde
Author: Toms Bauģis <toms baugis gmail com>
Date: Mon Dec 28 01:51:55 2009 +0000
don't initiate dialog classes on startup to avoid circular dependencies
hamster/configuration.py | 38 +++++++++++++++++++++++---------------
1 files changed, 23 insertions(+), 15 deletions(-)
---
diff --git a/hamster/configuration.py b/hamster/configuration.py
index 08e539e..629d8f7 100644
--- a/hamster/configuration.py
+++ b/hamster/configuration.py
@@ -110,9 +110,9 @@ runtime = RuntimeStore()
class OneWindow(object):
- def __init__(self, dialog_class):
+ def __init__(self, get_dialog_class):
self.dialogs = {}
- self.dialog_class = dialog_class
+ self.get_dialog_class = get_dialog_class
def on_dialog_destroy(self, params):
del self.dialogs[params]
@@ -125,10 +125,10 @@ class OneWindow(object):
self.dialogs[params].window.present()
else:
if parent:
- dialog = self.dialog_class(parent, **kwargs)
+ dialog = self.get_dialog_class()(parent, **kwargs)
dialog.window.set_transient_for(parent.get_toplevel())
else:
- dialog = self.dialog_class(**kwargs)
+ dialog = self.get_dialog_class()(**kwargs)
# to make things simple, we hope that the target has defined self.window
dialog.window.connect("destroy",
@@ -141,17 +141,25 @@ class Dialogs(Singleton):
"""makes sure that we have single instance open for windows where it makes
sense"""
def __init__(self):
- from edit_activity import CustomFactController
- self.edit = OneWindow(CustomFactController)
-
- from stats import StatsViewer
- self.stats = OneWindow(StatsViewer)
-
- from about import About
- self.about = OneWindow(About)
-
- from preferences import PreferencesEditor
- self.prefs = OneWindow(PreferencesEditor)
+ def get_edit_class():
+ from edit_activity import CustomFactController
+ return CustomFactController
+ self.edit = OneWindow(get_edit_class)
+
+ def get_stats_class():
+ from stats import StatsViewer
+ return StatsViewer
+ self.stats = OneWindow(get_stats_class)
+
+ def get_about_class():
+ from about import About
+ return About
+ self.about = OneWindow(get_about_class)
+
+ def get_prefs_class():
+ from preferences import PreferencesEditor
+ return PreferencesEditor
+ self.prefs = OneWindow(get_prefs_class)
dialogs = Dialogs()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]