* 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 2e667e8223
commit 53c3da4a2d
2 changed files with 78 additions and 26 deletions

View File

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

View File

@ -129,6 +129,9 @@ class Gramps:
# This will never contain data - It will be replaced by either # This will never contain data - It will be replaced by either
# a GrampsXML or GrampsZODB # a GrampsXML or GrampsZODB
self.history = []
self.hindex = -1
self.db = RelLib.GrampsDB() self.db = RelLib.GrampsDB()
self.db.set_iprefix(GrampsCfg.iprefix) self.db.set_iprefix(GrampsCfg.iprefix)
self.db.set_oprefix(GrampsCfg.oprefix) self.db.set_oprefix(GrampsCfg.oprefix)
@ -373,6 +376,8 @@ class Gramps:
self.editbtn = self.gtop.get_widget('editbtn') self.editbtn = self.gtop.get_widget('editbtn')
self.gtop.signal_autoconnect({ self.gtop.signal_autoconnect({
"on_back_clicked" : self.back_clicked,
"on_fwd_clicked" : self.fwd_clicked,
"on_editbtn_clicked" : self.edit_button_clicked, "on_editbtn_clicked" : self.edit_button_clicked,
"on_addbtn_clicked" : self.add_button_clicked, "on_addbtn_clicked" : self.add_button_clicked,
"on_removebtn_clicked" : self.remove_button_clicked, "on_removebtn_clicked" : self.remove_button_clicked,
@ -445,6 +450,35 @@ class Gramps:
self.topWindow.show() 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): def change_alpha_page(self,obj,junk,page):
"""Change the page. Be careful not to take action while the pages """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""" 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.familyAttributes = const.init_family_attribute_list()
const.familyRelations = const.init_family_relation_list() const.familyRelations = const.init_family_relation_list()
self.history = []
self.hindex = -1
self.clear_person_tabs() self.clear_person_tabs()
if zodb == 1: if zodb == 1:
@ -1428,16 +1465,15 @@ class Gramps:
self.active_person = person self.active_person = person
self.modify_statusbar() self.modify_statusbar()
if person: if person:
val = 1 if self.hindex+1 < len(self.history):
else: self.history = self.history[0:self.hindex+1]
val = 0 self.history.append(person.getId())
self.hindex += 1
self.report_menu.set_sensitive(val) if person:
self.tools_menu.set_sensitive(val) self.set_buttons(1)
self.report_button.set_sensitive(val) else:
self.tool_button.set_sensitive(val) self.set_buttons(0)
self.remove_button.set_sensitive(val)
self.edit_button.set_sensitive(val)
def modify_statusbar(self): def modify_statusbar(self):
@ -1800,8 +1836,7 @@ class Gramps:
self.statusbar.set_progress_percentage(1.0) self.statusbar.set_progress_percentage(1.0)
person = self.db.getDefaultPerson() person = self.db.getDefaultPerson()
if person: self.change_active_person(person)
self.active_person = person
self.full_update() self.full_update()
self.statusbar.set_progress_percentage(0.0) self.statusbar.set_progress_percentage(0.0)