* src/gramps_main.py: implement a basic history mechanism

* src/gramps.glade: add back and forward buttons


svn: r2000
This commit is contained in:
Don Allingham 2003-08-14 03:51:19 +00:00
parent 5df51f0b64
commit 206c3a29c2
2 changed files with 78 additions and 26 deletions

View File

@ -633,9 +633,8 @@
<widget class="button" id="button2">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Open file</property>
<property name="label" translatable="yes">Open</property>
<property name="use_underline">True</property>
<property name="stock_pixmap">gtk-open</property>
<property name="label">gtk-open</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_open_activate"/>
</widget>
</child>
@ -644,20 +643,40 @@
<widget class="button" id="button3">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Save file</property>
<property name="label" translatable="yes">Save</property>
<property name="use_underline">True</property>
<property name="stock_pixmap">gtk-save</property>
<property name="label">gtk-save</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_save_activate"/>
</widget>
</child>
<child>
<widget class="button" id="back_btn">
<property name="visible">True</property>
<property name="label">gtk-go-back</property>
<property name="use_stock">True</property>
<property name="new_group">True</property>
<signal name="clicked" handler="on_back_clicked" last_modification_time="Thu, 14 Aug 2003 02:19:55 GMT"/>
</widget>
<packing>
<property name="new_group">True</property>
</packing>
</child>
<child>
<widget class="button" id="fwd_btn">
<property name="visible">True</property>
<property name="label">gtk-go-forward</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_fwd_clicked" last_modification_time="Thu, 14 Aug 2003 02:20:17 GMT"/>
</widget>
</child>
<child>
<widget class="button" id="button97">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Make the Home Person the active person</property>
<property name="label" translatable="yes">Home</property>
<property name="use_underline">True</property>
<property name="stock_pixmap">gtk-home</property>
<property name="label">gtk-home</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_home_clicked"/>
</widget>
</child>
@ -692,9 +711,8 @@
<widget class="button" id="addbtn">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Add a new item</property>
<property name="label" translatable="yes">Add</property>
<property name="use_underline">True</property>
<property name="stock_pixmap">gtk-add</property>
<property name="label">gtk-add</property>
<property name="use_stock">True</property>
<property name="new_group">True</property>
<signal name="clicked" handler="on_addbtn_clicked" last_modification_time="Sun, 22 Sep 2002 04:17:19 GMT"/>
</widget>
@ -707,9 +725,8 @@
<widget class="button" id="removebtn">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Remove the currently selected item</property>
<property name="label" translatable="yes">Remove</property>
<property name="use_underline">True</property>
<property name="stock_pixmap">gtk-remove</property>
<property name="label">gtk-remove</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_removebtn_clicked" last_modification_time="Sun, 22 Sep 2002 04:17:33 GMT"/>
</widget>
</child>

View File

@ -128,6 +128,9 @@ class Gramps:
# This will never contain data - It will be replaced by either
# a GrampsXML or GrampsZODB
self.history = []
self.hindex = -1
self.db = RelLib.GrampsDB()
self.db.set_iprefix(GrampsCfg.iprefix)
@ -373,6 +376,8 @@ class Gramps:
self.editbtn = self.gtop.get_widget('editbtn')
self.gtop.signal_autoconnect({
"on_back_clicked" : self.back_clicked,
"on_fwd_clicked" : self.fwd_clicked,
"on_editbtn_clicked" : self.edit_button_clicked,
"on_addbtn_clicked" : self.add_button_clicked,
"on_removebtn_clicked" : self.remove_button_clicked,
@ -444,7 +449,36 @@ class Gramps:
self.views.set_current_page(1)
self.topWindow.show()
def set_buttons(self,val):
self.report_menu.set_sensitive(val)
self.tools_menu.set_sensitive(val)
self.report_button.set_sensitive(val)
self.tool_button.set_sensitive(val)
self.remove_button.set_sensitive(val)
self.edit_button.set_sensitive(val)
def back_clicked(self,obj):
if self.hindex > 0:
try:
self.hindex -= 1
self.active_person = self.db.getPerson(self.history[self.hindex])
self.modify_statusbar()
self.goto_active_person()
except:
self.set_buttons(0)
def fwd_clicked(self,obj):
if self.hindex+1 < len(self.history):
try:
self.hindex += 1
self.active_person = self.db.getPerson(self.history[self.hindex])
self.modify_statusbar()
self.goto_active_person()
self.set_buttons(1)
except:
self.set_buttons(0)
def change_alpha_page(self,obj,junk,page):
"""Change the page. Be careful not to take action while the pages
are begin removed. If clearing_tabs is set, then we don't do anything"""
@ -787,6 +821,9 @@ class Gramps:
const.familyAttributes = const.init_family_attribute_list()
const.familyRelations = const.init_family_relation_list()
self.history = []
self.hindex = -1
self.clear_person_tabs()
if zodb == 1:
@ -1427,18 +1464,17 @@ class Gramps:
if person != self.active_person:
self.active_person = person
self.modify_statusbar()
if person:
if self.hindex+1 < len(self.history):
self.history = self.history[0:self.hindex+1]
self.history.append(person.getId())
self.hindex += 1
if person:
val = 1
self.set_buttons(1)
else:
val = 0
self.set_buttons(0)
self.report_menu.set_sensitive(val)
self.tools_menu.set_sensitive(val)
self.report_button.set_sensitive(val)
self.tool_button.set_sensitive(val)
self.remove_button.set_sensitive(val)
self.edit_button.set_sensitive(val)
def modify_statusbar(self):
if self.active_person == None:
@ -1800,8 +1836,7 @@ class Gramps:
self.statusbar.set_progress_percentage(1.0)
person = self.db.getDefaultPerson()
if person:
self.active_person = person
self.change_active_person(person)
self.full_update()
self.statusbar.set_progress_percentage(0.0)