2009-10-20 16:48:06 +05:30
|
|
|
# -*- coding: utf-8 -*-
|
2009-10-08 06:42:51 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2005-2007 Donald N. Allingham
|
|
|
|
# Copyright (C) 2008-2009 Gary Burton
|
|
|
|
# Copyright (C) 2009 Doug Blank <doug.blank@gmail.com>
|
2011-07-25 00:00:28 +05:30
|
|
|
# Copyright (C) 20111 Tim G L Lyons
|
2009-10-08 06:42:51 +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.
|
|
|
|
#
|
|
|
|
# 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$
|
|
|
|
|
|
|
|
"""
|
|
|
|
This package implements access to GRAMPS configuration.
|
|
|
|
"""
|
|
|
|
|
|
|
|
#---------------------------------------------------------------
|
|
|
|
#
|
2009-12-21 10:11:56 +05:30
|
|
|
# Gramps imports
|
2009-10-08 06:42:51 +05:30
|
|
|
#
|
|
|
|
#---------------------------------------------------------------
|
2010-01-10 01:11:00 +05:30
|
|
|
import os, sys
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import gettext as _
|
2009-10-08 06:42:51 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Gramps imports
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------
|
|
|
|
import const
|
2009-12-21 10:11:56 +05:30
|
|
|
from gen.utils import ConfigManager
|
2009-10-08 06:42:51 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------
|
2010-01-24 17:48:30 +05:30
|
|
|
INIFILE = os.path.join(const.VERSION_DIR, "gramps.ini")
|
2009-10-08 06:42:51 +05:30
|
|
|
|
|
|
|
#---------------------------------------------------------------
|
|
|
|
#
|
2009-12-21 10:11:56 +05:30
|
|
|
# Module functions
|
2009-10-08 06:42:51 +05:30
|
|
|
#
|
|
|
|
#---------------------------------------------------------------
|
|
|
|
def register(key, value):
|
|
|
|
""" Module shortcut to register key, value """
|
2009-10-09 05:56:48 +05:30
|
|
|
return CONFIGMAN.register(key, value)
|
2009-10-08 06:42:51 +05:30
|
|
|
|
|
|
|
def get(key):
|
|
|
|
""" Module shortcut to get value from key """
|
|
|
|
return CONFIGMAN.get(key)
|
|
|
|
|
|
|
|
def get_default(key):
|
|
|
|
""" Module shortcut to get default from key """
|
|
|
|
return CONFIGMAN.get_default(key)
|
|
|
|
|
2009-10-09 05:56:48 +05:30
|
|
|
def has_default(key):
|
|
|
|
""" Module shortcut to get see if there is a default for key """
|
|
|
|
return CONFIGMAN.has_default(key)
|
|
|
|
|
|
|
|
def get_sections():
|
|
|
|
""" Module shortcut to get all section names of settings """
|
|
|
|
return CONFIGMAN.get_sections()
|
|
|
|
|
|
|
|
def get_section_settings(section):
|
|
|
|
""" Module shortcut to get all settings of a section """
|
|
|
|
return CONFIGMAN.get_section_settings(section)
|
|
|
|
|
2009-10-08 06:42:51 +05:30
|
|
|
def set(key, value):
|
|
|
|
""" Module shortcut to set value from key """
|
2009-10-09 05:56:48 +05:30
|
|
|
return CONFIGMAN.set(key, value)
|
|
|
|
|
|
|
|
def is_set(key):
|
|
|
|
""" Module shortcut to set value from key """
|
|
|
|
return CONFIGMAN.is_set(key)
|
2009-10-08 06:42:51 +05:30
|
|
|
|
|
|
|
def save(filename=None):
|
|
|
|
""" Module shortcut to save config file """
|
2009-10-09 05:56:48 +05:30
|
|
|
return CONFIGMAN.save(filename)
|
2009-10-08 06:42:51 +05:30
|
|
|
|
|
|
|
def connect(key, func):
|
2009-10-09 05:56:48 +05:30
|
|
|
"""
|
|
|
|
Module shortcut to connect a key to a callback func.
|
|
|
|
Returns a unique callback ID number.
|
|
|
|
"""
|
2009-10-08 06:42:51 +05:30
|
|
|
return CONFIGMAN.connect(key, func)
|
|
|
|
|
2009-10-09 05:56:48 +05:30
|
|
|
def disconnect(callback_id):
|
|
|
|
""" Module shortcut to remove callback by ID number """
|
|
|
|
return CONFIGMAN.disconnect(callback_id)
|
|
|
|
|
|
|
|
def reset(key=None):
|
|
|
|
""" Module shortcut to reset some or all config data """
|
|
|
|
return CONFIGMAN.reset(key)
|
|
|
|
|
|
|
|
def load(filename=None, oldstyle=False):
|
|
|
|
""" Module shortcut to load an INI file into config data """
|
|
|
|
return CONFIGMAN.load(filename, oldstyle)
|
|
|
|
|
|
|
|
def emit(key):
|
|
|
|
""" Module shortcut to call all callbacks associated with key """
|
|
|
|
return CONFIGMAN.emit(key)
|
|
|
|
|
2009-10-08 06:42:51 +05:30
|
|
|
#---------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Register the system-wide settings in a singleton config manager
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------
|
|
|
|
|
2010-01-24 17:48:30 +05:30
|
|
|
CONFIGMAN = ConfigManager(INIFILE, "plugins")
|
2009-10-08 06:42:51 +05:30
|
|
|
|
|
|
|
register('behavior.addmedia-image-dir', '')
|
|
|
|
register('behavior.addmedia-relative-path', False)
|
|
|
|
register('behavior.autoload', False)
|
|
|
|
register('behavior.avg-generation-gap', 20)
|
|
|
|
register('behavior.betawarn', False)
|
2010-08-14 23:46:10 +05:30
|
|
|
register('behavior.check-for-updates', 2)
|
|
|
|
register('behavior.check-for-update-types', ["update", "new"])
|
2010-08-13 12:12:14 +05:30
|
|
|
register('behavior.last-check-for-updates', "1970/01/01")
|
2010-08-19 06:34:10 +05:30
|
|
|
register('behavior.previously-seen-updates', [])
|
|
|
|
register('behavior.do-not-show-previously-seen-updates', True)
|
2009-10-08 06:42:51 +05:30
|
|
|
register('behavior.database-path', os.path.join( const.HOME_DIR, 'grampsdb'))
|
2010-01-06 07:09:23 +05:30
|
|
|
register('behavior.date-about-range', 50)
|
|
|
|
register('behavior.date-after-range', 50)
|
|
|
|
register('behavior.date-before-range', 50)
|
2009-10-08 06:42:51 +05:30
|
|
|
register('behavior.generation-depth', 15)
|
|
|
|
register('behavior.max-age-prob-alive', 110)
|
|
|
|
register('behavior.max-sib-age-diff', 20)
|
|
|
|
register('behavior.min-generation-years', 13)
|
|
|
|
register('behavior.owner-warn', False)
|
|
|
|
register('behavior.pop-plugin-status', False)
|
|
|
|
register('behavior.recent-export-type', 1)
|
|
|
|
register('behavior.spellcheck', False)
|
|
|
|
register('behavior.startup', 0)
|
|
|
|
register('behavior.surname-guessing', 0)
|
|
|
|
register('behavior.use-tips', False)
|
|
|
|
register('behavior.welcome', 100)
|
2010-08-26 19:30:27 +05:30
|
|
|
register('behavior.web-search-url', 'http://google.com/#&q=%(text)s')
|
2009-10-08 06:42:51 +05:30
|
|
|
|
2010-05-30 09:37:50 +05:30
|
|
|
register('export.proxy-order', [
|
|
|
|
["privacy", 0],
|
|
|
|
["living", 0],
|
|
|
|
["person", 0],
|
|
|
|
["note", 0],
|
|
|
|
["reference", 0],
|
|
|
|
])
|
2009-10-08 06:42:51 +05:30
|
|
|
|
2011-04-25 19:02:10 +05:30
|
|
|
register('geography.center-lon', 0.0)
|
|
|
|
register('geography.lock', False)
|
|
|
|
register('geography.center-lat', 0.0)
|
|
|
|
register('geography.map', "person")
|
|
|
|
register('geography.map_service', 1)
|
|
|
|
register('geography.zoom', 0)
|
2011-05-15 14:16:57 +05:30
|
|
|
register('geography.zoom_when_center', 12)
|
2011-04-25 19:02:10 +05:30
|
|
|
register('geography.show_cross', False)
|
|
|
|
register('geography.path', "")
|
2009-10-08 06:42:51 +05:30
|
|
|
|
2009-10-08 10:17:04 +05:30
|
|
|
register('htmlview.start-url', "http://gramps-project.org")
|
2010-08-23 19:36:41 +05:30
|
|
|
register('htmlview.url-handler', False)
|
2009-10-08 10:17:04 +05:30
|
|
|
|
2009-10-08 06:42:51 +05:30
|
|
|
register('interface.address-height', 450)
|
|
|
|
register('interface.address-width', 650)
|
|
|
|
register('interface.attribute-height', 350)
|
|
|
|
register('interface.attribute-width', 600)
|
|
|
|
register('interface.child-ref-height', 450)
|
|
|
|
register('interface.child-ref-width', 600)
|
|
|
|
register('interface.clipboard-height', 300)
|
|
|
|
register('interface.clipboard-width', 300)
|
|
|
|
register('interface.dont-ask', False)
|
2009-12-05 10:08:31 +05:30
|
|
|
register('interface.view-categories',
|
|
|
|
["Gramplets", "People", "Relationships", "Families",
|
2009-12-11 07:18:22 +05:30
|
|
|
"Ancestry", "Events", "Places", "Geography", "Sources",
|
2009-12-05 10:08:31 +05:30
|
|
|
"Repositories", "Media", "Notes"])
|
2010-11-23 06:18:36 +05:30
|
|
|
register('interface.edit-rule-width', 600)
|
|
|
|
register('interface.edit-rule-height', 450)
|
2009-10-08 06:42:51 +05:30
|
|
|
register('interface.event-height', 450)
|
|
|
|
register('interface.event-ref-height', 450)
|
|
|
|
register('interface.event-ref-width', 600)
|
|
|
|
register('interface.event-sel-height', 450)
|
|
|
|
register('interface.event-sel-width', 600)
|
|
|
|
register('interface.event-width', 600)
|
|
|
|
register('interface.family-height', 500)
|
|
|
|
register('interface.family-sel-height', 450)
|
|
|
|
register('interface.family-sel-width', 600)
|
|
|
|
register('interface.family-width', 700)
|
|
|
|
register('interface.filter', False)
|
|
|
|
register('interface.fullscreen', False)
|
|
|
|
register('interface.height', 500)
|
|
|
|
register('interface.lds-height', 450)
|
|
|
|
register('interface.lds-width', 600)
|
|
|
|
register('interface.location-height', 250)
|
|
|
|
register('interface.location-width', 600)
|
|
|
|
register('interface.mapservice', 'OpenStreetMap')
|
|
|
|
register('interface.media-height', 450)
|
|
|
|
register('interface.media-ref-height', 450)
|
|
|
|
register('interface.media-ref-width', 600)
|
|
|
|
register('interface.media-sel-height', 450)
|
|
|
|
register('interface.media-sel-width', 600)
|
|
|
|
register('interface.media-width', 650)
|
|
|
|
register('interface.name-height', 350)
|
|
|
|
register('interface.name-width', 600)
|
|
|
|
register('interface.note-height', 500)
|
|
|
|
register('interface.note-sel-height', 450)
|
|
|
|
register('interface.note-sel-width', 600)
|
|
|
|
register('interface.note-width', 700)
|
2010-12-04 23:39:00 +05:30
|
|
|
register('interface.open-with-default-viewer', False)
|
2009-10-08 06:42:51 +05:30
|
|
|
register('interface.pedview-layout', 0)
|
|
|
|
register('interface.pedview-show-images', True)
|
|
|
|
register('interface.pedview-show-marriage', False)
|
2010-03-04 04:42:56 +05:30
|
|
|
register('interface.pedview-tree-size', 5)
|
|
|
|
register('interface.pedview-tree-direction', 2)
|
|
|
|
register('interface.pedview-show-unknown-people', False)
|
2009-10-08 06:42:51 +05:30
|
|
|
register('interface.person-height', 550)
|
|
|
|
register('interface.person-ref-height', 350)
|
|
|
|
register('interface.person-ref-width', 600)
|
|
|
|
register('interface.person-sel-height', 450)
|
|
|
|
register('interface.person-sel-width', 600)
|
|
|
|
register('interface.person-width', 750)
|
|
|
|
register('interface.place-height', 450)
|
|
|
|
register('interface.place-sel-height', 450)
|
|
|
|
register('interface.place-sel-width', 600)
|
|
|
|
register('interface.place-width', 650)
|
|
|
|
register('interface.repo-height', 450)
|
|
|
|
register('interface.repo-ref-height', 450)
|
|
|
|
register('interface.repo-ref-width', 600)
|
|
|
|
register('interface.repo-sel-height', 450)
|
|
|
|
register('interface.repo-sel-width', 600)
|
|
|
|
register('interface.repo-width', 650)
|
|
|
|
register('interface.sidebar-text', True)
|
|
|
|
register('interface.size-checked', False)
|
|
|
|
register('interface.source-height', 450)
|
|
|
|
register('interface.source-ref-height', 450)
|
|
|
|
register('interface.source-ref-width', 600)
|
|
|
|
register('interface.source-sel-height', 450)
|
|
|
|
register('interface.source-sel-width', 600)
|
|
|
|
register('interface.source-width', 600)
|
|
|
|
register('interface.statusbar', 1)
|
|
|
|
register('interface.toolbar-on', True)
|
|
|
|
register('interface.url-height', 150)
|
|
|
|
register('interface.url-width', 600)
|
|
|
|
register('interface.view', True)
|
|
|
|
register('interface.width', 775)
|
2011-01-22 20:37:29 +05:30
|
|
|
register('interface.surname-box-height', 150)
|
2009-10-08 06:42:51 +05:30
|
|
|
|
|
|
|
register('paths.recent-export-dir', '')
|
|
|
|
register('paths.recent-file', '')
|
|
|
|
register('paths.recent-import-dir', '')
|
|
|
|
register('paths.report-directory', const.USER_HOME)
|
|
|
|
register('paths.website-directory', const.USER_HOME)
|
2010-07-22 07:20:00 +05:30
|
|
|
register('paths.quick-backup-directory', const.USER_HOME)
|
|
|
|
register('paths.quick-backup-filename',
|
|
|
|
"%(filename)s_%(year)d-%(month)02d-%(day)02d.%(extension)s")
|
2009-10-08 06:42:51 +05:30
|
|
|
|
|
|
|
register('preferences.date-format', 0)
|
2009-12-18 23:33:44 +05:30
|
|
|
register('preferences.calendar-format-report', 0)
|
2011-07-25 00:00:28 +05:30
|
|
|
register('preferences.cprefix', 'C%04d')
|
2009-10-08 06:42:51 +05:30
|
|
|
register('preferences.default-source', False)
|
|
|
|
register('preferences.eprefix', 'E%04d')
|
|
|
|
register('preferences.family-warn', True)
|
|
|
|
register('preferences.fprefix', 'F%04d')
|
|
|
|
register('preferences.hide-ep-msg', False)
|
|
|
|
register('preferences.invalid-date-format', "<b>%s</b>")
|
|
|
|
register('preferences.iprefix', 'I%04d')
|
|
|
|
register('preferences.name-format', 1)
|
2011-05-28 21:19:57 +05:30
|
|
|
register('preferences.patronimic-surname', False)
|
2009-10-08 06:42:51 +05:30
|
|
|
register('preferences.no-given-text', "[%s]" % _("Missing Given Name"))
|
|
|
|
register('preferences.no-record-text', "[%s]" % _("Missing Record"))
|
|
|
|
register('preferences.no-surname-text', "[%s]" % _("Missing Surname"))
|
|
|
|
register('preferences.nprefix', 'N%04d')
|
|
|
|
register('preferences.online-maps', False)
|
|
|
|
register('preferences.oprefix', 'O%04d')
|
|
|
|
register('preferences.paper-metric', 0)
|
|
|
|
register('preferences.paper-preference', 'Letter')
|
|
|
|
register('preferences.pprefix', 'P%04d')
|
|
|
|
register('preferences.private-given-text', "[%s]" % _("Living"))
|
|
|
|
register('preferences.private-record-text', "[%s]" % _("Private Record"))
|
|
|
|
register('preferences.private-surname-text', "[%s]" % _("Living"))
|
|
|
|
register('preferences.rprefix', 'R%04d')
|
|
|
|
register('preferences.sprefix', 'S%04d')
|
|
|
|
register('preferences.use-last-view', True)
|
2010-02-06 01:17:32 +05:30
|
|
|
register('preferences.last-view', '')
|
|
|
|
register('preferences.last-views', [])
|
2011-01-24 02:55:51 +05:30
|
|
|
register('preferences.use-bsddb3', False)
|
2009-10-08 06:42:51 +05:30
|
|
|
|
|
|
|
register('researcher.researcher-addr', '')
|
2010-10-30 04:41:08 +05:30
|
|
|
register('researcher.researcher-locality', '')
|
2009-10-08 06:42:51 +05:30
|
|
|
register('researcher.researcher-city', '')
|
|
|
|
register('researcher.researcher-country', '')
|
|
|
|
register('researcher.researcher-email', '')
|
|
|
|
register('researcher.researcher-name', '')
|
|
|
|
register('researcher.researcher-phone', '')
|
|
|
|
register('researcher.researcher-postal', '')
|
|
|
|
register('researcher.researcher-state', '')
|
|
|
|
|
2010-02-06 02:15:23 +05:30
|
|
|
register('plugin.hiddenplugins', ['htmlview'])
|
2010-01-18 03:15:37 +05:30
|
|
|
register('plugin.addonplugins', [])
|
2009-10-25 01:57:10 +05:30
|
|
|
|
2009-10-08 06:42:51 +05:30
|
|
|
#---------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Upgrade Conversions go here.
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------
|
|
|
|
|
|
|
|
# If we have not already upgraded to this version,
|
|
|
|
# we can tell by seeing if there is a key file for this version:
|
|
|
|
if not os.path.exists(CONFIGMAN.filename):
|
|
|
|
# If not, let's read old if there:
|
|
|
|
if os.path.exists(os.path.join(const.HOME_DIR, "keys.ini")):
|
|
|
|
# read it in old style:
|
2009-11-10 08:57:46 +05:30
|
|
|
print >> sys.stderr, "Importing old key file 'keys.ini'..."
|
2009-10-08 06:42:51 +05:30
|
|
|
CONFIGMAN.load(os.path.join(const.HOME_DIR, "keys.ini"),
|
|
|
|
oldstyle=True)
|
2009-11-10 08:57:46 +05:30
|
|
|
print >> sys.stderr, "Done importing old key file 'keys.ini'"
|
2009-10-08 06:42:51 +05:30
|
|
|
# other version upgrades here...
|
|
|
|
|
|
|
|
#---------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Now, load the settings from the config file, if one
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------
|
|
|
|
CONFIGMAN.load()
|
2009-12-21 04:14:23 +05:30
|
|
|
|
|
|
|
config = CONFIGMAN
|