Extend history functionality (back/forward) and active-changed signals to all primary objects

svn: r14023
This commit is contained in:
Nick Hall 2010-01-10 19:19:33 +00:00
parent 141100fdbf
commit b503fa2e25
42 changed files with 552 additions and 767 deletions

View File

@ -105,7 +105,7 @@ class Bookmarks :
""" """
Connect the person-delete signal Connect the person-delete signal
""" """
self.dbstate.db.connect('person-delete', self.remove_handles) raise NotImplementedError
def update_bookmarks(self, bookmarks): def update_bookmarks(self, bookmarks):
""" """
@ -146,10 +146,9 @@ class Bookmarks :
if len(self.bookmarks.get()) > 0: if len(self.bookmarks.get()) > 0:
text.write('<placeholder name="GoToBook">') text.write('<placeholder name="GoToBook">')
for item in self.bookmarks.get(): for item in self.bookmarks.get():
try: try:
label, obj = self.make_label(item) label = self.make_label(item)
func = self.callback(item) func = self.callback(item)
action_id = "BM:%s" % item action_id = "BM:%s" % item
actions.append((action_id, None, label, None, None, func)) actions.append((action_id, None, label, None, None, func))
@ -167,12 +166,10 @@ class Bookmarks :
text.close() text.close()
def make_label(self, handle): def make_label(self, handle):
person = self.dbstate.db.get_person_from_handle(handle) raise NotImplementedError
name = name_displayer.display(person)
return ("%s [%s]" % (name, person.gramps_id), person)
def callback(self, handle): def callback(self, handle):
return make_callback(handle, self.dbstate.change_active_handle) raise NotImplementedError
def add(self, person_handle): def add(self, person_handle):
"""Append the person to the bottom of the bookmarks.""" """Append the person to the bottom of the bookmarks."""
@ -326,6 +323,19 @@ class ListBookmarks(Bookmarks):
def do_callback(self, handle): def do_callback(self, handle):
self.goto_handle(handle) self.goto_handle(handle)
class PersonBookmarks(ListBookmarks) :
"Handle the bookmarks interface for Gramps."
def __init__(self, dbstate, uistate, bookmarks, goto_handle):
ListBookmarks.__init__(self, dbstate, uistate, bookmarks,
goto_handle)
def make_label(self, handle):
return Utils.navigation_label(self.dbstate.db, 'Person', handle)
def connect_signals(self):
self.dbstate.db.connect('person-delete', self.remove_handles)
class FamilyBookmarks(ListBookmarks) : class FamilyBookmarks(ListBookmarks) :
"Handle the bookmarks interface for Gramps." "Handle the bookmarks interface for Gramps."
@ -334,9 +344,7 @@ class FamilyBookmarks(ListBookmarks) :
goto_handle) goto_handle)
def make_label(self, handle): def make_label(self, handle):
obj = self.dbstate.db.get_family_from_handle(handle) return Utils.navigation_label(self.dbstate.db, 'Family', handle)
name = Utils.family_name(obj, self.dbstate.db)
return ("%s [%s]" % (name, obj.gramps_id), obj)
def connect_signals(self): def connect_signals(self):
self.dbstate.db.connect('family-delete', self.remove_handles) self.dbstate.db.connect('family-delete', self.remove_handles)
@ -349,12 +357,7 @@ class EventBookmarks(ListBookmarks) :
goto_handle) goto_handle)
def make_label(self, handle): def make_label(self, handle):
obj = self.dbstate.db.get_event_from_handle(handle) return Utils.navigation_label(self.dbstate.db, 'Event', handle)
if obj.get_description() == "":
name = str(obj.get_type())
else:
name = obj.get_description()
return ("%s [%s]" % (name, obj.gramps_id), obj)
def connect_signals(self): def connect_signals(self):
self.dbstate.db.connect('event-delete', self.remove_handles) self.dbstate.db.connect('event-delete', self.remove_handles)
@ -366,9 +369,7 @@ class SourceBookmarks(ListBookmarks) :
goto_handle) goto_handle)
def make_label(self, handle): def make_label(self, handle):
obj = self.dbstate.db.get_source_from_handle(handle) return Utils.navigation_label(self.dbstate.db, 'Source', handle)
name = obj.get_title()
return ("%s [%s]" % (name, obj.gramps_id), obj)
def connect_signals(self): def connect_signals(self):
self.dbstate.db.connect('source-delete', self.remove_handles) self.dbstate.db.connect('source-delete', self.remove_handles)
@ -381,9 +382,7 @@ class MediaBookmarks(ListBookmarks) :
goto_handle) goto_handle)
def make_label(self, handle): def make_label(self, handle):
obj = self.dbstate.db.get_object_from_handle(handle) return Utils.navigation_label(self.dbstate.db, 'Media', handle)
name = obj.get_description()
return ("%s [%s]" % (name, obj.gramps_id), obj)
def connect_signals(self): def connect_signals(self):
self.dbstate.db.connect('media-delete', self.remove_handles) self.dbstate.db.connect('media-delete', self.remove_handles)
@ -396,9 +395,7 @@ class RepoBookmarks(ListBookmarks) :
goto_handle) goto_handle)
def make_label(self, handle): def make_label(self, handle):
obj = self.dbstate.db.get_repository_from_handle(handle) return Utils.navigation_label(self.dbstate.db, 'Repository', handle)
name = obj.get_name()
return ("%s [%s]" % (name, obj.gramps_id), obj)
def connect_signals(self): def connect_signals(self):
self.dbstate.db.connect('repository-delete', self.remove_handles) self.dbstate.db.connect('repository-delete', self.remove_handles)
@ -411,9 +408,7 @@ class PlaceBookmarks(ListBookmarks) :
goto_handle) goto_handle)
def make_label(self, handle): def make_label(self, handle):
obj = self.dbstate.db.get_place_from_handle(handle) return Utils.navigation_label(self.dbstate.db, 'Place', handle)
name = obj.get_title()
return ("%s [%s]" % (name, obj.gramps_id), obj)
def connect_signals(self): def connect_signals(self):
self.dbstate.db.connect('place-delete', self.remove_handles) self.dbstate.db.connect('place-delete', self.remove_handles)
@ -426,13 +421,7 @@ class NoteBookmarks(ListBookmarks) :
goto_handle) goto_handle)
def make_label(self, handle): def make_label(self, handle):
obj = self.dbstate.db.get_note_from_handle(handle) return Utils.navigation_label(self.dbstate.db, 'Note', handle)
name = obj.get().replace('\n', ' ')
#String must be unicode for truncation to work for non ascii characters
name = unicode(name)
if len(name) > 40:
name = name[:40]+"..."
return ("%s [%s]" % (name, obj.gramps_id), obj)
def connect_signals(self): def connect_signals(self):
self.dbstate.db.connect('note-delete', self.remove_handles) self.dbstate.db.connect('note-delete', self.remove_handles)

View File

@ -25,29 +25,6 @@ Provide the database state class
from gen.db import DbBsddbRead from gen.db import DbBsddbRead
from gen.utils import Callback from gen.utils import Callback
import config import config
# FIXME: this brings in gtk
#from gui.views.navigationview import (NAVIGATION_PERSON, NAVIGATION_FAMILY,
# NAVIGATION_EVENT, NAVIGATION_PLACE,
# NAVIGATION_SOURCE, NAVIGATION_REPOSITORY,
# NAVIGATION_MEDIA, NAVIGATION_NOTE)
NAVIGATION_NONE = -1
NAVIGATION_PERSON = 0
NAVIGATION_FAMILY = 1
NAVIGATION_EVENT = 2
NAVIGATION_PLACE = 3
NAVIGATION_SOURCE = 4
NAVIGATION_REPOSITORY = 5
NAVIGATION_MEDIA = 6
NAVIGATION_NOTE = 7
ACTIVE_SIGNALS = ['person-active',
'family-active',
'event-active',
'place-active',
'source-active',
'repository-active',
'media-active',
'note-active']
class DbState(Callback): class DbState(Callback):
""" """
@ -56,15 +33,6 @@ class DbState(Callback):
__signals__ = { __signals__ = {
'database-changed' : (DbBsddbRead, ), 'database-changed' : (DbBsddbRead, ),
'active-changed' : (str, ),
'person-active' : (str, ),
'family-active' : (str, ),
'event-active' : (str, ),
'place-active' : (str, ),
'source-active' : (str, ),
'repository-active' : (str, ),
'media-active' : (str, ),
'note-active' : (str, ),
'no-database' : None, 'no-database' : None,
} }
@ -76,27 +44,6 @@ class DbState(Callback):
Callback.__init__(self) Callback.__init__(self)
self.db = DbBsddbRead() self.db = DbBsddbRead()
self.open = False self.open = False
self.active = None # Retained for backward compatibility.
self.__active_objects = [None] * 8
self.sighndl = None
def change_active_person(self, person):
"""
Change the active person and emits a signal to notify those who
are interested.
"""
print 'DbState: change_active_person is deprecated, ' + \
'use set_active_person instead.'
if person:
self.set_active_person(person.get_handle())
def change_active_handle(self, handle):
"""
Change the active person based on the person's handle
"""
print 'DbState: change_active_handle is deprecated, ' + \
'use set_active_person instead.'
self.set_active_person(handle)
def change_database(self, database): def change_database(self, database):
""" """
@ -120,8 +67,6 @@ class DbState(Callback):
config.get('preferences.eprefix'), config.get('preferences.eprefix'),
config.get('preferences.rprefix'), config.get('preferences.rprefix'),
config.get('preferences.nprefix') ) config.get('preferences.nprefix') )
self.active = None
self.open = True self.open = True
def signal_change(self): def signal_change(self):
@ -137,8 +82,6 @@ class DbState(Callback):
self.db.close() self.db.close()
self.db = DbBsddbRead() self.db = DbBsddbRead()
self.db.db_is_open = False self.db.db_is_open = False
self.active = None # Retained for backward compatibility.
self.__active_objects = [None] * 8
self.open = False self.open = False
self.emit('database-changed', (self.db, )) self.emit('database-changed', (self.db, ))
@ -147,114 +90,3 @@ class DbState(Callback):
Get a reference to the current database. Get a reference to the current database.
""" """
return self.db return self.db
def set_active(self, navigation_type, handle):
"""
Set the active handle for the given navigation type.
"""
handle = str(handle) # This is sometimes unicode.
old_handle = self.__active_objects[navigation_type]
if old_handle != handle:
self.__active_objects[navigation_type] = handle
signal = ACTIVE_SIGNALS[navigation_type]
try:
self.emit(signal, (handle, ))
except:
self.emit(signal, ("", ))
# Retained for backward compatibility.
if navigation_type == NAVIGATION_PERSON:
self.active = self.db.get_person_from_handle(handle)
try:
self.emit('active-changed', (handle, ))
except:
self.emit('active-changed', ("", ))
def get_active(self, navigation_type):
"""
Return the active handle for the given navigation type.
"""
handle = self.__active_objects[navigation_type]
if navigation_type == NAVIGATION_PERSON:
return self.db.get_person_from_handle(handle)
elif navigation_type == NAVIGATION_FAMILY:
return self.db.get_family_from_handle(handle)
elif navigation_type == NAVIGATION_EVENT:
return self.db.get_event_from_handle(handle)
elif navigation_type == NAVIGATION_PLACE:
return self.db.get_place_from_handle(handle)
elif navigation_type == NAVIGATION_SOURCE:
return self.db.get_source_from_handle(handle)
elif navigation_type == NAVIGATION_REPOSITORY:
return self.db.get_repository_from_handle(handle)
elif navigation_type == NAVIGATION_MEDIA:
return self.db.get_object_from_handle(handle)
elif navigation_type == NAVIGATION_NOTE:
return self.db.get_note_from_handle(handle)
###########################################################################
# Convenience functions
###########################################################################
def set_active_person(self, handle):
"""Set the active person to the given handle."""
self.set_active(NAVIGATION_PERSON, handle)
def get_active_person(self):
"""Return the handle for the active person."""
return self.get_active(NAVIGATION_PERSON)
def set_active_family(self, handle):
"""Set the active family to the given handle."""
self.set_active(NAVIGATION_FAMILY, handle)
def get_active_family(self):
"""Return the handle for the active family."""
return self.get_active(NAVIGATION_FAMILY)
def set_active_event(self, handle):
"""Set the active event to the given handle."""
self.set_active(NAVIGATION_EVENT, handle)
def get_active_event(self):
"""Return the handle for the active event."""
return self.get_active(NAVIGATION_EVENT)
def set_active_place(self, handle):
"""Set the active place to the given handle."""
self.set_active(NAVIGATION_PLACE, handle)
def get_active_place(self):
"""Return the handle for the active place."""
return self.get_active(NAVIGATION_PLACE)
def set_active_source(self, handle):
"""Set the active source to the given handle."""
self.set_active(NAVIGATION_SOURCE, handle)
def get_active_source(self):
"""Return the handle for the active source."""
return self.get_active(NAVIGATION_SOURCE)
def set_active_repository(self, handle):
"""Set the active repository to the given handle."""
self.set_active(NAVIGATION_REPOSITORY, handle)
def get_active_repository(self):
"""Return the handle for the active repository."""
return self.get_active(NAVIGATION_REPOSITORY)
def set_active_media(self, handle):
"""Set the active media to the given handle."""
self.set_active(NAVIGATION_MEDIA, handle)
def get_active_media(self):
"""Return the handle for the active media."""
return self.get_active(NAVIGATION_MEDIA)
def set_active_note(self, handle):
"""Set the active note to the given handle."""
self.set_active(NAVIGATION_NOTE, handle)
def get_active_note(self):
"""Return the handle for the active note."""
return self.get_active(NAVIGATION_NOTE)

View File

