PersonNavView changes
svn: r5052
This commit is contained in:
parent
0a245a7f2d
commit
30450e2efa
@ -1,3 +1,12 @@
|
||||
2005-08-11 Don Allingham <don@gramps-project.org>
|
||||
* src/DbState.py: handle self.index == -1
|
||||
* src/PageView.py: Provide PersonNavPage to handle page views
|
||||
that to person navigation
|
||||
* src/PedView.py: Derive from PersonNavPage
|
||||
* src/PersonView.py: Derive from PersonNavPage
|
||||
* src/ViewManager.py: Call new change_page to make sure history
|
||||
buttons are correct for the view.
|
||||
|
||||
2005-08-11 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||
* src/PedView.py: More work on it.
|
||||
* src/MapView.py: New View showing locations on a map. Early unfinished version.
|
||||
|
@ -112,7 +112,7 @@ class History(GrampsDBCallback.GrampsDBCallback):
|
||||
return self.index+1 == len(self.history)
|
||||
|
||||
def at_front(self):
|
||||
return self.index == 0
|
||||
return self.index <= 0
|
||||
|
||||
def prune(self):
|
||||
if not self.at_end():
|
||||
|
116
src/PageView.py
116
src/PageView.py
@ -101,4 +101,120 @@ class PageView:
|
||||
def add_action_group(self,group):
|
||||
self.additional_action_groups.append(group)
|
||||
|
||||
def change_page(self):
|
||||
pass
|
||||
|
||||
class PersonNavView(PageView):
|
||||
def __init__(self,title,dbstate,uistate):
|
||||
PageView.__init__(self,title,dbstate,uistate)
|
||||
|
||||
def navigation_type(self):
|
||||
return NAVIGATION_PERSON
|
||||
|
||||
def define_actions(self):
|
||||
# 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.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.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.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.enable_action_group(self,obj)
|
||||
|
||||
self.fwd_action.set_visible(True)
|
||||
self.back_action.set_visible(True)
|
||||
hobj = self.uistate.phistory
|
||||
self.fwd_action.set_sensitive(not hobj.at_end())
|
||||
self.back_action.set_sensitive(not hobj.at_front())
|
||||
|
||||
def home(self,obj):
|
||||
defperson = self.dbstate.db.get_default_person()
|
||||
if defperson:
|
||||
self.dbstate.change_active_person(defperson)
|
||||
|
||||
def fwd_clicked(self,obj,step=1):
|
||||
hobj = self.uistate.phistory
|
||||
hobj.lock = True
|
||||
if not hobj.at_end():
|
||||
try:
|
||||
handle = hobj.forward()
|
||||
self.dbstate.active = self.dbstate.db.get_person_from_handle(handle)
|
||||
self.uistate.modify_statusbar()
|
||||
self.dbstate.change_active_handle(handle)
|
||||
hobj.mhistory.append(hobj.history[hobj.index])
|
||||
#self.redraw_histmenu()
|
||||
self.fwd_action.set_sensitive(not hobj.at_end())
|
||||
self.back_action.set_sensitive(True)
|
||||
except:
|
||||
hobj.clear()
|
||||
self.fwd_action.set_sensitive(False)
|
||||
self.back_action.set_sensitive(False)
|
||||
else:
|
||||
self.fwd_action.set_sensitive(False)
|
||||
self.back_action.set_sensitive(True)
|
||||
hobj.lock = False
|
||||
|
||||
def back_clicked(self,obj,step=1):
|
||||
hobj = self.uistate.phistory
|
||||
hobj.lock = True
|
||||
if not hobj.at_front():
|
||||
try:
|
||||
handle = hobj.back()
|
||||
self.active = self.dbstate.db.get_person_from_handle(handle)
|
||||
self.uistate.modify_statusbar()
|
||||
self.dbstate.change_active_handle(handle)
|
||||
hobj.mhistory.append(hobj.history[hobj.index])
|
||||
# self.redraw_histmenu()
|
||||
self.back_action.set_sensitive(not hobj.at_front())
|
||||
self.fwd_action.set_sensitive(True)
|
||||
except:
|
||||
hobj.clear()
|
||||
self.fwd_action.set_sensitive(False)
|
||||
self.back_action.set_sensitive(False)
|
||||
else:
|
||||
self.back_action.set_sensitive(False)
|
||||
self.fwd_action.set_sensitive(True)
|
||||
hobj.lock = False
|
||||
|
||||
def handle_history(self, handle):
|
||||
"""
|
||||
Updates the person history information
|
||||
"""
|
||||
hobj = self.uistate.phistory
|
||||
if handle and not hobj.lock:
|
||||
hobj.push(handle)
|
||||
#self.redraw_histmenu()
|
||||
self.fwd_action.set_sensitive(not hobj.at_end())
|
||||
self.back_action.set_sensitive(not hobj.at_front())
|
||||
|
||||
def change_page(self):
|
||||
hobj = self.uistate.phistory
|
||||
print hobj.at_end(), hobj.at_front()
|
||||
self.fwd_action.set_sensitive(not hobj.at_end())
|
||||
self.back_action.set_sensitive(not hobj.at_front())
|
||||
|
@ -67,19 +67,15 @@ _CREM = _('crem.')
|
||||
# PedigreeView
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class PedView(PageView.PageView):
|
||||
class PedView(PageView.PersonNavView):
|
||||
|
||||
def __init__(self,dbstate,uistate):
|
||||
print "PedView.__init__"
|
||||
PageView.PageView.__init__(self,'Pedigree View',dbstate,uistate)
|
||||
PageView.PersonNavView.__init__(self,'Pedigree View',dbstate,uistate)
|
||||
dbstate.connect('database-changed',self.change_db)
|
||||
dbstate.connect('active-changed',self.goto_active_person)
|
||||
self.force_size = 0 # Automatic resize
|
||||
|
||||
def navigation_type(self):
|
||||
print "PedView.navigation_type"
|
||||
return PageView.NAVIGATION_PERSON
|
||||
|
||||
def init_parent_signals_cb(self, widget, event):
|
||||
print "PedView.init_parent_signals_cb"
|
||||
self.notebook.disconnect(self.bootstrap_handler)
|
||||
@ -96,54 +92,6 @@ class PedView(PageView.PageView):
|
||||
# for PyGtk < 2.4
|
||||
self.notebook.append_page(frame,gtk.Label(""))
|
||||
|
||||
def define_actions(self):
|
||||
print "PedView.define_actions"
|
||||
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('HomePerson', gtk.STOCK_HOME, "_Home", callback=self.home)
|
||||
|
||||
# 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.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.back_clicked)
|
||||
])
|
||||
|
||||
self.add_action_group(self.back_action)
|
||||
self.add_action_group(self.fwd_action)
|
||||
|
||||
def disable_action_group(self):
|
||||
print "PedView.disable_action_group"
|
||||
"""
|
||||
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):
|
||||
print "PedView.enable_action_group"
|
||||
"""
|
||||
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.uistate.phistory
|
||||
self.fwd_action.set_sensitive(not hobj.at_end())
|
||||
self.back_action.set_sensitive(not hobj.at_front())
|
||||
|
||||
def get_stock(self):
|
||||
"""
|
||||
Returns the name of the stock icon to use for the display.
|
||||
@ -211,6 +159,23 @@ class PedView(PageView.PageView):
|
||||
</toolbar>
|
||||
</ui>'''
|
||||
|
||||
def define_actions(self):
|
||||
"""
|
||||
Required define_actions function for PageView. Builds the action
|
||||
group information required. We extend beyond the normal here,
|
||||
since we want to have more than one action group for the PersonView.
|
||||
Most PageViews really won't care about this.
|
||||
|
||||
Special action groups for Forward and Back are created to allow the
|
||||
handling of navigation buttons. Forward and Back allow the user to
|
||||
advance or retreat throughout the history, and we want to have these
|
||||
be able to toggle these when you are at the end of the history or
|
||||
at the beginning of the history.
|
||||
"""
|
||||
|
||||
PageView.PersonNavView.define_actions(self)
|
||||
self.add_action('HomePerson',gtk.STOCK_HOME, "_Home", callback=self.home)
|
||||
|
||||
def change_db(self,db):
|
||||
print "PedView.change_db"
|
||||
"""
|
||||
@ -230,16 +195,12 @@ class PedView(PageView.PageView):
|
||||
def goto_active_person(self,handle=None):
|
||||
print "PedView.goto_active_person"
|
||||
if handle:
|
||||
self.rebuild_trees(self.db.get_person_from_handle(handle))
|
||||
person = self.db.get_person_from_handle(handle)
|
||||
self.rebuild_trees(person)
|
||||
self.handle_history(person.handle)
|
||||
else:
|
||||
self.rebuild_trees(None)
|
||||
|
||||
def fwd_clicked(self,obj,step=1):
|
||||
pass
|
||||
|
||||
def back_clicked(self,obj,step=1):
|
||||
pass
|
||||
|
||||
def person_updated_cb(self,handle_list):
|
||||
print "PedView.person_updated_cb"
|
||||
self.rebuild_trees(self.dbstate.active)
|
||||
|
@ -67,17 +67,14 @@ column_names = [
|
||||
]
|
||||
|
||||
|
||||
class PersonView(PageView.PageView):
|
||||
class PersonView(PageView.PersonNavView):
|
||||
|
||||
def __init__(self,dbstate,uistate):
|
||||
PageView.PageView.__init__(self,'Person View',dbstate,uistate)
|
||||
PageView.PersonNavView.__init__(self,'Person View',dbstate,uistate)
|
||||
self.inactive = False
|
||||
dbstate.connect('database-changed',self.change_db)
|
||||
dbstate.connect('active-changed',self.goto_active_person)
|
||||
|
||||
def navigation_type(self):
|
||||
return PageView.NAVIGATION_PERSON
|
||||
|
||||
def define_actions(self):
|
||||
"""
|
||||
Required define_actions function for PageView. Builds the action
|
||||
@ -92,6 +89,8 @@ class PersonView(PageView.PageView):
|
||||
at the beginning of the history.
|
||||
"""
|
||||
|
||||
PageView.PersonNavView.define_actions(self)
|
||||
|
||||
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)
|
||||
@ -99,46 +98,6 @@ class PersonView(PageView.PageView):
|
||||
|
||||
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.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.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.uistate.phistory
|
||||
self.fwd_action.set_sensitive(not hobj.at_end())
|
||||
self.back_action.set_sensitive(not hobj.at_front())
|
||||
|
||||
def get_stock(self):
|
||||
"""
|
||||
Returns the name of the stock icon to use for the display.
|
||||
@ -315,17 +274,6 @@ class PersonView(PageView.PageView):
|
||||
|
||||
# update history
|
||||
self.handle_history(p.handle)
|
||||
|
||||
def handle_history(self, handle):
|
||||
"""
|
||||
Updates the person history information
|
||||
"""
|
||||
hobj = self.uistate.phistory
|
||||
if handle and not hobj.lock:
|
||||
hobj.push(handle)
|
||||
#self.redraw_histmenu()
|
||||
self.fwd_action.set_sensitive(not hobj.at_end())
|
||||
self.back_action.set_sensitive(not hobj.at_front())
|
||||
|
||||
def setup_filter(self):
|
||||
"""
|
||||
@ -823,51 +771,3 @@ class PersonView(PageView.PageView):
|
||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||
self.build_fwdhistmenu(event)
|
||||
|
||||
def fwd_clicked(self,obj,step=1):
|
||||
hobj = self.uistate.phistory
|
||||
hobj.lock = True
|
||||
if not hobj.at_end():
|
||||
try:
|
||||
handle = hobj.forward()
|
||||
self.dbstate.active = self.dbstate.db.get_person_from_handle(handle)
|
||||
self.uistate.modify_statusbar()
|
||||
self.dbstate.change_active_handle(handle)
|
||||
hobj.mhistory.append(hobj.history[hobj.index])
|
||||
#self.redraw_histmenu()
|
||||
self.fwd_action.set_sensitive(not hobj.at_end())
|
||||
self.back_action.set_sensitive(True)
|
||||
except:
|
||||
hobj.clear()
|
||||
self.fwd_action.set_sensitive(False)
|
||||
self.back_action.set_sensitive(False)
|
||||
else:
|
||||
self.fwd_action.set_sensitive(False)
|
||||
self.back_action.set_sensitive(True)
|
||||
hobj.lock = False
|
||||
|
||||
def back_clicked(self,obj,step=1):
|
||||
hobj = self.uistate.phistory
|
||||
hobj.lock = True
|
||||
if not hobj.at_front():
|
||||
try:
|
||||
handle = hobj.back()
|
||||
self.active = self.dbstate.db.get_person_from_handle(handle)
|
||||
self.uistate.modify_statusbar()
|
||||
self.dbstate.change_active_handle(handle)
|
||||
hobj.mhistory.append(hobj.history[hobj.index])
|
||||
# self.redraw_histmenu()
|
||||
self.back_action.set_sensitive(not hobj.at_front())
|
||||
self.fwd_action.set_sensitive(True)
|
||||
except:
|
||||
hobj.clear()
|
||||
self.fwd_action.set_sensitive(False)
|
||||
self.back_action.set_sensitive(False)
|
||||
else:
|
||||
self.back_action.set_sensitive(False)
|
||||
self.fwd_action.set_sensitive(True)
|
||||
hobj.lock = False
|
||||
|
||||
def home(self,obj):
|
||||
defperson = self.dbstate.db.get_default_person()
|
||||
if defperson:
|
||||
self.dbstate.change_active_person(defperson)
|
||||
|
@ -288,6 +288,7 @@ class ViewManager:
|
||||
hbox.show_all()
|
||||
|
||||
# create notebook page and add to notebook
|
||||
page.define_actions()
|
||||
page_display = page.get_display()
|
||||
page_display.show_all()
|
||||
self.notebook.append_page(page_display,hbox)
|
||||
@ -323,7 +324,7 @@ class ViewManager:
|
||||
nav_type = self.navigation_type[self.active_page.navigation_type()]
|
||||
if nav_type[0] != None:
|
||||
nav_type[0].enable()
|
||||
|
||||
|
||||
groups = self.active_page.get_actions()
|
||||
|
||||
for grp in groups:
|
||||
@ -333,6 +334,8 @@ class ViewManager:
|
||||
mergeid = self.uimanager.add_ui_from_string(ui)
|
||||
self.merge_ids.append(mergeid)
|
||||
|
||||
self.active_page.change_page()
|
||||
|
||||
def on_open_activate(self,obj):
|
||||
|
||||
choose = gtk.FileChooserDialog(_('GRAMPS: Open database'),
|
||||
|
Loading…
Reference in New Issue
Block a user