* src/Bookmark.py: start of reimplementation

* src/PersonView.py: commit fixes


svn: r5615
This commit is contained in:
Don Allingham 2005-12-22 06:13:11 +00:00
parent c14e5e5dc6
commit 18e3e8c5cf
6 changed files with 46 additions and 29 deletions

View File

@ -1,6 +1,8 @@
2005-12-21 Don Allingham <don@gramps-project.org>
* src/DisplayState.py: remove print statements
* src/ViewManger.py: Fix const.app_*
* src/Bookmark.py: start of reimplementation
* src/PersonView.py: commit fixes
* src/GrampsDb/_GrampsBSDDB.py: refactor remove and id function
2005-12-21 Alex Roitman <shura@gramps-project.org>

View File

@ -56,7 +56,7 @@ import ListModel
class Bookmarks :
"Handle the bookmarks interface for Gramps"
def __init__(self,db,bookmarks,menu,callback):
def __init__(self,db,bookmarks):
"""
Creates a the bookmark editor.
@ -65,22 +65,12 @@ class Bookmarks :
callback - task to connect to the menu item as a callback
"""
self.db = db
self.menu = menu
self.bookmarks = bookmarks
self.callback = callback
self.redraw()
def redraw(self):
"""Create the pulldown menu"""
if len(self.bookmarks) > 0:
self.myMenu = gtk.Menu()
for person_handle in self.bookmarks:
self.add_to_menu(person_handle)
self.menu.set_submenu(self.myMenu)
self.menu.set_sensitive(1)
else:
self.menu.remove_submenu()
self.menu.set_sensitive(0)
pass
def add(self,person_handle):
"""appends the person to the bottom of the bookmarks"""
@ -103,16 +93,6 @@ class Bookmarks :
if modified:
self.redraw()
def add_to_menu(self,person_handle):
"""adds a person's name to the drop down menu"""
person = self.db.get_person_from_handle(person_handle)
if person:
name = NameDisplay.displayer.display(person)
item = gtk.MenuItem(name)
item.connect("activate", self.callback, person_handle)
item.show()
self.myMenu.append(item)
def draw_window(self):
"""Draws the bookmark dialog box"""
title = "%s - GRAMPS" % _("Edit Bookmarks")

View File

@ -717,7 +717,7 @@ class GrampsBSDDB(GrampsDbBase):
self.emit('person-rebuild')
def get_surname_list(self):
vals = [ unicode(val) for val in set(self.surname.keys()) ]
vals = [ unicode(val) for val in set(self.surnames.keys()) ]
vals.sort(locale.strcoll)
return vals

View File

@ -306,7 +306,7 @@ class GrampsDbBase(GrampsDBCallback):
Closes the specified database. The method needs to be overridden
in the derived class.
"""
assert False, "Needs to be overridden in the derived class"
pass
def abort_changes(self):
pass

View File

@ -500,22 +500,22 @@ class PersonView(PageView.PersonNavView):
for child_handle in family.get_child_handle_list():
child = self.dbstate.db.get_person_from_handle(child_handle)
child.remove_parent_family_handle(family_handle)
self.db.commit_person(child,trans)
self.dbstate.db.commit_person(child,trans)
self.dbstate.db.remove_family(family_handle,trans)
else:
self.dbstate.db.commit_family(family,trans)
for (family_handle,mrel,frel) in self.active_person.get_parent_family_handle_list():
if family_handle:
family = self.db.get_family_from_handle(family_handle)
family = self.dbstate.db.get_family_from_handle(family_handle)
family.remove_child_handle(self.active_person.get_handle())
self.db.commit_family(family,trans)
self.dbstate.db.commit_family(family,trans)
handle = self.active_person.get_handle()
person = self.active_person
self.remove_from_person_list(person)
self.people_view.remove_from_history(handle)
#self.remove_from_history(handle)
self.dbstate.db.remove_person(handle, trans)
if self.uistate.phistory.index >= 0:

View File

@ -60,6 +60,7 @@ import QuestionDialog
import PageView
import Navigation
import TipOfDay
import Bookmarks
#-------------------------------------------------------------------------
#
@ -689,7 +690,7 @@ class ViewManager:
if res.get_name() == "" and owner.get_name():
self.state.db.set_researcher(owner)
#self.setup_bookmarks()
self.setup_bookmarks()
#self.state.db.set_undo_callback(self.undo_callback)
#self.state.db.set_redo_callback(self.redo_callback)
@ -707,6 +708,40 @@ class ViewManager:
self.actiongroup.set_visible(True)
return True
def setup_bookmarks(self):
self.bookmarks = Bookmarks.Bookmarks(self.state.db,self.state.db.get_bookmarks())
def on_add_bookmark_activate(self,obj):
return
if self.active_person:
self.bookmarks.add(self.active_person.get_handle())
name = NameDisplay.displayer.display(self.active_person)
self.status_text(_("%s has been bookmarked") % name)
gtk.timeout_add(5000,self.modify_statusbar)
else:
WarningDialog(_("Could Not Set a Bookmark"),
_("A bookmark could not be set because "
"no one was selected."))
def on_edit_bookmarks_activate(self,obj):
self.bookmarks.edit()
def bookmark_callback(self,obj,person_handle):
old_person = self.active_person
person = self.state.db.get_person_from_handle(person_handle)
try:
self.change_active_person(person)
self.update_display(0)
self.goto_active_person()
except TypeError:
WarningDialog(_("Could not go to a Person"),
_("Either stale bookmark or broken history "
"caused by IDs reorder."))
self.clear_history()
self.change_active_person(old_person)
self.update_display(0)
self.goto_active_person()
def find_initial_person(self):
person = self.state.db.get_default_person()
if not person: