From bd377f63a038ee67b90a1c4b6244761bc556375c Mon Sep 17 00:00:00 2001 From: Zsolt Foldvari Date: Fri, 25 Aug 2006 17:17:37 +0000 Subject: [PATCH] 2006-08-25 Zsolt Foldvari * src/GrampsCfg.py: Implement callback mechanism for dynamic name format change. * src/ViewManager.py (__init__, preferences_activate, change_page): Rebuild the active page after name fomat changed by connecting to GrampsPreferences' signal svn: r7262 --- ChangeLog | 7 +++++++ src/GrampsCfg.py | 13 ++++++++++--- src/ViewManager.py | 11 +++++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1302ea5c0..c39212992 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-08-25 Zsolt Foldvari + * src/GrampsCfg.py: Implement callback mechanism for dynamic name format + change. + * src/ViewManager.py (__init__, preferences_activate, change_page): + Rebuild the active page after name fomat changed by connecting to + GrampsPreferences' signal + 2006-08-24 Alex Roitman * src/GrampsDb/_GrampsInMemDB.py (undo_data): Add method to take care of secondary indices on undo/redo; diff --git a/src/GrampsCfg.py b/src/GrampsCfg.py index 29793bfec..6ce0e96c1 100644 --- a/src/GrampsCfg.py +++ b/src/GrampsCfg.py @@ -46,6 +46,7 @@ from RelLib import Name import ManagedWindow from GrampsWidgets import * import QuestionDialog +from GrampsDb import GrampsDBCallback #------------------------------------------------------------------------- # @@ -91,13 +92,18 @@ def get_researcher(): # # #------------------------------------------------------------------------- -class GrampsPreferences(ManagedWindow.ManagedWindow): - def __init__(self, uistate, dbstate): +class GrampsPreferences(ManagedWindow.ManagedWindow,GrampsDBCallback): + __signals__ = { + 'nameformat-changed': None, + } + + def __init__(self, uistate, dbstate): + GrampsDBCallback.__init__(self) ManagedWindow.ManagedWindow.__init__(self,uistate,[],GrampsPreferences) self.dbstate = dbstate - + tlabel = gtk.Label() self.set_window( gtk.Dialog(_('Preferences'), @@ -345,6 +351,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): new_idx = the_list.get_value(the_iter,COL_NUM) Config.set(Config.NAME_FORMAT,new_idx) _nd.set_default_format(new_idx) + self.emit('nameformat-changed') def cb_format_tree_select(self, tree_selection): """ diff --git a/src/ViewManager.py b/src/ViewManager.py index 48fb7408a..dfbb332f0 100644 --- a/src/ViewManager.py +++ b/src/ViewManager.py @@ -190,6 +190,7 @@ class ViewManager: self.views = [] self.pages = [] self.file_loaded = False + self._prefs = None self._build_main_window() self._connect_signals() self.do_load_plugins() @@ -517,7 +518,9 @@ class ViewManager: def preferences_activate(self, obj): try: - GrampsCfg.GrampsPreferences(self.uistate,self.state) + self._prefs = GrampsCfg.GrampsPreferences(self.uistate,self.state) + self._key = self._prefs.connect('nameformat-changed', + self.active_page.build_tree) except Errors.WindowActiveError: pass @@ -735,7 +738,11 @@ class ViewManager: while gtk.events_pending(): gtk.main_iteration() - self.pages[num].change_page() + self.active_page.change_page() + if self._prefs: + self._prefs.disconnect(self._key) + self._key = self._prefs.connect('nameformat-changed', + self.active_page.build_tree) def import_data(self, obj): if self.state.db.db_is_open: