From 26a0ed92039a72cc841de88b9fbc86d4d76c598f Mon Sep 17 00:00:00 2001 From: Martin Hawlisch Date: Wed, 10 Aug 2005 15:25:46 +0000 Subject: [PATCH] * src/PedView.py: Better autoscaling; better ui management svn: r5046 --- gramps2/ChangeLog | 3 ++ gramps2/src/PedView.py | 77 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 66 insertions(+), 14 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 9aaaaf1b3..657c80b54 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,6 @@ +2005-08-10 Martin Hawlisch + * src/PedView.py: Better autoscaling; better ui management + 2005-08-09 Don Allingham * src/ScratchPad.py: added * src/stock_link.png: added diff --git a/gramps2/src/PedView.py b/gramps2/src/PedView.py index 754340804..4d3e8f1ce 100644 --- a/gramps2/src/PedView.py +++ b/gramps2/src/PedView.py @@ -99,6 +99,8 @@ class PedView(PageView.PageView): self.table_5.connect("button-press-event", self.on_show_option_menu_cb) self.add_table_to_notebook( self.table_5) + self.rebuild_trees(None) + return self.notebook def init_parent_signals_cb(self, widget, event): @@ -121,10 +123,49 @@ class PedView(PageView.PageView): #self.add_action('Add', gtk.STOCK_ADD, "_Add", callback=self.add) #self.add_action('Edit', gtk.STOCK_EDIT, "_Edit", callback=self.edit) #self.add_action('Remove', gtk.STOCK_REMOVE, "_Remove", callback=self.remove) - #self.add_action('Forward',gtk.STOCK_GO_FORWARD,"_Forward", callback=self.fwd_clicked) - #self.add_action('Back', gtk.STOCK_GO_BACK, "_Back", callback=self.back_clicked) + self.add_action('Forward',gtk.STOCK_GO_FORWARD,"_Forward", callback=self.home)#callback=self.fwd_clicked) + self.add_action('Back', gtk.STOCK_GO_BACK, "_Back", callback=self.home)#callback=self.back_clicked) self.add_action('HomePerson', gtk.STOCK_HOME, "_Home", callback=self.home) #self.add_toggle_action('Filter', None, '_Filter', callback=self.filter_toggle) + # add the Forward action group to handle the Forward button + self.fwd_action = gtk.ActionGroup(self.title + '/Forward') + self.fwd_action.add_actions([ + ('Forward',gtk.STOCK_GO_FORWARD,"_Forward", None, None, self.home)#callback=self.fwd_clicked) + ]) + + # add the Backward action group to handle the Forward button + self.back_action = gtk.ActionGroup(self.title + '/Backward') + self.back_action.add_actions([ + ('Back',gtk.STOCK_GO_BACK,"_Back", None, None, self.home)#callback=self.back_clicked) + ]) + + self.add_action_group(self.back_action) + self.add_action_group(self.fwd_action) + + def disable_action_group(self): + """ + Normally, this would not be overridden from the base class. However, + in this case, we have additional action groups that need to be + handled correctly. + """ + PageView.PageView.disable_action_group(self) + + self.fwd_action.set_visible(False) + self.back_action.set_visible(False) + + def enable_action_group(self,obj): + """ + Normally, this would not be overridden from the base class. However, + in this case, we have additional action groups that need to be + handled correctly. + """ + PageView.PageView.enable_action_group(self,obj) + + self.fwd_action.set_visible(True) + self.back_action.set_visible(True) + hobj = self.state.phistory + self.fwd_action.set_sensitive(not hobj.at_end()) + self.back_action.set_sensitive(not hobj.at_front()) def ui_definition(self): return ''' @@ -137,6 +178,8 @@ class PedView(PageView.PageView): + + @@ -152,23 +195,28 @@ class PedView(PageView.PageView): db.connect('person-update', self.person_updated_cb) db.connect('person-delete', self.person_updated_cb) db.connect('person-rebuild', self.person_rebuild) - self.active_person = None - + self.rebuild_trees(None) + def person_updated_cb(self,handle_list): - self.rebuild_trees(self.active_person) + print "PedView.person_updated_cb" + self.rebuild_trees(self.state.active) def person_rebuild(self): - self.rebuild_trees(self.active_person) + print "PedView.person_rebuild" + self.rebuild_trees(self.state.active) + + def person_edited_cb(self, p1=None, p2=None): + print "PedView.person_edited_cb" def goto_active_person(self,handle): print "PedView.goto_active_person" if handle: - self.active_person = self.db.get_person_from_handle(handle) - self.rebuild_trees(self.active_person) + self.rebuild_trees(self.db.get_person_from_handle(handle)) else: self.rebuild_trees(None) def request_resize(self): + print "PedView.request_resize" self.size_request_cb(self.notebook.parent,None,None) def size_request_cb(self, widget, event, data=None): @@ -247,13 +295,14 @@ class PedView(PageView.PageView): self.rebuild( self.table_4, pos_4, person) self.rebuild( self.table_5, pos_5, person) - gobject.idle_add(self.request_resize) + #gobject.idle_add(self.request_resize) + def rebuild( self, table_widget, positions, active_person): print "PedView.rebuild" # Build ancestor tree lst = [None]*31 - self.find_tree(self.active_person,0,1,lst) + self.find_tree(active_person,0,1,lst) # Purge current table content for child in table_widget.get_children(): @@ -388,7 +437,7 @@ class PedView(PageView.PageView): person_handle = obj.get_data(_PERSON) person = self.db.get_person_from_handle(person_handle) if person: - EditPerson.EditPerson(self.state, person, self.state.db, None) + EditPerson.EditPerson(self.state, person, self.person_edited_cb) return True return False @@ -401,16 +450,16 @@ class PedView(PageView.PageView): def on_show_child_menu(self,obj): """User clicked button to move to child of active person""" - if self.active_person: + if self.state.active: # Build and display the menu attached to the left pointing arrow # button. The menu consists of the children of the current root # person of the tree. Attach a child to each menu item. - childlist = find_children(self.db,self.active_person) + childlist = find_children(self.db,self.state.active) if len(childlist) == 1: child = self.db.get_person_from_handle(childlist[0]) if child: - self.parent.change_active_person(child) + self.state.change_active_person(child) elif len(childlist) > 1: myMenu = gtk.Menu() for child_handle in childlist: