2005-08-09 10:11:20 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-14 11:02:06 +05:30
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2008-05-19 00:54:28 +05:30
|
|
|
# Copyright (C) 2008 Brian G. Matherly
|
2010-01-11 00:49:33 +05:30
|
|
|
# Copyright (C) 2010 Nick Hall
|
2005-08-09 10:11:20 +05:30
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2007-09-17 00:15:57 +05:30
|
|
|
# This program is distributed in the hope that it will be useful,
|
2005-08-09 10:11:20 +05:30
|
|
|
# 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
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-12-16 03:20:14 +05:30
|
|
|
from cStringIO import StringIO
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import gettext as _
|
2009-05-06 20:14:22 +05:30
|
|
|
import os
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-03-05 10:15:44 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# set up logging
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import logging
|
2007-06-14 11:02:06 +05:30
|
|
|
_LOG = logging.getLogger(".DisplayState")
|
2006-03-05 10:15:44 +05:30
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-02-19 01:37:09 +05:30
|
|
|
import gtk
|
2005-08-09 10:11:20 +05:30
|
|
|
import gobject
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-01-07 03:55:41 +05:30
|
|
|
import gen.utils
|
2009-12-12 22:31:06 +05:30
|
|
|
from gui.utils import process_pending_events
|
2010-01-11 00:49:33 +05:30
|
|
|
from gui.views.navigationview import NavigationView
|
2009-10-08 06:42:51 +05:30
|
|
|
import config
|
2010-01-14 09:38:04 +05:30
|
|
|
from gen.display.name import displayer as name_displayer
|
2006-04-01 09:29:42 +05:30
|
|
|
import ManagedWindow
|
2009-10-25 19:22:29 +05:30
|
|
|
import Relationship
|
2009-05-15 01:45:59 +05:30
|
|
|
from glade import Glade
|
2010-01-11 00:49:33 +05:30
|
|
|
from Utils import navigation_label
|
2006-04-01 09:29:42 +05:30
|
|
|
|
|
|
|
DISABLED = -1
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2005-08-15 09:15:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# History manager
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-02-21 10:28:56 +05:30
|
|
|
class History(gen.utils.Callback):
|
2007-09-17 00:15:57 +05:30
|
|
|
""" History manages the objects of a certain type that have been viewed,
|
2007-09-09 03:36:30 +05:30
|
|
|
with ability to go back, or forward.
|
|
|
|
When accessing an object, it should be pushed on the History.
|
|
|
|
"""
|
2005-08-11 05:23:24 +05:30
|
|
|
|
|
|
|
__signals__ = {
|
2010-01-11 00:49:33 +05:30
|
|
|
'active-changed' : (str, ),
|
2010-01-13 21:29:36 +05:30
|
|
|
'mru-changed' : (list, )
|
2005-08-11 05:23:24 +05:30
|
|
|
}
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2010-03-02 21:19:27 +05:30
|
|
|
def __init__(self, dbstate, nav_type):
|
2008-02-21 10:28:56 +05:30
|
|
|
gen.utils.Callback.__init__(self)
|
2007-09-17 00:15:57 +05:30
|
|
|
self.clear()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2010-03-02 21:19:27 +05:30
|
|
|
dbstate.connect('database-changed', self.connect_signals)
|
|
|
|
self.signal_map = {}
|
|
|
|
self.signal_map[nav_type.lower() + '-delete'] = self.handles_removed
|
|
|
|
self.signal_map[nav_type.lower() + '-rebuild'] = self.history_changed
|
|
|
|
|
|
|
|
def connect_signals(self, dbstate):
|
|
|
|
"""
|
|
|
|
Connects database signals when the database has changed.
|
|
|
|
"""
|
|
|
|
for sig in self.signal_map:
|
|
|
|
dbstate.connect(sig, self.signal_map[sig])
|
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
def clear(self):
|
2007-09-17 00:15:57 +05:30
|
|
|
"""
|
2009-05-15 01:45:59 +05:30
|
|
|
Clears the history, resetting the values back to their defaults
|
2007-09-17 00:15:57 +05:30
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
self.history = []
|
2010-01-13 21:29:36 +05:30
|
|
|
self.mru = []
|
2005-08-09 10:11:20 +05:30
|
|
|
self.index = -1
|
|
|
|
self.lock = False
|
|
|
|
|
2007-09-17 00:15:57 +05:30
|
|
|
def remove(self, handle, old_id=None):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Remove a handle from the history list
|
2007-09-17 00:15:57 +05:30
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
if old_id:
|
|
|
|
del_id = old_id
|
|
|
|
else:
|
2007-09-17 00:15:57 +05:30
|
|
|
del_id = handle
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2007-05-21 09:14:18 +05:30
|
|
|
history_count = self.history.count(del_id)
|
|
|
|
for c in range(history_count):
|
2005-08-09 10:11:20 +05:30
|
|
|
self.history.remove(del_id)
|
|
|
|
self.index -= 1
|
|
|
|
|
2010-01-13 21:29:36 +05:30
|
|
|
mhc = self.mru.count(del_id)
|
2005-08-09 10:11:20 +05:30
|
|
|
for c in range(mhc):
|
2010-01-13 21:29:36 +05:30
|
|
|
self.mru.remove(del_id)
|
|
|
|
self.emit('mru-changed', (self.mru, ))
|
2010-01-11 00:49:33 +05:30
|
|
|
if self.history:
|
|
|
|
self.emit('active-changed', (self.history[self.index],))
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2007-09-17 00:15:57 +05:30
|
|
|
def push(self, handle):
|
|
|
|
"""
|
|
|
|
Pushes the handle on the history stack
|
|
|
|
"""
|
2005-08-10 19:58:16 +05:30
|
|
|
self.prune()
|
2007-09-17 00:15:57 +05:30
|
|
|
if len(self.history) == 0 or handle != self.history[-1]:
|
2010-01-11 00:49:33 +05:30
|
|
|
self.history.append(str(handle))
|
2010-01-13 21:29:36 +05:30
|
|
|
if handle in self.mru:
|
|
|
|
self.mru.remove(handle)
|
|
|
|
self.mru.append(handle)
|
|
|
|
self.emit('mru-changed', (self.mru, ))
|
2005-08-10 19:58:16 +05:30
|
|
|
self.index += 1
|
2010-01-11 00:49:33 +05:30
|
|
|
if self.history:
|
|
|
|
self.emit('active-changed', (self.history[self.index],))
|
|
|
|
|
2007-04-03 09:35:36 +05:30
|
|
|
def forward(self, step=1):
|
2007-09-17 00:15:57 +05:30
|
|
|
"""
|
|
|
|
Moves forward in the history list
|
|
|
|
"""
|
2005-08-10 19:58:16 +05:30
|
|
|
self.index += step
|
2007-09-17 00:15:57 +05:30
|
|
|
handle = self.history[self.index]
|
2010-01-13 21:29:36 +05:30
|
|
|
if handle in self.mru:
|
|
|
|
self.mru.remove(handle)
|
|
|
|
self.mru.append(handle)
|
|
|
|
self.emit('mru-changed', (self.mru, ))
|
2010-01-11 00:49:33 +05:30
|
|
|
if self.history:
|
|
|
|
self.emit('active-changed', (self.history[self.index],))
|
2005-08-10 19:58:16 +05:30
|
|
|
return str(self.history[self.index])
|
|
|
|
|
2007-04-03 09:35:36 +05:30
|
|
|
def back(self, step=1):
|
2007-09-17 00:15:57 +05:30
|
|
|
"""
|
|
|
|
Moves backward in the history list
|
|
|
|
"""
|
2005-08-10 19:58:16 +05:30
|
|
|
self.index -= step
|
2007-01-22 03:02:53 +05:30
|
|
|
try:
|
2007-09-17 00:15:57 +05:30
|
|
|
handle = self.history[self.index]
|
2010-01-13 21:29:36 +05:30
|
|
|
if handle in self.mru:
|
|
|
|
self.mru.remove(handle)
|
|
|
|
self.mru.append(handle)
|
|
|
|
self.emit('mru-changed', (self.mru, ))
|
2010-01-11 00:49:33 +05:30
|
|
|
if self.history:
|
|
|
|
self.emit('active-changed', (self.history[self.index],))
|
2007-01-22 03:02:53 +05:30
|
|
|
return str(self.history[self.index])
|
|
|
|
except IndexError:
|
|
|
|
return u""
|
2007-09-09 03:36:30 +05:30
|
|
|
|
|
|
|
def present(self):
|
2008-02-18 21:22:40 +05:30
|
|
|
"""
|
2007-09-17 00:15:57 +05:30
|
|
|
return the person handle that is now active in the history
|
2008-02-18 21:22:40 +05:30
|
|
|
"""
|
2007-09-09 03:36:30 +05:30
|
|
|
try :
|
|
|
|
if self.history :
|
|
|
|
return self.history[self.index]
|
|
|
|
else:
|
|
|
|
return u""
|
|
|
|
except IndexError:
|
|
|
|
return u""
|
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
def at_end(self):
|
2007-09-17 00:15:57 +05:30
|
|
|
"""
|
|
|
|
returns True if we are at the end of the history list
|
|
|
|
"""
|
2005-08-10 19:58:16 +05:30
|
|
|
return self.index+1 == len(self.history)
|
|
|
|
|
|
|
|
def at_front(self):
|
2007-09-17 00:15:57 +05:30
|
|
|
"""
|
|
|
|
returns True if we are at the front of the history list
|
|
|
|
"""
|
2005-08-11 22:49:03 +05:30
|
|
|
return self.index <= 0
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def prune(self):
|
2007-09-17 00:15:57 +05:30
|
|
|
"""
|
|
|
|
Truncates the history list at the current object.
|
|
|
|
"""
|
2005-08-10 19:58:16 +05:30
|
|
|
if not self.at_end():
|
|
|
|
self.history = self.history[0:self.index+1]
|
|
|
|
|
2010-03-02 21:19:27 +05:30
|
|
|
def handles_removed(self, handle_list):
|
|
|
|
"""
|
|
|
|
Called in response to an object-delete signal.
|
|
|
|
Removes a list of handles from the history.
|
|
|
|
"""
|
|
|
|
for handle in handle_list:
|
|
|
|
self.remove(handle)
|
|
|
|
|
|
|
|
def history_changed(self):
|
|
|
|
"""
|
|
|
|
Called in response to an object-rebuild signal.
|
|
|
|
Objects in the history list may have been deleted.
|
|
|
|
"""
|
|
|
|
self.clear()
|
|
|
|
self.emit('mru-changed', (self.mru, ))
|
|
|
|
|
2005-12-24 05:39:04 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Recent Docs Menu
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2007-06-14 11:02:06 +05:30
|
|
|
_RCT_TOP = '<ui><menubar name="MenuBar"><menu action="FileMenu"><menu action="OpenRecent">'
|
|
|
|
_RCT_BTM = '</menu></menu></menubar></ui>'
|
2005-12-24 05:39:04 +05:30
|
|
|
|
|
|
|
import RecentFiles
|
|
|
|
import os
|
|
|
|
|
2009-05-21 22:49:50 +05:30
|
|
|
class RecentDocsMenu(object):
|
2007-05-21 09:14:18 +05:30
|
|
|
def __init__(self, uistate, state, fileopen):
|
2005-12-24 05:39:04 +05:30
|
|
|
self.action_group = gtk.ActionGroup('RecentFiles')
|
|
|
|
self.active = DISABLED
|
2006-01-05 02:36:28 +05:30
|
|
|
self.uistate = uistate
|
|
|
|
self.uimanager = uistate.uimanager
|
2005-12-25 00:48:18 +05:30
|
|
|
self.fileopen = fileopen
|
|
|
|
self.state = state
|
|
|
|
|
2007-05-21 09:14:18 +05:30
|
|
|
def load(self, item):
|
2007-06-14 11:02:06 +05:30
|
|
|
filename = item.get_path()
|
2007-09-10 07:39:50 +05:30
|
|
|
self.fileopen(filename)
|
2005-12-24 05:39:04 +05:30
|
|
|
|
|
|
|
def build(self):
|
2007-05-21 09:14:18 +05:30
|
|
|
buf = StringIO()
|
2007-06-14 11:02:06 +05:30
|
|
|
buf.write(_RCT_TOP)
|
|
|
|
gramps_rf = RecentFiles.RecentFiles()
|
2005-12-24 05:39:04 +05:30
|
|
|
|
|
|
|
count = 0
|
|
|
|
|
|
|
|
if self.active != DISABLED:
|
|
|
|
self.uimanager.remove_ui(self.active)
|
|
|
|
self.uimanager.remove_action_group(self.action_group)
|
2007-10-15 01:14:58 +05:30
|
|
|
self.action_group = gtk.ActionGroup('RecentFiles')
|
2005-12-24 05:39:04 +05:30
|
|
|
self.active = DISABLED
|
|
|
|
|
|
|
|
actions = []
|
2005-12-25 09:31:47 +05:30
|
|
|
rfiles = gramps_rf.gramps_recent_files
|
|
|
|
rfiles.sort(by_time)
|
2006-11-27 08:54:39 +05:30
|
|
|
|
|
|
|
new_menu = gtk.Menu()
|
|
|
|
|
2005-12-25 09:31:47 +05:30
|
|
|
for item in rfiles:
|
2005-12-24 05:39:04 +05:30
|
|
|
try:
|
2007-06-14 11:02:06 +05:30
|
|
|
title = item.get_name().replace('_', '__')
|
|
|
|
filename = os.path.basename(item.get_path())
|
2005-12-24 05:39:04 +05:30
|
|
|
action_id = "RecentMenu%d" % count
|
2007-05-21 09:14:18 +05:30
|
|
|
buf.write('<menuitem action="%s"/>' % action_id)
|
2007-09-17 00:15:57 +05:30
|
|
|
actions.append((action_id, None, title, None, None,
|
2007-05-21 09:14:18 +05:30
|
|
|
make_callback(item, self.load)))
|
2007-06-14 11:02:06 +05:30
|
|
|
mitem = gtk.MenuItem(title)
|
2006-11-27 08:54:39 +05:30
|
|
|
mitem.connect('activate', make_callback(item, self.load))
|
|
|
|
mitem.show()
|
|
|
|
new_menu.append(mitem)
|
2005-12-24 05:39:04 +05:30
|
|
|
except RuntimeError:
|
|
|
|
pass # ignore no longer existing files
|
|
|
|
|
2007-05-21 09:14:18 +05:30
|
|
|
count += 1
|
2007-06-14 11:02:06 +05:30
|
|
|
buf.write(_RCT_BTM)
|
2005-12-24 05:39:04 +05:30
|
|
|
self.action_group.add_actions(actions)
|
2007-05-21 09:14:18 +05:30
|
|
|
self.uimanager.insert_action_group(self.action_group, 1)
|
|
|
|
self.active = self.uimanager.add_ui_from_string(buf.getvalue())
|
2006-04-27 03:45:22 +05:30
|
|
|
self.uimanager.ensure_update()
|
2007-05-21 09:14:18 +05:30
|
|
|
buf.close()
|
2005-12-24 05:39:04 +05:30
|
|
|
|
2008-01-24 03:28:09 +05:30
|
|
|
if len(rfiles) > 0:
|
|
|
|
new_menu.show()
|
|
|
|
self.uistate.set_open_recent_menu(new_menu)
|
2006-01-05 02:36:28 +05:30
|
|
|
|
2007-05-21 09:14:18 +05:30
|
|
|
def make_callback(val, func):
|
|
|
|
return lambda x: func(val)
|
2005-12-25 00:48:18 +05:30
|
|
|
|
2007-05-21 09:14:18 +05:30
|
|
|
def by_time(first, second):
|
|
|
|
return cmp(second.get_time(), first.get_time())
|
2005-12-25 09:31:47 +05:30
|
|
|
|
2005-08-15 09:15:16 +05:30
|
|
|
|
2006-01-24 03:18:34 +05:30
|
|
|
from GrampsLogger import RotateHandler
|
|
|
|
|
|
|
|
class WarnHandler(RotateHandler):
|
2007-05-21 09:14:18 +05:30
|
|
|
|
|
|
|
def __init__(self, capacity, button):
|
|
|
|
RotateHandler.__init__(self, capacity)
|
2006-01-24 03:18:34 +05:30
|
|
|
self.setLevel(logging.WARN)
|
|
|
|
self.button = button
|
|
|
|
button.on_clicked(self.display)
|
2006-01-24 04:06:34 +05:30
|
|
|
self.timer = None
|
2010-09-06 16:59:07 +05:30
|
|
|
self.last_line = '-1'
|
2006-01-24 03:18:34 +05:30
|
|
|
|
2007-05-21 09:14:18 +05:30
|
|
|
def emit(self, record):
|
2010-09-06 16:59:07 +05:30
|
|
|
if self.timer is None:
|
|
|
|
#check every 5 minutes if warn button can disappear
|
|
|
|
self.timer = gobject.timeout_add(300*1000, self._check_clear)
|
2007-05-21 09:14:18 +05:30
|
|
|
RotateHandler.emit(self, record)
|
2006-01-24 03:18:34 +05:30
|
|
|
self.button.show()
|
|
|
|
|
2010-09-06 16:59:07 +05:30
|
|
|
def _check_clear(self):
|
|
|
|
new_last_line = self.get_buffer()[-1]
|
|
|
|
if self.last_line == new_last_line:
|
|
|
|
#buffer has not changed for 3 minutes, let's clear it:
|
|
|
|
self._clear()
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
self.last_line = new_last_line
|
|
|
|
return True
|
|
|
|
|
2006-01-24 04:06:34 +05:30
|
|
|
def _clear(self):
|
|
|
|
self.button.hide()
|
|
|
|
self.set_capacity(self._capacity)
|
2010-09-06 16:59:07 +05:30
|
|
|
self.last_line = '-1'
|
2006-01-24 04:06:34 +05:30
|
|
|
self.timer = None
|
|
|
|
|
2007-05-21 09:14:18 +05:30
|
|
|
def display(self, obj):
|
2006-01-24 03:18:34 +05:30
|
|
|
obj.hide()
|
2009-05-15 01:45:59 +05:30
|
|
|
self.glade = Glade()
|
2009-07-29 23:09:58 +05:30
|
|
|
top = self.glade.toplevel
|
2009-05-15 01:45:59 +05:30
|
|
|
msg = self.glade.get_object('msg')
|
2006-01-24 03:18:34 +05:30
|
|
|
buf = msg.get_buffer()
|
|
|
|
for i in self.get_formatted_log():
|
|
|
|
buf.insert_at_cursor(i + '\n')
|
|
|
|
top.run()
|
2006-01-24 04:06:34 +05:30
|
|
|
top.destroy()
|
2006-01-24 03:18:34 +05:30
|
|
|
|
2008-02-21 10:28:56 +05:30
|
|
|
class DisplayState(gen.utils.Callback):
|
2005-08-11 05:23:24 +05:30
|
|
|
|
|
|
|
__signals__ = {
|
2007-09-17 00:15:57 +05:30
|
|
|
'filters-changed' : (str, ),
|
|
|
|
'filter-name-changed' : (str, unicode, unicode),
|
|
|
|
'nameformat-changed' : None,
|
2005-08-11 05:23:24 +05:30
|
|
|
}
|
2010-02-14 22:25:06 +05:30
|
|
|
|
|
|
|
#nav_type to message
|
|
|
|
NAV2MES = {
|
|
|
|
'Person': _("No active person"),
|
|
|
|
'Family': _("No active family"),
|
|
|
|
'Event': _("No active event"),
|
|
|
|
'Place': _("No active place"),
|
|
|
|
'Source': _("No active source"),
|
|
|
|
'Repository': _("No active repository"),
|
|
|
|
'Media': _("No active media"),
|
|
|
|
'Note': _("No active note"),
|
|
|
|
}
|
2005-08-11 05:23:24 +05:30
|
|
|
|
2007-02-18 01:29:21 +05:30
|
|
|
def __init__(self, window, status, progress, warnbtn, uimanager,
|
2008-02-15 19:48:55 +05:30
|
|
|
progress_monitor, viewmanager=None):
|
2007-01-16 11:24:40 +05:30
|
|
|
|
|
|
|
self.busy = False
|
2008-02-15 19:48:55 +05:30
|
|
|
self.viewmanager = viewmanager
|
2005-08-11 05:23:24 +05:30
|
|
|
self.uimanager = uimanager
|
2007-02-18 01:29:21 +05:30
|
|
|
self.progress_monitor = progress_monitor
|
2005-08-11 05:23:24 +05:30
|
|
|
self.window = window
|
2008-02-21 10:28:56 +05:30
|
|
|
gen.utils.Callback.__init__(self)
|
2005-08-11 05:23:24 +05:30
|
|
|
self.status = status
|
|
|
|
self.status_id = status.get_context_id('GRAMPS')
|
2006-03-01 11:46:36 +05:30
|
|
|
self.progress = progress
|
2010-01-11 00:49:33 +05:30
|
|
|
self.history_lookup = {}
|
2006-04-01 09:29:42 +05:30
|
|
|
self.gwm = ManagedWindow.GrampsWindowManager(uimanager)
|
2006-01-05 02:36:28 +05:30
|
|
|
self.widget = None
|
2007-11-22 04:45:10 +05:30
|
|
|
self.disprel_old = ''
|
|
|
|
self.disprel_defpers = None
|
|
|
|
self.disprel_active = None
|
2006-01-23 09:39:20 +05:30
|
|
|
self.warnbtn = warnbtn
|
2010-02-13 01:48:07 +05:30
|
|
|
self.last_bar = self.status.insert(min_width=35, ralign=True)
|
2007-10-26 04:45:28 +05:30
|
|
|
self.set_relationship_class()
|
2006-01-05 02:36:28 +05:30
|
|
|
|
2006-01-24 04:06:34 +05:30
|
|
|
formatter = logging.Formatter('%(levelname)s %(name)s: %(message)s')
|
2007-05-21 09:14:18 +05:30
|
|
|
self.rhandler = WarnHandler(capacity=400, button=warnbtn)
|
|
|
|
self.rhandler.setFormatter(formatter)
|
|
|
|
self.rhandler.setLevel(logging.WARNING)
|
2006-01-24 03:18:34 +05:30
|
|
|
self.log = logging.getLogger()
|
2007-05-21 09:14:18 +05:30
|
|
|
self.log.addHandler(self.rhandler)
|
2007-09-17 00:15:57 +05:30
|
|
|
# This call has been moved one level up,
|
In .:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* src/Filters/_SearchBar.py (SearchBar.__init__): Take dbstate as
a constructor argument; (SearchBar.apply_filter): pass dbstate.
* src/PageView.py (BookMarkView.add_bookmark,
PersonNavView.jumpto, PersonNavView.fwd_clicked,
PersonNavView.back_clicked, ListView.build_widget): Pass dbstate.
* src/Navigation.py (BaseNavigation.__init__,
PersonNavigation.__init__): Take dbstate as a constructor argument;
(PersonNavigation.build_item_name): properly access dbstate.
* src/DisplayState.py (__init__): Do not take dbstate as a
constructor argument; Do not connect dbstate signal here (moved to
ViewManager);
(display_relationship,push_message,modify_statusbar): Make dbstate
an argument.
* src/plugins/Checkpoint.py (run_tool): Pass dbstate.
* src/ViewManager.py (_build_main_window): Do not pass dbstate to
uistate DisplayState constructor; connect dbstate signal handler;
pass dbstate to Navigation; (keypress): Pass dbstate;
(statusbar_key_update): Pass dbstate;
(do_load_plugins): Pass dbstate;
(ViewManager.add_bookmark): Pass dbstate.
* src/DataViews/_RelationView.py (shade_update): Pass dbstate.
* src/DataViews/_PersonView.py (build_widget,_goto,
key_goto_home_person, key_edit_selected_person): Pass dbstate.
* src/Filters/Makefile.am (pkgdata_PYTHON): Remove obsolete file.
* src/Filters/__init__.py: Remove importing obsolete module.
* src/Filters/_FilterWidget.py: Remove obsolete module.
In po:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Remove obsolete file.
svn: r7104
2006-08-01 10:01:10 +05:30
|
|
|
# but this connection is still made!
|
|
|
|
# self.dbstate.connect('database-changed', self.db_changed)
|
2007-01-28 08:21:18 +05:30
|
|
|
|
2010-01-12 06:59:07 +05:30
|
|
|
def clear_history(self):
|
|
|
|
"""
|
|
|
|
Clear all history objects.
|
|
|
|
"""
|
|
|
|
for history in self.history_lookup.values():
|
|
|
|
history.clear()
|
|
|
|
|
2010-01-11 00:49:33 +05:30
|
|
|
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))
|
|
|
|
|
2010-03-02 21:19:27 +05:30
|
|
|
def register(self, dbstate, nav_type, nav_group):
|
2010-01-11 00:49:33 +05:30
|
|
|
"""
|
|
|
|
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:
|
2010-03-02 21:19:27 +05:30
|
|
|
history = History(dbstate, nav_type)
|
2010-01-11 00:49:33 +05:30
|
|
|
self.history_lookup[(nav_type, nav_group)] = history
|
|
|
|
|
|
|
|
def get_active(self, nav_type, nav_group=0):
|
|
|
|
"""
|
2010-09-06 16:59:07 +05:30
|
|
|
Return the handle for the active obejct specified by the given
|
2010-01-11 00:49:33 +05:30
|
|
|
navigation type and group.
|
|
|
|
"""
|
|
|
|
history = self.get_history(nav_type, nav_group)
|
2010-04-05 21:44:26 +05:30
|
|
|
return history.present() if history else None
|
2010-01-11 00:49:33 +05:30
|
|
|
|
|
|
|
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)
|
2010-05-02 19:16:23 +05:30
|
|
|
if history:
|
|
|
|
history.push(handle)
|
2010-01-11 00:49:33 +05:30
|
|
|
|
2007-01-28 08:21:18 +05:30
|
|
|
def set_sensitive(self, state):
|
|
|
|
self.window.set_sensitive(state)
|
2006-05-07 04:19:51 +05:30
|
|
|
|
|
|
|
def db_changed(self, db):
|
2007-02-18 01:29:21 +05:30
|
|
|
db.connect('long-op-start', self.progress_monitor.add_op)
|
2010-01-12 06:59:07 +05:30
|
|
|
self.clear_history()
|
2006-05-07 04:19:51 +05:30
|
|
|
|
2007-10-26 04:45:28 +05:30
|
|
|
def set_relationship_class(self):
|
|
|
|
"""method that rebinds the relationship to the current rel calc
|
|
|
|
Should be called after load or reload of plugins
|
|
|
|
"""
|
2009-10-25 19:22:29 +05:30
|
|
|
self.relationship = Relationship.get_relationship_calculator(reinit=True)
|
2007-11-22 21:43:10 +05:30
|
|
|
|
|
|
|
def set_gendepth(self, value):
|
|
|
|
""" Set the generations we search back for showing relationships
|
|
|
|
on GRAMPS interface. Value must be integer > 0
|
|
|
|
This method will be used by the preference editor when user changes
|
|
|
|
the generations.
|
|
|
|
"""
|
|
|
|
self.relationship.set_depth(value)
|
2007-10-26 04:45:28 +05:30
|
|
|
|
2010-01-11 00:49:33 +05:30
|
|
|
def display_relationship(self, dbstate, active_handle):
|
2008-02-18 21:22:40 +05:30
|
|
|
""" Construct the relationship in order to show it in the statusbar
|
2007-11-22 04:45:10 +05:30
|
|
|
This can be a time intensive calculation, so we only want to do
|
|
|
|
it if persons are different than before.
|
|
|
|
Eg: select a person, then double click, will result in calling
|
|
|
|
three times to construct build the statusbar. We only want
|
|
|
|
to obtain relationship once!
|
|
|
|
This means the relationship part of statusbar only changes on
|
|
|
|
change of row.
|
2008-02-18 21:22:40 +05:30
|
|
|
"""
|
2007-11-22 04:45:10 +05:30
|
|
|
self.relationship.connect_db_signals(dbstate)
|
In .:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* src/Filters/_SearchBar.py (SearchBar.__init__): Take dbstate as
a constructor argument; (SearchBar.apply_filter): pass dbstate.
* src/PageView.py (BookMarkView.add_bookmark,
PersonNavView.jumpto, PersonNavView.fwd_clicked,
PersonNavView.back_clicked, ListView.build_widget): Pass dbstate.
* src/Navigation.py (BaseNavigation.__init__,
PersonNavigation.__init__): Take dbstate as a constructor argument;
(PersonNavigation.build_item_name): properly access dbstate.
* src/DisplayState.py (__init__): Do not take dbstate as a
constructor argument; Do not connect dbstate signal here (moved to
ViewManager);
(display_relationship,push_message,modify_statusbar): Make dbstate
an argument.
* src/plugins/Checkpoint.py (run_tool): Pass dbstate.
* src/ViewManager.py (_build_main_window): Do not pass dbstate to
uistate DisplayState constructor; connect dbstate signal handler;
pass dbstate to Navigation; (keypress): Pass dbstate;
(statusbar_key_update): Pass dbstate;
(do_load_plugins): Pass dbstate;
(ViewManager.add_bookmark): Pass dbstate.
* src/DataViews/_RelationView.py (shade_update): Pass dbstate.
* src/DataViews/_PersonView.py (build_widget,_goto,
key_goto_home_person, key_edit_selected_person): Pass dbstate.
* src/Filters/Makefile.am (pkgdata_PYTHON): Remove obsolete file.
* src/Filters/__init__.py: Remove importing obsolete module.
* src/Filters/_FilterWidget.py: Remove obsolete module.
In po:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Remove obsolete file.
svn: r7104
2006-08-01 10:01:10 +05:30
|
|
|
default_person = dbstate.db.get_default_person()
|
2010-01-11 00:49:33 +05:30
|
|
|
if default_person is None or active_handle is None:
|
2006-05-07 04:19:51 +05:30
|
|
|
return u''
|
2007-11-22 04:45:10 +05:30
|
|
|
if default_person.handle == self.disprel_defpers and \
|
2010-01-11 00:49:33 +05:30
|
|
|
active_handle == self.disprel_active :
|
2007-11-22 04:45:10 +05:30
|
|
|
return self.disprel_old
|
2010-01-11 00:49:33 +05:30
|
|
|
|
|
|
|
active = dbstate.db.get_person_from_handle(active_handle)
|
2007-11-06 16:14:17 +05:30
|
|
|
name = self.relationship.get_one_relationship(
|
|
|
|
dbstate.db, default_person, active)
|
2007-11-22 04:45:10 +05:30
|
|
|
#store present call data
|
|
|
|
self.disprel_old = name
|
|
|
|
self.disprel_defpers = default_person.handle
|
2010-01-11 00:49:33 +05:30
|
|
|
self.disprel_active = active_handle
|
2006-05-07 04:19:51 +05:30
|
|
|
if name:
|
2007-11-06 16:14:17 +05:30
|
|
|
return name
|
2006-05-07 04:19:51 +05:30
|
|
|
else:
|
|
|
|
return u""
|
2006-01-24 03:18:34 +05:30
|
|
|
|
2007-05-21 09:14:18 +05:30
|
|
|
def set_busy_cursor(self, value):
|
2007-01-16 11:24:40 +05:30
|
|
|
if value == self.busy:
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
self.busy = value
|
2006-02-02 22:30:37 +05:30
|
|
|
if value:
|
|
|
|
self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
|
|
|
else:
|
|
|
|
self.window.window.set_cursor(None)
|
2009-12-12 22:31:06 +05:30
|
|
|
process_pending_events()
|
2006-02-02 22:30:37 +05:30
|
|
|
|
2007-05-21 09:14:18 +05:30
|
|
|
def set_open_widget(self, widget):
|
2006-01-05 02:36:28 +05:30
|
|
|
self.widget = widget
|
|
|
|
|
2007-05-21 09:14:18 +05:30
|
|
|
def set_open_recent_menu(self, menu):
|
2006-01-05 02:36:28 +05:30
|
|
|
self.widget.set_menu(menu)
|
2005-08-11 05:23:24 +05:30
|
|
|
|
In .:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* src/Filters/_SearchBar.py (SearchBar.__init__): Take dbstate as
a constructor argument; (SearchBar.apply_filter): pass dbstate.
* src/PageView.py (BookMarkView.add_bookmark,
PersonNavView.jumpto, PersonNavView.fwd_clicked,
PersonNavView.back_clicked, ListView.build_widget): Pass dbstate.
* src/Navigation.py (BaseNavigation.__init__,
PersonNavigation.__init__): Take dbstate as a constructor argument;
(PersonNavigation.build_item_name): properly access dbstate.
* src/DisplayState.py (__init__): Do not take dbstate as a
constructor argument; Do not connect dbstate signal here (moved to
ViewManager);
(display_relationship,push_message,modify_statusbar): Make dbstate
an argument.
* src/plugins/Checkpoint.py (run_tool): Pass dbstate.
* src/ViewManager.py (_build_main_window): Do not pass dbstate to
uistate DisplayState constructor; connect dbstate signal handler;
pass dbstate to Navigation; (keypress): Pass dbstate;
(statusbar_key_update): Pass dbstate;
(do_load_plugins): Pass dbstate;
(ViewManager.add_bookmark): Pass dbstate.
* src/DataViews/_RelationView.py (shade_update): Pass dbstate.
* src/DataViews/_PersonView.py (build_widget,_goto,
key_goto_home_person, key_edit_selected_person): Pass dbstate.
* src/Filters/Makefile.am (pkgdata_PYTHON): Remove obsolete file.
* src/Filters/__init__.py: Remove importing obsolete module.
* src/Filters/_FilterWidget.py: Remove obsolete module.
In po:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Remove obsolete file.
svn: r7104
2006-08-01 10:01:10 +05:30
|
|
|
def push_message(self, dbstate, text):
|
2005-12-23 11:05:32 +05:30
|
|
|
self.status_text(text)
|
2007-05-21 09:14:18 +05:30
|
|
|
gobject.timeout_add(5000, self.modify_statusbar, dbstate)
|
2005-12-23 11:05:32 +05:30
|
|
|
|
2007-04-02 04:07:10 +05:30
|
|
|
def show_filter_results(self, dbstate, matched, total):
|
2010-02-13 01:48:07 +05:30
|
|
|
#nav_type = self.viewmanager.active_page.navigation_type()
|
|
|
|
#text = ((_("%(nav_type)s View") % {"nav_type": _(nav_type)}) +
|
|
|
|
text = (self.viewmanager.active_page.title +
|
|
|
|
(": %d/%d" % (matched, total)))
|
2007-04-02 04:07:10 +05:30
|
|
|
self.status.pop(1, self.last_bar)
|
|
|
|
self.status.push(1, text, self.last_bar)
|
|
|
|
|
|
|
|
def clear_filter_results(self):
|
|
|
|
self.status.pop(1, self.last_bar)
|
|
|
|
self.status.push(1, '', self.last_bar)
|
|
|
|
|
2007-05-21 09:14:18 +05:30
|
|
|
def modify_statusbar(self, dbstate, active=None):
|
2010-01-11 00:49:33 +05:30
|
|
|
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())
|
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
self.status.pop(self.status_id)
|
2010-01-11 00:49:33 +05:30
|
|
|
|
2010-01-12 06:00:23 +05:30
|
|
|
name, obj = navigation_label(dbstate.db, nav_type, active_handle)
|
2010-01-11 00:49:33 +05:30
|
|
|
|
|
|
|
# Append relationship to default person if funtionality is enabled.
|
|
|
|
if nav_type == 'Person' and active_handle \
|
|
|
|
and config.get('interface.statusbar') > 1:
|
|
|
|
if active_handle != dbstate.db.get_default_handle():
|
|
|
|
msg = self.display_relationship(dbstate, active_handle)
|
|
|
|
if msg:
|
|
|
|
name = '%s (%s)' % (name, msg.strip())
|
|
|
|
|
|
|
|
if not name:
|
2010-02-14 22:25:06 +05:30
|
|
|
name = self.NAV2MES[nav_type]
|
2010-01-11 00:49:33 +05:30
|
|
|
|
|
|
|
self.status.push(self.status_id, name)
|
2009-12-12 22:31:06 +05:30
|
|
|
process_pending_events()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2007-05-21 09:14:18 +05:30
|
|
|
def pulse_progressbar(self, value):
|
|
|
|
self.progress.set_fraction(min(value/100.0, 1.0))
|
2006-03-01 11:46:36 +05:30
|
|
|
self.progress.set_text("%d%%" % value)
|
2009-12-12 22:31:06 +05:30
|
|
|
process_pending_events()
|
2006-03-01 11:46:36 +05:30
|
|
|
|
2007-05-21 09:14:18 +05:30
|
|
|
def status_text(self, text):
|
2005-08-09 10:11:20 +05:30
|
|
|
self.status.pop(self.status_id)
|
2007-05-21 09:14:18 +05:30
|
|
|
self.status.push(self.status_id, text)
|
2009-12-12 22:31:06 +05:30
|
|
|
process_pending_events()
|