6419b4ea14
* src/DisplayState.py: Rename from DbState, kepp only DisplayState class. * src/GrampsDbBase.py: Add DbState class. * src/MapView.py: Swap zoom_in and zoom_out to reflect reality; add place list with the ScrollableWindow, request size for the place list. * src/ViewManager.py: Use DisplayState.DisplayState. * src/gramps_main.py: Use GrampsDbBase.DbState; add docstring; svn: r5055
155 lines
4.8 KiB
Python
155 lines
4.8 KiB
Python
#
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
#
|
|
# Copyright (C) 2000-2005 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
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#-------------------------------------------------------------------------
|
|
#
|
|
# Standard python modules
|
|
#
|
|
#-------------------------------------------------------------------------
|
|
|
|
#-------------------------------------------------------------------------
|
|
#
|
|
# GNOME python modules
|
|
#
|
|
#-------------------------------------------------------------------------
|
|
import gobject
|
|
import gtk
|
|
|
|
#-------------------------------------------------------------------------
|
|
#
|
|
# GRAMPS modules
|
|
#
|
|
#-------------------------------------------------------------------------
|
|
import GrampsDbBase
|
|
import GrampsDBCallback
|
|
import GrampsKeys
|
|
import NameDisplay
|
|
|
|
class History(GrampsDBCallback.GrampsDBCallback):
|
|
|
|
__signals__ = {
|
|
'changed' : (list,),
|
|
'menu-changed' : (list,),
|
|
}
|
|
|
|
def __init__(self):
|
|
GrampsDBCallback.GrampsDBCallback.__init__(self)
|
|
self.history = []
|
|
self.mhistory = []
|
|
self.index = -1
|
|
self.lock = False
|
|
|
|
def clear(self):
|
|
self.history = []
|
|
self.mistory = []
|
|
self.index = -1
|
|
self.lock = False
|
|
|
|
def remove(self,person_handle,old_id=None):
|
|
"""Removes a person from the history list"""
|
|
if old_id:
|
|
del_id = old_id
|
|
else:
|
|
del_id = person_handle
|
|
|
|
hc = self.history.count(del_id)
|
|
for c in range(hc):
|
|
self.history.remove(del_id)
|
|
self.index -= 1
|
|
|
|
mhc = self.mhistory.count(del_id)
|
|
for c in range(mhc):
|
|
self.mhistory.remove(del_id)
|
|
self.emit('changed',(self.history,))
|
|
self.emit('menu-changed',(self.mhistory,))
|
|
|
|
def push(self,person_handle):
|
|
self.prune()
|
|
if len(self.history) == 0 or person_handle != self.history[-1]:
|
|
self.history.append(person_handle)
|
|
if person_handle not in self.mhistory:
|
|
self.mhistory.append(person_handle)
|
|
self.emit('menu-changed',(self.mhistory,))
|
|
self.index += 1
|
|
self.emit('changed',(self.history,))
|
|
|
|
def forward(self,step=1):
|
|
self.index += step
|
|
person_handle = self.history[self.index]
|
|
if person_handle not in self.mhistory:
|
|
self.mhistory.append(person_handle)
|
|
self.emit('menu-changed',(self.mhistory,))
|
|
return str(self.history[self.index])
|
|
|
|
def back(self,step=1):
|
|
self.index -= step
|
|
person_handle = self.history[self.index]
|
|
if person_handle not in self.mhistory:
|
|
self.mhistory.append(person_handle)
|
|
self.emit('menu-changed',(self.mhistory,))
|
|
return str(self.history[self.index])
|
|
|
|
def at_end(self):
|
|
return self.index+1 == len(self.history)
|
|
|
|
def at_front(self):
|
|
return self.index <= 0
|
|
|
|
def prune(self):
|
|
if not self.at_end():
|
|
self.history = self.history[0:self.index+1]
|
|
|
|
class DisplayState(GrampsDBCallback.GrampsDBCallback):
|
|
|
|
__signals__ = {
|
|
}
|
|
|
|
def __init__(self,window,status,uimanager,dbstate):
|
|
self.dbstate = dbstate
|
|
self.uimanager = uimanager
|
|
self.window = window
|
|
GrampsDBCallback.GrampsDBCallback.__init__(self)
|
|
self.status = status
|
|
self.status_id = status.get_context_id('GRAMPS')
|
|
self.phistory = History()
|
|
|
|
def modify_statusbar(self,active=None):
|
|
self.status.pop(self.status_id)
|
|
if self.dbstate.active == None:
|
|
self.status.push(self.status_id,"")
|
|
else:
|
|
if GrampsKeys.get_statusbar() <= 1:
|
|
pname = NameDisplay.displayer.display(self.dbstate.active)
|
|
name = "[%s] %s" % (self.dbstate.active.get_gramps_id(),pname)
|
|
else:
|
|
name = self.display_relationship()
|
|
self.status.push(self.status_id,name)
|
|
|
|
while gtk.events_pending():
|
|
gtk.main_iteration()
|
|
|
|
def status_text(self,text):
|
|
self.status.pop(self.status_id)
|
|
self.status.push(self.status_id,text)
|
|
while gtk.events_pending():
|
|
gtk.main_iteration()
|