multiple bookmark lists
svn: r6452
This commit is contained in:
parent
f2fe4dc6f9
commit
0593cae180
17
ChangeLog
17
ChangeLog
@ -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>
|
||||
* src/DataViews/_MapView.py: First badly hacked version of online map
|
||||
downloading.
|
||||
|
154
src/Bookmarks.py
154
src/Bookmarks.py
@ -56,6 +56,7 @@ import gtk
|
||||
import GrampsDisplay
|
||||
import NameDisplay
|
||||
import ListModel
|
||||
import Utils
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -84,40 +85,53 @@ class Bookmarks :
|
||||
self.bookmarks = bookmarks
|
||||
self.active = DISABLED
|
||||
self.action_group = gtk.ActionGroup('Bookmarks')
|
||||
|
||||
def update_bookmarks(self, bookmarks):
|
||||
self.bookmarks = bookmarks
|
||||
|
||||
def display(self):
|
||||
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):
|
||||
"""Create the pulldown menu"""
|
||||
f = StringIO()
|
||||
f.write(_top)
|
||||
|
||||
count = 0
|
||||
if self.active != DISABLED:
|
||||
self.uistate.uimanager.remove_ui(self.active)
|
||||
self.uistate.uimanager.remove_action_group(self.action_group)
|
||||
self.active = DISABLED
|
||||
|
||||
self.undisplay()
|
||||
|
||||
actions = []
|
||||
count = 0
|
||||
|
||||
if len(self.bookmarks) > 0:
|
||||
f.write('<placeholder name="GoToBook">')
|
||||
for item in self.bookmarks:
|
||||
person = self.dbstate.db.get_person_from_handle(item)
|
||||
name = NameDisplay.displayer.display(person)
|
||||
label, obj = self.make_label(item)
|
||||
func = self.callback(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))
|
||||
f.write('<menuitem action="%s"/>' % action_id)
|
||||
count +=1
|
||||
f.write('</placeholder>')
|
||||
f.write(_btm)
|
||||
self.action_group.add_actions(actions)
|
||||
self.uistate.uimanager.insert_action_group(self.action_group,1)
|
||||
print f.getvalue()
|
||||
self.active = self.uistate.uimanager.add_ui_from_string(f.getvalue())
|
||||
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):
|
||||
"""appends the person to the bottom of the bookmarks"""
|
||||
if person_handle not in self.bookmarks:
|
||||
@ -189,12 +203,11 @@ class Bookmarks :
|
||||
list is not empty, or -1 if it is.
|
||||
"""
|
||||
self.draw_window()
|
||||
for person_handle in self.bookmarks:
|
||||
person = self.dbstate.db.get_person_from_handle(person_handle)
|
||||
if person:
|
||||
name = NameDisplay.displayer.display(person)
|
||||
gramps_id = person.get_gramps_id()
|
||||
self.namemodel.add([name,gramps_id,person_handle])
|
||||
for handle in self.bookmarks:
|
||||
name, obj = self.make_label(handle)
|
||||
if obj:
|
||||
gramps_id = obj.get_gramps_id()
|
||||
self.namemodel.add([name,gramps_id,handle])
|
||||
self.namemodel.connect_model()
|
||||
|
||||
self.modified = False
|
||||
@ -246,5 +259,110 @@ class Bookmarks :
|
||||
GrampsDisplay.help('gramps-nav')
|
||||
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):
|
||||
return lambda x: f(n)
|
||||
|
@ -38,6 +38,7 @@ import DisplayModels
|
||||
import const
|
||||
import Utils
|
||||
import Errors
|
||||
import Bookmarks
|
||||
|
||||
from DdTargets import DdTargets
|
||||
from QuestionDialog import QuestionDialog, ErrorDialog
|
||||
@ -78,7 +79,11 @@ class EventView(PageView.ListView):
|
||||
PageView.ListView.__init__(
|
||||
self, _('Events'), dbstate, uistate,
|
||||
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):
|
||||
return DdTargets.EVENT
|
||||
@ -95,6 +100,12 @@ class EventView(PageView.ListView):
|
||||
<menu action="ViewMenu">
|
||||
<menuitem action="Filter"/>
|
||||
</menu>
|
||||
<menu action="BookMenu">
|
||||
<placeholder name="AddEditBook">
|
||||
<menuitem action="AddBook"/>
|
||||
<menuitem action="EditBook"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
<menu action="EditMenu">
|
||||
<placeholder name="CommonEdit">
|
||||
<menuitem action="Add"/>
|
||||
|
@ -35,6 +35,7 @@ import gtk.gdk
|
||||
import RelLib
|
||||
import PageView
|
||||
import DisplayModels
|
||||
import Bookmarks
|
||||
import const
|
||||
import Errors
|
||||
from QuestionDialog import QuestionDialog, ErrorDialog
|
||||
@ -72,16 +73,32 @@ class FamilyListView(PageView.ListView):
|
||||
PageView.ListView.__init__(
|
||||
self, _('Family List'), dbstate, uistate,
|
||||
column_names, len(column_names), DisplayModels.FamilyModel,
|
||||
signal_map)
|
||||
signal_map, dbstate.db.get_family_bookmarks(),
|
||||
Bookmarks.FamilyBookmarks)
|
||||
|
||||
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):
|
||||
return self.dbstate.db.get_family_list_column_order()
|
||||
|
||||
def get_stock(self):
|
||||
return 'gramps-family-list'
|
||||
|
||||
def ui_definition(self):
|
||||
return '''<ui>
|
||||
<menubar name="MenuBar">
|
||||
@ -95,6 +112,12 @@ class FamilyListView(PageView.ListView):
|
||||
<menu action="ViewMenu">
|
||||
<menuitem action="Filter"/>
|
||||
</menu>
|
||||
<menu action="BookMenu">
|
||||
<placeholder name="AddEditBook">
|
||||
<menuitem action="AddBook"/>
|
||||
<menuitem action="EditBook"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
</menubar>
|
||||
<toolbar name="ToolBar">
|
||||
<placeholder name="CommonEdit">
|
||||
@ -133,7 +156,6 @@ class FamilyListView(PageView.ListView):
|
||||
def family_add_loop(self,handle_list):
|
||||
if self.updating:
|
||||
return False
|
||||
print handle_list
|
||||
self.updating = True
|
||||
self.row_add(handle_list)
|
||||
self.updating = False
|
||||
|
@ -188,6 +188,12 @@ class FamilyView(PageView.PersonNavView):
|
||||
<separator/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
<menu action="BookMenu">
|
||||
<placeholder name="AddEditBook">
|
||||
<menuitem action="AddBook"/>
|
||||
<menuitem action="EditBook"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
<menu action="ViewMenu">
|
||||
<menuitem action="Siblings"/>
|
||||
<menuitem action="Details"/>
|
||||
@ -239,6 +245,9 @@ class FamilyView(PageView.PersonNavView):
|
||||
self.dbstate.db.connect('person-update', self.redraw)
|
||||
self.dbstate.db.connect('person-add', 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):
|
||||
if handle:
|
||||
|
@ -37,6 +37,8 @@ import DisplayModels
|
||||
import ImgManip
|
||||
import const
|
||||
import Utils
|
||||
import Bookmarks
|
||||
|
||||
from QuestionDialog import QuestionDialog, ErrorDialog
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -73,12 +75,17 @@ class MediaView(PageView.ListView):
|
||||
PageView.ListView.__init__(
|
||||
self, _('Media'), dbstate, uistate,
|
||||
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):
|
||||
PageView.ListView.define_actions(self)
|
||||
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
|
||||
'_Column Editor', callback=self.column_editor)
|
||||
|
||||
|
||||
def column_editor(self,obj):
|
||||
import ColumnOrder
|
||||
@ -134,6 +141,12 @@ class MediaView(PageView.ListView):
|
||||
</placeholder>
|
||||
<menuitem action="ColumnEdit"/>
|
||||
</menu>
|
||||
<menu action="BookMenu">
|
||||
<placeholder name="AddEditBook">
|
||||
<menuitem action="AddBook"/>
|
||||
<menuitem action="EditBook"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
</menubar>
|
||||
<toolbar name="ToolBar">
|
||||
<placeholder name="CommonEdit">
|
||||
|
@ -493,6 +493,12 @@ class PedigreeView(PageView.PersonNavView):
|
||||
<separator/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
<menu action="BookMenu">
|
||||
<placeholder name="AddEditBook">
|
||||
<menuitem action="AddBook"/>
|
||||
<menuitem action="EditBook"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
</menubar>
|
||||
<toolbar name="ToolBar">
|
||||
<placeholder name="CommonNavigation">
|
||||
@ -546,6 +552,10 @@ class PedigreeView(PageView.PersonNavView):
|
||||
db.connect('person-update', self.person_updated_cb)
|
||||
db.connect('person-delete', self.person_updated_cb)
|
||||
db.connect('person-rebuild', self.person_rebuild)
|
||||
self.bookmarks.update_bookmarks(db.get_bookmarks())
|
||||
if self.active:
|
||||
self.bookmarks.redraw()
|
||||
|
||||
self.rebuild_trees(None)
|
||||
|
||||
def goto_active_person(self,handle=None):
|
||||
|
@ -208,6 +208,12 @@ class PersonView(PageView.PersonNavView):
|
||||
<menu action="ViewMenu">
|
||||
<menuitem action="Filter"/>
|
||||
</menu>
|
||||
<menu action="BookMenu">
|
||||
<placeholder name="AddEditBook">
|
||||
<menuitem action="AddBook"/>
|
||||
<menuitem action="EditBook"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
<menu action="GoMenu">
|
||||
<placeholder name="CommonGo">
|
||||
<menuitem action="Back"/>
|
||||
@ -266,7 +272,9 @@ class PersonView(PageView.PersonNavView):
|
||||
db.connect('person-rebuild', self.build_tree)
|
||||
self.generic_filter_widget.apply_filter()
|
||||
self.goto_active_person()
|
||||
|
||||
self.bookmarks.update_bookmarks(db.get_bookmarks())
|
||||
if self.active:
|
||||
self.bookmarks.redraw()
|
||||
|
||||
def goto_active_person(self,obj=None):
|
||||
"""
|
||||
|
@ -38,6 +38,8 @@ import DisplayModels
|
||||
import const
|
||||
import Utils
|
||||
import Errors
|
||||
import Bookmarks
|
||||
|
||||
from Editors import EditPlace, DeletePlaceQuery
|
||||
from QuestionDialog import QuestionDialog, ErrorDialog
|
||||
|
||||
@ -79,7 +81,12 @@ class PlaceView(PageView.ListView):
|
||||
|
||||
PageView.ListView.__init__(
|
||||
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):
|
||||
PageView.ListView.define_actions(self)
|
||||
@ -112,6 +119,12 @@ class PlaceView(PageView.ListView):
|
||||
<menu action="ViewMenu">
|
||||
<menuitem action="Filter"/>
|
||||
</menu>
|
||||
<menu action="BookMenu">
|
||||
<placeholder name="AddEditBook">
|
||||
<menuitem action="AddBook"/>
|
||||
<menuitem action="EditBook"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
<menu action="EditMenu">
|
||||
<placeholder name="CommonEdit">
|
||||
<menuitem action="Add"/>
|
||||
|
@ -37,6 +37,8 @@ import PageView
|
||||
import DisplayModels
|
||||
import const
|
||||
import Utils
|
||||
import Bookmarks
|
||||
|
||||
from Editors import EditRepository, DelRepositoryQuery
|
||||
from DdTargets import DdTargets
|
||||
|
||||
@ -82,7 +84,12 @@ class RepositoryView(PageView.ListView):
|
||||
PageView.ListView.__init__(
|
||||
self, _('Repositories'), dbstate, uistate,
|
||||
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):
|
||||
return DdTargets.REPO_LINK
|
||||
@ -118,6 +125,12 @@ class RepositoryView(PageView.ListView):
|
||||
<menu action="ViewMenu">
|
||||
<menuitem action="Filter"/>
|
||||
</menu>
|
||||
<menu action="BookMenu">
|
||||
<placeholder name="AddEditBook">
|
||||
<menuitem action="AddBook"/>
|
||||
<menuitem action="EditBook"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
<menu action="EditMenu">
|
||||
<placeholder name="CommonEdit">
|
||||
<menuitem action="Add"/>
|
||||
|
@ -37,9 +37,10 @@ import PageView
|
||||
import DisplayModels
|
||||
import const
|
||||
import Utils
|
||||
import Bookmarks
|
||||
|
||||
from DdTargets import DdTargets
|
||||
from Editors import EditSource, DelSrcQuery
|
||||
|
||||
from QuestionDialog import QuestionDialog, ErrorDialog
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -75,7 +76,12 @@ class SourceView(PageView.ListView):
|
||||
|
||||
PageView.ListView.__init__(
|
||||
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):
|
||||
return DdTargets.SOURCE_LINK
|
||||
@ -111,6 +117,12 @@ class SourceView(PageView.ListView):
|
||||
<menu action="ViewMenu">
|
||||
<menuitem action="Filter"/>
|
||||
</menu>
|
||||
<menu action="BookMenu">
|
||||
<placeholder name="AddEditBook">
|
||||
<menuitem action="AddBook"/>
|
||||
<menuitem action="EditBook"/>
|
||||
</placeholder>
|
||||
</menu>
|
||||
<menu action="EditMenu">
|
||||
<placeholder name="CommonEdit">
|
||||
<menuitem action="Add"/>
|
||||
|
@ -337,7 +337,13 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
dbtype=db.DB_BTREE)
|
||||
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.individual_event_names = set(self.metadata.get('pevent_names',[]))
|
||||
self.family_attributes = set(self.metadata.get('fattr_names',[]))
|
||||
@ -351,9 +357,6 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
elif not self.metadata.has_key('version'):
|
||||
self.metadata['version'] = 0
|
||||
|
||||
if self.bookmarks == None:
|
||||
self.bookmarks = []
|
||||
|
||||
self.genderStats = GenderStats(gstats)
|
||||
|
||||
# Here we take care of any changes in the tables related to new code.
|
||||
@ -802,6 +805,12 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
return
|
||||
if not self.readonly:
|
||||
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['fevent_names'] = list(self.family_event_names)
|
||||
self.metadata['pevent_names'] = list(self.individual_event_names)
|
||||
|
@ -262,6 +262,12 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
self.default = None
|
||||
self.owner = Researcher()
|
||||
self.bookmarks = []
|
||||
self.family_bookmarks = []
|
||||
self.event_bookmarks = []
|
||||
self.place_bookmarks = []
|
||||
self.source_bookmarks = []
|
||||
self.repo_bookmarks = []
|
||||
self.media_bookmarks = []
|
||||
self.path = ""
|
||||
self.place2title = {}
|
||||
self.name_group = {}
|
||||
@ -1430,6 +1436,30 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
"""returns the list of Person handles in the 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):
|
||||
"""sets the information about the owner of the database"""
|
||||
self.owner.set(owner.get_name(), owner.get_address(),
|
||||
|
@ -43,6 +43,7 @@ from gtk.gdk import ACTION_COPY, BUTTON1_MASK
|
||||
#
|
||||
#----------------------------------------------------------------
|
||||
import TreeTips
|
||||
import Bookmarks
|
||||
import GenericFilter
|
||||
import const
|
||||
|
||||
@ -185,15 +186,72 @@ class PageView:
|
||||
else:
|
||||
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
|
||||
#
|
||||
#----------------------------------------------------------------
|
||||
class PersonNavView(PageView):
|
||||
class PersonNavView(BookMarkView):
|
||||
|
||||
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):
|
||||
return NAVIGATION_PERSON
|
||||
@ -201,6 +259,8 @@ class PersonNavView(PageView):
|
||||
def define_actions(self):
|
||||
# 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.add_actions([
|
||||
('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
|
||||
handled correctly.
|
||||
"""
|
||||
PageView.disable_action_group(self)
|
||||
BookMarkView.disable_action_group(self)
|
||||
|
||||
self.fwd_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
|
||||
handled correctly.
|
||||
"""
|
||||
PageView.enable_action_group(self,obj)
|
||||
BookMarkView.enable_action_group(self,obj)
|
||||
|
||||
self.fwd_action.set_visible(True)
|
||||
self.back_action.set_visible(True)
|
||||
@ -347,11 +407,14 @@ class PersonNavView(PageView):
|
||||
# ListView
|
||||
#
|
||||
#----------------------------------------------------------------
|
||||
class ListView(PageView):
|
||||
class ListView(BookMarkView):
|
||||
|
||||
def __init__(self, title, dbstate, uistate, columns, handle_col,
|
||||
make_model, signal_map):
|
||||
PageView.__init__(self, title, dbstate, uistate)
|
||||
make_model, signal_map, get_bookmarks, bm_type):
|
||||
|
||||
BookMarkView.__init__(self, title, dbstate, uistate,
|
||||
get_bookmarks, bm_type)
|
||||
|
||||
self.renderer = gtk.CellRendererText()
|
||||
self.renderer.set_property('ellipsize',pango.ELLIPSIZE_END)
|
||||
self.sort_col = 0
|
||||
@ -362,6 +425,19 @@ class ListView(PageView):
|
||||
self.signal_map = signal_map
|
||||
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):
|
||||
return None
|
||||
|
||||
@ -510,8 +586,10 @@ class ListView(PageView):
|
||||
self.model = self.make_model(self.dbstate.db,0)
|
||||
self.list.set_model(self.model)
|
||||
self.build_columns()
|
||||
self.bookmarks.update_bookmarks(self.get_bookmarks())
|
||||
if self.active:
|
||||
self.build_tree()
|
||||
self.bookmarks.redraw()
|
||||
else:
|
||||
self.dirty = True
|
||||
|
||||
@ -537,6 +615,8 @@ class ListView(PageView):
|
||||
since we want to have more than one action group for the PersonView.
|
||||
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('Edit', gtk.STOCK_EDIT, "_Edit", callback=self.edit)
|
||||
@ -570,3 +650,4 @@ class ListView(PageView):
|
||||
self.generic_filter_widget.show()
|
||||
else:
|
||||
self.generic_filter_widget.hide()
|
||||
|
||||
|
@ -126,8 +126,7 @@ uidefault = '''<ui>
|
||||
<placeholder name="CommonHistory"/>
|
||||
</menu>
|
||||
<menu action="BookMenu">
|
||||
<menuitem action="AddBook"/>
|
||||
<menuitem action="EditBook"/>
|
||||
<placeholder name="AddEditBook"/>
|
||||
<separator/>
|
||||
<placeholder name="GoToBook"/>
|
||||
</menu>
|
||||
@ -324,10 +323,6 @@ class ViewManager:
|
||||
('ColumnEdit', gtk.STOCK_PROPERTIES, '_Column Editor'),
|
||||
('GoMenu', None, '_Go'),
|
||||
('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'),
|
||||
('ToolsMenu', None, '_Tools'),
|
||||
('WindowsMenu', None, '_Windows'),
|
||||
|
@ -156,6 +156,8 @@ class Gramps:
|
||||
|
||||
state = GrampsDb.DbState()
|
||||
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():
|
||||
self.vm.register_view(view)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user