diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index af9faec1b..fd914b05a 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -2,6 +2,10 @@ * src/plugins/Check.py: Adapt to new family relation types. 2006-04-26 Don Allingham + * src/Bookmarks.py: connect goto_handle function for bookmark + callback + * src/PageView.py: connect goto_handle function for bookmark + callback * src/ViewManager.py: force uimanager updates * src/Bookmarks.py: force uimanager updates * src/DisplayState.py: force uimanager updates diff --git a/gramps2/src/Bookmarks.py b/gramps2/src/Bookmarks.py index 67a6563ec..1ce4d59d8 100644 --- a/gramps2/src/Bookmarks.py +++ b/gramps2/src/Bookmarks.py @@ -72,7 +72,7 @@ DISABLED = -1 class Bookmarks : "Handle the bookmarks interface for Gramps" - def __init__(self,dbstate,uistate,bookmarks): + def __init__(self, dbstate, uistate, bookmarks, callback=None): """ Creates a the bookmark editor. @@ -260,28 +260,37 @@ class Bookmarks : GrampsDisplay.help('gramps-nav') self.response = self.top.run() -class FamilyBookmarks(Bookmarks) : +class ListBookmarks(Bookmarks): + + def __init__(self,dbstate,uistate,bookmarks, goto_handle): + self.goto_handle = goto_handle + Bookmarks.__init__(self, dbstate, uistate, bookmarks) + + def callback(self, handle): + return make_callback(handle, self.do_callback) + + def do_callback(self, handle): + self.goto_handle(handle) + + +class FamilyBookmarks(ListBookmarks) : "Handle the bookmarks interface for Gramps" - def __init__(self,dbstate,uistate,bookmarks): - Bookmarks.__init__(self, dbstate, uistate, bookmarks) + def __init__(self,dbstate,uistate,bookmarks, goto_handle): + ListBookmarks.__init__(self, dbstate, uistate, bookmarks, + goto_handle) 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) : +class EventBookmarks(ListBookmarks) : "Handle the bookmarks interface for Gramps" - def __init__(self,dbstate,uistate,bookmarks): - Bookmarks.__init__(self, dbstate, uistate, bookmarks) + def __init__(self,dbstate,uistate,bookmarks, goto_handle): + ListBookmarks.__init__(self, dbstate, uistate, bookmarks, + goto_handle) def make_label(self,handle): obj = self.dbstate.db.get_event_from_handle(handle) @@ -291,79 +300,52 @@ class EventBookmarks(Bookmarks) : 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) : +class SourceBookmarks(ListBookmarks) : "Handle the bookmarks interface for Gramps" - - def __init__(self,dbstate,uistate,bookmarks): - Bookmarks.__init__(self, dbstate, uistate, bookmarks) + def __init__(self,dbstate,uistate,bookmarks, goto_handle): + ListBookmarks.__init__(self, dbstate, uistate, bookmarks, + goto_handle) 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) : +class MediaBookmarks(ListBookmarks) : "Handle the bookmarks interface for Gramps" - def __init__(self,dbstate,uistate,bookmarks): - Bookmarks.__init__(self, dbstate, uistate, bookmarks) + def __init__(self,dbstate,uistate,bookmarks, goto_handle): + ListBookmarks.__init__(self, dbstate, uistate, bookmarks, + goto_handle) 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) : +class RepoBookmarks(ListBookmarks) : "Handle the bookmarks interface for Gramps" - def __init__(self,dbstate,uistate,bookmarks): - Bookmarks.__init__(self, dbstate, uistate, bookmarks) + def __init__(self,dbstate,uistate,bookmarks, goto_handle): + ListBookmarks.__init__(self, dbstate, uistate, bookmarks, + goto_handle) 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) : +class PlaceBookmarks(ListBookmarks) : "Handle the bookmarks interface for Gramps" - def __init__(self,dbstate,uistate,bookmarks): - Bookmarks.__init__(self, dbstate, uistate, bookmarks) + def __init__(self,dbstate,uistate,bookmarks, goto_handle): + ListBookmarks.__init__(self, dbstate, uistate, bookmarks, + goto_handle) 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) diff --git a/gramps2/src/PageView.py b/gramps2/src/PageView.py index 7493f38f0..a395e2c60 100644 --- a/gramps2/src/PageView.py +++ b/gramps2/src/PageView.py @@ -194,9 +194,12 @@ class BookMarkView(PageView): self.bm_type = bm_type self.setup_bookmarks(bookmarks) + def goto_handle(self, obj): + pass + def setup_bookmarks(self, bookmarks): self.bookmarks = self.bm_type( - self.dbstate, self.uistate, bookmarks) + self.dbstate, self.uistate, bookmarks, self.goto_handle) def add_bookmark(self, obj): import NameDisplay @@ -248,7 +251,7 @@ class BookMarkView(PageView): #---------------------------------------------------------------- class PersonNavView(BookMarkView): - def __init__(self,title,dbstate,uistate): + def __init__(self,title,dbstate,uistate, callback=None): BookMarkView.__init__(self, title, dbstate, uistate, dbstate.db.get_bookmarks(), Bookmarks.Bookmarks) @@ -525,6 +528,27 @@ class ListView(BookMarkView): ] self.generic_filter_widget.setup_filter( default_filters) + def goto_handle(self, handle): + if not self.dbstate.active or self.inactive: + return + + # mark inactive to prevent recusion + self.inactive = True + + # select the active person in the person view + + try: + path = self.model.on_get_path(handle) + self.selection.unselect_all() + self.selection.select_path(path) + self.list.scroll_to_cell(path,None,1,0.5,0) + except KeyError: + self.selection.unselect_all() + + # disable the inactive flag + self.inactive = False + + def column_clicked(self,obj,data): if self.sort_col != data: order = gtk.SORT_ASCENDING