* src/PedView.py: Better autoscaling; better ui management

svn: r5046
This commit is contained in:
Martin Hawlisch 2005-08-10 15:25:46 +00:00
parent bad1414dfc
commit 26a0ed9203
2 changed files with 66 additions and 14 deletions

View File

@ -1,3 +1,6 @@
2005-08-10 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/PedView.py: Better autoscaling; better ui management
2005-08-09 Don Allingham <don@gramps-project.org> 2005-08-09 Don Allingham <don@gramps-project.org>
* src/ScratchPad.py: added * src/ScratchPad.py: added
* src/stock_link.png: added * src/stock_link.png: added

View File

@ -99,6 +99,8 @@ class PedView(PageView.PageView):
self.table_5.connect("button-press-event", self.on_show_option_menu_cb) self.table_5.connect("button-press-event", self.on_show_option_menu_cb)
self.add_table_to_notebook( self.table_5) self.add_table_to_notebook( self.table_5)
self.rebuild_trees(None)
return self.notebook return self.notebook
def init_parent_signals_cb(self, widget, event): 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('Add', gtk.STOCK_ADD, "_Add", callback=self.add)
#self.add_action('Edit', gtk.STOCK_EDIT, "_Edit", callback=self.edit) #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('Remove', gtk.STOCK_REMOVE, "_Remove", callback=self.remove)
#self.add_action('Forward',gtk.STOCK_GO_FORWARD,"_Forward", callback=self.fwd_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.back_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_action('HomePerson', gtk.STOCK_HOME, "_Home", callback=self.home)
#self.add_toggle_action('Filter', None, '_Filter', callback=self.filter_toggle) #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): def ui_definition(self):
return '''<ui> return '''<ui>
@ -137,6 +178,8 @@ class PedView(PageView.PageView):
</menubar> </menubar>
<toolbar name="ToolBar"> <toolbar name="ToolBar">
<placeholder name="CommonNavigation"> <placeholder name="CommonNavigation">
<toolitem action="Back"/>
<toolitem action="Forward"/>
<toolitem action="HomePerson"/> <toolitem action="HomePerson"/>
</placeholder> </placeholder>
</toolbar> </toolbar>
@ -152,23 +195,28 @@ class PedView(PageView.PageView):
db.connect('person-update', self.person_updated_cb) db.connect('person-update', self.person_updated_cb)
db.connect('person-delete', self.person_updated_cb) db.connect('person-delete', self.person_updated_cb)
db.connect('person-rebuild', self.person_rebuild) db.connect('person-rebuild', self.person_rebuild)
self.active_person = None self.rebuild_trees(None)
def person_updated_cb(self,handle_list): 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): 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): def goto_active_person(self,handle):
print "PedView.goto_active_person" print "PedView.goto_active_person"
if handle: if handle:
self.active_person = self.db.get_person_from_handle(handle) self.rebuild_trees(self.db.get_person_from_handle(handle))
self.rebuild_trees(self.active_person)
else: else:
self.rebuild_trees(None) self.rebuild_trees(None)
def request_resize(self): def request_resize(self):
print "PedView.request_resize"
self.size_request_cb(self.notebook.parent,None,None) self.size_request_cb(self.notebook.parent,None,None)
def size_request_cb(self, widget, event, data=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_4, pos_4, person)
self.rebuild( self.table_5, pos_5, 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): def rebuild( self, table_widget, positions, active_person):
print "PedView.rebuild" print "PedView.rebuild"
# Build ancestor tree # Build ancestor tree
lst = [None]*31 lst = [None]*31
self.find_tree(self.active_person,0,1,lst) self.find_tree(active_person,0,1,lst)
# Purge current table content # Purge current table content
for child in table_widget.get_children(): for child in table_widget.get_children():
@ -388,7 +437,7 @@ class PedView(PageView.PageView):
person_handle = obj.get_data(_PERSON) person_handle = obj.get_data(_PERSON)
person = self.db.get_person_from_handle(person_handle) person = self.db.get_person_from_handle(person_handle)
if person: if person:
EditPerson.EditPerson(self.state, person, self.state.db, None) EditPerson.EditPerson(self.state, person, self.person_edited_cb)
return True return True
return False return False
@ -401,16 +450,16 @@ class PedView(PageView.PageView):
def on_show_child_menu(self,obj): def on_show_child_menu(self,obj):
"""User clicked button to move to child of active person""" """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 # Build and display the menu attached to the left pointing arrow
# button. The menu consists of the children of the current root # button. The menu consists of the children of the current root
# person of the tree. Attach a child to each menu item. # 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: if len(childlist) == 1:
child = self.db.get_person_from_handle(childlist[0]) child = self.db.get_person_from_handle(childlist[0])
if child: if child:
self.parent.change_active_person(child) self.state.change_active_person(child)
elif len(childlist) > 1: elif len(childlist) > 1:
myMenu = gtk.Menu() myMenu = gtk.Menu()
for child_handle in childlist: for child_handle in childlist: