multiple bookmark lists

svn: r6452
This commit is contained in:
Don Allingham 2006-04-26 21:48:13 +00:00
parent f2fe4dc6f9
commit 0593cae180
16 changed files with 408 additions and 45 deletions

View File

@ -1,3 +1,20 @@
2006-04-26 Don Allingham <don@gramps-project.org>
* src/DataViews/_MediaView.py:
* src/DataViews/_RepositoryView.py
* src/DataViews/_SourceView.py:
* src/DataViews/_EventView.py: multiple bookmark lists
* src/DataViews/_FamilyView.py: multiple bookmark lists
* src/DataViews/_FamilyList.py: multiple bookmark lists
* src/DataViews/_PedigreeView.py: multiple bookmark lists
* src/DataViews/_PlaceView.py: multiple bookmark lists
* src/DataViews/_PersonView.py: multiple bookmark lists
* src/ViewManager.py: multiple bookmark lists
* src/GrampsDb/_GrampsDbBase.py: multiple bookmark lists
* src/GrampsDb/_GrampsBSDDB.py: multiple bookmark lists
* src/Bookmarks.py: multiple bookmark lists
* src/gramps_main.py: multiple bookmark lists
* src/PageView.py: multiple bookmark lists
2006-04-26 Martin Hawlisch <Martin.Hawlisch@gmx.de> 2006-04-26 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/DataViews/_MapView.py: First badly hacked version of online map * src/DataViews/_MapView.py: First badly hacked version of online map
downloading. downloading.

View File

@ -56,6 +56,7 @@ import gtk
import GrampsDisplay import GrampsDisplay
import NameDisplay import NameDisplay
import ListModel import ListModel
import Utils
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -84,40 +85,53 @@ class Bookmarks :
self.bookmarks = bookmarks self.bookmarks = bookmarks
self.active = DISABLED self.active = DISABLED
self.action_group = gtk.ActionGroup('Bookmarks') self.action_group = gtk.ActionGroup('Bookmarks')
def update_bookmarks(self, bookmarks):
self.bookmarks = bookmarks
def display(self):
self.redraw() self.redraw()
def undisplay(self):
if self.active != DISABLED:
self.uistate.uimanager.remove_ui(self.active)
self.uistate.uimanager.remove_action_group(self.action_group)
self.active = DISABLED
def redraw(self): def redraw(self):
"""Create the pulldown menu""" """Create the pulldown menu"""
f = StringIO() f = StringIO()
f.write(_top) f.write(_top)
count = 0 self.undisplay()
if self.active != DISABLED:
self.uistate.uimanager.remove_ui(self.active)
self.uistate.uimanager.remove_action_group(self.action_group)
self.active = DISABLED
actions = [] actions = []
count = 0
if len(self.bookmarks) > 0: if len(self.bookmarks) > 0:
f.write('<placeholder name="GoToBook">') f.write('<placeholder name="GoToBook">')
for item in self.bookmarks: for item in self.bookmarks:
person = self.dbstate.db.get_person_from_handle(item) label, obj = self.make_label(item)
name = NameDisplay.displayer.display(person) func = self.callback(item)
action_id = "BM:%s" % item action_id = "BM:%s" % item
f.write('<menuitem action="%s"/>' % action_id)
label = "%s [%s]" % (name,person.gramps_id)
func = make_callback(item,self.dbstate.change_active_handle)
actions.append((action_id,None,label,None,None,func)) actions.append((action_id,None,label,None,None,func))
f.write('<menuitem action="%s"/>' % action_id)
count +=1 count +=1
f.write('</placeholder>') f.write('</placeholder>')
f.write(_btm) f.write(_btm)
self.action_group.add_actions(actions) self.action_group.add_actions(actions)
self.uistate.uimanager.insert_action_group(self.action_group,1) self.uistate.uimanager.insert_action_group(self.action_group,1)
print f.getvalue()
self.active = self.uistate.uimanager.add_ui_from_string(f.getvalue()) self.active = self.uistate.uimanager.add_ui_from_string(f.getvalue())
f.close() f.close()
def make_label(self,handle):
person = self.dbstate.db.get_person_from_handle(handle)
name = NameDisplay.displayer.display(person)
return ("%s [%s]" % (name,person.gramps_id), person)
def callback(self, handle):
return make_callback(handle, self.dbstate.change_active_handle)
def add(self,person_handle): def add(self,person_handle):
"""appends the person to the bottom of the bookmarks""" """appends the person to the bottom of the bookmarks"""
if person_handle not in self.bookmarks: if person_handle not in self.bookmarks:
@ -189,12 +203,11 @@ class Bookmarks :
list is not empty, or -1 if it is. list is not empty, or -1 if it is.
""" """
self.draw_window() self.draw_window()
for person_handle in self.bookmarks: for handle in self.bookmarks:
person = self.dbstate.db.get_person_from_handle(person_handle) name, obj = self.make_label(handle)
if person: if obj:
name = NameDisplay.displayer.display(person) gramps_id = obj.get_gramps_id()
gramps_id = person.get_gramps_id() self.namemodel.add([name,gramps_id,handle])
self.namemodel.add([name,gramps_id,person_handle])
self.namemodel.connect_model() self.namemodel.connect_model()
self.modified = False self.modified = False
@ -246,5 +259,110 @@ class Bookmarks :
GrampsDisplay.help('gramps-nav') GrampsDisplay.help('gramps-nav')
self.response = self.top.run() self.response = self.top.run()
class FamilyBookmarks(Bookmarks) :
"Handle the bookmarks interface for Gramps"
def __init__(self,dbstate,uistate,bookmarks):
Bookmarks.__init__(self, dbstate, uistate, bookmarks)
def make_label(self,handle):
obj = self.dbstate.db.get_family_from_handle(handle)
name = Utils.family_name(obj, self.dbstate.db)
return ("%s [%s]" % (name, obj.gramps_id), obj)
def callback(self, handle):
return make_callback(handle, self.do_nothing)
def do_nothing(self, handle):
print handle
class EventBookmarks(Bookmarks) :
"Handle the bookmarks interface for Gramps"
def __init__(self,dbstate,uistate,bookmarks):
Bookmarks.__init__(self, dbstate, uistate, bookmarks)
def make_label(self,handle):
obj = self.dbstate.db.get_event_from_handle(handle)
if obj.get_description() == "":
name = str(obj.get_type())
else:
name = obj.get_description()
return ("%s [%s]" % (name, obj.gramps_id), obj)
def callback(self, handle):
return make_callback(handle, self.do_nothing)
def do_nothing(self, handle):
print handle
class SourceBookmarks(Bookmarks) :
"Handle the bookmarks interface for Gramps"
def __init__(self,dbstate,uistate,bookmarks):
Bookmarks.__init__(self, dbstate, uistate, bookmarks)
def make_label(self,handle):
obj = self.dbstate.db.get_source_from_handle(handle)
name = obj.get_title()
return ("%s [%s]" % (name, obj.gramps_id), obj)
def callback(self, handle):
return make_callback(handle, self.do_nothing)
def do_nothing(self, handle):
print handle
class MediaBookmarks(Bookmarks) :
"Handle the bookmarks interface for Gramps"
def __init__(self,dbstate,uistate,bookmarks):
Bookmarks.__init__(self, dbstate, uistate, bookmarks)
def make_label(self,handle):
obj = self.dbstate.db.get_object_from_handle(handle)
name = obj.get_description()
return ("%s [%s]" % (name, obj.gramps_id), obj)
def callback(self, handle):
return make_callback(handle, self.do_nothing)
def do_nothing(self, handle):
print handle
class RepoBookmarks(Bookmarks) :
"Handle the bookmarks interface for Gramps"
def __init__(self,dbstate,uistate,bookmarks):
Bookmarks.__init__(self, dbstate, uistate, bookmarks)
def make_label(self,handle):
obj = self.dbstate.db.get_repository_from_handle(handle)
name = obj.get_name()
return ("%s [%s]" % (name, obj.gramps_id), obj)
def callback(self, handle):
return make_callback(handle, self.do_nothing)
def do_nothing(self, handle):
print handle
class PlaceBookmarks(Bookmarks) :
"Handle the bookmarks interface for Gramps"
def __init__(self,dbstate,uistate,bookmarks):
Bookmarks.__init__(self, dbstate, uistate, bookmarks)
def make_label(self,handle):
obj = self.dbstate.db.get_place_from_handle(handle)
name = obj.get_title()
return ("%s [%s]" % (name, obj.gramps_id), obj)
def callback(self, handle):
return make_callback(handle, self.do_nothing)
def do_nothing(self, handle):
print handle
def make_callback(n,f): def make_callback(n,f):
return lambda x: f(n) return lambda x: f(n)

View File

@ -38,6 +38,7 @@ import DisplayModels
import const import const
import Utils import Utils
import Errors import Errors
import Bookmarks
from DdTargets import DdTargets from DdTargets import DdTargets
from QuestionDialog import QuestionDialog, ErrorDialog from QuestionDialog import QuestionDialog, ErrorDialog
@ -78,7 +79,11 @@ class EventView(PageView.ListView):
PageView.ListView.__init__( PageView.ListView.__init__(
self, _('Events'), dbstate, uistate, self, _('Events'), dbstate, uistate,
column_names, len(column_names), DisplayModels.EventModel, column_names, len(column_names), DisplayModels.EventModel,
signal_map) signal_map, dbstate.db.get_event_bookmarks(),
Bookmarks.EventBookmarks)
def get_bookmarks(self):
return self.dbstate.db.get_event_bookmarks()
def drag_info(self): def drag_info(self):
return DdTargets.EVENT return DdTargets.EVENT
@ -95,6 +100,12 @@ class EventView(PageView.ListView):
<menu action="ViewMenu"> <menu action="ViewMenu">
<menuitem action="Filter"/> <menuitem action="Filter"/>
</menu> </menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
<menuitem action="EditBook"/>
</placeholder>
</menu>
<menu action="EditMenu"> <menu action="EditMenu">
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<menuitem action="Add"/> <menuitem action="Add"/>

View File

@ -35,6 +35,7 @@ import gtk.gdk
import RelLib import RelLib
import PageView import PageView
import DisplayModels import DisplayModels
import Bookmarks
import const import const
import Errors import Errors
from QuestionDialog import QuestionDialog, ErrorDialog from QuestionDialog import QuestionDialog, ErrorDialog
@ -72,16 +73,32 @@ class FamilyListView(PageView.ListView):
PageView.ListView.__init__( PageView.ListView.__init__(
self, _('Family List'), dbstate, uistate, self, _('Family List'), dbstate, uistate,
column_names, len(column_names), DisplayModels.FamilyModel, column_names, len(column_names), DisplayModels.FamilyModel,
signal_map) signal_map, dbstate.db.get_family_bookmarks(),
Bookmarks.FamilyBookmarks)
self.updating = False self.updating = False
def add_bookmark(self, obj):
mlist = []
self.selection.selected_foreach(self.blist, mlist)
if mlist:
self.bookmarks.add(mlist[0])
else:
from QuestionDialog import WarningDialog
WarningDialog(
_("Could Not Set a Bookmark"),
_("A bookmark could not be set because "
"no one was selected."))
def get_bookmarks(self):
return self.dbstate.db.get_family_bookmarks()
def column_order(self): def column_order(self):
return self.dbstate.db.get_family_list_column_order() return self.dbstate.db.get_family_list_column_order()
def get_stock(self): def get_stock(self):
return 'gramps-family-list' return 'gramps-family-list'
def ui_definition(self): def ui_definition(self):
return '''<ui> return '''<ui>
<menubar name="MenuBar"> <menubar name="MenuBar">
@ -95,6 +112,12 @@ class FamilyListView(PageView.ListView):
<menu action="ViewMenu"> <menu action="ViewMenu">
<menuitem action="Filter"/> <menuitem action="Filter"/>
</menu> </menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
<menuitem action="EditBook"/>
</placeholder>
</menu>
</menubar> </menubar>
<toolbar name="ToolBar"> <toolbar name="ToolBar">
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
@ -133,7 +156,6 @@ class FamilyListView(PageView.ListView):
def family_add_loop(self,handle_list): def family_add_loop(self,handle_list):
if self.updating: if self.updating:
return False return False
print handle_list
self.updating = True self.updating = True
self.row_add(handle_list) self.row_add(handle_list)
self.updating = False self.updating = False

View File

@ -188,6 +188,12 @@ class FamilyView(PageView.PersonNavView):
<separator/> <separator/>
</placeholder> </placeholder>
</menu> </menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
<menuitem action="EditBook"/>
</placeholder>
</menu>
<menu action="ViewMenu"> <menu action="ViewMenu">
<menuitem action="Siblings"/> <menuitem action="Siblings"/>
<menuitem action="Details"/> <menuitem action="Details"/>
@ -239,6 +245,9 @@ class FamilyView(PageView.PersonNavView):
self.dbstate.db.connect('person-update', self.redraw) self.dbstate.db.connect('person-update', self.redraw)
self.dbstate.db.connect('person-add', self.redraw) self.dbstate.db.connect('person-add', self.redraw)
self.dbstate.db.connect('person-delete', self.redraw) self.dbstate.db.connect('person-delete', self.redraw)
self.bookmarks.update_bookmarks(db.get_bookmarks())
if self.active:
self.bookmarks.redraw()
def get_name(self, handle, use_gender=False): def get_name(self, handle, use_gender=False):
if handle: if handle:

View File

@ -37,6 +37,8 @@ import DisplayModels
import ImgManip import ImgManip
import const import const
import Utils import Utils
import Bookmarks
from QuestionDialog import QuestionDialog, ErrorDialog from QuestionDialog import QuestionDialog, ErrorDialog
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -73,12 +75,17 @@ class MediaView(PageView.ListView):
PageView.ListView.__init__( PageView.ListView.__init__(
self, _('Media'), dbstate, uistate, self, _('Media'), dbstate, uistate,
column_names,len(column_names), DisplayModels.MediaModel, column_names,len(column_names), DisplayModels.MediaModel,
signal_map) signal_map, dbstate.db.get_media_bookmarks(),
Bookmarks.MediaBookmarks)
def get_bookmarks(self):
return self.dbstate.db.get_media_bookmarks()
def define_actions(self): def define_actions(self):
PageView.ListView.define_actions(self) PageView.ListView.define_actions(self)
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES, self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
'_Column Editor', callback=self.column_editor) '_Column Editor', callback=self.column_editor)
def column_editor(self,obj): def column_editor(self,obj):
import ColumnOrder import ColumnOrder
@ -134,6 +141,12 @@ class MediaView(PageView.ListView):
</placeholder> </placeholder>
<menuitem action="ColumnEdit"/> <menuitem action="ColumnEdit"/>
</menu> </menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
<menuitem action="EditBook"/>
</placeholder>
</menu>
</menubar> </menubar>
<toolbar name="ToolBar"> <toolbar name="ToolBar">
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">

View File

@ -493,6 +493,12 @@ class PedigreeView(PageView.PersonNavView):
<separator/> <separator/>
</placeholder> </placeholder>
</menu> </menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
<menuitem action="EditBook"/>
</placeholder>
</menu>
</menubar> </menubar>
<toolbar name="ToolBar"> <toolbar name="ToolBar">
<placeholder name="CommonNavigation"> <placeholder name="CommonNavigation">
@ -546,6 +552,10 @@ class PedigreeView(PageView.PersonNavView):
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.bookmarks.update_bookmarks(db.get_bookmarks())
if self.active:
self.bookmarks.redraw()
self.rebuild_trees(None) self.rebuild_trees(None)
def goto_active_person(self,handle=None): def goto_active_person(self,handle=None):

View File

@ -208,6 +208,12 @@ class PersonView(PageView.PersonNavView):
<menu action="ViewMenu"> <menu action="ViewMenu">
<menuitem action="Filter"/> <menuitem action="Filter"/>
</menu> </menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
<menuitem action="EditBook"/>
</placeholder>
</menu>
<menu action="GoMenu"> <menu action="GoMenu">
<placeholder name="CommonGo"> <placeholder name="CommonGo">
<menuitem action="Back"/> <menuitem action="Back"/>
@ -266,7 +272,9 @@ class PersonView(PageView.PersonNavView):
db.connect('person-rebuild', self.build_tree) db.connect('person-rebuild', self.build_tree)
self.generic_filter_widget.apply_filter() self.generic_filter_widget.apply_filter()
self.goto_active_person() self.goto_active_person()
self.bookmarks.update_bookmarks(db.get_bookmarks())
if self.active:
self.bookmarks.redraw()
def goto_active_person(self,obj=None): def goto_active_person(self,obj=None):
""" """

View File

@ -38,6 +38,8 @@ import DisplayModels
import const import const
import Utils import Utils
import Errors import Errors
import Bookmarks
from Editors import EditPlace, DeletePlaceQuery from Editors import EditPlace, DeletePlaceQuery
from QuestionDialog import QuestionDialog, ErrorDialog from QuestionDialog import QuestionDialog, ErrorDialog
@ -79,7 +81,12 @@ class PlaceView(PageView.ListView):
PageView.ListView.__init__( PageView.ListView.__init__(
self, _('Places'), dbstate, uistate, column_names, self, _('Places'), dbstate, uistate, column_names,
len(column_names), DisplayModels.PlaceModel, signal_map) len(column_names), DisplayModels.PlaceModel, signal_map,
dbstate.db.get_place_bookmarks(),
Bookmarks.PlaceBookmarks)
def get_bookmarks(self):
return self.dbstate.db.get_place_bookmarks()
def define_actions(self): def define_actions(self):
PageView.ListView.define_actions(self) PageView.ListView.define_actions(self)
@ -112,6 +119,12 @@ class PlaceView(PageView.ListView):
<menu action="ViewMenu"> <menu action="ViewMenu">
<menuitem action="Filter"/> <menuitem action="Filter"/>
</menu> </menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
<menuitem action="EditBook"/>
</placeholder>
</menu>
<menu action="EditMenu"> <menu action="EditMenu">
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<menuitem action="Add"/> <menuitem action="Add"/>

View File

@ -37,6 +37,8 @@ import PageView
import DisplayModels import DisplayModels
import const import const
import Utils import Utils
import Bookmarks
from Editors import EditRepository, DelRepositoryQuery from Editors import EditRepository, DelRepositoryQuery
from DdTargets import DdTargets from DdTargets import DdTargets
@ -82,7 +84,12 @@ class RepositoryView(PageView.ListView):
PageView.ListView.__init__( PageView.ListView.__init__(
self, _('Repositories'), dbstate, uistate, self, _('Repositories'), dbstate, uistate,
column_names, len(column_names), column_names, len(column_names),
DisplayModels.RepositoryModel, signal_map) DisplayModels.RepositoryModel, signal_map,
dbstate.db.get_repo_bookmarks(),
Bookmarks.RepoBookmarks)
def get_bookmarks(self):
return self.dbstate.db.get_repo_bookmarks()
def drag_info(self): def drag_info(self):
return DdTargets.REPO_LINK return DdTargets.REPO_LINK
@ -118,6 +125,12 @@ class RepositoryView(PageView.ListView):
<menu action="ViewMenu"> <menu action="ViewMenu">
<menuitem action="Filter"/> <menuitem action="Filter"/>
</menu> </menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
<menuitem action="EditBook"/>
</placeholder>
</menu>
<menu action="EditMenu"> <menu action="EditMenu">
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<menuitem action="Add"/> <menuitem action="Add"/>

View File

@ -37,9 +37,10 @@ import PageView
import DisplayModels import DisplayModels
import const import const
import Utils import Utils
import Bookmarks
from DdTargets import DdTargets from DdTargets import DdTargets
from Editors import EditSource, DelSrcQuery from Editors import EditSource, DelSrcQuery
from QuestionDialog import QuestionDialog, ErrorDialog from QuestionDialog import QuestionDialog, ErrorDialog
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -75,7 +76,12 @@ class SourceView(PageView.ListView):
PageView.ListView.__init__( PageView.ListView.__init__(
self, _('Sources'), dbstate, uistate, column_names, self, _('Sources'), dbstate, uistate, column_names,
len(column_names), DisplayModels.SourceModel, signal_map) len(column_names), DisplayModels.SourceModel, signal_map,
dbstate.db.get_source_bookmarks(),
Bookmarks.SourceBookmarks)
def get_bookmarks(self):
return self.dbstate.db.get_source_bookmarks()
def drag_info(self): def drag_info(self):
return DdTargets.SOURCE_LINK return DdTargets.SOURCE_LINK
@ -111,6 +117,12 @@ class SourceView(PageView.ListView):
<menu action="ViewMenu"> <menu action="ViewMenu">
<menuitem action="Filter"/> <menuitem action="Filter"/>
</menu> </menu>
<menu action="BookMenu">
<placeholder name="AddEditBook">
<menuitem action="AddBook"/>
<menuitem action="EditBook"/>
</placeholder>
</menu>
<menu action="EditMenu"> <menu action="EditMenu">
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<menuitem action="Add"/> <menuitem action="Add"/>

View File

@ -337,7 +337,13 @@ class GrampsBSDDB(GrampsDbBase):
dbtype=db.DB_BTREE) dbtype=db.DB_BTREE)
callback(37) callback(37)
self.bookmarks = self.metadata.get('bookmarks') self.bookmarks = self.metadata.get('bookmarks',[])
self.family_bookmarks = self.metadata.get('family_bookmarks',[])
self.event_bookmarks = self.metadata.get('event_bookmarks',[])
self.source_bookmarks = self.metadata.get('source_bookmarks',[])
self.repo_bookmarks = self.metadata.get('repo_bookmarks',[])
self.media_bookmarks = self.metadata.get('media_bookmarks',[])
self.place_bookmarks = self.metadata.get('place_bookmarks',[])
self.family_event_names = set(self.metadata.get('fevent_names',[])) self.family_event_names = set(self.metadata.get('fevent_names',[]))
self.individual_event_names = set(self.metadata.get('pevent_names',[])) self.individual_event_names = set(self.metadata.get('pevent_names',[]))
self.family_attributes = set(self.metadata.get('fattr_names',[])) self.family_attributes = set(self.metadata.get('fattr_names',[]))
@ -351,9 +357,6 @@ class GrampsBSDDB(GrampsDbBase):
elif not self.metadata.has_key('version'): elif not self.metadata.has_key('version'):
self.metadata['version'] = 0 self.metadata['version'] = 0
if self.bookmarks == None:
self.bookmarks = []
self.genderStats = GenderStats(gstats) self.genderStats = GenderStats(gstats)
# Here we take care of any changes in the tables related to new code. # Here we take care of any changes in the tables related to new code.
@ -802,6 +805,12 @@ class GrampsBSDDB(GrampsDbBase):
return return
if not self.readonly: if not self.readonly:
self.metadata['bookmarks'] = self.bookmarks self.metadata['bookmarks'] = self.bookmarks
self.metadata['family_bookmarks'] = self.family_bookmarks
self.metadata['event_bookmarks'] = self.event_bookmarks
self.metadata['source_bookmarks'] = self.source_bookmarks
self.metadata['place_bookmarks'] = self.place_bookmarks
self.metadata['repo_bookmarks'] = self.repo_bookmarks
self.metadata['media_bookmarks'] = self.media_bookmarks
self.metadata['gender_stats'] = self.genderStats.save_stats() self.metadata['gender_stats'] = self.genderStats.save_stats()
self.metadata['fevent_names'] = list(self.family_event_names) self.metadata['fevent_names'] = list(self.family_event_names)
self.metadata['pevent_names'] = list(self.individual_event_names) self.metadata['pevent_names'] = list(self.individual_event_names)

View File

@ -262,6 +262,12 @@ class GrampsDbBase(GrampsDBCallback):
self.default = None self.default = None
self.owner = Researcher() self.owner = Researcher()
self.bookmarks = [] self.bookmarks = []
self.family_bookmarks = []
self.event_bookmarks = []
self.place_bookmarks = []
self.source_bookmarks = []
self.repo_bookmarks = []
self.media_bookmarks = []
self.path = "" self.path = ""
self.place2title = {} self.place2title = {}
self.name_group = {} self.name_group = {}
@ -1430,6 +1436,30 @@ class GrampsDbBase(GrampsDBCallback):
"""returns the list of Person handles in the bookmarks""" """returns the list of Person handles in the bookmarks"""
return self.bookmarks return self.bookmarks
def get_family_bookmarks(self):
"""returns the list of Person handles in the bookmarks"""
return self.family_bookmarks
def get_event_bookmarks(self):
"""returns the list of Person handles in the bookmarks"""
return self.event_bookmarks
def get_place_bookmarks(self):
"""returns the list of Person handles in the bookmarks"""
return self.place_bookmarks
def get_source_bookmarks(self):
"""returns the list of Person handles in the bookmarks"""
return self.source_bookmarks
def get_media_bookmarks(self):
"""returns the list of Person handles in the bookmarks"""
return self.media_bookmarks
def get_repo_bookmarks(self):
"""returns the list of Person handles in the bookmarks"""
return self.repo_bookmarks
def set_researcher(self, owner): def set_researcher(self, owner):
"""sets the information about the owner of the database""" """sets the information about the owner of the database"""
self.owner.set(owner.get_name(), owner.get_address(), self.owner.set(owner.get_name(), owner.get_address(),

View File

@ -43,6 +43,7 @@ from gtk.gdk import ACTION_COPY, BUTTON1_MASK
# #
#---------------------------------------------------------------- #----------------------------------------------------------------
import TreeTips import TreeTips
import Bookmarks
import GenericFilter import GenericFilter
import const import const
@ -185,15 +186,72 @@ class PageView:
else: else:
return None return None
class BookMarkView(PageView):
def __init__(self, title, state, uistate, bookmarks, bm_type):
PageView.__init__(self, title, state, uistate)
self.bm_type = bm_type
self.setup_bookmarks(bookmarks)
def setup_bookmarks(self, bookmarks):
self.bookmarks = self.bm_type(
self.dbstate, self.uistate, bookmarks)
def add_bookmark(self, obj):
import NameDisplay
if self.dbstate.active:
self.bookmarks.add(self.dbstate.active.get_handle())
name = NameDisplay.displayer.display(self.dbstate.active)
self.uistate.push_message(_("%s has been bookmarked") % name)
else:
from QuestionDialog import WarningDialog
WarningDialog(
_("Could Not Set a Bookmark"),
_("A bookmark could not be set because "
"no one was selected."))
def set_active(self):
PageView.set_active(self)
self.bookmarks.display()
def set_inactive(self):
PageView.set_inactive(self)
self.bookmarks.undisplay()
def edit_bookmarks(self, obj):
self.bookmarks.edit()
def enable_action_group(self, obj):
PageView.enable_action_group(self, obj)
def disable_action_group(self, obj):
PageView.disable_action_group(self)
def define_actions(self):
self.book_action = gtk.ActionGroup(self.title + '/Bookmark')
self.book_action.add_actions([
('AddBook', gtk.STOCK_INDEX, '_Add bookmark', '<control>d', None,
self.add_bookmark),
('EditBook', None, '_Edit bookmarks', '<control>b', None,
self.edit_bookmarks),
])
self.add_action_group(self.book_action)
#---------------------------------------------------------------- #----------------------------------------------------------------
# #
# PersonNavView # PersonNavView
# #
#---------------------------------------------------------------- #----------------------------------------------------------------
class PersonNavView(PageView): class PersonNavView(BookMarkView):
def __init__(self,title,dbstate,uistate): def __init__(self,title,dbstate,uistate):
PageView.__init__(self,title,dbstate,uistate) BookMarkView.__init__(self, title, dbstate, uistate,
dbstate.db.get_bookmarks(),
Bookmarks.Bookmarks)
def navigation_type(self): def navigation_type(self):
return NAVIGATION_PERSON return NAVIGATION_PERSON
@ -201,6 +259,8 @@ class PersonNavView(PageView):
def define_actions(self): def define_actions(self):
# add the Forward action group to handle the Forward button # add the Forward action group to handle the Forward button
BookMarkView.define_actions(self)
self.fwd_action = gtk.ActionGroup(self.title + '/Forward') self.fwd_action = gtk.ActionGroup(self.title + '/Forward')
self.fwd_action.add_actions([ self.fwd_action.add_actions([
('Forward',gtk.STOCK_GO_FORWARD,"_Forward", None, None, self.fwd_clicked) ('Forward',gtk.STOCK_GO_FORWARD,"_Forward", None, None, self.fwd_clicked)
@ -226,7 +286,7 @@ class PersonNavView(PageView):
in this case, we have additional action groups that need to be in this case, we have additional action groups that need to be
handled correctly. handled correctly.
""" """
PageView.disable_action_group(self) BookMarkView.disable_action_group(self)
self.fwd_action.set_visible(False) self.fwd_action.set_visible(False)
self.back_action.set_visible(False) self.back_action.set_visible(False)
@ -237,7 +297,7 @@ class PersonNavView(PageView):
in this case, we have additional action groups that need to be in this case, we have additional action groups that need to be
handled correctly. handled correctly.
""" """
PageView.enable_action_group(self,obj) BookMarkView.enable_action_group(self,obj)
self.fwd_action.set_visible(True) self.fwd_action.set_visible(True)
self.back_action.set_visible(True) self.back_action.set_visible(True)
@ -347,11 +407,14 @@ class PersonNavView(PageView):
# ListView # ListView
# #
#---------------------------------------------------------------- #----------------------------------------------------------------
class ListView(PageView): class ListView(BookMarkView):
def __init__(self, title, dbstate, uistate, columns, handle_col, def __init__(self, title, dbstate, uistate, columns, handle_col,
make_model, signal_map): make_model, signal_map, get_bookmarks, bm_type):
PageView.__init__(self, title, dbstate, uistate)
BookMarkView.__init__(self, title, dbstate, uistate,
get_bookmarks, bm_type)
self.renderer = gtk.CellRendererText() self.renderer = gtk.CellRendererText()
self.renderer.set_property('ellipsize',pango.ELLIPSIZE_END) self.renderer.set_property('ellipsize',pango.ELLIPSIZE_END)
self.sort_col = 0 self.sort_col = 0
@ -362,6 +425,19 @@ class ListView(PageView):
self.signal_map = signal_map self.signal_map = signal_map
dbstate.connect('database-changed',self.change_db) dbstate.connect('database-changed',self.change_db)
def add_bookmark(self, obj):
mlist = []
self.selection.selected_foreach(self.blist, mlist)
if mlist:
self.bookmarks.add(mlist[0])
else:
from QuestionDialog import WarningDialog
WarningDialog(
_("Could Not Set a Bookmark"),
_("A bookmark could not be set because "
"nothing was selected."))
def drag_info(self): def drag_info(self):
return None return None
@ -510,8 +586,10 @@ class ListView(PageView):
self.model = self.make_model(self.dbstate.db,0) self.model = self.make_model(self.dbstate.db,0)
self.list.set_model(self.model) self.list.set_model(self.model)
self.build_columns() self.build_columns()
self.bookmarks.update_bookmarks(self.get_bookmarks())
if self.active: if self.active:
self.build_tree() self.build_tree()
self.bookmarks.redraw()
else: else:
self.dirty = True self.dirty = True
@ -537,6 +615,8 @@ class ListView(PageView):
since we want to have more than one action group for the PersonView. since we want to have more than one action group for the PersonView.
Most PageViews really won't care about this. Most PageViews really won't care about this.
""" """
BookMarkView.define_actions(self)
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)
@ -570,3 +650,4 @@ class ListView(PageView):
self.generic_filter_widget.show() self.generic_filter_widget.show()
else: else:
self.generic_filter_widget.hide() self.generic_filter_widget.hide()

View File

@ -126,8 +126,7 @@ uidefault = '''<ui>
<placeholder name="CommonHistory"/> <placeholder name="CommonHistory"/>
</menu> </menu>
<menu action="BookMenu"> <menu action="BookMenu">
<menuitem action="AddBook"/> <placeholder name="AddEditBook"/>
<menuitem action="EditBook"/>
<separator/> <separator/>
<placeholder name="GoToBook"/> <placeholder name="GoToBook"/>
</menu> </menu>
@ -324,10 +323,6 @@ class ViewManager:
('ColumnEdit', gtk.STOCK_PROPERTIES, '_Column Editor'), ('ColumnEdit', gtk.STOCK_PROPERTIES, '_Column Editor'),
('GoMenu', None, '_Go'), ('GoMenu', None, '_Go'),
('BookMenu', None, '_Bookmarks'), ('BookMenu', None, '_Bookmarks'),
('AddBook', gtk.STOCK_INDEX, '_Add bookmark', '<control>d', None,
self.add_bookmark),
('EditBook', None, '_Edit bookmarks', '<control>b', None,
self.edit_bookmarks),
('ReportsMenu', None, '_Reports'), ('ReportsMenu', None, '_Reports'),
('ToolsMenu', None, '_Tools'), ('ToolsMenu', None, '_Tools'),
('WindowsMenu', None, '_Windows'), ('WindowsMenu', None, '_Windows'),

View File

@ -156,6 +156,8 @@ class Gramps:
state = GrampsDb.DbState() state = GrampsDb.DbState()
self.vm = ViewManager.ViewManager(state) self.vm = ViewManager.ViewManager(state)
# self.vm.register_view(DataViews._PersonView.PersonView)
# self.vm.register_view(DataViews._FamilyList.FamilyListView)
for view in DataViews.get_views(): for view in DataViews.get_views():
self.vm.register_view(view) self.vm.register_view(view)