@ -3,6 +3,7 @@
# #
# Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2008 Brian G. Matherly # Copyright (C) 2008 Brian G. Matherly
# Copyright (C) 2010 Nick Hall
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -53,12 +54,14 @@ import gobject
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gen.utils import gen.utils
from gui.utils import process_pending_events from gui.utils import process_pending_events
from gui.views.navigationview import NavigationView
import config import config
from BasicUtils import name_displayer from BasicUtils import name_displayer
import const import const
import ManagedWindow import ManagedWindow
import Relationship import Relationship
from glade import Glade from glade import Glade
from Utils import navigation_label
DISABLED = -1 DISABLED = -1
@ -74,7 +77,7 @@ class History(gen.utils.Callback):
""" """
__signals__ = { __signals__ = {
'changed' : (list, ), 'active-changed' : (str, ),
'menu-changed' : (list, ), 'menu-changed' : (list, ),
} }
@ -108,7 +111,8 @@ class History(gen.utils.Callback):
mhc = self.mhistory.count(del_id) mhc = self.mhistory.count(del_id)
for c in range(mhc): for c in range(mhc):
self.mhistory.remove(del_id) self.mhistory.remove(del_id)
self.emit('changed', (self.history, )) if self.history:
self.emit('active-changed', (self.history[self.index],))
self.emit('menu-changed', (self.mhistory, )) self.emit('menu-changed', (self.mhistory, ))
def push(self, handle): def push(self, handle):
@ -117,13 +121,14 @@ class History(gen.utils.Callback):
""" """
self.prune() self.prune()
if len(self.history) == 0 or handle != self.history[-1]: if len(self.history) == 0 or handle != self.history[-1]:
self.history.append(handle) self.history.append(str(handle))
if handle in self.mhistory: if handle in self.mhistory:
self.mhistory.remove(handle) self.mhistory.remove(handle)
self.mhistory.append(handle) self.mhistory.append(handle)
self.index += 1 self.index += 1
if self.history:
self.emit('active-changed', (self.history[self.index],))
self.emit('menu-changed', (self.mhistory, )) self.emit('menu-changed', (self.mhistory, ))
self.emit('changed', (self.history, ))
def forward(self, step=1): def forward(self, step=1):
""" """
@ -134,6 +139,8 @@ class History(gen.utils.Callback):
if handle not in self.mhistory: if handle not in self.mhistory:
self.mhistory.append(handle) self.mhistory.append(handle)
self.emit('menu-changed', (self.mhistory, )) self.emit('menu-changed', (self.mhistory, ))
if self.history:
self.emit('active-changed', (self.history[self.index],))
return str(self.history[self.index]) return str(self.history[self.index])
def back(self, step=1): def back(self, step=1):
@ -146,6 +153,8 @@ class History(gen.utils.Callback):
if handle not in self.mhistory: if handle not in self.mhistory:
self.mhistory.append(handle) self.mhistory.append(handle)
self.emit('menu-changed', (self.mhistory, )) self.emit('menu-changed', (self.mhistory, ))
if self.history:
self.emit('active-changed', (self.history[self.index],))
return str(self.history[self.index]) return str(self.history[self.index])
except IndexError: except IndexError:
return u"" return u""
@ -316,7 +325,7 @@ class DisplayState(gen.utils.Callback):
self.status = status self.status = status
self.status_id = status.get_context_id('GRAMPS') self.status_id = status.get_context_id('GRAMPS')
self.progress = progress self.progress = progress
self.phistory = History() self.history_lookup = {}
self.gwm = ManagedWindow.GrampsWindowManager(uimanager) self.gwm = ManagedWindow.GrampsWindowManager(uimanager)
self.widget = None self.widget = None
self.disprel_old = '' self.disprel_old = ''
@ -336,6 +345,37 @@ class DisplayState(gen.utils.Callback):
# but this connection is still made! # but this connection is still made!
# self.dbstate.connect('database-changed', self.db_changed) # self.dbstate.connect('database-changed', self.db_changed)
def get_history(self, nav_type, nav_group=0):
"""
Return the history object for the given navigation type and group.
"""
return self.history_lookup.get((nav_type, nav_group))
def register(self, nav_type, nav_group):
"""
Create a history and navigation object for the specified
navigation type and group, if they don't exist.
"""
if (nav_type, nav_group) not in self.history_lookup:
history = History()
self.history_lookup[(nav_type, nav_group)] = history
def get_active(self, nav_type, nav_group=0):
"""
Return the handle for the active obejct specified by the given
navigation type and group.
"""
history = self.get_history(nav_type, nav_group)
return history.present()
def set_active(self, handle, nav_type, nav_group=0):
"""
Set the active object for the specified navigation type and group to
the given handle.
"""
history = self.get_history(nav_type, nav_group)
history.push(handle)
def set_sensitive(self, state): def set_sensitive(self, state):
self.window.set_sensitive(state) self.window.set_sensitive(state)
@ -356,7 +396,7 @@ class DisplayState(gen.utils.Callback):
""" """
self.relationship.set_depth(value) self.relationship.set_depth(value)
def display_relationship(self, dbstate): def display_relationship(self, dbstate, active_handle):
""" Construct the relationship in order to show it in the statusbar """ Construct the relationship in order to show it in the statusbar
This can be a time intensive calculation, so we only want to do This can be a time intensive calculation, so we only want to do
it if persons are different than before. it if persons are different than before.
@ -368,34 +408,24 @@ class DisplayState(gen.utils.Callback):
""" """
self.relationship.connect_db_signals(dbstate) self.relationship.connect_db_signals(dbstate)
default_person = dbstate.db.get_default_person() default_person = dbstate.db.get_default_person()
active = dbstate.get_active_person() if default_person is None or active_handle is None:
if default_person is None or active is None:
return u'' return u''
if default_person.handle == self.disprel_defpers and \ if default_person.handle == self.disprel_defpers and \
active.handle == self.disprel_active : active_handle == self.disprel_active :
return self.disprel_old return self.disprel_old
active = dbstate.db.get_person_from_handle(active_handle)
name = self.relationship.get_one_relationship( name = self.relationship.get_one_relationship(
dbstate.db, default_person, active) dbstate.db, default_person, active)
#store present call data #store present call data
self.disprel_old = name self.disprel_old = name
self.disprel_defpers = default_person.handle self.disprel_defpers = default_person.handle
self.disprel_active = active.handle self.disprel_active = active_handle
if name: if name:
return name return name
else: else:
return u"" return u""
def clear_history(self, handle=None):
"""Clear the history. If handle is given, then the history is
immediately initialized with a first entry
(you'd eg want active person you view there as History contains the
present object too!)
"""
self.phistory.clear()
if handle :
self.phistory.push(handle)
def set_busy_cursor(self, value): def set_busy_cursor(self, value):
if value == self.busy: if value == self.busy:
return return
@ -427,21 +457,28 @@ class DisplayState(gen.utils.Callback):
self.status.push(1, '', self.last_bar) self.status.push(1, '', self.last_bar)
def modify_statusbar(self, dbstate, active=None): def modify_statusbar(self, dbstate, active=None):
view = self.viewmanager.active_page
if not isinstance(view, NavigationView):
return
nav_type = view.navigation_type()
active_handle = self.get_active(nav_type, view.navigation_group())
self.status.pop(self.status_id) self.status.pop(self.status_id)
if dbstate.active is None:
self.status.push(self.status_id, "") name = navigation_label(dbstate.db, nav_type, active_handle)
else:
person = dbstate.get_active_person() # Append relationship to default person if funtionality is enabled.
if person: if nav_type == 'Person' and active_handle \
pname = name_displayer.display(person) and config.get('interface.statusbar') > 1:
name = "[%s] %s" % (person.get_gramps_id(), pname) if active_handle != dbstate.db.get_default_handle():
if config.get('interface.statusbar') > 1: msg = self.display_relationship(dbstate, active_handle)
if person.handle != dbstate.db.get_default_handle():
msg = self.display_relationship(dbstate)
if msg: if msg:
name = "%s (%s)" % (name, msg.strip()) name = '%s (%s)' % (name, msg.strip())
else:
name = _("No active person") if not name:
name = _('No active object')
self.status.push(self.status_id, name) self.status.push(self.status_id, name)
process_pending_events() process_pending_events()

View File

@ -124,9 +124,9 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) :
#set up callback method for the export plugins #set up callback method for the export plugins
self.callback = self.pulse_progressbar self.callback = self.pulse_progressbar
if self.dbstate.active: person_handle = self.uistate.get_active('Person')
self.person = self.dbstate.get_active_person() self.person = self.dbstate.db.get_person_from_handle(person_handle)
else: if not self.person:
self.person = self.dbstate.db.find_initial_person() self.person = self.dbstate.db.find_initial_person()
self.logo = gtk.gdk.pixbuf_new_from_file(_gramps_png) self.logo = gtk.gdk.pixbuf_new_from_file(_gramps_png)

View File

@ -1,173 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2007 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
"""
Base history navigation class. Builds the action group and ui for the
uimanager. Changes to the associated history objects are tracked. When
the history changes, the UI XML string and the action groups are updated.
"""
#-------------------------------------------------------------------
#
# constants
#
#-------------------------------------------------------------------
import gtk
from BasicUtils import name_displayer
DISABLED = -1
#-------------------------------------------------------------------
#
# UI Manager XML code
#
#-------------------------------------------------------------------
_top = [
'<ui>'
'<menubar name="MenuBar">'
'<menu action="GoMenu">'
'<placeholder name="CommonHistory">'
]
_btm = [
'</placeholder>'
'</menu>'
'</menubar>'
'</ui>'
]
class BaseNavigation(object):
"""
Base history navigation class. Builds the action group and ui for the
uimanager. Changes to the associated history objects are tracked. When
the history changes, the UI XML string and the action groups are updated.
Import variables:
self.title - name used for Action group name and Actions
self.ui - XML string used to build menu items for UIManager
self.action_group - associate action group for selecting items
self.active - merge ID for the action group. DISABLED if not active
self.items - history handles associated with the menu
self.func - array of functions to take action based off of.
"""
def __init__(self, dbstate, uistate, history, title):
self.title = title
self.ui = "".join(_top) + "".join(_btm)
self.dbstate = dbstate
self.uistate = uistate
self.action_group = gtk.ActionGroup(self.title)
self.active = DISABLED
self.items = []
self.func = []
self.history = history
def clear(self):
"""
Clears out the specified history
"""
self.history.clear()
def disable(self):
"""
Remove the UI and action groups if the navigation is enabled
"""
if self.active != DISABLED:
self.uistate.uimanager.remove_ui(self.active)
self.uistate.uimanager.remove_action_group(self.action_group)
self.active = DISABLED
def enable(self):
"""
Enables the UI and action groups
"""
if self.active == DISABLED:
self.uistate.uimanager.insert_action_group(self.action_group, 1)
self.active = self.uistate.uimanager.add_ui_from_string(self.ui)
self.uistate.uimanager.ensure_update()
def build_item_name(self, handle):
"""
Builds a string from the passed handle. Must be overridden by the
derived class.
"""
return "ERROR"
def update_menu(self, items):
"""
Builds the UI and action group.
"""
self.items = items
self.disable()
menu_len = min(len(items), 10)
entry = '<menuitem action="%s%02d"/>'
data = [ entry % (self.title, index) for index in range(0, menu_len) ]
self.ui = "".join(_top) + "".join(data) + "".join(_btm)
self.action_group = gtk.ActionGroup(self.title)
data = []
index = 0
mitems = items[:]
mitems.reverse()
for item in mitems[:10]:
name = self.build_item_name(item)
func = self.func[index]
data.append(('%s%02d'%(self.title, index), None, name,
"<alt>%d" % index, None, func))
index += 1
self.action_group.add_actions(data)
self.enable()
class PersonNavigation(BaseNavigation):
"""
Builds a navigation item for the Person class.
"""
def __init__(self, dbstate, uistate):
"""
Associates the functions with the associated items. Builds the function
array so that there are unique functions for each possible index (0-9)
The callback simply calls change_active_handle
"""
BaseNavigation.__init__(self, dbstate, uistate,
uistate.phistory, 'PersonHistory')
fcn_ptr = self.dbstate.change_active_handle
self.func = [ generate(fcn_ptr, self.items, index) \
for index in range(0, 10) ]
def build_item_name(self, item):
"""
Builds a name in the format of 'NAME [GRAMPSID]'
"""
person = self.dbstate.db.get_person_from_handle(item)
return "%s [%s]" % (name_displayer.display(person),
person.gramps_id)
def generate(func, items, index):
"""
Generates a callback function based off the passed arguments
"""
return lambda x: func(items[index])

View File

@ -433,7 +433,8 @@ class GuiPersonOption(gtk.HBox):
self.pack_start(pevt, False) self.pack_start(pevt, False)
self.pack_end(person_button, False) self.pack_end(person_button, False)
person = self.__dbstate.get_active_person() person_handle = self.__uistate.get_active('Person')
person = self.__dbstate.db.get_person_from_handle(person_handle)
if not person: if not person:
person = self.__db.get_default_person() person = self.__db.get_default_person()
self.__update_person(person) self.__update_person(person)
@ -461,7 +462,8 @@ class GuiPersonOption(gtk.HBox):
rfilter.add_rule(Rules.Person.HasIdOf([gid])) rfilter.add_rule(Rules.Person.HasIdOf([gid]))
# Add the selected person if one exists. # Add the selected person if one exists.
active_person = self.__dbstate.get_active_person() person_handle = self.__uistate.get_active('Person')
active_person = self.__dbstate.db.get_person_from_handle(person_handle)
if active_person: if active_person:
gid = active_person.get_gramps_id() gid = active_person.get_gramps_id()
rfilter.add_rule(Rules.Person.HasIdOf([gid])) rfilter.add_rule(Rules.Person.HasIdOf([gid]))
@ -540,7 +542,8 @@ class GuiFamilyOption(gtk.HBox):
family_list = [] family_list = []
# First try the family of the active person # First try the family of the active person
person = self.__dbstate.get_active_person() person_handle = self.__uistate.get_active('Person')
person = self.__dbstate.db.get_person_from_handle(person_handle)
if person: if person:
family_list = person.get_family_handle_list() family_list = person.get_family_handle_list()

View File

@ -74,7 +74,7 @@ class PluginDialog(ManagedWindow.ManagedWindow):
reports. This is used to build the selection tree on the left reports. This is used to build the selection tree on the left
hand side of the dialog box. hand side of the dialog box.
""" """
self.active = state.active self.active = uistate.get_active('Person')
self.imap = {} self.imap = {}
self.msg = msg self.msg = msg
self.content = content self.content = content
@ -238,7 +238,9 @@ class PluginDialog(ManagedWindow.ManagedWindow):
return return
if pdata.ptype == REPORT: if pdata.ptype == REPORT:
report(self.state, self.uistate, self.state.active, active_handle = self.uistate.get_active('Person')
report(self.state, self.uistate,
self.state.db.get_person_from_handle(active_handle),
eval('mod.' + pdata.reportclass), eval('mod.' + pdata.reportclass),
eval('mod.' + pdata.optionclass), eval('mod.' + pdata.optionclass),
pdata.name, pdata.id, pdata.name, pdata.id,

View File

@ -482,7 +482,7 @@ class ToolManagedWindowBase(ManagedWindow.ManagedWindow):
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass pass
else: else:
self.dbstate.change_active_person(person) self.uistate.set_active(person_handle, 'Person')
return True # handled event return True # handled event
return False # did not handle event return False # did not handle event

View File

@ -76,7 +76,6 @@ class Tool(object):
def __init__(self, dbstate, options_class, name): def __init__(self, dbstate, options_class, name):
from PluginUtils import MenuToolOptions from PluginUtils import MenuToolOptions
self.db = dbstate.db self.db = dbstate.db
self.person = dbstate.active
try: try:
if issubclass(options_class, MenuToolOptions): if issubclass(options_class, MenuToolOptions):
# FIXME: pass in person_id # FIXME: pass in person_id
@ -125,9 +124,9 @@ class ActivePersonTool(Tool):
for tools that depend on active person. for tools that depend on active person.
""" """
def __init__(self, dbstate, options_class, name): def __init__(self, dbstate, uistate, options_class, name):
if not dbstate.get_active_person(): if not uistate.get_active('Person'):
from QuestionDialog import ErrorDialog from QuestionDialog import ErrorDialog
ErrorDialog(_('Active person has not been set'), ErrorDialog(_('Active person has not been set'),

View File

@ -202,9 +202,9 @@ class SimpleTable(object):
import gobject import gobject
# If you emmit the signal here and it causes this table to be deleted, # If you emmit the signal here and it causes this table to be deleted,
# then you'll crash Python: # then you'll crash Python:
#self.simpledoc.doc.dbstate.set_active_person(handle) #self.simpledoc.doc.uistate.set_active(handle, 'Person')
# So, let's return from this, then change the active person: # So, let's return from this, then change the active person:
return gobject.timeout_add(100, self.simpledoc.doc.dbstate.set_active_person, handle) return gobject.timeout_add(100, self.simpledoc.doc.uistate.set_active, handle, 'Person')
return True return True
return False # didn't handle event return False # didn't handle event

View File

@ -1136,3 +1136,58 @@ def find_witnessed_people(db,p):
if pref.ref != p.get_handle and pref.ref not in people: if pref.ref != p.get_handle and pref.ref not in people:
people.append(pref.ref) people.append(pref.ref)
return people return people
#-------------------------------------------------------------------------
#
# Function to return a label to display the active object in the status bar
# and to describe bookmarked objects.
#
#-------------------------------------------------------------------------
def navigation_label(db, nav_type, handle):
label = None
if nav_type == 'Person':
obj = db.get_person_from_handle(handle)
if obj:
label = name_displayer.display(obj)
elif nav_type == 'Family':
obj = db.get_family_from_handle(handle)
if obj:
label = family_name(obj, db)
elif nav_type == 'Event':
obj = db.get_event_from_handle(handle)
if obj:
type = obj.get_type()
who = get_participant_from_event(db, handle)
desc = obj.get_description()
label = '%s - %s' % (type, who)
if desc:
label = '%s - %s' % (label, desc)
elif nav_type == 'Place':
obj = db.get_place_from_handle(handle)
if obj:
label = obj.get_title()
elif nav_type == 'Source':
obj = db.get_source_from_handle(handle)
if obj:
label = obj.get_title()
elif nav_type == 'Repository':
obj = db.get_repository_from_handle(handle)
if obj:
label = obj.get_name()
elif nav_type == 'Media':
obj = db.get_object_from_handle(handle)
if obj:
label = obj.get_description()
elif nav_type == 'Note':
obj = db.get_note_from_handle(handle)
if obj:
label = obj.get()
label = " ".join(label.split())
if len(label) > 40:
label = label[:40] + "..."
if label:
label = '[%s] %s' % (obj.get_gramps_id(), label)
return label

View File

@ -274,8 +274,8 @@ class CLIManager(object):
config.set('paths.recent-file', filename) config.set('paths.recent-file', filename)
try: try:
self.dbstate.change_active_person( initial_person = self.dbstate.db.find_initial_person().get_handle()
self.dbstate.db.find_initial_person()) self.uistate.set_active(initial_person, 'Person')
except: except:
pass pass

View File

@ -27,7 +27,7 @@ class Gramplet(object):
""" """
Base class for non-graphical gramplet code. Base class for non-graphical gramplet code.
""" """
def __init__(self, gui): def __init__(self, gui, nav_group=0):
""" """
Internal constructor for non-graphical gramplets. Internal constructor for non-graphical gramplets.
""" """
@ -41,22 +41,34 @@ class Gramplet(object):
# links to each other: # links to each other:
self.gui = gui # plugin gramplet has link to gui self.gui = gui # plugin gramplet has link to gui
gui.pui = self # gui has link to plugin ui gui.pui = self # gui has link to plugin ui
self.nav_group = nav_group
self.dbstate = gui.dbstate self.dbstate = gui.dbstate
self.uistate = gui.uistate self.uistate = gui.uistate
self.init() self.init()
self.on_load() self.on_load()
self.build_options() self.build_options()
self.connect(self.dbstate, "database-changed", self._db_changed) self.connect(self.dbstate, "database-changed", self._db_changed)
self.connect(self.dbstate, "active-changed", self._active_changed)
self.connect(self.gui.textview, "button-press-event", self.connect(self.gui.textview, "button-press-event",
self.gui.on_button_press) self.gui.on_button_press)
self.connect(self.gui.textview, "motion-notify-event", self.connect(self.gui.textview, "motion-notify-event",
self.gui.on_motion) self.gui.on_motion)
if self.dbstate.active: # already changed self.connect_signal('Person', self._active_changed)
active_person = self.get_active('Person')
if active_person: # already changed
self._db_changed(self.dbstate.db) self._db_changed(self.dbstate.db)
self._active_changed(self.dbstate.active.handle) self._active_changed(active_person)
self.post_init() self.post_init()
def connect_signal(self, nav_type, method):
"""
Connect the given method to the active-changed signal for the
navigation type requested.
"""
self.uistate.register(nav_type, self.nav_group)
history = self.uistate.get_history(nav_type, self.nav_group)
self.connect(history, "active-changed", method)
def init(self): # once, constructor def init(self): # once, constructor
""" """
External constructor for developers to put their initialization External constructor for developers to put their initialization
@ -95,6 +107,18 @@ class Gramplet(object):
""" """
return return
def get_active(self, nav_type):
"""
Return the handle of the active object for the given navigation type.
"""
return self.uistate.get_active(nav_type, self.nav_group)
def set_active(self, nav_type, handle):
"""
Change the handle of the active object for the given navigation type.
"""
self.uistate.set_active(handle, nav_type, self.nav_group)
def active_changed(self, handle): def active_changed(self, handle):
""" """
Developers should put their code that occurs when the active Developers should put their code that occurs when the active

View File

@ -580,7 +580,7 @@ class EditPerson(EditPrimary):
self.home_action.set_sensitive(True) self.home_action.set_sensitive(True)
def _make_active(self, obj): def _make_active(self, obj):
self.dbstate.change_active_person(self.obj) self.uistate.set_active(self.obj.get_handle(), 'Person')
def _make_home_person(self, obj): def _make_home_person(self, obj):
handle = self.obj.get_handle() handle = self.obj.get_handle()

View File

@ -71,8 +71,6 @@ import GrampsCfg
import Errors import Errors
from QuestionDialog import (ErrorDialog, WarningDialog, QuestionDialog2, from QuestionDialog import (ErrorDialog, WarningDialog, QuestionDialog2,
InfoDialog) InfoDialog)
import gui.views.navigationview as NavigationView
import Navigation
from BasicUtils import name_displayer from BasicUtils import name_displayer
from gui import widgets from gui import widgets
import UndoHistory import UndoHistory
@ -342,9 +340,6 @@ class ViewManager(CLIManager):
self.uistate.set_open_widget(openbtn) self.uistate.set_open_widget(openbtn)
self.toolbar.insert(openbtn, 0) self.toolbar.insert(openbtn, 0)
self.person_nav = Navigation.PersonNavigation(self.dbstate, self.uistate)
self._navigation_type[NavigationView.NAVIGATION_PERSON] = \
(self.person_nav, None)
self.recent_manager = DisplayState.RecentDocsMenu( self.recent_manager = DisplayState.RecentDocsMenu(
self.uistate, self.dbstate, self._read_recent_file) self.uistate, self.dbstate, self._read_recent_file)
self.recent_manager.build() self.recent_manager.build()
@ -531,18 +526,6 @@ class ViewManager(CLIManager):
_('Undo History...'), "<control>H", None, self.undo_history), _('Undo History...'), "<control>H", None, self.undo_history),
] ]
self._navigation_type = {
None: (None, None),
NavigationView.NAVIGATION_PERSON: (None, None),
NavigationView.NAVIGATION_FAMILY: (None, None),
NavigationView.NAVIGATION_EVENT: (None, None),
NavigationView.NAVIGATION_PLACE: (None, None),
NavigationView.NAVIGATION_SOURCE: (None, None),
NavigationView.NAVIGATION_REPOSITORY: (None, None),
NavigationView.NAVIGATION_MEDIA: (None, None),
NavigationView.NAVIGATION_NOTE: (None, None)
}
def __keypress(self, action): def __keypress(self, action):
""" """
Callback that is called on a keypress. It works by extracting the Callback that is called on a keypress. It works by extracting the
@ -576,8 +559,8 @@ class ViewManager(CLIManager):
def __prev_view(self, action): def __prev_view(self, action):
""" """
Callback that is called when the previous view action is selected. Callback that is called when the previous view action is selected.
It selects the previous view as the active view. If we reach the beginning It selects the previous view as the active view. If we reach the
of the list of views, we wrap around to the last view. beginning of the list of views, we wrap around to the last view.
""" """
current_page = self.notebook.get_current_page() current_page = self.notebook.get_current_page()
if current_page == 0: if current_page == 0:
@ -883,7 +866,6 @@ class ViewManager(CLIManager):
Create the Views Create the Views
""" """
self.pages = [] self.pages = []
self.prev_nav = None
self.ui_category = {} self.ui_category = {}
self.view_toggle_actions = {} self.view_toggle_actions = {}
self.cat_view_group = None self.cat_view_group = None
@ -908,6 +890,7 @@ class ViewManager(CLIManager):
page_category = page.get_category() page_category = page.get_category()
page_translated_category = page.get_translated_category() page_translated_category = page.get_translated_category()
page_stock = page.get_stock() page_stock = page.get_stock()
if nrpage == 0: if nrpage == 0:
#the first page of this category, used to obtain #the first page of this category, used to obtain
#category workspace notebook #category workspace notebook
@ -1123,19 +1106,6 @@ class ViewManager(CLIManager):
category_page]) category_page])
self.merge_ids.append(mergeid) self.merge_ids.append(mergeid)
def __setup_navigation(self):
"""
Initialize the navigation scheme
"""
old_nav = self._navigation_type[self.prev_nav]
if old_nav[0] is not None:
old_nav[0].disable()
page_type = self.active_page.navigation_type()
nav_type = self._navigation_type[page_type]
if nav_type[0] is not None:
nav_type[0].enable()
def change_category(self, obj, page, num=-1): def change_category(self, obj, page, num=-1):
""" """
Wrapper for the __do_change_category, to prevent entering into the Wrapper for the __do_change_category, to prevent entering into the
@ -1184,7 +1154,6 @@ class ViewManager(CLIManager):
self.views[category_page][view_page][0].id) self.views[category_page][view_page][0].id)
config.save() config.save()
self.__setup_navigation()
self.__connect_active_page(category_page, view_page) self.__connect_active_page(category_page, view_page)
self.uimanager.ensure_update() self.uimanager.ensure_update()
@ -1226,12 +1195,6 @@ class ViewManager(CLIManager):
This method is for the common UI post_load, both new files This method is for the common UI post_load, both new files
and added data like imports. and added data like imports.
""" """
if self.dbstate.active :
# clear history and fill history with first entry, active person
self.uistate.clear_history(self.dbstate.active.handle)
else :
self.uistate.clear_history(None)
self.dbstate.db.undo_callback = self.__change_undo_label self.dbstate.db.undo_callback = self.__change_undo_label
self.dbstate.db.redo_callback = self.__change_redo_label self.dbstate.db.redo_callback = self.__change_redo_label
self.__change_undo_label(None) self.__change_undo_label(None)
@ -1270,8 +1233,6 @@ class ViewManager(CLIManager):
self.uistate.window.set_title(msg) self.uistate.window.set_title(msg)
self.actiongroup.set_sensitive(True) self.actiongroup.set_sensitive(True)
self.setup_bookmarks()
self.change_category(None, None) self.change_category(None, None)
self.actiongroup.set_visible(True) self.actiongroup.set_visible(True)
self.readonlygroup.set_visible(True) self.readonlygroup.set_visible(True)
@ -1339,36 +1300,6 @@ class ViewManager(CLIManager):
# Let it go: history window does not exist # Let it go: history window does not exist
return return
def setup_bookmarks(self):
"""
Initialize the bookmarks based of the database. This needs to
be called anytime the database changes.
"""
import Bookmarks
self.bookmarks = Bookmarks.Bookmarks(
self.dbstate, self.uistate, self.dbstate.db.get_bookmarks())
def add_bookmark(self, obj):
"""
Add a bookmark to the bookmark list
"""
if self.dbstate.active:
self.bookmarks.add(self.dbstate.active.get_handle())
name = name_displayer.display(self.dbstate.active)
self.uistate.push_message(self.dbstate,
_("%s has been bookmarked") % name)
else:
WarningDialog(
_("Could Not Set a Bookmark"),
_("A bookmark could not be set because "
"no one was selected."))
def edit_bookmarks(self, obj):
"""
Displays the Bookmark editor
"""
self.bookmarks.edit()
def reports_clicked(self, obj): def reports_clicked(self, obj):
""" """
Displays the Reports dialog Displays the Reports dialog
@ -1615,7 +1546,7 @@ def run_plugin(pdata, dbstate, uistate):
return return
if pdata.ptype == REPORT: if pdata.ptype == REPORT:
ReportBase.report(dbstate, uistate, dbstate.active, ReportBase.report(dbstate, uistate, uistate.get_active('Person'),
getattr(mod, pdata.reportclass), getattr(mod, pdata.reportclass),
getattr(mod, pdata.optionclass), getattr(mod, pdata.optionclass),
pdata.name, pdata.id, pdata.name, pdata.id,

View File

@ -87,11 +87,11 @@ class ListView(NavigationView):
QR_CATEGORY = -1 QR_CATEGORY = -1
def __init__(self, title, dbstate, uistate, columns, handle_col, def __init__(self, title, dbstate, uistate, columns, handle_col,
make_model, signal_map, get_bookmarks, bm_type, make_model, signal_map, get_bookmarks, bm_type, nav_group,
multiple=False, filter_class=None, markup=False): multiple=False, filter_class=None, markup=False):
NavigationView.__init__(self, title, dbstate, uistate, NavigationView.__init__(self, title, dbstate, uistate,
get_bookmarks, bm_type) get_bookmarks, bm_type, nav_group)
#default is listviews keep themself in sync with database #default is listviews keep themself in sync with database
self._dirty_on_change_inactive = False self._dirty_on_change_inactive = False
@ -756,7 +756,7 @@ class ListView(NavigationView):
self.uistate.uimanager.\ self.uistate.uimanager.\
get_widget('/Popup/QuickReport').remove_submenu() get_widget('/Popup/QuickReport').remove_submenu()
reportactions = [] reportactions = []
if menu and self.dbstate.active: if menu and self.get_active():
(ui, reportactions) = create_quickreport_menu( (ui, reportactions) = create_quickreport_menu(
self.QR_CATEGORY, self.QR_CATEGORY,
self.dbstate, self.dbstate,

View File

@ -2,7 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2001-2007 Donald N. Allingham # Copyright (C) 2001-2007 Donald N. Allingham
# Copyright (C) 2009 Nick Hall # Copyright (C) 2009-2010 Nick Hall
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -47,19 +47,8 @@ import gtk
# #
#---------------------------------------------------------------- #----------------------------------------------------------------
from gui.views.pageview import PageView from gui.views.pageview import PageView
from TransUtils import sgettext as _ from TransUtils import sgettext as _
NAVIGATION_NONE = -1
NAVIGATION_PERSON = 0
NAVIGATION_FAMILY = 1
NAVIGATION_EVENT = 2
NAVIGATION_PLACE = 3
NAVIGATION_SOURCE = 4
NAVIGATION_REPOSITORY = 5
NAVIGATION_MEDIA = 6
NAVIGATION_NOTE = 7
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# #
# NavigationView # NavigationView
@ -72,7 +61,7 @@ class NavigationView(PageView):
should derive from this class. should derive from this class.
""" """
def __init__(self, title, state, uistate, bookmarks, bm_type): def __init__(self, title, state, uistate, bookmarks, bm_type, nav_group):
PageView.__init__(self, title, state, uistate) PageView.__init__(self, title, state, uistate)
self.bookmarks = bm_type(self.dbstate, self.uistate, bookmarks, self.bookmarks = bm_type(self.dbstate, self.uistate, bookmarks,
self.goto_handle) self.goto_handle)
@ -81,7 +70,10 @@ class NavigationView(PageView):
self.back_action = None self.back_action = None
self.book_action = None self.book_action = None
self.other_action = None self.other_action = None
self.key_active_changed = None self.active_signal = None
self.nav_group = nav_group
self.uistate.register(self.navigation_type(), self.nav_group)
def define_actions(self): def define_actions(self):
""" """
@ -111,7 +103,7 @@ class NavigationView(PageView):
self.fwd_action.set_visible(True) self.fwd_action.set_visible(True)
self.back_action.set_visible(True) self.back_action.set_visible(True)
hobj = self.uistate.phistory hobj = self.get_history()
self.fwd_action.set_sensitive(not hobj.at_end()) self.fwd_action.set_sensitive(not hobj.at_end())
self.back_action.set_sensitive(not hobj.at_front()) self.back_action.set_sensitive(not hobj.at_front())
@ -119,10 +111,11 @@ class NavigationView(PageView):
""" """
Called when the page changes. Called when the page changes.
""" """
hobj = self.uistate.phistory hobj = self.get_history()
self.fwd_action.set_sensitive(not hobj.at_end()) self.fwd_action.set_sensitive(not hobj.at_end())
self.back_action.set_sensitive(not hobj.at_front()) self.back_action.set_sensitive(not hobj.at_front())
self.other_action.set_sensitive(not self.dbstate.db.readonly) self.other_action.set_sensitive(not self.dbstate.db.readonly)
self.uistate.modify_statusbar(self.dbstate)
def set_active(self): def set_active(self):
""" """
@ -130,8 +123,10 @@ class NavigationView(PageView):
""" """
PageView.set_active(self) PageView.set_active(self)
self.bookmarks.display() self.bookmarks.display()
self.key_active_changed = self.dbstate.connect('active-changed',
self.goto_active) hobj = self.get_history()
self.active_signal = hobj.connect('active-changed', self.goto_active)
self.goto_active(None) self.goto_active(None)
def set_inactive(self): def set_inactive(self):
@ -141,26 +136,51 @@ class NavigationView(PageView):
if self.active: if self.active:
PageView.set_inactive(self) PageView.set_inactive(self)
self.bookmarks.undisplay() self.bookmarks.undisplay()
self.dbstate.disconnect(self.key_active_changed) hobj = self.get_history()
hobj.disconnect(self.active_signal)
def navigation_group(self):
"""
Return the navigation group.
"""
return self.nav_group
def get_history(self):
"""
Return the history object.
"""
return self.uistate.get_history(self.navigation_type(),
self.navigation_group())
def goto_active(self, active_handle): def goto_active(self, active_handle):
""" """
Callback (and usable function) that selects the active person Callback (and usable function) that selects the active person
in the display tree. in the display tree.
""" """
if self.dbstate.active: active_handle = self.uistate.get_active(self.navigation_type(),
self.handle_history(self.dbstate.active.handle) self.navigation_group())
if active_handle:
self.goto_handle(active_handle)
# active object for each navigation type hobj = self.get_history()
if self.navigation_type() == NAVIGATION_PERSON: self.fwd_action.set_sensitive(not hobj.at_end())
if self.dbstate.active: self.back_action.set_sensitive(not hobj.at_front())
self.goto_handle(self.dbstate.active.handle)
def get_active(self):
"""
Return the handle of the active object.
"""
hobj = self.uistate.get_history(self.navigation_type(),
self.navigation_group())
return hobj.present()
def change_active(self, handle): def change_active(self, handle):
""" """
Changes the active object. Changes the active object.
""" """
self.dbstate.set_active(self.navigation_type(), handle) hobj = self.get_history()
if handle and not hobj.lock and not (handle == hobj.present()):
hobj.push(handle)
def goto_handle(self, handle): def goto_handle(self, handle):
""" """
@ -178,9 +198,11 @@ class NavigationView(PageView):
""" """
from BasicUtils import name_displayer from BasicUtils import name_displayer
if self.dbstate.active: active_handle = self.uistate.get_active('Person')
self.bookmarks.add(self.dbstate.active.get_handle()) active_person = self.dbstate.db.get_person_from_handle(active_handle)
name = name_displayer.display(self.dbstate.active) if active_person:
self.bookmarks.add(active_handle)
name = name_displayer.display(active_person)
self.uistate.push_message(self.dbstate, self.uistate.push_message(self.dbstate,
_("%s has been bookmarked") % name) _("%s has been bookmarked") % name)
else: else:
@ -253,9 +275,9 @@ class NavigationView(PageView):
""" """
Set the default person. Set the default person.
""" """
active = self.dbstate.active active = self.uistate.get_active('Person')
if active: if active:
self.dbstate.db.set_default_person_handle(active.get_handle()) self.dbstate.db.set_default_person_handle(active)
def home(self, obj): def home(self, obj):
""" """
@ -263,7 +285,7 @@ class NavigationView(PageView):
""" """
defperson = self.dbstate.db.get_default_person() defperson = self.dbstate.db.get_default_person()
if defperson: if defperson:
self.dbstate.change_active_person(defperson) self.change_active(defperson.get_handle())
def jump(self): def jump(self):
""" """
@ -293,9 +315,7 @@ class NavigationView(PageView):
gid = text.get_text() gid = text.get_text()
handle = self.get_handle_from_gramps_id(gid) handle = self.get_handle_from_gramps_id(gid)
if handle is not None: if handle is not None:
if self.navigation_type() == NAVIGATION_PERSON:
self.change_active(handle) self.change_active(handle)
self.goto_handle(handle) self.goto_handle(handle)
else: else:
self.uistate.push_message( self.uistate.push_message(
@ -314,12 +334,11 @@ class NavigationView(PageView):
""" """
Move forward one object in the history. Move forward one object in the history.
""" """
hobj = self.uistate.phistory hobj = self.get_history()
hobj.lock = True hobj.lock = True
if not hobj.at_end(): if not hobj.at_end():
try: try:
handle = hobj.forward() handle = hobj.forward()
self.dbstate.change_active_handle(handle)
self.uistate.modify_statusbar(self.dbstate) self.uistate.modify_statusbar(self.dbstate)
hobj.mhistory.append(hobj.history[hobj.index]) hobj.mhistory.append(hobj.history[hobj.index])
self.fwd_action.set_sensitive(not hobj.at_end()) self.fwd_action.set_sensitive(not hobj.at_end())
@ -337,14 +356,12 @@ class NavigationView(PageView):
""" """
Move backward one object in the history. Move backward one object in the history.
""" """
hobj = self.uistate.phistory hobj = self.get_history()
hobj.lock = True hobj.lock = True
if not hobj.at_front(): if not hobj.at_front():
try: try:
handle = hobj.back() handle = hobj.back()
self.active = self.dbstate.db.get_person_from_handle(handle)
self.uistate.modify_statusbar(self.dbstate) self.uistate.modify_statusbar(self.dbstate)
self.dbstate.change_active_handle(handle)
hobj.mhistory.append(hobj.history[hobj.index]) hobj.mhistory.append(hobj.history[hobj.index])
self.back_action.set_sensitive(not hobj.at_front()) self.back_action.set_sensitive(not hobj.at_front())
self.fwd_action.set_sensitive(True) self.fwd_action.set_sensitive(True)
@ -357,18 +374,6 @@ class NavigationView(PageView):
self.fwd_action.set_sensitive(True) self.fwd_action.set_sensitive(True)
hobj.lock = False hobj.lock = False
def handle_history(self, handle):
"""
Updates the person history information
It will push the person at the end of the history if that person is
not present person
"""
hobj = self.uistate.phistory
if handle and not hobj.lock and not (handle == hobj.present()):
hobj.push(handle)
self.fwd_action.set_sensitive(not hobj.at_end())
self.back_action.set_sensitive(not hobj.at_front())
#################################################################### ####################################################################
# Template functions # Template functions
#################################################################### ####################################################################

View File

@ -44,7 +44,6 @@ import gtk
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gen.lib import gen.lib
from gui.views.navigationview import NAVIGATION_PLACE
from gui.views.listview import ListView from gui.views.listview import ListView
from gui.utils import add_menuitem from gui.utils import add_menuitem
import Errors import Errors
@ -93,7 +92,7 @@ class PlaceBaseView(ListView):
FILTER_TYPE = "Place" FILTER_TYPE = "Place"
QR_CATEGORY = CATEGORY_QR_PLACE QR_CATEGORY = CATEGORY_QR_PLACE
def __init__(self, dbstate, uistate, title, model): def __init__(self, dbstate, uistate, title, model, nav_group):
signal_map = { signal_map = {
'place-add' : self.row_add, 'place-add' : self.row_add,
@ -115,7 +114,7 @@ class PlaceBaseView(ListView):
len(PlaceBaseView.COLUMN_NAMES), len(PlaceBaseView.COLUMN_NAMES),
model, signal_map, model, signal_map,
dbstate.db.get_place_bookmarks(), dbstate.db.get_place_bookmarks(),
Bookmarks.PlaceBookmarks, Bookmarks.PlaceBookmarks, nav_group,
multiple=True, multiple=True,
filter_class=PlaceSidebarFilter) filter_class=PlaceSidebarFilter)
@ -123,7 +122,7 @@ class PlaceBaseView(ListView):
self.filter_toggle) self.filter_toggle)
def navigation_type(self): def navigation_type(self):
return NAVIGATION_PLACE return 'Place'
def column_ord_setfunc(self, clist): def column_ord_setfunc(self, clist):
self.dbstate.db.set_place_column_order(clist) self.dbstate.db.set_place_column_order(clist)
@ -298,6 +297,12 @@ class PlaceBaseView(ListView):
<menuitem action="EditBook"/> <menuitem action="EditBook"/>
</placeholder> </placeholder>
</menu> </menu>
<menu action="GoMenu">
<placeholder name="CommonGo">
<menuitem action="Back"/>
<menuitem action="Forward"/>
</placeholder>
</menu>
<menu action="EditMenu"> <menu action="EditMenu">
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<menuitem action="Add"/> <menuitem action="Add"/>
@ -312,6 +317,10 @@ class PlaceBaseView(ListView):
</menu> </menu>
</menubar> </menubar>
<toolbar name="ToolBar"> <toolbar name="ToolBar">
<placeholder name="CommonNavigation">
<toolitem action="Back"/>
<toolitem action="Forward"/>
</placeholder>
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<toolitem action="Add"/> <toolitem action="Add"/>
<toolitem action="Edit"/> <toolitem action="Edit"/>
@ -321,6 +330,9 @@ class PlaceBaseView(ListView):
</placeholder> </placeholder>
</toolbar> </toolbar>
<popup name="Popup"> <popup name="Popup">
<menuitem action="Back"/>
<menuitem action="Forward"/>
<separator/>
<menuitem action="Add"/> <menuitem action="Add"/>
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>

View File

@ -97,7 +97,7 @@ _UNSUPPORTED = _("Unsupported")
# Private Functions # Private Functions
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
def _initialize_options(options, dbstate): def _initialize_options(options, dbstate, uistate):
""" """
Validates all options by making sure that their values are consistent with Validates all options by making sure that their values are consistent with
the database. the database.
@ -116,12 +116,14 @@ def _initialize_options(options, dbstate):
if isinstance(option, PersonOption): if isinstance(option, PersonOption):
if not dbase.get_person_from_gramps_id(value): if not dbase.get_person_from_gramps_id(value):
person = dbstate.get_active_person() person_handle = uistate.get_active('Person')
person = dbase.get_person_from_handle(person_handle)
option.set_value(person.get_gramps_id()) option.set_value(person.get_gramps_id())
elif isinstance(option, FamilyOption): elif isinstance(option, FamilyOption):
if not dbase.get_family_from_gramps_id(value): if not dbase.get_family_from_gramps_id(value):
person = dbstate.get_active_person() person_handle = uistate.get_active('Person')
person = dbase.get_person_from_handle(person_handle)
family_list = person.get_family_handle_list() family_list = person.get_family_handle_list()
if family_list: if family_list:
family_handle = family_list[0] family_handle = family_list[0]
@ -825,7 +827,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
return return
data = self.avail_model.get_data(the_iter, range(self.avail_nr_cols)) data = self.avail_model.get_data(the_iter, range(self.avail_nr_cols))
item = BookItem(self.db, data[2]) item = BookItem(self.db, data[2])
_initialize_options(item.option_class, self.dbstate) _initialize_options(item.option_class, self.dbstate, self.uistate)
data[2] = _get_subject(item.option_class, self.db) data[2] = _get_subject(item.option_class, self.db)
self.book_model.add(data) self.book_model.add(data)
self.book.append_item(item) self.book.append_item(item)

View File

@ -41,7 +41,8 @@ class AttributesGramplet(Gramplet):
def main(self): # return false finishes def main(self): # return false finishes
self.set_text("") self.set_text("")
active_person = self.dbstate.get_active_person() active_handle = self.get_active('Person')
active_person = self.dbstate.db.get_person_from_handle(active_handle)
if not active_person: if not active_person:
return return
name = name_displayer.display(active_person) name = name_displayer.display(active_person)

View File

@ -57,11 +57,12 @@ class DescendantGramplet(Gramplet):
self.update() self.update()
def main(self): def main(self):
if self.dbstate.get_active_person() is None: active_handle = self.get_active('Person')
if not active_handle:
self.set_text(_("No Active Person selected.")) self.set_text(_("No Active Person selected."))
return return
self.set_text("") self.set_text("")
self.center_person = self.dbstate.get_active_person() self.center_person = self.dbstate.db.get_person_from_handle(active_handle)
name = name_displayer.display(self.center_person) name = name_displayer.display(self.center_person)
title = _("Descendants of %s") % name title = _("Descendants of %s") % name
self.append_text(title) self.append_text(title)

View File

@ -613,7 +613,8 @@ class FanChartGramplet(Gramplet):
data. data.
""" """
self.gui.fan.reset_generations() self.gui.fan.reset_generations()
person = self.dbstate.get_active_person() active_handle = self.get_active('Person')
person = self.dbstate.db.get_person_from_handle(active_handle)
if not person: if not person:
name = None name = None
else: else:
@ -657,10 +658,10 @@ class FanChartGramplet(Gramplet):
parent += 1 parent += 1
self.gui.fan.queue_draw() self.gui.fan.queue_draw()
def on_childmenu_changed(self, obj,person_handle): def on_childmenu_changed(self, obj, person_handle):
"""Callback for the pulldown menu selection, changing to the person """Callback for the pulldown menu selection, changing to the person
attached with menu item.""" attached with menu item."""
self.dbstate.change_active_handle(person_handle) self.set_active('Person', person_handle)
return True return True
def edit_person_cb(self, obj,person_handle): def edit_person_cb(self, obj,person_handle):

View File

@ -229,7 +229,8 @@ class PedigreeGramplet(Gramplet):
self._boxes = [0] * (self.max_generations + 1) self._boxes = [0] * (self.max_generations + 1)
self._generations = {} self._generations = {}
self.gui.buffer.set_text("") self.gui.buffer.set_text("")
active_person = self.dbstate.get_active_person() active_handle = self.get_active('Person')
active_person = self.dbstate.db.get_person_from_handle(active_handle)
if not active_person: if not active_person:
return False return False
#no wrap in Gramplet #no wrap in Gramplet

View File

@ -53,12 +53,12 @@ class QuickViewGramplet(Gramplet):
qv_option = self.get_option(_("Quick Views")) qv_option = self.get_option(_("Quick Views"))
quick_view = qv_option.get_value() quick_view = qv_option.get_value()
if quick_type == CATEGORY_QR_PERSON: if quick_type == CATEGORY_QR_PERSON:
active = self.dbstate.get_active_person() active_handle = self.get_active('Person')
if active: if active_handle:
run_quick_report_by_name(self.gui.dbstate, run_quick_report_by_name(self.gui.dbstate,
self.gui.uistate, self.gui.uistate,
quick_view, quick_view,
active.handle, active_handle,
container=self.gui.textview) container=self.gui.textview)
else: else:
active_list = [] active_list = []

View File

@ -63,7 +63,8 @@ class RelativesGramplet(Gramplet):
""" """
self.set_text("") self.set_text("")
database = self.dbstate.db database = self.dbstate.db
active_person = self.dbstate.get_active_person() active_handle = self.get_active('Person')
active_person = self.dbstate.db.get_person_from_handle(active_handle)
if not active_person: if not active_person:
return return
name = name_displayer.display(active_person) name = name_displayer.display(active_person)

View File

@ -56,12 +56,14 @@ class DesBrowse(Tool.ActivePersonTool, ManagedWindow.ManagedWindow):
def __init__(self, dbstate, uistate, options_class, name, callback=None): def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.ActivePersonTool.__init__(self, dbstate, options_class, name) Tool.ActivePersonTool.__init__(self, dbstate, uistate, options_class,
name)
if self.fail: if self.fail:
return return
self.dbstate = dbstate self.dbstate = dbstate
self.active = dbstate.get_active_person() active_handle = uistate.get_active('Person')
self.active = dbstate.db.get_person_from_handle(active_handle)
self.callback = callback self.callback = callback
self.active_name = _("Descendant Browser: %s") \ self.active_name = _("Descendant Browser: %s") \
% name_displayer.display(self.active) % name_displayer.display(self.active)

View File

@ -63,12 +63,14 @@ WIKI_HELP_SEC = _('manual|Not_Related...')
class NotRelated(Tool.ActivePersonTool, ManagedWindow.ManagedWindow) : class NotRelated(Tool.ActivePersonTool, ManagedWindow.ManagedWindow) :
def __init__(self, dbstate, uistate, options_class, name, callback=None): def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.ActivePersonTool.__init__(self, dbstate, options_class, name) Tool.ActivePersonTool.__init__(self, dbstate, uistate, options_class,
name)
if self.fail: # bug #2709 -- fail if we have no active person if self.fail: # bug #2709 -- fail if we have no active person
return return
person = dbstate.get_active_person() person_handle = uistate.get_active('Person')
person = dbstate.db.get_person_from_handle(person_handle)
self.name = person.get_primary_name().get_regular_name() self.name = person.get_primary_name().get_regular_name()
self.title = _('Not related to "%s"') % self.name self.title = _('Not related to "%s"') % self.name
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__) ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)

View File

@ -46,7 +46,6 @@ import gtk
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gen.lib import gen.lib
from gui.views.navigationview import NAVIGATION_EVENT
from gui.views.listview import ListView from gui.views.listview import ListView
from gui.views.treemodels import EventModel from gui.views.treemodels import EventModel
import Utils import Utils
@ -83,7 +82,7 @@ class EventView(ListView):
FILTER_TYPE = "Event" FILTER_TYPE = "Event"
QR_CATEGORY = CATEGORY_QR_EVENT QR_CATEGORY = CATEGORY_QR_EVENT
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate, nav_group=0):
""" """
Create the Event View Create the Event View
""" """
@ -99,7 +98,7 @@ class EventView(ListView):
EventView.COLUMN_NAMES, len(EventView.COLUMN_NAMES), EventView.COLUMN_NAMES, len(EventView.COLUMN_NAMES),
EventModel, EventModel,
signal_map, dbstate.db.get_event_bookmarks(), signal_map, dbstate.db.get_event_bookmarks(),
Bookmarks.EventBookmarks, Bookmarks.EventBookmarks, nav_group,
multiple=True, multiple=True,
filter_class=EventSidebarFilter) filter_class=EventSidebarFilter)
@ -112,7 +111,7 @@ class EventView(ListView):
self.filter_toggle) self.filter_toggle)
def navigation_type(self): def navigation_type(self):
return NAVIGATION_EVENT return 'Event'
def column_ord_setfunc(self, clist): def column_ord_setfunc(self, clist):
self.dbstate.db.set_event_column_order(clist) self.dbstate.db.set_event_column_order(clist)
@ -153,6 +152,12 @@ class EventView(ListView):
<menuitem action="EditBook"/> <menuitem action="EditBook"/>
</placeholder> </placeholder>
</menu> </menu>
<menu action="GoMenu">
<placeholder name="CommonGo">
<menuitem action="Back"/>
<menuitem action="Forward"/>
</placeholder>
</menu>
<menu action="FileMenu"> <menu action="FileMenu">
<placeholder name="LocalExport"> <placeholder name="LocalExport">
<menuitem action="ExportTab"/> <menuitem action="ExportTab"/>
@ -169,6 +174,10 @@ class EventView(ListView):
</menu> </menu>
</menubar> </menubar>
<toolbar name="ToolBar"> <toolbar name="ToolBar">
<placeholder name="CommonNavigation">
<toolitem action="Back"/>
<toolitem action="Forward"/>
</placeholder>
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<toolitem action="Add"/> <toolitem action="Add"/>
<toolitem action="Edit"/> <toolitem action="Edit"/>
@ -176,6 +185,9 @@ class EventView(ListView):
</placeholder> </placeholder>
</toolbar> </toolbar>
<popup name="Popup"> <popup name="Popup">
<menuitem action="Back"/>
<menuitem action="Forward"/>
<separator/>
<menuitem action="Add"/> <menuitem action="Add"/>
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>

View File

@ -44,7 +44,6 @@ import gtk
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gen.lib import gen.lib
from gui.views.navigationview import NAVIGATION_FAMILY
from gui.views.listview import ListView from gui.views.listview import ListView
from gui.views.treemodels import FamilyModel from gui.views.treemodels import FamilyModel
from gui.editors import EditFamily from gui.editors import EditFamily
@ -76,7 +75,7 @@ class FamilyView(ListView):
FILTER_TYPE = "Family" FILTER_TYPE = "Family"
QR_CATEGORY = CATEGORY_QR_FAMILY QR_CATEGORY = CATEGORY_QR_FAMILY
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate, nav_group=0):
signal_map = { signal_map = {
'family-add' : self.row_add, 'family-add' : self.row_add,
@ -90,7 +89,8 @@ class FamilyView(ListView):
FamilyView.COLUMN_NAMES, len(FamilyView.COLUMN_NAMES), FamilyView.COLUMN_NAMES, len(FamilyView.COLUMN_NAMES),
FamilyModel, FamilyModel,
signal_map, dbstate.db.get_family_bookmarks(), signal_map, dbstate.db.get_family_bookmarks(),
Bookmarks.FamilyBookmarks, filter_class=FamilySidebarFilter) Bookmarks.FamilyBookmarks, nav_group,
filter_class=FamilySidebarFilter)
self.func_list = { self.func_list = {
'<CONTROL>J' : self.jump, '<CONTROL>J' : self.jump,
@ -101,7 +101,7 @@ class FamilyView(ListView):
self.filter_toggle) self.filter_toggle)
def navigation_type(self): def navigation_type(self):
return NAVIGATION_FAMILY return 'Family'
def column_ord_setfunc(self, clist): def column_ord_setfunc(self, clist):
self.dbstate.db.set_family_list_column_order(clist) self.dbstate.db.set_family_list_column_order(clist)
@ -130,6 +130,12 @@ class FamilyView(ListView):
<menuitem action="ExportTab"/> <menuitem action="ExportTab"/>
</placeholder> </placeholder>
</menu> </menu>
<menu action="GoMenu">
<placeholder name="CommonGo">
<menuitem action="Back"/>
<menuitem action="Forward"/>
</placeholder>
</menu>
<menu action="EditMenu"> <menu action="EditMenu">
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<menuitem action="Add"/> <menuitem action="Add"/>
@ -147,6 +153,10 @@ class FamilyView(ListView):
</menu> </menu>
</menubar> </menubar>
<toolbar name="ToolBar"> <toolbar name="ToolBar">
<placeholder name="CommonNavigation">
<toolitem action="Back"/>
<toolitem action="Forward"/>
</placeholder>
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<toolitem action="Add"/> <toolitem action="Add"/>
<toolitem action="Edit"/> <toolitem action="Edit"/>
@ -154,6 +164,9 @@ class FamilyView(ListView):
</placeholder> </placeholder>
</toolbar> </toolbar>
<popup name="Popup"> <popup name="Popup">
<menuitem action="Back"/>
<menuitem action="Forward"/>
<separator/>
<menuitem action="Add"/> <menuitem action="Add"/>
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>

View File

@ -53,11 +53,11 @@ if gtk.pygtk_version < (2,3,93):
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gui.views.navigationview import NavigationView
from BasicUtils import name_displayer from BasicUtils import name_displayer
from Utils import (find_children, find_parents, find_witnessed_people) from Utils import (find_children, find_parents, find_witnessed_people)
from libformatting import FormattingHelper from libformatting import FormattingHelper
import gen.lib import gen.lib
from gui.views.navigationview import NavigationView
import Errors import Errors
import Bookmarks import Bookmarks
from gui.editors import EditPerson, EditFamily from gui.editors import EditPerson, EditFamily
@ -565,11 +565,12 @@ class FanChartView(NavigationView):
""" """
The Gramplet code that realizes the FanChartWidget. The Gramplet code that realizes the FanChartWidget.
""" """
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate, nav_group=0):
NavigationView.__init__(self, _('Fan Chart'), NavigationView.__init__(self, _('Fan Chart'),
dbstate, uistate, dbstate, uistate,
dbstate.db.get_bookmarks(), dbstate.db.get_bookmarks(),
Bookmarks.Bookmarks) Bookmarks.PersonBookmarks,
nav_group)
dbstate.connect('active-changed', self.active_changed) dbstate.connect('active-changed', self.active_changed)
self.dbstate = dbstate self.dbstate = dbstate
@ -577,6 +578,9 @@ class FanChartView(NavigationView):
self.generations = 9 self.generations = 9
self.format_helper = FormattingHelper(self.dbstate) self.format_helper = FormattingHelper(self.dbstate)
def navigation_type(self):
return 'Person'
def build_widget(self): def build_widget(self):
self.fan = FanChartWidget(self.generations, self.fan = FanChartWidget(self.generations,
context_popup_callback=self.on_popup) context_popup_callback=self.on_popup)
@ -618,6 +622,9 @@ class FanChartView(NavigationView):
def update(self): def update(self):
self.main() self.main()
def goto_handle(self, handle):
self.main()
def have_parents(self, person): def have_parents(self, person):
""" """
Returns True if a person has parents. Returns True if a person has parents.
@ -663,7 +670,7 @@ class FanChartView(NavigationView):
data. data.
""" """
self.fan.reset_generations() self.fan.reset_generations()
person = self.dbstate.get_active_person() person = self.dbstate.db.get_person_from_handle(self.get_active())
if not person: if not person:
name = None name = None
else: else:
@ -710,7 +717,7 @@ class FanChartView(NavigationView):
def on_childmenu_changed(self, obj,person_handle): def on_childmenu_changed(self, obj,person_handle):
"""Callback for the pulldown menu selection, changing to the person """Callback for the pulldown menu selection, changing to the person
attached with menu item.""" attached with menu item."""
self.dbstate.change_active_handle(person_handle) self.change_active(person_handle)
return True return True
def edit_person_cb(self, obj,person_handle): def edit_person_cb(self, obj,person_handle):

View File

@ -609,7 +609,7 @@ class GeoView(HtmlView):
self.width = gws.width self.width = gws.width
self.height = gws.height self.height = gws.height
self.header_size = self.box1.get_allocation().height + 8 self.header_size = self.box1.get_allocation().height + 8
if not self.dbstate.active: if not self.uistate.get_active('Person'):
return return
self.external_uri() self.external_uri()
@ -927,7 +927,7 @@ class GeoView(HtmlView):
""" """
Change the style of the map view Change the style of the map view
""" """
if not self.dbstate.active: if not self.uistate.get_active('Person'):
return return
self._geo_places() self._geo_places()
@ -935,7 +935,7 @@ class GeoView(HtmlView):
""" """
Here when the GeoView page is loaded Here when the GeoView page is loaded
""" """
if not self.dbstate.active: if not self.uistate.get_active('Person'):
return return
self._geo_places() self._geo_places()
@ -951,7 +951,7 @@ class GeoView(HtmlView):
Specifies the person places. Specifies the person places.
""" """
self.displaytype = "person" self.displaytype = "person"
if not self.dbstate.active: if not self.uistate.get_active('Person'):
return return
self._geo_places() self._geo_places()
@ -960,7 +960,7 @@ class GeoView(HtmlView):
Specifies the family places to display with mapstraction. Specifies the family places to display with mapstraction.
""" """
self.displaytype = "family" self.displaytype = "family"
if not self.dbstate.active: if not self.uistate.get_active('Person'):
return return
self._geo_places() self._geo_places()
@ -1795,9 +1795,8 @@ class GeoView(HtmlView):
self.minyear = 9999 self.minyear = 9999
self.maxyear = 0 self.maxyear = 0
self.center = True self.center = True
person = None person_handle = self.uistate.get_active('Person')
if dbstate.active: person = dbstate.db.get_person_from_handle(person_handle)
person = dbstate.active
if person is not None: if person is not None:
family_list = person.get_family_handle_list() family_list = person.get_family_handle_list()
if len(family_list) > 0: if len(family_list) > 0:
@ -1855,9 +1854,8 @@ class GeoView(HtmlView):
self.maxyear = 0 self.maxyear = 0
latitude = "" latitude = ""
longitude = "" longitude = ""
person = None person_handle = self.uistate.get_active('Person')
if dbstate.active: person = dbstate.db.get_person_from_handle(person_handle)
person = dbstate.active
self.center = True self.center = True
if person is not None: if person is not None:
# For each event, if we have a place, set a marker. # For each event, if we have a place, set a marker.

View File

@ -684,7 +684,7 @@ class GuiGramplet(object):
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass pass
elif event.type == gtk.gdk.BUTTON_PRESS: # single click elif event.type == gtk.gdk.BUTTON_PRESS: # single click
self.dbstate.change_active_person(person) self.uistate.set_active(handle, 'Person')
return True # handled event return True # handled event
elif event.button == 3: # right mouse elif event.button == 3: # right mouse
#FIXME: add a popup menu with options #FIXME: add a popup menu with options

View File

@ -47,7 +47,6 @@ import gtk
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gui.utils import open_file_with_default_application from gui.utils import open_file_with_default_application
from gui.views.navigationview import NAVIGATION_MEDIA
from gui.views.listview import ListView from gui.views.listview import ListView
from gui.views.treemodels import MediaModel from gui.views.treemodels import MediaModel
import ThumbNails import ThumbNails
@ -94,7 +93,7 @@ class MediaView(ListView):
_DND_TYPE = DdTargets.URI_LIST _DND_TYPE = DdTargets.URI_LIST
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate, nav_group=0):
signal_map = { signal_map = {
'media-add' : self.row_add, 'media-add' : self.row_add,
@ -108,7 +107,8 @@ class MediaView(ListView):
MediaView.COLUMN_NAMES, len(MediaView.COLUMN_NAMES), MediaView.COLUMN_NAMES, len(MediaView.COLUMN_NAMES),
MediaModel, MediaModel,
signal_map, dbstate.db.get_media_bookmarks(), signal_map, dbstate.db.get_media_bookmarks(),
Bookmarks.MediaBookmarks, filter_class=MediaSidebarFilter, Bookmarks.MediaBookmarks, nav_group,
filter_class=MediaSidebarFilter,
multiple=True) multiple=True)
self.func_list = { self.func_list = {
@ -120,7 +120,7 @@ class MediaView(ListView):
self.filter_toggle) self.filter_toggle)
def navigation_type(self): def navigation_type(self):
return NAVIGATION_MEDIA return 'Media'
def column_ord_setfunc(self, clist): def column_ord_setfunc(self, clist):
self.dbstate.db.set_media_column_order(clist) self.dbstate.db.set_media_column_order(clist)
@ -363,8 +363,18 @@ class MediaView(ListView):
<menuitem action="EditBook"/> <menuitem action="EditBook"/>
</placeholder> </placeholder>
</menu> </menu>
<menu action="GoMenu">
<placeholder name="CommonGo">
<menuitem action="Back"/>
<menuitem action="Forward"/>
</placeholder>
</menu>
</menubar> </menubar>
<toolbar name="ToolBar"> <toolbar name="ToolBar">
<placeholder name="CommonNavigation">
<toolitem action="Back"/>
<toolitem action="Forward"/>
</placeholder>
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<toolitem action="Add"/> <toolitem action="Add"/>
<toolitem action="Edit"/> <toolitem action="Edit"/>
@ -374,6 +384,9 @@ class MediaView(ListView):
<toolitem action="OpenMedia"/> <toolitem action="OpenMedia"/>
</toolbar> </toolbar>
<popup name="Popup"> <popup name="Popup">
<menuitem action="Back"/>
<menuitem action="Forward"/>
<separator/>
<menuitem action="OpenMedia"/> <menuitem action="OpenMedia"/>
<menuitem action="OpenContainingFolder"/> <menuitem action="OpenContainingFolder"/>
<separator/> <separator/>

View File

@ -44,7 +44,6 @@ import gtk
# gramps modules # gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gui.views.navigationview import NAVIGATION_NOTE
from gui.views.listview import ListView from gui.views.listview import ListView
from gui.views.treemodels import NoteModel from gui.views.treemodels import NoteModel
import Utils import Utils
@ -78,7 +77,7 @@ class NoteView(ListView):
FILTER_TYPE = "Note" FILTER_TYPE = "Note"
QR_CATEGORY = CATEGORY_QR_NOTE QR_CATEGORY = CATEGORY_QR_NOTE
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate, nav_group=0):
signal_map = { signal_map = {
'note-add' : self.row_add, 'note-add' : self.row_add,
@ -96,7 +95,7 @@ class NoteView(ListView):
self, _('Notes'), dbstate, uistate, NoteView.COLUMN_NAMES, self, _('Notes'), dbstate, uistate, NoteView.COLUMN_NAMES,
len(NoteView.COLUMN_NAMES), NoteModel, signal_map, len(NoteView.COLUMN_NAMES), NoteModel, signal_map,
dbstate.db.get_note_bookmarks(), dbstate.db.get_note_bookmarks(),
Bookmarks.NoteBookmarks, Bookmarks.NoteBookmarks, nav_group,
filter_class=NoteSidebarFilter, filter_class=NoteSidebarFilter,
multiple=True) multiple=True)
@ -104,7 +103,7 @@ class NoteView(ListView):
self.filter_toggle) self.filter_toggle)
def navigation_type(self): def navigation_type(self):
return NAVIGATION_NOTE return 'Note'
def column_ord_setfunc(self, clist): def column_ord_setfunc(self, clist):
self.dbstate.db.set_note_column_order(clist) self.dbstate.db.set_note_column_order(clist)
@ -150,6 +149,12 @@ class NoteView(ListView):
<menuitem action="EditBook"/> <menuitem action="EditBook"/>
</placeholder> </placeholder>
</menu> </menu>
<menu action="GoMenu">
<placeholder name="CommonGo">
<menuitem action="Back"/>
<menuitem action="Forward"/>
</placeholder>
</menu>
<menu action="EditMenu"> <menu action="EditMenu">
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<menuitem action="Add"/> <menuitem action="Add"/>
@ -161,6 +166,10 @@ class NoteView(ListView):
</menu> </menu>
</menubar> </menubar>
<toolbar name="ToolBar"> <toolbar name="ToolBar">
<placeholder name="CommonNavigation">
<toolitem action="Back"/>
<toolitem action="Forward"/>
</placeholder>
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<toolitem action="Add"/> <toolitem action="Add"/>
<toolitem action="Edit"/> <toolitem action="Edit"/>
@ -168,6 +177,9 @@ class NoteView(ListView):
</placeholder> </placeholder>
</toolbar> </toolbar>
<popup name="Popup"> <popup name="Popup">
<menuitem action="Back"/>
<menuitem action="Forward"/>
<separator/>
<menuitem action="Add"/> <menuitem action="Add"/>
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>

View File

@ -51,7 +51,7 @@ except:
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gen.lib import gen.lib
from gui.views.navigationview import NavigationView, NAVIGATION_PERSON from gui.views.navigationview import NavigationView
from BasicUtils import name_displayer from BasicUtils import name_displayer
from Utils import (media_path_full, probably_alive, find_children, from Utils import (media_path_full, probably_alive, find_children,
find_parents, find_witnessed_people) find_parents, find_witnessed_people)
@ -368,10 +368,11 @@ class PersonBoxWidget( gtk.DrawingArea, _PersonWidget_base):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class PedigreeView(NavigationView): class PedigreeView(NavigationView):
def __init__(self,dbstate,uistate): def __init__(self, dbstate, uistate, nav_group=0):
NavigationView.__init__(self, _('Pedigree'), dbstate, uistate, NavigationView.__init__(self, _('Pedigree'), dbstate, uistate,
dbstate.db.get_bookmarks(), dbstate.db.get_bookmarks(),
Bookmarks.Bookmarks) Bookmarks.PersonBookmarks,
nav_group)
self.func_list = { self.func_list = {
'<CONTROL>J' : self.jump, '<CONTROL>J' : self.jump,
} }
@ -521,11 +522,7 @@ class PedigreeView(NavigationView):
information. information.
""" """
try: try:
active = self.dbstate.get_active_person() self.rebuild_trees(self.get_active())
if active:
self.rebuild_trees(active.handle)
else:
self.rebuild_trees(None)
except AttributeError, msg: except AttributeError, msg:
RunDatabaseRepair(str(msg)) RunDatabaseRepair(str(msg))
@ -551,13 +548,16 @@ class PedigreeView(NavigationView):
self.build_tree() self.build_tree()
def navigation_type(self): def navigation_type(self):
return NAVIGATION_PERSON return 'Person'
def goto_handle(self, handle=None): def goto_handle(self, handle=None):
self.dirty = True self.dirty = True
if handle: if handle:
person = self.dbstate.db.get_person_from_handle(handle)
if person:
self.rebuild_trees(handle) self.rebuild_trees(handle)
self.handle_history(handle) else:
self.rebuild_trees(None)
else: else:
self.rebuild_trees(None) self.rebuild_trees(None)
self.uistate.modify_statusbar(self.dbstate) self.uistate.modify_statusbar(self.dbstate)
@ -571,10 +571,7 @@ class PedigreeView(NavigationView):
def person_rebuild(self,dummy=None): def person_rebuild(self,dummy=None):
self.format_helper.clear_cache() self.format_helper.clear_cache()
self.dirty = True self.dirty = True
if self.dbstate.active: self.rebuild_trees(self.get_active())
self.rebuild_trees(self.dbstate.active.handle)
else:
self.rebuild_trees(None)
def request_resize(self): def request_resize(self):
self.size_request_cb(self.notebook.parent,None,None) self.size_request_cb(self.notebook.parent,None,None)
@ -592,10 +589,11 @@ class PedigreeView(NavigationView):
else: else:
self.notebook.set_current_page(self.force_size-2) self.notebook.set_current_page(self.force_size-2)
def rebuild_trees(self,person_handle): def rebuild_trees(self, person_handle):
person = None person = None
if person_handle: if person_handle:
person = self.dbstate.db.get_person_from_handle( person_handle) person = self.dbstate.db.get_person_from_handle(person_handle)
self.dirty = False self.dirty = False
@ -1010,7 +1008,7 @@ class PedigreeView(NavigationView):
def home(self, obj): def home(self, obj):
defperson = self.dbstate.db.get_default_person() defperson = self.dbstate.db.get_default_person()
if defperson: if defperson:
self.dbstate.change_active_person(defperson) self.change_active(defperson.get_handle())
def edit_person_cb(self, obj,person_handle): def edit_person_cb(self, obj,person_handle):
person = self.dbstate.db.get_person_from_handle(person_handle) person = self.dbstate.db.get_person_from_handle(person_handle)
@ -1100,16 +1098,17 @@ class PedigreeView(NavigationView):
def on_show_child_menu(self, obj): def on_show_child_menu(self, obj):
"""User clicked button to move to child of active person""" """User clicked button to move to child of active person"""
if self.dbstate.active: person = self.dbstate.db.get_person_from_handle(self.get_active())
if person:
# Build and display the menu attached to the left pointing arrow # Build and display the menu attached to the left pointing arrow
# button. The menu consists of the children of the current root # button. The menu consists of the children of the current root
# person of the tree. Attach a child to each menu item. # person of the tree. Attach a child to each menu item.
childlist = find_children(self.dbstate.db,self.dbstate.active) childlist = find_children(self.dbstate.db, person)
if len(childlist) == 1: if len(childlist) == 1:
child = self.dbstate.db.get_person_from_handle(childlist[0]) child = self.dbstate.db.get_person_from_handle(childlist[0])
if child: if child:
self.dbstate.change_active_person(child) self.change_active(childlist[0])
elif len(childlist) > 1: elif len(childlist) > 1:
myMenu = gtk.Menu() myMenu = gtk.Menu()
for child_handle in childlist: for child_handle in childlist:
@ -1137,7 +1136,7 @@ class PedigreeView(NavigationView):
def on_childmenu_changed(self, obj,person_handle): def on_childmenu_changed(self, obj,person_handle):
"""Callback for the pulldown menu selection, changing to the person """Callback for the pulldown menu selection, changing to the person
attached with menu item.""" attached with menu item."""
self.dbstate.change_active_handle(person_handle) self.change_active(person_handle)
return True return True
def change_force_size_cb(self,event,data): def change_force_size_cb(self,event,data):
@ -1153,28 +1152,19 @@ class PedigreeView(NavigationView):
if self.tree_style != data: if self.tree_style != data:
self.dirty = True self.dirty = True
self.tree_style = data self.tree_style = data
if self.dbstate.active: self.rebuild_trees(self.get_active()) # Rebuild using new style
self.rebuild_trees(self.dbstate.active.handle) # Rebuild using new style
else:
self.rebuild_trees(None)
def change_show_images_cb(self,event): def change_show_images_cb(self,event):
self.show_images = not self.show_images self.show_images = not self.show_images
config.set('interface.pedview-show-images',self.show_images) config.set('interface.pedview-show-images',self.show_images)
self.dirty = True self.dirty = True
if self.dbstate.active: self.rebuild_trees(self.get_active()) # Rebuild using new style
self.rebuild_trees(self.dbstate.active.handle) # Rebuild using new style
else:
self.rebuild_trees(None)
def change_show_marriage_cb(self,event): def change_show_marriage_cb(self,event):
self.show_marriage_data = not self.show_marriage_data self.show_marriage_data = not self.show_marriage_data
config.set('interface.pedview-show-marriage', self.show_marriage_data) config.set('interface.pedview-show-marriage', self.show_marriage_data)
self.dirty = True self.dirty = True
if self.dbstate.active: self.rebuild_trees(self.get_active()) # Rebuild using new style
self.rebuild_trees(self.dbstate.active.handle) # Rebuild using new style
else:
self.rebuild_trees(None)
def find_tree(self,person,index,depth,lst,val=0): def find_tree(self,person,index,depth,lst,val=0):
"""Recursively build a list of ancestors""" """Recursively build a list of ancestors"""

View File

@ -52,8 +52,7 @@ except:
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gen.lib import gen.lib
import gui.views.pageview as PageView from gui.views.navigationview import NavigationView
from gui.views.navigationview import NavigationView, NAVIGATION_PERSON
from BasicUtils import name_displayer from BasicUtils import name_displayer
from Utils import (media_path_full, probably_alive, find_children, from Utils import (media_path_full, probably_alive, find_children,
find_parents, find_witnessed_people) find_parents, find_witnessed_people)
@ -482,10 +481,11 @@ class PedigreeViewExt(NavigationView):
Displays the ancestors of a selected individual. Displays the ancestors of a selected individual.
""" """
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate, nav_group=0):
NavigationView.__init__(self, _('Pedigree'), dbstate, uistate, NavigationView.__init__(self, _('Pedigree'), dbstate, uistate,
dbstate.db.get_bookmarks(), dbstate.db.get_bookmarks(),
Bookmarks.Bookmarks) Bookmarks.PersonBookmarks,
nav_group)
self.func_list = { self.func_list = {
'F2' : self.kb_goto_home, 'F2' : self.kb_goto_home,
@ -647,9 +647,9 @@ class PedigreeViewExt(NavigationView):
information. information.
""" """
try: try:
active = self.dbstate.get_active_person() active = self.get_active()
if active: if active:
self.rebuild_trees(active.handle) self.rebuild_trees(active)
else: else:
self.rebuild_trees(None) self.rebuild_trees(None)
except AttributeError, msg: except AttributeError, msg:
@ -677,14 +677,16 @@ class PedigreeViewExt(NavigationView):
self.build_tree() self.build_tree()
def navigation_type(self): def navigation_type(self):
return NAVIGATION_PERSON return 'Person'
def goto_handle(self, handle=None): def goto_handle(self, handle=None):
"""Callback function for change active person in other GRAMPS page."""
self.dirty = True self.dirty = True
if handle: if handle:
person = self.dbstate.db.get_person_from_handle(handle)
if person:
self.rebuild_trees(handle) self.rebuild_trees(handle)
self.handle_history(handle) else:
self.rebuild_trees(None)
else: else:
self.rebuild_trees(None) self.rebuild_trees(None)
self.uistate.modify_statusbar(self.dbstate) self.uistate.modify_statusbar(self.dbstate)
@ -699,23 +701,19 @@ class PedigreeViewExt(NavigationView):
"""Callback function for signals of change database.""" """Callback function for signals of change database."""
self.format_helper.clear_cache() self.format_helper.clear_cache()
self.dirty = True self.dirty = True
if self.dbstate.active: self.rebuild_trees(self.get_active())
self.rebuild_trees(self.dbstate.active.handle)
else:
self.rebuild_trees(None)
def rebuild_trees(self, person_handle): def rebuild_trees(self, person_handle):
""" """
Rebild tree with root person_handle. Rebild tree with root person_handle.
Called from many fuctions, when need full redraw tree. Called from many fuctions, when need full redraw tree.
""" """
self.dirty = False
person = None person = None
if person_handle: if person_handle:
person = self.dbstate.db.get_person_from_handle(person_handle) person = self.dbstate.db.get_person_from_handle(person_handle)
self.dirty = False
if self.tree_style != 2 and \ if self.tree_style != 2 and \
(self.force_size > 5 or self.force_size == 0): (self.force_size > 5 or self.force_size == 0):
self.force_size = 5 self.force_size = 5
@ -1515,7 +1513,7 @@ class PedigreeViewExt(NavigationView):
"""Change root person to default person for database.""" """Change root person to default person for database."""
defperson = self.dbstate.db.get_default_person() defperson = self.dbstate.db.get_default_person()
if defperson: if defperson:
self.dbstate.change_active_person(defperson) self.change_active(defperson.get_handle())
def edit_person_cb(self, obj, person_handle): def edit_person_cb(self, obj, person_handle):
""" """
@ -1696,16 +1694,17 @@ class PedigreeViewExt(NavigationView):
def on_show_child_menu(self, obj): def on_show_child_menu(self, obj):
"""User clicked button to move to child of active person""" """User clicked button to move to child of active person"""
if self.dbstate.active: person = self.dbstate.db.get_person_from_handle(self.get_active())
if person:
# Build and display the menu attached to the left pointing arrow # Build and display the menu attached to the left pointing arrow
# button. The menu consists of the children of the current root # button. The menu consists of the children of the current root
# person of the tree. Attach a child to each menu item. # person of the tree. Attach a child to each menu item.
childlist = find_children(self.dbstate.db, self.dbstate.active) childlist = find_children(self.dbstate.db, person)
if len(childlist) == 1: if len(childlist) == 1:
child = self.dbstate.db.get_person_from_handle(childlist[0]) child = self.dbstate.db.get_person_from_handle(childlist[0])
if child: if child:
self.dbstate.change_active_person(child) self.change_active(childlist[0])
elif len(childlist) > 1: elif len(childlist) > 1:
myMenu = gtk.Menu() myMenu = gtk.Menu()
for child_handle in childlist: for child_handle in childlist:
@ -1737,7 +1736,7 @@ class PedigreeViewExt(NavigationView):
Callback for the pulldown menu selection, changing to the person Callback for the pulldown menu selection, changing to the person
attached with menu item. attached with menu item.
""" """
self.dbstate.change_active_handle(person_handle) self.change_active(person_handle)
return True return True
def change_force_size_cb(self, menuitem, data): def change_force_size_cb(self, menuitem, data):
@ -1747,7 +1746,7 @@ class PedigreeViewExt(NavigationView):
self.force_size = data self.force_size = data
self.dirty = True self.dirty = True
# switch to matching size # switch to matching size
self.rebuild_trees(self.dbstate.active.handle) self.rebuild_trees(self.get_active())
def change_tree_style_cb(self, menuitem, data): def change_tree_style_cb(self, menuitem, data):
"""Change tree_style option.""" """Change tree_style option."""
@ -1758,11 +1757,7 @@ class PedigreeViewExt(NavigationView):
self.force_size = 5 self.force_size = 5
self.dirty = True self.dirty = True
self.tree_style = data self.tree_style = data
if self.dbstate.active: self.rebuild_trees(self.get_active())
# Rebuild using new style
self.rebuild_trees(self.dbstate.active.handle)
else:
self.rebuild_trees(None)
def change_tree_direction_cb(self, menuitem, data): def change_tree_direction_cb(self, menuitem, data):
"""Change tree_direction option.""" """Change tree_direction option."""
@ -1771,22 +1766,14 @@ class PedigreeViewExt(NavigationView):
if self.tree_direction != data: if self.tree_direction != data:
self.dirty = True self.dirty = True
self.tree_direction = data self.tree_direction = data
if self.dbstate.active: self.rebuild_trees(self.get_active())
# Rebuild using new tree direction
self.rebuild_trees(self.dbstate.active.handle)
else:
self.rebuild_trees(None)
def change_show_images_cb(self, event): def change_show_images_cb(self, event):
"""Change show_images option.""" """Change show_images option."""
self.show_images = not self.show_images self.show_images = not self.show_images
config.set('interface.pedviewext-show-images', self.show_images) config.set('interface.pedviewext-show-images', self.show_images)
self.dirty = True self.dirty = True
if self.dbstate.active: self.rebuild_trees(self.get_active())
# Rebuild using new style
self.rebuild_trees(self.dbstate.active.handle)
else:
self.rebuild_trees(None)
def change_show_marriage_cb(self, event): def change_show_marriage_cb(self, event):
"""Change show_marriage_data option.""" """Change show_marriage_data option."""
@ -1794,11 +1781,7 @@ class PedigreeViewExt(NavigationView):
config.set('interface.pedviewext-show-marriage', config.set('interface.pedviewext-show-marriage',
self.show_marriage_data) self.show_marriage_data)
self.dirty = True self.dirty = True
if self.dbstate.active: self.rebuild_trees(self.get_active())
# Rebuild using new style
self.rebuild_trees(self.dbstate.active.handle)
else:
self.rebuild_trees(None)
def change_show_unknown_peoples_cb(self, event): def change_show_unknown_peoples_cb(self, event):
"""Change show_unknown_peoples option.""" """Change show_unknown_peoples option."""
@ -1806,11 +1789,7 @@ class PedigreeViewExt(NavigationView):
config.set('interface.pedviewext-show-unknown-peoples', config.set('interface.pedviewext-show-unknown-peoples',
self.show_unknown_peoples) self.show_unknown_peoples)
self.dirty = True self.dirty = True
if self.dbstate.active: self.rebuild_trees(self.get_active())
# Rebuild using new style
self.rebuild_trees(self.dbstate.active.handle)
else:
self.rebuild_trees(None)
def change_scroll_direction_cb(self, menuitem, data): def change_scroll_direction_cb(self, menuitem, data):
"""Change scroll_direction option.""" """Change scroll_direction option."""
@ -1898,7 +1877,8 @@ class PedigreeViewExt(NavigationView):
to the context menu. Used by both build_nav_menu() and to the context menu. Used by both build_nav_menu() and
build_full_nav_menu() methods. build_full_nav_menu() methods.
""" """
hobj = self.uistate.phistory hobj = self.uistate.get_history(self.navigation_type(),
self.get_group())
home_sensitivity = True home_sensitivity = True
if not self.dbstate.db.get_default_person(): if not self.dbstate.db.get_default_person():
home_sensitivity = False home_sensitivity = False

View File

@ -46,7 +46,6 @@ _LOG = logging.getLogger(".gui.personview")
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gen.lib import gen.lib
from gui.views.navigationview import NAVIGATION_PERSON
from gui.views.listview import ListView, LISTTREE from gui.views.listview import ListView, LISTTREE
from gui.views.treemodels import PeopleModel from gui.views.treemodels import PeopleModel
import Utils import Utils
@ -94,7 +93,7 @@ class PersonView(ListView):
FILTER_TYPE = "Person" FILTER_TYPE = "Person"
QR_CATEGORY = CATEGORY_QR_PERSON QR_CATEGORY = CATEGORY_QR_PERSON
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate, nav_group=0):
""" """
Create the Person View Create the Person View
""" """
@ -110,7 +109,7 @@ class PersonView(ListView):
PersonView.COLUMN_NAMES, len(PersonView.COLUMN_NAMES), PersonView.COLUMN_NAMES, len(PersonView.COLUMN_NAMES),
PeopleModel, PeopleModel,
signal_map, dbstate.db.get_bookmarks(), signal_map, dbstate.db.get_bookmarks(),
Bookmarks.Bookmarks, Bookmarks.PersonBookmarks, nav_group,
multiple=True, multiple=True,
filter_class=PersonSidebarFilter, filter_class=PersonSidebarFilter,
markup=True) markup=True)
@ -132,7 +131,7 @@ class PersonView(ListView):
self.dbstate.db.set_person_column_order(clist) self.dbstate.db.set_person_column_order(clist)
def navigation_type(self): def navigation_type(self):
return NAVIGATION_PERSON return 'Person'
def get_bookmarks(self): def get_bookmarks(self):
""" """
@ -332,7 +331,9 @@ class PersonView(ListView):
self.dbstate.db.transaction_commit(trans, active_name) self.dbstate.db.transaction_commit(trans, active_name)
# select the previously active person, turn off the busy cursor # select the previously active person, turn off the busy cursor
self.uistate.phistory.back() history = self.uistate.get_history(self.navigation_type(),
self.get_group())
self.uistate.history.back()
self.uistate.set_busy_cursor(False) self.uistate.set_busy_cursor(False)
def remove_from_person_list(self, person): def remove_from_person_list(self, person):

View File

@ -54,7 +54,8 @@ class PlaceTreeView(PlaceBaseView):
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate):
PlaceBaseView.__init__(self, dbstate, uistate, PlaceBaseView.__init__(self, dbstate, uistate,
_('Tree'), PlaceTreeModel) _('Tree'), PlaceTreeModel,
nav_group=0)
def type_list(self): def type_list(self):
""" """

View File

@ -48,4 +48,6 @@ class PlaceView(PlaceBaseView):
Flat place view. (Original code in PlaceBaseView). Flat place view. (Original code in PlaceBaseView).
""" """
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate):
PlaceBaseView.__init__(self, dbstate, uistate, _('Places'), PlaceModel) PlaceBaseView.__init__(self, dbstate, uistate,
_('Places'), PlaceModel,
nav_group=0)

View File

