[billreminder] a simple function to avoid modality, but keep one window per instance
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [billreminder] a simple function to avoid modality, but keep one window per instance
- Date: Sun, 29 Nov 2009 13:29:38 +0000 (UTC)
commit a762a7b1b76836a6e919fe39e6b2bb26f66761a8
Author: Toms Bauģis <toms baugis gmail com>
Date: Sun Nov 29 13:15:51 2009 +0000
a simple function to avoid modality, but keep one window per instance
src/lib/dialogs.py | 34 ++++++++++++++++++++++++----------
1 files changed, 24 insertions(+), 10 deletions(-)
---
diff --git a/src/lib/dialogs.py b/src/lib/dialogs.py
index 5e21e8b..ca701c1 100644
--- a/src/lib/dialogs.py
+++ b/src/lib/dialogs.py
@@ -24,19 +24,33 @@ from gui.prefdialog import PrefDialog
from gui.categoriesdialog import CategoriesDialog
from lib import i18n
-def about_dialog(parent=None):
- about = AboutDialog()
- ret = about.run()
- about.destroy()
- return ret
+class OneWindow(object):
+ def __init__(self, dialog_class):
+ self.dialog = None
+ self.dialog_class = dialog_class
+
+ def on_dialog_destroy(self):
+ self.dialog = None
-def preferences_dialog(parent=None):
- pref = PrefDialog(parent=parent)
- ret = pref.run()
- pref.destroy()
+ def show(self, parent = None):
+ if self.dialog:
+ self.dialog.present()
+ else:
+ if parent:
+ self.dialog = self.dialog_class(parent)
+ else:
+ self.dialog = self.dialog_class()
+ self.dialog.connect("destroy", lambda *args: self.on_dialog_destroy())
- return ret
+about = OneWindow(AboutDialog)
+prefs = OneWindow(PrefDialog)
+
+def about_dialog(parent=None):
+ about.show(parent)
+
+def preferences_dialog(parent=None):
+ prefs.show(parent)
def categories_dialog(parent=None):
categories = CategoriesDialog(parent=parent)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]