@ -47,8 +47,8 @@ import pango
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gen.lib import gen.lib
from gui.views.navigationview import NavigationView
from gui.editors import EditPerson, EditFamily from gui.editors import EditPerson, EditFamily
from gui.views.navigationview import NavigationView, NAVIGATION_PERSON
from BasicUtils import name_displayer from BasicUtils import name_displayer
from Utils import media_path_full, probably_alive from Utils import media_path_full, probably_alive
import DateHandler import DateHandler
@ -115,11 +115,12 @@ class AttachList(object):
class RelationshipView(NavigationView): class RelationshipView(NavigationView):
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate, nav_group=0):
NavigationView.__init__(self, _('Relationships'), NavigationView.__init__(self, _('Relationships'),
dbstate, uistate, dbstate, uistate,
dbstate.db.get_bookmarks(), dbstate.db.get_bookmarks(),
Bookmarks.Bookmarks) Bookmarks.PersonBookmarks,
nav_group)
self.func_list = { self.func_list = {
'<CONTROL>J' : self.jump, '<CONTROL>J' : self.jump,
@ -163,7 +164,7 @@ class RelationshipView(NavigationView):
self.callman.add_db_signal('person-delete', self.redraw) self.callman.add_db_signal('person-delete', self.redraw)
def navigation_type(self): def navigation_type(self):
return NAVIGATION_PERSON return 'Person'
def goto_handle(self, handle): def goto_handle(self, handle):
self.redraw() self.redraw()
@ -181,8 +182,9 @@ class RelationshipView(NavigationView):
self.redraw() self.redraw()
def person_update(self, handle_list): def person_update(self, handle_list):
if self.dbstate.active: person = self.get_active()
while not self.change_person(self.dbstate.active.handle): if person:
while not self.change_person(person):
pass pass
else: else:
self.change_person(None) self.change_person(None)
@ -191,36 +193,41 @@ class RelationshipView(NavigationView):
"""Large change to person database""" """Large change to person database"""
if self.active: if self.active:
self.bookmarks.redraw() self.bookmarks.redraw()
if self.dbstate.active: person = self.get_active()
while not self.change_person(self.dbstate.active.handle): if person:
while not self.change_person(person):
pass pass
else: else:
self.change_person(None) self.change_person(None)
def family_update(self, handle_list): def family_update(self, handle_list):
if self.dbstate.active: person = self.get_active()
while not self.change_person(self.dbstate.active.handle): if person:
while not self.change_person(person):
pass pass
else: else:
self.change_person(None) self.change_person(None)
def family_add(self, handle_list): def family_add(self, handle_list):
if self.dbstate.active: person = self.get_active()
while not self.change_person(self.dbstate.active.handle): if person:
while not self.change_person(person):
pass pass
else: else:
self.change_person(None) self.change_person(None)
def family_delete(self, handle_list): def family_delete(self, handle_list):
if self.dbstate.active: person = self.get_active()
while not self.change_person(self.dbstate.active.handle): if person:
while not self.change_person(person):
pass pass
else: else:
self.change_person(None) self.change_person(None)
def family_rebuild(self): def family_rebuild(self):
if self.dbstate.active: person = self.get_active()
while not self.change_person(self.dbstate.active.handle): if person:
while not self.change_person(person):
pass pass
else: else:
self.change_person(None) self.change_person(None)
@ -387,12 +394,12 @@ class RelationshipView(NavigationView):
def siblings_toggle(self, obj): def siblings_toggle(self, obj):
self.show_siblings = obj.get_active() self.show_siblings = obj.get_active()
self.change_person(self.dbstate.active.handle) self.change_person(self.get_active())
config.set('preferences.family-siblings', self.show_siblings) config.set('preferences.family-siblings', self.show_siblings)
def details_toggle(self, obj): def details_toggle(self, obj):
self.show_details = obj.get_active() self.show_details = obj.get_active()
self.change_person(self.dbstate.active.handle) self.change_person(self.get_active())
config.set('preferences.family-details', self.show_details) config.set('preferences.family-details', self.show_details)
def change_db(self, db): def change_db(self, db):
@ -422,9 +429,9 @@ class RelationshipView(NavigationView):
return (_(u"Unknown"), "") return (_(u"Unknown"), "")
def redraw(self, *obj): def redraw(self, *obj):
if self.dbstate.active: active_person = self.get_active()
self.handle_history(self.dbstate.active.handle) if active_person:
self.change_person(self.dbstate.active.handle) self.change_person(active_person)
else: else:
self.change_person(None) self.change_person(None)
@ -812,7 +819,7 @@ class RelationshipView(NavigationView):
# don't show rest # don't show rest
self.write_label("%s:" % _('Parents'), family, True, person) self.write_label("%s:" % _('Parents'), family, True, person)
self.row -= 1 # back up one row for summary names self.row -= 1 # back up one row for summary names
active = self.dbstate.active.handle active = self.ui.get_active()
child_list = [ref.ref for ref in family.get_child_ref_list() child_list = [ref.ref for ref in family.get_child_ref_list()
if ref.ref != active] if ref.ref != active]
if child_list: if child_list:
@ -849,7 +856,7 @@ class RelationshipView(NavigationView):
self.write_person(_('Mother'), family.get_mother_handle()) self.write_person(_('Mother'), family.get_mother_handle())
if self.show_siblings: if self.show_siblings:
active = self.dbstate.active.handle active = self.get_active()
hbox = gtk.HBox() hbox = gtk.HBox()
if self.check_collapsed(person.handle, "SIBLINGS"): if self.check_collapsed(person.handle, "SIBLINGS"):
arrow = widgets.ExpandCollapseArrow(True, arrow = widgets.ExpandCollapseArrow(True,
@ -1181,7 +1188,7 @@ class RelationshipView(NavigationView):
def _button_press(self, obj, event, handle): def _button_press(self, obj, event, handle):
if button_activated(event, _LEFT_BUTTON): if button_activated(event, _LEFT_BUTTON):
self.dbstate.change_active_handle(handle) self.change_active(handle)
elif button_activated(event, _RIGHT_BUTTON): elif button_activated(event, _RIGHT_BUTTON):
myMenu = gtk.Menu() myMenu = gtk.Menu()
myMenu.append(self.build_menu_item(handle)) myMenu.append(self.build_menu_item(handle))
@ -1280,7 +1287,7 @@ class RelationshipView(NavigationView):
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
if self.dbstate.active.handle == father_handle: if self.get_active() == father_handle:
handle = mother_handle handle = mother_handle
else: else:
handle = father_handle handle = father_handle
@ -1410,7 +1417,7 @@ class RelationshipView(NavigationView):
def add_family(self, obj, event, handle): def add_family(self, obj, event, handle):
if button_activated(event, _LEFT_BUTTON): if button_activated(event, _LEFT_BUTTON):
family = gen.lib.Family() family = gen.lib.Family()
person = self.dbstate.active person = self.dbstate.db.get_person_from_handle(self.get_active())
if not person: if not person:
return return
@ -1426,7 +1433,7 @@ class RelationshipView(NavigationView):
def add_spouse(self, obj): def add_spouse(self, obj):
family = gen.lib.Family() family = gen.lib.Family()
person = self.dbstate.active person = self.dbstate.db.get_person_from_handle(self.get_active())
if not person: if not person:
return return
@ -1442,7 +1449,7 @@ class RelationshipView(NavigationView):
pass pass
def edit_active(self, obj): def edit_active(self, obj):
phandle = self.dbstate.get_active_person().handle phandle = self.get_active()
self.edit_person(obj, phandle) self.edit_person(obj, phandle)
def add_child_to_fam(self, obj, event, handle): def add_child_to_fam(self, obj, event, handle):
@ -1496,7 +1503,7 @@ class RelationshipView(NavigationView):
if button_activated(event, _LEFT_BUTTON): if button_activated(event, _LEFT_BUTTON):
SelectFamily = SelectorFactory('Family') SelectFamily = SelectorFactory('Family')
phandle = self.dbstate.get_active_person().handle phandle = self.get_active()
person = self.dbstate.db.get_person_from_handle(phandle) person = self.dbstate.db.get_person_from_handle(phandle)
skip = set(person.get_family_handle_list()) skip = set(person.get_family_handle_list())
@ -1504,15 +1511,14 @@ class RelationshipView(NavigationView):
family = dialog.run() family = dialog.run()
if family: if family:
active_handle = self.dbstate.active.handle child = self.dbstate.db.get_person_from_handle(self.get_active())
child = self.dbstate.db.get_person_from_handle(active_handle)
self.dbstate.db.add_child_to_family(family, child) self.dbstate.db.add_child_to_family(family, child)
def select_parents(self, obj): def select_parents(self, obj):
SelectFamily = SelectorFactory('Family') SelectFamily = SelectorFactory('Family')
phandle = self.dbstate.get_active_person().handle phandle = self.get_active()
person = self.dbstate.db.get_person_from_handle(phandle) person = self.dbstate.db.get_person_from_handle(phandle)
skip = set(person.get_family_handle_list()+ skip = set(person.get_family_handle_list()+
person.get_parent_family_handle_list()) person.get_parent_family_handle_list())
@ -1521,14 +1527,13 @@ class RelationshipView(NavigationView):
family = dialog.run() family = dialog.run()
if family: if family:
active_handle = self.dbstate.active.handle child = self.dbstate.db.get_person_from_handle(self.get_active())
child = self.dbstate.db.get_person_from_handle(active_handle)
self.dbstate.db.add_child_to_family(family, child) self.dbstate.db.add_child_to_family(family, child)
def add_parents(self, obj): def add_parents(self, obj):
family = gen.lib.Family() family = gen.lib.Family()
person = self.dbstate.active person = self.dbstate.db.get_person_from_handle(self.get_active())
if not person: if not person:
return return
@ -1545,7 +1550,7 @@ class RelationshipView(NavigationView):
def add_parent_family(self, obj, event, handle): def add_parent_family(self, obj, event, handle):
if button_activated(event, _LEFT_BUTTON): if button_activated(event, _LEFT_BUTTON):
family = gen.lib.Family() family = gen.lib.Family()
person = self.dbstate.active person = self.dbstate.db.get_person_from_handle(self.get_active())
ref = gen.lib.ChildRef() ref = gen.lib.ChildRef()
ref.ref = person.handle ref.ref = person.handle
@ -1558,27 +1563,25 @@ class RelationshipView(NavigationView):
def delete_family(self, obj, event, handle): def delete_family(self, obj, event, handle):
if button_activated(event, _LEFT_BUTTON): if button_activated(event, _LEFT_BUTTON):
self.dbstate.db.remove_parent_from_family(self.dbstate.active.handle, self.dbstate.db.remove_parent_from_family(self.get_active(), handle)
handle)
def delete_parent_family(self, obj, event, handle): def delete_parent_family(self, obj, event, handle):
if button_activated(event, _LEFT_BUTTON): if button_activated(event, _LEFT_BUTTON):
self.dbstate.db.remove_child_from_family(self.dbstate.active.handle, self.dbstate.db.remove_child_from_family(self.get_active(), handle)
handle)
def change_to(self, obj, handle): def change_to(self, obj, handle):
self.dbstate.change_active_handle(handle) self.change_active(handle)
def reorder_button_press(self, obj, event, handle): def reorder_button_press(self, obj, event, handle):
if button_activated(event, _LEFT_BUTTON): if button_activated(event, _LEFT_BUTTON):
self.reorder(obj) self.reorder(obj)
def reorder(self, obj, dumm1=None, dummy2=None): def reorder(self, obj, dumm1=None, dummy2=None):
if self.dbstate.active: if self.get_active():
try: try:
import Reorder import Reorder
Reorder.Reorder(self.dbstate, self.uistate, [], Reorder.Reorder(self.dbstate, self.uistate, [],
self.dbstate.active.handle) self.get_active())
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass pass

View File

@ -37,7 +37,6 @@ import gtk
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gen.lib import gen.lib
from gui.views.navigationview import NAVIGATION_REPOSITORY
from gui.views.listview import ListView from gui.views.listview import ListView
from gui.views.treemodels import RepositoryModel from gui.views.treemodels import RepositoryModel
import Bookmarks import Bookmarks
@ -85,7 +84,7 @@ class RepositoryView(ListView):
FILTER_TYPE = "Repository" FILTER_TYPE = "Repository"
QR_CATEGORY = CATEGORY_QR_REPOSITORY QR_CATEGORY = CATEGORY_QR_REPOSITORY
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate, nav_group=0):
signal_map = { signal_map = {
'repository-add' : self.row_add, 'repository-add' : self.row_add,
@ -104,14 +103,15 @@ class RepositoryView(ListView):
RepositoryView.COLUMN_NAMES, len(RepositoryView.COLUMN_NAMES), RepositoryView.COLUMN_NAMES, len(RepositoryView.COLUMN_NAMES),
RepositoryModel, signal_map, RepositoryModel, signal_map,
dbstate.db.get_repo_bookmarks(), dbstate.db.get_repo_bookmarks(),
Bookmarks.RepoBookmarks, multiple=True, Bookmarks.RepoBookmarks, nav_group,
multiple=True,
filter_class=RepoSidebarFilter) filter_class=RepoSidebarFilter)
config.connect("interface.filter", config.connect("interface.filter",
self.filter_toggle) self.filter_toggle)
def navigation_type(self): def navigation_type(self):
return NAVIGATION_REPOSITORY return 'Repository'
def column_ord_setfunc(self, clist): def column_ord_setfunc(self, clist):
self.dbstate.db.set_repository_column_order(clist) self.dbstate.db.set_repository_column_order(clist)
@ -163,6 +163,12 @@ class RepositoryView(ListView):
<menuitem action="EditBook"/> <menuitem action="EditBook"/>
</placeholder> </placeholder>
</menu> </menu>
<menu action="GoMenu">
<placeholder name="CommonGo">
<menuitem action="Back"/>
<menuitem action="Forward"/>
</placeholder>
</menu>
<menu action="EditMenu"> <menu action="EditMenu">
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<menuitem action="Add"/> <menuitem action="Add"/>
@ -174,6 +180,10 @@ class RepositoryView(ListView):
</menu> </menu>
</menubar> </menubar>
<toolbar name="ToolBar"> <toolbar name="ToolBar">
<placeholder name="CommonNavigation">
<toolitem action="Back"/>
<toolitem action="Forward"/>
</placeholder>
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<toolitem action="Add"/> <toolitem action="Add"/>
<toolitem action="Edit"/> <toolitem action="Edit"/>
@ -181,6 +191,9 @@ class RepositoryView(ListView):
</placeholder> </placeholder>
</toolbar> </toolbar>
<popup name="Popup"> <popup name="Popup">
<menuitem action="Back"/>
<menuitem action="Forward"/>
<separator/>
<menuitem action="Add"/> <menuitem action="Add"/>
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>

View File

@ -38,7 +38,6 @@ import gtk
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gen.lib import gen.lib
import config import config
from gui.views.navigationview import NAVIGATION_SOURCE
from gui.views.listview import ListView from gui.views.listview import ListView
from gui.views.treemodels import SourceModel from gui.views.treemodels import SourceModel
import Utils import Utils
@ -80,7 +79,7 @@ class SourceView(ListView):
FILTER_TYPE = "Source" FILTER_TYPE = "Source"
QR_CATEGORY = CATEGORY_QR_SOURCE QR_CATEGORY = CATEGORY_QR_SOURCE
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate, nav_group=0):
signal_map = { signal_map = {
'source-add' : self.row_add, 'source-add' : self.row_add,
@ -99,14 +98,15 @@ class SourceView(ListView):
SourceView.COLUMN_NAMES, len(SourceView.COLUMN_NAMES), SourceView.COLUMN_NAMES, len(SourceView.COLUMN_NAMES),
SourceModel, signal_map, SourceModel, signal_map,
dbstate.db.get_source_bookmarks(), dbstate.db.get_source_bookmarks(),
Bookmarks.SourceBookmarks, multiple=True, Bookmarks.SourceBookmarks, nav_group,
multiple=True,
filter_class=SourceSidebarFilter) filter_class=SourceSidebarFilter)
config.connect("interface.filter", config.connect("interface.filter",
self.filter_toggle) self.filter_toggle)
def navigation_type(self): def navigation_type(self):
return NAVIGATION_SOURCE return 'Source'
def column_ord_setfunc(self, clist): def column_ord_setfunc(self, clist):
self.dbstate.db.set_source_column_order(clist) self.dbstate.db.set_source_column_order(clist)
@ -158,6 +158,12 @@ class SourceView(ListView):
<menuitem action="EditBook"/> <menuitem action="EditBook"/>
</placeholder> </placeholder>
</menu> </menu>
<menu action="GoMenu">
<placeholder name="CommonGo">
<menuitem action="Back"/>
<menuitem action="Forward"/>
</placeholder>
</menu>
<menu action="EditMenu"> <menu action="EditMenu">
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<menuitem action="Add"/> <menuitem action="Add"/>
@ -172,6 +178,10 @@ class SourceView(ListView):
</menu> </menu>
</menubar> </menubar>
<toolbar name="ToolBar"> <toolbar name="ToolBar">
<placeholder name="CommonNavigation">
<toolitem action="Back"/>
<toolitem action="Forward"/>
</placeholder>
<placeholder name="CommonEdit"> <placeholder name="CommonEdit">
<toolitem action="Add"/> <toolitem action="Add"/>
<toolitem action="Edit"/> <toolitem action="Edit"/>
@ -179,6 +189,9 @@ class SourceView(ListView):
</placeholder> </placeholder>
</toolbar> </toolbar>
<popup name="Popup"> <popup name="Popup">
<menuitem action="Back"/>
<menuitem action="Forward"/>
<separator/>
<menuitem action="Add"/> <menuitem action="Add"/>
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>