diff --git a/src/BasicUtils/_NameDisplay.py b/src/BasicUtils/_NameDisplay.py index e4ebad266..3d4b659ff 100644 --- a/src/BasicUtils/_NameDisplay.py +++ b/src/BasicUtils/_NameDisplay.py @@ -41,7 +41,7 @@ from gen.lib import Name from Errors import NameDisplayError try: - import Config + import config WITH_GRAMPS_CONFIG=True except ImportError: WITH_GRAMPS_CONFIG=False @@ -113,10 +113,10 @@ class NameDisplay(object): self.set_name_format(self.STANDARD_FORMATS) if WITH_GRAMPS_CONFIG: - self.default_format = Config.get(Config.NAME_FORMAT) + self.default_format = config.get('preferences.name-format') if self.default_format == 0: self.default_format = Name.LNFN - Config.set(Config.NAME_FORMAT, self.default_format) + config.set('preferences.name-format', self.default_format) else: self.default_format = 1 diff --git a/src/Config/Makefile.am b/src/Config/Makefile.am deleted file mode 100644 index d8f6b7682..000000000 --- a/src/Config/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -# This is the src/Config level Makefile for Gramps -# We could use GNU make's ':=' syntax for nice wildcard use, -# but that is not necessarily portable. -# If not using GNU make, then list all .py files individually - -pkgdatadir = $(datadir)/@PACKAGE@/Config - -pkgdata_PYTHON = \ - __init__.py\ - _GrampsConfigKeys.py\ - _GrampsIniKeys.py - -pkgpyexecdir = @pkgpyexecdir@/Config -pkgpythondir = @pkgpythondir@/Config - -# Clean up all the byte-compiled files -MOSTLYCLEANFILES = *pyc *pyo - -GRAMPS_PY_MODPATH = "../" - -pycheck: - (export PYTHONPATH=$(GRAMPS_PY_MODPATH); \ - pychecker $(pkgdata_PYTHON)); diff --git a/src/Config/_GrampsConfigKeys.py b/src/Config/_GrampsConfigKeys.py deleted file mode 100644 index 711e6ee4f..000000000 --- a/src/Config/_GrampsConfigKeys.py +++ /dev/null @@ -1,373 +0,0 @@ -# -# Gramps - a GTK+/GNOME based genealogy program -# -# Copyright (C) 2006-2007 Donald N. Allingham -# Copyright (C) 2008-2009 Gary Burton -# -# 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$ - -import os -from gettext import gettext as _ - -import const - -""" -Adding a new configuration key: - -Add a value in the form of: - - VARIABLE = ( category, key_name, type) - -Where: - - cateogory is a single word string defining the grouping along - with related keys - - key_name is a single word string defining the actual configuration - name - - type is an integer defining the type of the value of the - configuration value. - - 0 - boolean - 1 - integer - 2 - string - -Then add the variable to the default_value map at the end of the -file, and provide a default value according to the value's type. -""" - -EXPORT_NO_PRIVATE = ('export', 'no-private', 0) -EXPORT_RESTRICT = ('export', 'restrict-living', 0) -EXPORT_NO_UNLINKED = ('export', 'no-unlinked', 0) -DEFAULT_SOURCE = ('preferences', 'default-source', 0) -RELATION_SHADE = ('preferences', 'relation-shade', 0) -ONLINE_MAPS = ('preferences', 'online-maps', 0) -FAMILY_DETAILS = ('preferences', 'family-details', 0) -COMPLETE_COLOR = ('preferences', 'complete-color', 2) -TODO_COLOR = ('preferences', 'todo-color', 2) -CUSTOM_MARKER_COLOR = ('preferences', 'custom-marker-color', 2) -FAMILY_WARN = ('preferences', 'family-warn', 0) -HIDE_EP_MSG = ('preferences', 'hide-ep-msg', 0) -LAST_VIEW = ('preferences', 'last-view', 1) -USE_LAST_VIEW = ('preferences', 'use-last-view', 0) -FAMILY_SIBLINGS = ('preferences', 'family-siblings', 0) -AUTOLOAD = ('behavior', 'autoload', 0) -SPELLCHECK = ('behavior', 'spellcheck', 0) -BETAWARN = ('behavior', 'betawarn', 0) -WELCOME = ('behavior', 'welcome', 1) -DATE_FORMAT = ('preferences', 'date-format', 1) -DONT_ASK = ('interface', 'dont-ask', 0) -RELEDITBTN = ('interface', 'releditbtn', 0) -HEIGHT = ('interface', 'height', 1) -WIDTH = ('interface', 'width', 1) -FAMILY_HEIGHT = ('interface', 'family-height', 1) -FAMILY_WIDTH = ('interface', 'family-width', 1) -NOTE_HEIGHT = ('interface', 'note-height', 1) -NOTE_WIDTH = ('interface', 'note-width', 1) -PERSON_HEIGHT = ('interface', 'person-height', 1) -PERSON_WIDTH = ('interface', 'person-width', 1) -PREFIX_SUFFIX = ('interface', 'prefix-suffix', 1) -PATRO_TITLE = ('interface', 'patro-title', 1) -EVENT_HEIGHT = ('interface', 'event-height', 1) -EVENT_WIDTH = ('interface', 'event-width', 1) -EVENT_REF_HEIGHT = ('interface', 'event-ref-height', 1) -EVENT_REF_WIDTH = ('interface', 'event-ref-width', 1) -CHILD_REF_HEIGHT = ('interface', 'child-ref-height', 1) -CHILD_REF_WIDTH = ('interface', 'child-ref-width', 1) -PLACE_HEIGHT = ('interface', 'place-height', 1) -PLACE_WIDTH = ('interface', 'place-width', 1) -REPO_HEIGHT = ('interface', 'repo-height', 1) -REPO_WIDTH = ('interface', 'repo-width', 1) -MEDIA_HEIGHT = ('interface', 'media-height', 1) -MEDIA_WIDTH = ('interface', 'media-width', 1) -ADDRESS_HEIGHT = ('interface', 'address-height', 1) -ADDRESS_WIDTH = ('interface', 'address-width', 1) -ATTRIBUTE_HEIGHT = ('interface', 'attribute-height', 1) -ATTRIBUTE_WIDTH = ('interface', 'attribute-width', 1) -NAME_HEIGHT = ('interface', 'name-height', 1) -NAME_WIDTH = ('interface', 'name-width', 1) -SOURCE_HEIGHT = ('interface', 'source-height', 1) -SOURCE_WIDTH = ('interface', 'source-width', 1) -SOURCE_REF_HEIGHT = ('interface', 'source-ref-height', 1) -SOURCE_REF_WIDTH = ('interface', 'source-ref-width', 1) -SOURCE_SEL_WIDTH = ('interface', 'source-sel-width', 1) -SOURCE_SEL_HEIGHT = ('interface', 'source-sel-height', 1) -EVENT_SEL_WIDTH = ('interface', 'event-sel-width', 1) -EVENT_SEL_HEIGHT = ('interface', 'event-sel-height', 1) -FAMILY_SEL_WIDTH = ('interface', 'family-sel-width', 1) -FAMILY_SEL_HEIGHT = ('interface', 'family-sel-height', 1) -NOTE_SEL_WIDTH = ('interface', 'note-sel-width', 1) -NOTE_SEL_HEIGHT = ('interface', 'note-sel-height', 1) -REPO_SEL_WIDTH = ('interface', 'repo-sel-width', 1) -REPO_SEL_HEIGHT = ('interface', 'repo-sel-height', 1) -PLACE_SEL_WIDTH = ('interface', 'place-sel-width', 1) -PLACE_SEL_HEIGHT = ('interface', 'place-sel-height', 1) -PERSON_SEL_WIDTH = ('interface', 'person-sel-width', 1) -PERSON_SEL_HEIGHT = ('interface', 'person-sel-height', 1) -MEDIA_SEL_WIDTH = ('interface', 'media-sel-width', 1) -MEDIA_SEL_HEIGHT = ('interface', 'media-sel-height', 1) -FILTER = ('interface', 'filter', 0) -PEDVIEW_TREESIZE = ('interface', 'pedview-tree-size', 1) -PEDVIEW_LAYOUT = ('interface', 'pedview-layout', 1) -PEDVIEW_SHOW_MARRIAGE= ('interface', 'pedview-show-marriage', 0) -PEDVIEW_SHOW_IMAGES = ('interface', 'pedview-show-images', 0) -CLIPBOARD_WIDTH = ('interface', 'clipboard-width', 1) -CLIPBOARD_HEIGHT = ('interface', 'clipboard-height', 1) -DATABASE_PATH = ('behavior', 'database-path', 2) -FPREFIX = ('preferences', 'fprefix', 2) -EPREFIX = ('preferences', 'eprefix', 2) -RPREFIX = ('preferences', 'rprefix', 2) -NPREFIX = ('preferences', 'nprefix', 2) -IPREFIX = ('preferences', 'iprefix', 2) -OPREFIX = ('preferences', 'oprefix', 2) -PPREFIX = ('preferences', 'pprefix', 2) -SPREFIX = ('preferences', 'sprefix', 2) -PAPER_METRIC = ('preferences', 'paper-metric', 1) -PAPER_PREFERENCE = ('preferences', 'paper-preference', 2) -RECENT_FILE = ('paths', 'recent-file', 2) -RECENT_IMPORT_DIR = ('paths', 'recent-import-dir', 2) -RECENT_EXPORT_DIR = ('paths', 'recent-export-dir', 2) -RECENT_EXPORT_TYPE = ('behavior', 'recent-export-type', 1) -NAME_FORMAT = ('preferences', 'name-format', 1) -REPORT_DIRECTORY = ('paths', 'report-directory', 2) -RESEARCHER_ADDR = ('researcher', 'researcher-addr', 2) -RESEARCHER_CITY = ('researcher', 'researcher-city', 2) -RESEARCHER_COUNTRY = ('researcher', 'researcher-country', 2) -RESEARCHER_EMAIL = ('researcher', 'researcher-email', 2) -RESEARCHER_NAME = ('researcher', 'researcher-name', 2) -RESEARCHER_PHONE = ('researcher', 'researcher-phone', 2) -RESEARCHER_POSTAL = ('researcher', 'researcher-postal', 2) -RESEARCHER_STATE = ('researcher', 'researcher-state', 2) -STARTUP = ('behavior', 'startup', 1) -SIZE_CHECKED = ('interface', 'size-checked', 0) -STATUSBAR = ('interface', 'statusbar', 1) -SURNAME_GUESSING = ('behavior', 'surname-guessing', 1) -TOOLBAR_ON = ('interface', 'toolbar-on', 0) -USE_TIPS = ('behavior', 'use-tips', 0) -POP_PLUGIN_STATUS = ('behavior', 'pop-plugin-status', 0) -VIEW = ('interface', 'view', 0) -SIDEBAR_TEXT = ('interface', 'sidebar-text', 0) -WEBSITE_DIRECTORY = ('paths', 'website-directory', 2) -LDS_HEIGHT = ('interface', 'lds-height', 1) -LDS_WIDTH = ('interface', 'lds-width', 1) -LOCATION_HEIGHT = ('interface', 'location-height', 1) -LOCATION_WIDTH = ('interface', 'location-width', 1) -MAPSERVICE = ('interface', 'mapservice', 2) -MEDIA_REF_HEIGHT = ('interface', 'media-ref-height', 1) -MEDIA_REF_WIDTH = ('interface', 'media-ref-width', 1) -URL_HEIGHT = ('interface', 'url-height', 1) -URL_WIDTH = ('interface', 'url-width', 1) -PERSON_REF_HEIGHT = ('interface', 'person-ref-height', 1) -PERSON_REF_WIDTH = ('interface', 'person-ref-width', 1) -REPO_REF_HEIGHT = ('interface', 'repo-ref-height', 1) -REPO_REF_WIDTH = ('interface', 'repo-ref-width', 1) -OWNER_WARN = ('behavior', 'owner-warn', 0) -DATE_BEFORE_RANGE = ('behavior', 'date-before-range', 1) -DATE_AFTER_RANGE = ('behavior', 'date-after-range', 1) -DATE_ABOUT_RANGE = ('behavior', 'date-about-range', 1) -MAX_AGE_PROB_ALIVE = ('behavior', 'max-age-prob-alive', 1) -MAX_SIB_AGE_DIFF = ('behavior', 'max-sib-age-diff', 1) -MIN_GENERATION_YEARS = ('behavior', 'min-generation-years', 1) -AVG_GENERATION_GAP = ('behavior', 'avg-generation-gap', 1) -GENERATION_DEPTH = ('behavior', 'generation-depth', 1) -DATA_VIEWS = ('interface','data-views', 2) -ADDMEDIA_IMGDIR = ('behavior', 'addmedia-image-dir', 2) -ADDMEDIA_RELPATH = ('behavior', 'addmedia-relative-path', 0) -NO_SURNAME_TEXT = ('preferences', 'no-surname-text', 2) -NO_GIVEN_TEXT = ('preferences', 'no-given-text', 2) -NO_RECORD_TEXT = ('preferences', 'no-record-text', 2) -PRIVATE_SURNAME_TEXT = ('preferences', 'private-surname-text', 2) -PRIVATE_GIVEN_TEXT = ('preferences', 'private-given-text', 2) -PRIVATE_RECORD_TEXT = ('preferences', 'private-record-text', 2) -RELATION_DISPLAY_THEME= ('preferences', 'relation-display-theme', 2) -INVALID_DATE_FORMAT = ('preferences', 'invalid-date-format', 2) -FULLSCREEN = ('interface', 'fullscreen', 0) -GEOVIEW = ('preferences', 'geoview', 0) -GEOVIEW_GOOGLEMAPS = ('preferences', 'googlemap', 0) -GEOVIEW_OPENLAYERS = ('preferences', 'openlayers', 0) -GEOVIEW_YAHOO = ('preferences', 'yahoo', 0) -GEOVIEW_MICROSOFT = ('preferences', 'microsoft', 0) -GEOVIEW_LOCKZOOM = ('geoview', 'lock', 0) -GEOVIEW_ZOOM = ('geoview', 'zoom', 1) -GEOVIEW_LATITUDE = ('geoview', 'latitude', 2) -GEOVIEW_LONGITUDE = ('geoview', 'longitude', 2) -GEOVIEW_MAP = ('geoview', 'map', 2) -GEOVIEW_STYLESHEET = ('geoview', 'stylesheet', 2) - -default_value = { - DEFAULT_SOURCE : False, - RELATION_SHADE : True, - ONLINE_MAPS : False, - FAMILY_DETAILS : True, - COMPLETE_COLOR : '#008b00', - TODO_COLOR : '#ff0000', - CUSTOM_MARKER_COLOR : '#8b008b', - FAMILY_WARN : True, - HIDE_EP_MSG : False, - LAST_VIEW : 0, - USE_LAST_VIEW : True, - FAMILY_SIBLINGS : True, - AUTOLOAD : False, - SPELLCHECK : False, - BETAWARN : False, - WELCOME : 100, - DATE_FORMAT : 0, - DONT_ASK : False, - RELEDITBTN : False, - HEIGHT : 500, - WIDTH : 775, - FAMILY_HEIGHT : 500, - FAMILY_WIDTH : 700, - NOTE_HEIGHT : 500, - NOTE_WIDTH : 700, - PERSON_HEIGHT : 550, - PERSON_WIDTH : 750, - PREFIX_SUFFIX : 0, - PATRO_TITLE : 0, - EVENT_HEIGHT : 450, - EVENT_WIDTH : 600, - EVENT_REF_HEIGHT : 450, - EVENT_REF_WIDTH : 600, - CHILD_REF_HEIGHT : 450, - CHILD_REF_WIDTH : 600, - PLACE_HEIGHT : 450, - PLACE_WIDTH : 650, - REPO_HEIGHT : 450, - REPO_WIDTH : 650, - MEDIA_HEIGHT : 450, - MEDIA_WIDTH : 650, - ADDRESS_HEIGHT : 450, - ADDRESS_WIDTH : 650, - ATTRIBUTE_HEIGHT : 350, - ATTRIBUTE_WIDTH : 600, - NAME_HEIGHT : 350, - NAME_WIDTH : 600, - SOURCE_HEIGHT : 450, - SOURCE_WIDTH : 600, - SOURCE_REF_HEIGHT : 450, - SOURCE_REF_WIDTH : 600, - SOURCE_SEL_WIDTH : 600, - SOURCE_SEL_HEIGHT : 450, - EVENT_SEL_WIDTH : 600, - EVENT_SEL_HEIGHT : 450, - FAMILY_SEL_WIDTH : 600, - FAMILY_SEL_HEIGHT : 450, - NOTE_SEL_WIDTH : 600, - NOTE_SEL_HEIGHT : 450, - REPO_SEL_WIDTH : 600, - REPO_SEL_HEIGHT : 450, - PLACE_SEL_WIDTH : 600, - PLACE_SEL_HEIGHT : 450, - PERSON_SEL_WIDTH : 600, - PERSON_SEL_HEIGHT : 450, - MEDIA_SEL_WIDTH : 600, - MEDIA_SEL_HEIGHT : 450, - CLIPBOARD_WIDTH : 300, - CLIPBOARD_HEIGHT : 300, - FILTER : False, - PEDVIEW_TREESIZE : 0, - PEDVIEW_LAYOUT : 0, - PEDVIEW_SHOW_MARRIAGE: False, - PEDVIEW_SHOW_IMAGES : True, - DATABASE_PATH : os.path.join( const.HOME_DIR, 'grampsdb'), - FPREFIX : 'F%04d', - EPREFIX : 'E%04d', - RPREFIX : 'R%04d', - NPREFIX : 'N%04d', - IPREFIX : 'I%04d', - OPREFIX : 'O%04d', - PPREFIX : 'P%04d', - SPREFIX : 'S%04d', - PAPER_METRIC : 0, - PAPER_PREFERENCE : 'Letter', - RECENT_FILE : '', - RECENT_IMPORT_DIR : '', - RECENT_EXPORT_DIR : '', - RECENT_EXPORT_TYPE : 1, - NAME_FORMAT : 1, - REPORT_DIRECTORY : const.USER_HOME, - RESEARCHER_ADDR : '', - RESEARCHER_CITY : '', - RESEARCHER_COUNTRY : '', - RESEARCHER_EMAIL : '', - RESEARCHER_NAME : '', - RESEARCHER_PHONE : '', - RESEARCHER_POSTAL : '', - RESEARCHER_STATE : '', - STARTUP : 0, - SIZE_CHECKED : False, - STATUSBAR : 1, - SURNAME_GUESSING : 0, - TOOLBAR_ON : True, - USE_TIPS : False, - POP_PLUGIN_STATUS : False, - VIEW : True, - SIDEBAR_TEXT : True, - WEBSITE_DIRECTORY : const.USER_HOME, - LDS_HEIGHT : 450, - LDS_WIDTH : 600, - LOCATION_HEIGHT : 250, - LOCATION_WIDTH : 600, - MAPSERVICE : 'OpenStreetMap', - MEDIA_REF_HEIGHT : 450, - MEDIA_REF_WIDTH : 600, - URL_HEIGHT : 150, - URL_WIDTH : 600, - PERSON_REF_HEIGHT : 350, - PERSON_REF_WIDTH : 600, - REPO_REF_HEIGHT : 450, - REPO_REF_WIDTH : 600, - OWNER_WARN : False, - EXPORT_NO_PRIVATE : True, - EXPORT_RESTRICT : True, - EXPORT_NO_UNLINKED : True, - DATE_BEFORE_RANGE : 10, - DATE_AFTER_RANGE : 10, - DATE_ABOUT_RANGE : 10, - MAX_AGE_PROB_ALIVE : 110, - MAX_SIB_AGE_DIFF : 20, - MIN_GENERATION_YEARS : 13, - AVG_GENERATION_GAP : 20, - GENERATION_DEPTH : 15, - DATA_VIEWS: ('GrampletView,PersonView,RelationshipView,FamilyListView,' - 'PedigreeView,EventView,SourceView,PlaceView,MediaView,' - 'RepositoryView,NoteView'), - ADDMEDIA_IMGDIR : '', - ADDMEDIA_RELPATH : False, - NO_SURNAME_TEXT : "[%s]" % _("Missing Surname"), - NO_GIVEN_TEXT : "[%s]" % _("Missing Given Name"), - NO_RECORD_TEXT : "[%s]" % _("Missing Record"), - PRIVATE_SURNAME_TEXT : "[%s]" % _("Living"), - PRIVATE_GIVEN_TEXT : "[%s]" % _("Living"), - PRIVATE_RECORD_TEXT : "[%s]" % _("Private Record"), - RELATION_DISPLAY_THEME: "CLASSIC", - INVALID_DATE_FORMAT : "%s", - FULLSCREEN : False, - GEOVIEW : False, - GEOVIEW_GOOGLEMAPS : True, - GEOVIEW_OPENLAYERS : False, - GEOVIEW_YAHOO : False, - GEOVIEW_MICROSOFT : False, - GEOVIEW_LOCKZOOM : False, - GEOVIEW_ZOOM : 0, - GEOVIEW_LATITUDE : "0.0", - GEOVIEW_LONGITUDE : "0.0", - GEOVIEW_MAP : "person", - GEOVIEW_STYLESHEET : "", -} diff --git a/src/Config/_GrampsIniKeys.py b/src/Config/_GrampsIniKeys.py deleted file mode 100644 index 7f237ee69..000000000 --- a/src/Config/_GrampsIniKeys.py +++ /dev/null @@ -1,259 +0,0 @@ -# -# Gramps - a GTK+/GNOME based genealogy program -# -# Copyright (C) 2005-2006 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$ - -""" -Low-level handling of .ini keys. -""" -import os -import time -import ConfigParser -import errno -import const -from Config import DATE_FORMAT, NAME_FORMAT, default_value - -NL = "\n" # FIX: newlines on Mac/Windows, if different? - -INIFILE = os.path.join(const.HOME_DIR,"keys.ini") - -def make_bool(val): - """ Function to turn strings into booleans. """ - # these are the possible strings that should be considered False - if val.lower() in ["0", "false", "none", ""]: - return False - else: - return True - -class IniKeyClient(object): - """ Class to emulate gconf's client """ - def __init__(self, filename = None): - """ Constructor takes an optional filename """ - self.data = {} - self.callbacks = {} - self.filename = filename - if self.filename and os.path.exists(filename): - self.data = self.load_ini(self.filename) - - def notify_add(self, path, func): - """ - I think that these are callbacks that get called when the keys - are set. - """ - parts = path.split("/") # FIX: make path-sep independent - # /apps/gramps/section/key - section = parts[-2] - key = parts[-1] - if section not in self.callbacks: - self.callbacks[section] = {} - if key not in self.callbacks[section]: - self.callbacks[section][key] = [] - if func not in self.callbacks[section][key]: - self.callbacks[section][key].append(func) - - def load_ini(self, filename): - """ Load .ini into dict of dicts, which it returns """ - cp = ConfigParser.ConfigParser() - cp.read(filename) - data = {} - for sec in cp.sections(): - name = sec.lower() - if name not in data: - data[name] = {} - for opt in cp.options(sec): - data[name][opt.lower()] = cp.get(sec, opt).strip() - return data - - def save_ini(self, filename = None): - """ - Saves the current section/keys to a .ini file. Optional filename - will override the default filename, if one. - """ - if not filename: - filename = self.filename - if filename: - try: - head, tail = os.path.split( filename ) - os.makedirs( head ) - except OSError, e: - if e.errno != errno.EEXIST: - raise - fp = open(filename, "w") - fp.write(";; Gramps key file" + NL) - fp.write((";; Automatically created at %s" % time.strftime("%Y/%m/%d %H:%M:%S")) + NL + NL) - sections = sorted(self.data) - for section in sections: - fp.write(("[%s]" + NL) % section) - keys = sorted(self.data[section]) - for key in keys: - fp.write(("%s=%s" + NL)% (key, self.data[section][key])) - fp.write(NL) - fp.close() - # else, no filename given - - def get_bool(self, key): - """ Emulates gconf's client method """ - return make_bool(self.data[key[0]][key[1]]) - - def get_string(self, key): - """ Emulates gconf's client method """ - return self.data[key[0]][key[1]] - - def get_int(self, key): - """ Emulates gconf's client method """ - try: - val = int(self.data[key[0]][key[1]]) - return val - except ValueError: - if self.data[key[0]][key[1]].lower() in ["true"]: - return 1 - else: - return 0 - - def set_bool(self, key, val): - """ Emulates gconf's client method """ - if key[0] not in self.data: - self.data[key[0]] = {} - self.data[key[0]][key[1]] = str(val) - if key[0] in self.callbacks and key[1] in self.callbacks[key[0]]: - for func in self.callbacks[key[0]][key[1]]: - func(self,0,self.data[key[0]][key[1]],None) - - def set_string(self, key, val): - """ Emulates gconf's client method """ - if key[0] not in self.data: - self.data[key[0]] = {} - self.data[key[0]][key[1]] = val - if key[0] in self.callbacks and key[1] in self.callbacks[key[0]]: - for func in self.callbacks[key[0]][key[1]]: - func(self,0,self.data[key[0]][key[1]],None) - - def set_int(self, key, val): - """ Emulates gconf's client method """ - if key[0] not in self.data: - self.data[key[0]] = {} - self.data[key[0]][key[1]] = str(val) - if key[0] in self.callbacks and key[1] in self.callbacks[key[0]]: - for func in self.callbacks[key[0]][key[1]]: - func(self,0,self.data[key[0]][key[1]],None) - - def suggest_sync(self): - self.save_ini() # save back to default file, if named - -client = IniKeyClient(INIFILE) - -#------------------------------------------------------------------------- -# -# Functions to obtain values from .ini keys -# and store values into .ini keys -# -# All gramps keys should be accessed through these functions! -# -#------------------------------------------------------------------------- - - -def get_date_format(_date_format_list=[]): - return get_int(DATE_FORMAT, - range(len(_date_format_list))) - -def save_date_format(val,_date_format_list=[]): - set_int(DATE_FORMAT, val, - range(len(_date_format_list))) - -def get_name_format(_name_format_list): - return get_int(NAME_FORMAT, - range(len(_name_format_list))) - -def save_name_format(val,_name_format_list): - set_int(NAME_FORMAT, val, - range(len(_name_format_list))) - - -#------------------------------------------------------------------------- -# -# Low-level grabbing and saving keys with error checking. -# -#------------------------------------------------------------------------- - -def set(key, value): - if key[2] == 0: - set_bool(key, value) - elif key[2] == 1: - set_int(key, value) - else: - set_string(key, value) - -def get(key): - if key[2] == 0: - val = get_bool(key) - elif key[2] == 1: - val = get_int(key) - else: - val = get_string(key) - if val is None or val == "": - val = default_value[key] - return val - -def get_bool(key): - try: - val = client.get_bool(key) - except KeyError: - val = None - if val in (True, False): - return val - elif key in default_value: - return default_value[key] - else: - print "No default value for %s" % key - return False - -def set_bool(key, val): - if val in (True,False): - client.set_bool(key,val) - -def get_int(key, correct_tuple=None): - try: - return client.get_int(key) - except KeyError: - return default_value[key] - -def set_int(key, val, correct_tuple=None): - if not correct_tuple or val in correct_tuple: - client.set_int(key, val) - -def get_string(key, test_func=None): - try: - val = client.get_string(key) - except KeyError: - val = "" - if not test_func or test_func(val): - return val - else: - return default_value[key] - -def set_string(key, val, test_func=None): - if not test_func or test_func(val): - client.set_string(key, val) - -def sync(): - client.suggest_sync() - -def get_default(key,sample=''): - return default_value[key] diff --git a/src/Config/__init__.py b/src/Config/__init__.py deleted file mode 100644 index c5dce245c..000000000 --- a/src/Config/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# -# Gramps - a GTK+/GNOME based genealogy program -# -# Copyright (C) 2004-2006 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$ - -""" -This package implements access to GRAMPS configuration. -It provides the choice between different storage backends. - -""" - -from _GrampsConfigKeys import * -from _GrampsIniKeys import * - diff --git a/src/DataViews/EventView.py b/src/DataViews/EventView.py index 087c03aa9..e7beed1ba 100644 --- a/src/DataViews/EventView.py +++ b/src/DataViews/EventView.py @@ -42,7 +42,7 @@ import DisplayModels import Utils import Errors import Bookmarks -import Config +import config from DdTargets import DdTargets from Editors import EditEvent, DelEventQuery from Filters.SideBar import EventSidebarFilter @@ -106,8 +106,8 @@ class EventView(ListView): 'BackSpace' : self.key_delete, } - Config.client.notify_add("/apps/gramps/interface/filter", - self.filter_toggle) + config.connect("interface.filter", + self.filter_toggle) def column_ord_setfunc(self, clist): self.dbstate.db.set_event_column_order(clist) diff --git a/src/DataViews/FamilyList.py b/src/DataViews/FamilyList.py index f1b1d6fab..896ebd710 100644 --- a/src/DataViews/FamilyList.py +++ b/src/DataViews/FamilyList.py @@ -47,7 +47,7 @@ from gui.views.listview import ListView import DisplayModels import Bookmarks import Errors -import Config +import config from Filters.SideBar import FamilySidebarFilter from ReportBase import CATEGORY_QR_FAMILY @@ -94,8 +94,8 @@ class FamilyListView(ListView): 'BackSpace' : self.key_delete, } - Config.client.notify_add("/apps/gramps/interface/filter", - self.filter_toggle) + config.connect("interface.filter", + self.filter_toggle) def column_ord_setfunc(self, clist): self.dbstate.db.set_family_list_column_order(clist) diff --git a/src/DataViews/GeoView.py b/src/DataViews/GeoView.py index 838829ef5..da5e8ab98 100644 --- a/src/DataViews/GeoView.py +++ b/src/DataViews/GeoView.py @@ -55,7 +55,7 @@ import gtk #------------------------------------------------------------------------- import gen.lib import Utils -import Config +import config import PageView from gui.utils import add_menuitem from ReportBase import CSS_FILES @@ -213,13 +213,13 @@ def _alternate_map(): """ return the alternate name of the map provider. """ - if Config.get(Config.GEOVIEW_GOOGLEMAPS): + if config.get('preferences.googlemap'): alternate_map = "google" - elif Config.get(Config.GEOVIEW_OPENLAYERS): + elif config.get('preferences.openlayers'): alternate_map = "openlayers" - elif Config.get(Config.GEOVIEW_YAHOO): + elif config.get('preferences.yahoo'): alternate_map = "yahoo" - elif Config.get(Config.GEOVIEW_MICROSOFT): + elif config.get('preferences.microsoft'): alternate_map = "microsoft" return alternate_map @@ -299,14 +299,14 @@ class GeoView(HtmlView): self.realzoom = 0 self.reallatitude = 0.0 self.reallongitude = 0.0 - if Config.get(Config.GEOVIEW_LOCKZOOM): - self.realzoom = Config.get(Config.GEOVIEW_ZOOM) - self.displaytype = Config.get(Config.GEOVIEW_MAP) + if config.get('geoview.lock'): + self.realzoom = config.get('geoview.zoom') + self.displaytype = config.get('geoview.map') self.reallatitude, self.reallongitude = conv_lat_lon( - Config.get(Config.GEOVIEW_LATITUDE), - Config.get(Config.GEOVIEW_LONGITUDE), + config.get('geoview.latitude'), + config.get('geoview.longitude'), "D.D8") - self.stylesheet = Config.get(Config.GEOVIEW_STYLESHEET) + self.stylesheet = config.get('geoview.stylesheet') if ( self.stylesheet == "" ): self.stylesheet = CSS_FILES[0][1] self.minyear = 1 @@ -341,20 +341,20 @@ class GeoView(HtmlView): Save the zoom, latitude, longitude and lock """ self._savezoomandposition() - Config.set(Config.GEOVIEW_LOCKZOOM, + config.set('geoview.lock', self.lock_action.get_action('SaveZoom').get_active() ) if self.lock_action.get_action('SaveZoom').get_active(): - Config.set(Config.GEOVIEW_ZOOM, self.realzoom) - Config.set(Config.GEOVIEW_LATITUDE, self.reallatitude) - Config.set(Config.GEOVIEW_LONGITUDE, self.reallongitude) - Config.set(Config.GEOVIEW_MAP, self.displaytype) + config.set('geoview.zoom', self.realzoom) + config.set('geoview.latitude', self.reallatitude) + config.set('geoview.longitude', self.reallongitude) + config.set('geoview.map', self.displaytype) else: - Config.set(Config.GEOVIEW_ZOOM, 0) - Config.set(Config.GEOVIEW_LATITUDE, "0.0") - Config.set(Config.GEOVIEW_LONGITUDE, "0.0") - Config.set(Config.GEOVIEW_MAP, "person") - Config.set(Config.GEOVIEW_STYLESHEET, self.stylesheet) + config.set('geoview.zoom', 0) + config.set('geoview.latitude', "0.0") + config.set('geoview.longitude', "0.0") + config.set('geoview.map', "person") + config.set('geoview.stylesheet', self.stylesheet) def init_parent_signals_for_map(self, widget, event): """ @@ -457,22 +457,22 @@ class GeoView(HtmlView): _('_OpenStreetMap'), callback=self._select_openstreetmap_map, tip=_("Select OpenStreetMap Maps")) - if Config.get(Config.GEOVIEW_GOOGLEMAPS): + if config.get('preferences.googlemap'): self._add_action('google', 'gramps-geo-altmap', _('_Google Maps'), callback=self._select_google_map, tip=_("Select Google Maps.")) - elif Config.get(Config.GEOVIEW_OPENLAYERS): + elif config.get('preferences.openlayers'): self._add_action('openlayers', 'gramps-geo-altmap', _('_OpenLayers Maps'), callback=self._select_openlayers_map, tip=_("Select OpenLayers Maps.")) - elif Config.get(Config.GEOVIEW_YAHOO): + elif config.get('preferences.yahoo'): self._add_action('yahoo', 'gramps-geo-altmap', _('_Yahoo! Maps'), callback=self._select_yahoo_map, tip=_("Select Yahoo Maps.")) - elif Config.get(Config.GEOVIEW_MICROSOFT): + elif config.get('preferences.microsoft'): self._add_action('microsoft', 'gramps-geo-altmap', _('_Microsoft Maps'), callback=self._select_microsoft_map, @@ -483,7 +483,7 @@ class GeoView(HtmlView): _("Save the zoom between places map, person map, " "family map and events map"), self._save_zoom, - Config.get(Config.GEOVIEW_LOCKZOOM) + config.get('geoview.lock') ) ]) self._add_action_group(self.lock_action) @@ -630,12 +630,12 @@ class GeoView(HtmlView): We just change the database. Restore the initial config. Is it good ? """ - if Config.get(Config.GEOVIEW_LOCKZOOM): - self.realzoom = Config.get(Config.GEOVIEW_ZOOM) - self.displaytype = Config.get(Config.GEOVIEW_MAP) + if config.get('geoview.lock'): + self.realzoom = config.get('geoview.zoom') + self.displaytype = config.get('geoview.map') self.reallatitude, self.reallongitude = conv_lat_lon( - Config.get(Config.GEOVIEW_LATITUDE), - Config.get(Config.GEOVIEW_LONGITUDE), + config.get('geoview.latitude'), + config.get('geoview.longitude'), "D.D8") def _geo_places(self): @@ -762,7 +762,7 @@ class GeoView(HtmlView): This can't be in createmapstractionheader because we need to know something which is known only after some work. """ - self.maxgen = Config.get(Config.GENERATION_DEPTH) + self.maxgen = config.get('behavior.generation-depth') if self.maxyear == 0: self.maxyear = 2100 if self.minyear == 9999: diff --git a/src/DataViews/HtmlRenderer.py b/src/DataViews/HtmlRenderer.py index 2aaab4573..dcdd4937f 100644 --- a/src/DataViews/HtmlRenderer.py +++ b/src/DataViews/HtmlRenderer.py @@ -51,7 +51,7 @@ import gtk #------------------------------------------------------------------------- from gui.views.pageview import PageView import Utils -import Config +import config from const import TEMP_DIR #------------------------------------------------------------------------- @@ -112,7 +112,7 @@ except: #no interfaces present, raise Error so that options for GeoView do not show if TOOLKIT == NOWEB : - Config.set(Config.GEOVIEW, False) + config.set('preferences.geoview', False) raise ImportError, 'No GTK html plugin found' #------------------------------------------------------------------------- diff --git a/src/DataViews/MediaView.py b/src/DataViews/MediaView.py index ba1631d11..492e8165e 100644 --- a/src/DataViews/MediaView.py +++ b/src/DataViews/MediaView.py @@ -51,7 +51,7 @@ from gui.views.listview import ListView import DisplayModels import ThumbNails import const -import Config +import config import Utils import Bookmarks import Mime @@ -114,8 +114,8 @@ class MediaView(ListView): 'BackSpace' : self.key_delete, } - Config.client.notify_add("/apps/gramps/interface/filter", - self.filter_toggle) + config.connect("interface.filter", + self.filter_toggle) def column_ord_setfunc(self, clist): self.dbstate.db.set_media_column_order(clist) diff --git a/src/DataViews/NoteView.py b/src/DataViews/NoteView.py index a833f6525..78b2fffa4 100644 --- a/src/DataViews/NoteView.py +++ b/src/DataViews/NoteView.py @@ -41,7 +41,7 @@ import DisplayModels import Utils import Errors import Bookmarks -import Config +import config import ColumnOrder from gen.lib import Note from DdTargets import DdTargets @@ -97,8 +97,8 @@ class NoteView(ListView): filter_class=NoteSidebarFilter, multiple=True) - Config.client.notify_add("/apps/gramps/interface/filter", - self.filter_toggle) + config.connect("interface.filter", + self.filter_toggle) def column_ord_setfunc(self, clist): self.dbstate.db.set_note_column_order(clist) diff --git a/src/DataViews/PedigreeView.py b/src/DataViews/PedigreeView.py index 299966636..95d8655fc 100644 --- a/src/DataViews/PedigreeView.py +++ b/src/DataViews/PedigreeView.py @@ -61,7 +61,7 @@ from ReportBase import ReportUtils from Editors import EditPerson, EditFamily from DdTargets import DdTargets import cPickle as pickle -import Config +import config from QuestionDialog import RunDatabaseRepair, ErrorDialog #------------------------------------------------------------------------- @@ -472,10 +472,10 @@ class PedigreeView(PageView.PersonNavView): self.dbstate = dbstate self.dbstate.connect('database-changed',self.change_db) #self.dbstate.connect('active-changed',self.goto_active_person) - self.force_size = Config.get(Config.PEDVIEW_TREESIZE) # Automatic resize - self.tree_style = Config.get(Config.PEDVIEW_LAYOUT) # Nice tree - self.show_images = Config.get(Config.PEDVIEW_SHOW_IMAGES) # Show photos of persons - self.show_marriage_data = Config.get(Config.PEDVIEW_SHOW_MARRIAGE) # Hide marriage data by default + self.force_size = config.get('interface.pedview-tree-size') # Automatic resize + self.tree_style = config.get('interface.pedview-layout') # Nice tree + self.show_images = config.get('interface.pedview-show-images') # Show photos of persons + self.show_marriage_data = config.get('interface.pedview-show-marriage') # Hide marriage data by default self.format_helper = FormattingHelper( self.dbstate) def change_page(self): @@ -1223,14 +1223,14 @@ class PedigreeView(PageView.PersonNavView): def change_force_size_cb(self,event,data): if data in [0,2,3,4,5]: - Config.set(Config.PEDVIEW_TREESIZE,data) + config.set('interface.pedview-tree-size',data) self.force_size = data self.dirty = True self.size_request_cb(self.notebook.parent,None) # switch to matching size def change_tree_style_cb(self,event,data): if data in [0,1]: - Config.set(Config.PEDVIEW_LAYOUT,data) + config.set('interface.pedview-layout',data) if self.tree_style != data: self.dirty = True self.tree_style = data @@ -1241,7 +1241,7 @@ class PedigreeView(PageView.PersonNavView): def change_show_images_cb(self,event): self.show_images = not self.show_images - Config.set(Config.PEDVIEW_SHOW_IMAGES,self.show_images) + config.set('interface.pedview-show-images',self.show_images) self.dirty = True if self.dbstate.active: self.rebuild_trees(self.dbstate.active.handle) # Rebuild using new style @@ -1250,7 +1250,7 @@ class PedigreeView(PageView.PersonNavView): def change_show_marriage_cb(self,event): self.show_marriage_data = not self.show_marriage_data - Config.set(Config.PEDVIEW_SHOW_MARRIAGE,self.show_marriage_data) + config.set('interface.pedview-show-marriage', self.show_marriage_data) self.dirty = True if self.dbstate.active: self.rebuild_trees(self.dbstate.active.handle) # Rebuild using new style diff --git a/src/DataViews/PersonView.py b/src/DataViews/PersonView.py index ea6116488..08a8a1f58 100644 --- a/src/DataViews/PersonView.py +++ b/src/DataViews/PersonView.py @@ -55,7 +55,7 @@ from gui.utils import add_menuitem from QuestionDialog import ErrorDialog, QuestionDialog import TreeTips import Errors -import Config +import config import const from TransUtils import sgettext as _ @@ -101,8 +101,8 @@ class PersonView(PageView.PersonNavView): } self.dirty = True - Config.client.notify_add("/apps/gramps/interface/filter", - self.filter_toggle) + config.connect("interface.filter", + self.filter_toggle) def change_page(self): PageView.PersonNavView.change_page(self) @@ -317,7 +317,7 @@ class PersonView(PageView.PersonNavView): return hpaned def post(self): - if Config.get(Config.FILTER): + if config.get('interface.filter'): self.search_bar.hide() self.filter_pane.show() else: @@ -329,7 +329,7 @@ class PersonView(PageView.PersonNavView): self.build_tree() def filter_toggle(self, client, cnxn_id, entry, data): - if Config.get(Config.FILTER): + if config.get('interface.filter'): self.search_bar.hide() self.filter_pane.show() else: @@ -519,7 +519,7 @@ class PersonView(PageView.PersonNavView): since it can change when rows are unselected when the model is set. """ if self.active: - if Config.get(Config.FILTER): + if config.get('interface.filter'): filter_info = (PeopleModel.GENERIC, self.generic_filter) else: filter_info = (PeopleModel.SEARCH, self.search_bar.get_value()) diff --git a/src/DataViews/PlaceView.py b/src/DataViews/PlaceView.py index 0eddbf96a..f30bad4c3 100644 --- a/src/DataViews/PlaceView.py +++ b/src/DataViews/PlaceView.py @@ -49,7 +49,7 @@ import DisplayModels from gui.utils import add_menuitem import Errors import Bookmarks -import Config +import config from QuestionDialog import ErrorDialog from gen.plug import PluginManager from DdTargets import DdTargets @@ -105,7 +105,7 @@ class PlaceView(PageView.ListView): 'BackSpace' : self.key_delete, } - self.mapservice = Config.get(Config.MAPSERVICE) + self.mapservice = config.get('interface.mapservice') self.mapservicedata = {} PageView.ListView.__init__( @@ -117,8 +117,8 @@ class PlaceView(PageView.ListView): multiple=True, filter_class=PlaceSidebarFilter) - Config.client.notify_add("/apps/gramps/interface/filter", - self.filter_toggle) + config.connect("interface.filter", + self.filter_toggle) def column_ord_setfunc(self, clist): self.dbstate.db.set_place_column_order(clist) @@ -213,8 +213,8 @@ class PlaceView(PageView.ListView): for label in self.mapslistlabel: label.set_label(self.mapservice_label()) label.show() - Config.set(Config.MAPSERVICE, mapkey) - Config.sync() + config.set('interface.mapservice', mapkey) + config.save() def mapservice_label(self): """ diff --git a/src/DataViews/RelationView.py b/src/DataViews/RelationView.py index 654029941..173a6937a 100644 --- a/src/DataViews/RelationView.py +++ b/src/DataViews/RelationView.py @@ -51,7 +51,7 @@ from BasicUtils import name_displayer from Utils import media_path_full, probably_alive import DateHandler import ThumbNails -import Config +import config import widgets import Errors import gen.utils @@ -121,22 +121,22 @@ class RelationshipView(PageView.PersonNavView): } dbstate.connect('database-changed', self.change_db) - self.show_siblings = Config.get(Config.FAMILY_SIBLINGS) - self.show_details = Config.get(Config.FAMILY_DETAILS) + self.show_siblings = config.get('preferences.family-siblings') + self.show_details = config.get('preferences.family-details') self.redrawing = False - self.use_shade = Config.get(Config.RELATION_SHADE) - self.toolbar_visible = Config.get(Config.TOOLBAR_ON) + self.use_shade = config.get('preferences.relation-shade') + self.toolbar_visible = config.get('interface.toolbar-on') self.color = gtk.TextView().style.white self.child = None self.old_handle = None - Config.client.notify_add("/apps/gramps/preferences/relation-shade", - self.shade_update) - Config.client.notify_add("/apps/gramps/interface/releditbtn", - self.config_update) - Config.client.notify_add("/apps/gramps/interface/toolbar-on", - self.shade_update) + config.connect("preferences.relation-shade", + self.shade_update) + config.connect("interface.releditbtn", + self.config_update) + config.connect("interface.toolbar-on", + self.shade_update) self.reorder_sensitive = False self.collapsed_items = {} @@ -168,8 +168,8 @@ class RelationshipView(PageView.PersonNavView): self.dbstate.disconnect(self.key_active_changed) def shade_update(self, client, cnxn_id, entry, data): - self.use_shade = Config.get(Config.RELATION_SHADE) - self.toolbar_visible = Config.get(Config.TOOLBAR_ON) + self.use_shade = config.get('preferences.relation-shade') + self.toolbar_visible = config.get('interface.toolbar-on') self.uistate.modify_statusbar(self.dbstate) self.redraw() @@ -369,12 +369,12 @@ class RelationshipView(PageView.PersonNavView): def siblings_toggle(self, obj): self.show_siblings = obj.get_active() self.change_person(self.dbstate.active.handle) - Config.set(Config.FAMILY_SIBLINGS, self.show_siblings) + config.set('preferences.family-siblings', self.show_siblings) def details_toggle(self, obj): self.show_details = obj.get_active() self.change_person(self.dbstate.active.handle) - Config.set(Config.FAMILY_DETAILS, self.show_details) + config.set('preferences.family-details', self.show_details) def change_db(self, db): #reset the connects @@ -535,7 +535,7 @@ class RelationshipView(PageView.PersonNavView): text = fmt % cgi.escape(name) label = widgets.DualMarkupLabel(text, _GenderCode[person.gender], x_align=1, y_align=0) - if Config.get(Config.RELEDITBTN): + if config.get('interface.releditbtn'): button = widgets.IconButton(self.edit_button_press, person.handle) button.set_tooltip_text(_('Edit %s') % name) @@ -928,7 +928,7 @@ class RelationshipView(PageView.PersonNavView): link_label = widgets.LinkLabel(name, self._button_press, handle) if self.use_shade: link_label.modify_bg(gtk.STATE_NORMAL, self.color) - if Config.get(Config.RELEDITBTN): + if config.get('interface.releditbtn'): button = widgets.IconButton(self.edit_button_press, handle) button.set_tooltip_text(_('Edit %s') % name[0]) @@ -954,7 +954,7 @@ class RelationshipView(PageView.PersonNavView): label = widgets.MarkupLabel(format % cgi.escape(title), x_align=1, y_align=0) - if Config.get(Config.RELEDITBTN): + if config.get('interface.releditbtn'): label.set_padding(0, 5) self.attach.attach(label, _PLABEL_START, _PLABEL_STOP, self.row, self.row+1, xoptions=gtk.FILL|gtk.SHRINK, @@ -967,7 +967,7 @@ class RelationshipView(PageView.PersonNavView): person = self.dbstate.db.get_person_from_handle(handle) parent = len(person.get_parent_family_handle_list()) > 0 format = '' - relation_display_theme = Config.get(Config.RELATION_DISPLAY_THEME) + relation_display_theme = config.get('preferences.relation-display-theme') if parent: if relation_display_theme == "CLASSIC": format = 'underline="single" weight="heavy" style="italic"' @@ -982,7 +982,7 @@ class RelationshipView(PageView.PersonNavView): handle, format) if self.use_shade: link_label.modify_bg(gtk.STATE_NORMAL, self.color) - if Config.get(Config.RELEDITBTN): + if config.get('interface.releditbtn'): button = widgets.IconButton(self.edit_button_press, handle) button.set_tooltip_text(_('Edit %s') % name[0]) else: @@ -1017,7 +1017,7 @@ class RelationshipView(PageView.PersonNavView): lbl = widgets.MarkupLabel(format % cgi.escape(title), x_align=1, y_align=.5) - if Config.get(Config.RELEDITBTN): + if config.get('interface.releditbtn'): lbl.set_padding(0, 5) return lbl @@ -1040,7 +1040,7 @@ class RelationshipView(PageView.PersonNavView): self.dbstate.db.get_person_from_handle(handle)) format = '' - relation_display_theme = Config.get(Config.RELATION_DISPLAY_THEME) + relation_display_theme = config.get('preferences.relation-display-theme') if child_should_be_linked and parent: if relation_display_theme == "CLASSIC": format = 'underline="single" weight="heavy" style="italic"' @@ -1069,7 +1069,7 @@ class RelationshipView(PageView.PersonNavView): if self.use_shade: link_label.modify_bg(gtk.STATE_NORMAL, self.color) link_label.set_padding(3, 0) - if child_should_be_linked and Config.get(Config.RELEDITBTN): + if child_should_be_linked and config.get('interface.releditbtn'): button = widgets.IconButton(self.edit_button_press, handle) button.set_tooltip_text(_('Edit %s') % name[0]) else: diff --git a/src/DataViews/RepositoryView.py b/src/DataViews/RepositoryView.py index 9349e5710..31ab1b32f 100644 --- a/src/DataViews/RepositoryView.py +++ b/src/DataViews/RepositoryView.py @@ -42,7 +42,7 @@ import DisplayModels import Utils import Bookmarks import Errors -import Config +import config from Editors import EditRepository, DelRepositoryQuery from DdTargets import DdTargets from Filters.SideBar import RepoSidebarFilter @@ -107,8 +107,8 @@ class RepositoryView(ListView): Bookmarks.RepoBookmarks, multiple=True, filter_class=RepoSidebarFilter) - Config.client.notify_add("/apps/gramps/interface/filter", - self.filter_toggle) + config.connect("interface.filter", + self.filter_toggle) def column_ord_setfunc(self, clist): self.dbstate.db.set_repository_column_order(clist) diff --git a/src/DataViews/SourceView.py b/src/DataViews/SourceView.py index 239ee63f5..5a54035bd 100644 --- a/src/DataViews/SourceView.py +++ b/src/DataViews/SourceView.py @@ -37,7 +37,7 @@ import gtk # #------------------------------------------------------------------------- import gen.lib -import Config +import config from gui.views.listview import ListView import DisplayModels import Utils @@ -99,8 +99,8 @@ class SourceView(ListView): Bookmarks.SourceBookmarks, multiple=True, filter_class=SourceSidebarFilter) - Config.client.notify_add("/apps/gramps/interface/filter", - self.filter_toggle) + config.connect("interface.filter", + self.filter_toggle) def column_ord_setfunc(self, clist): self.dbstate.db.set_source_column_order(clist) diff --git a/src/DataViews/__init__.py b/src/DataViews/__init__.py index 33d4ee09a..46bec0c2f 100644 --- a/src/DataViews/__init__.py +++ b/src/DataViews/__init__.py @@ -42,26 +42,26 @@ except: geopresent = False try: - import Config - dv = Config.get(Config.DATA_VIEWS) + import config + dv = config.get('interface.data-views') #remove GeoView so we do not try to eval it if import fails if not geopresent and not dv.find('GeoView') == -1: dv = dv.replace('GeoView','').replace(',,',',') DATA_VIEWS = eval("["+dv+"]") #add or remove GeoView if config says so - if geopresent and Config.get(Config.GEOVIEW) and \ + if geopresent and config.get('preferences.geoview') and \ not GeoView in DATA_VIEWS: DATA_VIEWS.append(GeoView) - Config.set(Config.DATA_VIEWS, - Config.get(Config.DATA_VIEWS)+",GeoView") - elif geopresent and not Config.get(Config.GEOVIEW) and \ + config.set('interface.data-views', + config.get('interface.data-views')+",GeoView") + elif geopresent and not config.get('preferences.geoview') and \ GeoView in DATA_VIEWS: DATA_VIEWS.remove(GeoView) - newval = Config.get(Config.DATA_VIEWS).replace('GeoView','')\ + newval = config.get('interface.data-views').replace('GeoView','')\ .replace(',,',',') if newval[-1] == ',': newval = newval[:-1] - Config.set(Config.DATA_VIEWS, newval) + config.set('interface.data-views', newval) except AttributeError: # Fallback if bad config line, or if no Config system DATA_VIEWS = [ diff --git a/src/DateHandler/__init__.py b/src/DateHandler/__init__.py index 2b7c12314..f70b1bef4 100644 --- a/src/DateHandler/__init__.py +++ b/src/DateHandler/__init__.py @@ -59,13 +59,10 @@ except: # Initialize global displayer try: - import Config - val = Config.get_date_format(LANG_TO_DISPLAY[LANG].formats) + import config + val = config.get('preferences.date-format') except: - try: - val = Config.get_date_format(LANG_TO_DISPLAY["C"].formats) - except: - val = 0 + val = 0 try: if LANG in LANG_TO_DISPLAY: diff --git a/src/DbState.py b/src/DbState.py index 313f321e3..924266bad 100644 --- a/src/DbState.py +++ b/src/DbState.py @@ -24,7 +24,7 @@ Provide the database state class from gen.db import GrampsDbRead from gen.utils import Callback -import Config +import config class DbState(Callback): """ @@ -92,14 +92,14 @@ class DbState(Callback): """ self.db = database self.db.set_prefixes( - Config.get(Config.IPREFIX), - Config.get(Config.OPREFIX), - Config.get(Config.FPREFIX), - Config.get(Config.SPREFIX), - Config.get(Config.PPREFIX), - Config.get(Config.EPREFIX), - Config.get(Config.RPREFIX), - Config.get(Config.NPREFIX) ) + config.get('preferences.iprefix'), + config.get('preferences.oprefix'), + config.get('preferences.fprefix'), + config.get('preferences.sprefix'), + config.get('preferences.pprefix'), + config.get('preferences.eprefix'), + config.get('preferences.rprefix'), + config.get('preferences.nprefix') ) self.active = None self.open = True diff --git a/src/DisplayModels/_PeopleModel.py b/src/DisplayModels/_PeopleModel.py index 274ad5ff1..f068f6bfe 100644 --- a/src/DisplayModels/_PeopleModel.py +++ b/src/DisplayModels/_PeopleModel.py @@ -62,13 +62,13 @@ from BasicUtils import name_displayer import DateHandler import ToolTips import GrampsLocale -import Config +import config from gen.utils.longop import LongOpStatus from Filters import SearchFilter, ExactSearchFilter from Lru import LRU _CACHE_SIZE = 250 -invalid_date_format = Config.get(Config.INVALID_DATE_FORMAT) +invalid_date_format = config.get('preferences.invalid-date-format') class NodeTreeMap(object): @@ -246,16 +246,16 @@ class PeopleModel(gtk.GenericTreeModel): self.lru_bdate = LRU(_CACHE_SIZE) self.lru_ddate = LRU(_CACHE_SIZE) - Config.client.notify_add("/apps/gramps/preferences/todo-color", - self.update_todo) - Config.client.notify_add("/apps/gramps/preferences/custom-marker-color", - self.update_custom) - Config.client.notify_add("/apps/gramps/preferences/complete-color", - self.update_complete) + config.connect("preferences.todo-color", + self.update_todo) + config.connect("preferences.custom-marker-color", + self.update_custom) + config.connect("preferences.complete-color", + self.update_complete) - self.complete_color = Config.get(Config.COMPLETE_COLOR) - self.todo_color = Config.get(Config.TODO_COLOR) - self.custom_color = Config.get(Config.CUSTOM_MARKER_COLOR) + self.complete_color = config.get('preferences.complete-color') + self.todo_color = config.get('preferences.todo-color') + self.custom_color = config.get('preferences.custom-marker-color') self.marker_color_column = 10 self.tooltip_column = 11 @@ -289,13 +289,13 @@ class PeopleModel(gtk.GenericTreeModel): self.rebuild_data(data_filter, skip) def update_todo(self,client,cnxn_id,entry,data): - self.todo_color = Config.get(Config.TODO_COLOR) + self.todo_color = config.get('preferences.todo-color') def update_custom(self,client,cnxn_id,entry,data): - self.custom_color = Config.get(Config.CUSTOM_MARKER_COLOR) + self.custom_color = config.get('preferences.custom-marker-color') def update_complete(self,client,cnxn_id,entry,data): - self.complete_color = Config.get(Config.COMPLETE_COLOR) + self.complete_color = config.get('preferences.complete-color') def rebuild_data(self, data_filter=None, skip=[]): """ diff --git a/src/DisplayState.py b/src/DisplayState.py index 99582e1d7..a948cac28 100644 --- a/src/DisplayState.py +++ b/src/DisplayState.py @@ -52,7 +52,7 @@ import gobject # #------------------------------------------------------------------------- import gen.utils -import Config +import config from BasicUtils import name_displayer import const import ManagedWindow @@ -436,7 +436,7 @@ class DisplayState(gen.utils.Callback): if person: pname = name_displayer.display(person) name = "[%s] %s" % (person.get_gramps_id(), pname) - if Config.get(Config.STATUSBAR) > 1: + if config.get('interface.statusbar') > 1: if person.handle != dbstate.db.get_default_handle(): msg = self.display_relationship(dbstate) if msg: diff --git a/src/DisplayTabs/_EventRefModel.py b/src/DisplayTabs/_EventRefModel.py index 44a0bb5e5..6432c6a27 100644 --- a/src/DisplayTabs/_EventRefModel.py +++ b/src/DisplayTabs/_EventRefModel.py @@ -43,14 +43,14 @@ import cgi # #------------------------------------------------------------------------- import DateHandler -import Config +import config #------------------------------------------------------------------------- # # Globals # #------------------------------------------------------------------------- -invalid_date_format = Config.get(Config.INVALID_DATE_FORMAT) +invalid_date_format = config.get('preferences.invalid-date-format') #------------------------------------------------------------------------- # diff --git a/src/Editors/AddMedia.py b/src/Editors/AddMedia.py index 73e5260c8..4663b2ec4 100644 --- a/src/Editors/AddMedia.py +++ b/src/Editors/AddMedia.py @@ -51,7 +51,7 @@ import gtk # #------------------------------------------------------------------------- import const -import Config +import config import Utils import Mime import GrampsDisplay @@ -84,8 +84,8 @@ class AddMediaObject(ManagedWindow.ManagedWindow): self.obj = mediaobj self.callback = callback - self.last_directory = Config.get(Config.ADDMEDIA_IMGDIR) - self.relative_path = Config.get(Config.ADDMEDIA_RELPATH) + self.last_directory = config.get('behavior.addmedia-image-dir') + self.relative_path = config.get('behavior.addmedia-relative-path') self.glade = Glade() self.set_window( @@ -204,9 +204,9 @@ class AddMediaObject(ManagedWindow.ManagedWindow): self.image.set_from_pixbuf(image) def _cleanup_on_exit(self): - Config.set(Config.ADDMEDIA_IMGDIR, self.last_directory) - Config.set(Config.ADDMEDIA_RELPATH, self.relative_path) - Config.sync() + config.set('behavior.addmedia-image-dir', self.last_directory) + config.set('behavior.addmedia-relative-path', self.relative_path) + config.save() #------------------------------------------------------------------------- # diff --git a/src/Editors/_EditAddress.py b/src/Editors/_EditAddress.py index 65544fb8c..b828ea7ec 100644 --- a/src/Editors/_EditAddress.py +++ b/src/Editors/_EditAddress.py @@ -46,7 +46,7 @@ import gtk # #------------------------------------------------------------------------- import const -import Config +import config from _EditSecondary import EditSecondary from gen.lib import NoteType from glade import Glade @@ -74,8 +74,8 @@ class EditAddress(EditSecondary): EditSecondary.__init__(self, dbstate, uistate, track, addr, callback) def _local_init(self): - self.width_key = Config.ADDRESS_WIDTH - self.height_key = Config.ADDRESS_HEIGHT + self.width_key = 'interface.address-width' + self.height_key = 'interface.address-height' self.top = Glade() self.set_window(self.top.toplevel, diff --git a/src/Editors/_EditAttribute.py b/src/Editors/_EditAttribute.py index a6866d272..0b0ace15b 100644 --- a/src/Editors/_EditAttribute.py +++ b/src/Editors/_EditAttribute.py @@ -46,7 +46,7 @@ import gtk # #------------------------------------------------------------------------- import const -import Config +import config from _EditSecondary import EditSecondary from gen.lib import NoteType from glade import Glade @@ -76,8 +76,8 @@ class EditAttribute(EditSecondary): EditSecondary.__init__(self, state, uistate, track, attrib, callback) def _local_init(self): - self.width_key = Config.ATTRIBUTE_WIDTH - self.height_key = Config.ATTRIBUTE_HEIGHT + self.width_key = 'interface.attribute-width' + self.height_key = 'interface.attribute-height' self.top = Glade() self.set_window(self.top.toplevel, diff --git a/src/Editors/_EditChildRef.py b/src/Editors/_EditChildRef.py index 90d1a7f44..9053de8a8 100644 --- a/src/Editors/_EditChildRef.py +++ b/src/Editors/_EditChildRef.py @@ -49,7 +49,7 @@ import const from _EditSecondary import EditSecondary from gen.lib import NoteType import Errors -import Config +import config from glade import Glade from DisplayTabs import SourceEmbedList, NoteTab from widgets import MonitoredDataType, PrivacyButton @@ -87,8 +87,8 @@ class EditChildRef(EditSecondary): childref, callback) def _local_init(self): - self.width_key = Config.CHILD_REF_WIDTH - self.height_key = Config.CHILD_REF_HEIGHT + self.width_key = 'interface.child-ref-width' + self.height_key = 'interface.child-ref-height' self.top = Glade() self.set_window(self.top.toplevel, diff --git a/src/Editors/_EditEvent.py b/src/Editors/_EditEvent.py index f73511bf0..fece4e294 100644 --- a/src/Editors/_EditEvent.py +++ b/src/Editors/_EditEvent.py @@ -41,7 +41,7 @@ import gtk # #------------------------------------------------------------------------- import const -import Config +import config import gen.lib import GrampsDisplay from _EditPrimary import EditPrimary @@ -97,8 +97,8 @@ class EditEvent(EditPrimary): self.dbstate.db.get_family_event_types() def _local_init(self): - self.width_key = Config.EVENT_WIDTH - self.height_key = Config.EVENT_HEIGHT + self.width_key = 'interface.event-width' + self.height_key = 'interface.event-height' self.top = Glade() self.set_window(self.top.toplevel, None, diff --git a/src/Editors/_EditEventRef.py b/src/Editors/_EditEventRef.py index 81707893b..f06e2cf07 100644 --- a/src/Editors/_EditEventRef.py +++ b/src/Editors/_EditEventRef.py @@ -34,7 +34,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- import const -import Config +import config import gen.lib from glade import Glade from DisplayTabs import (SourceEmbedList, NoteTab, GalleryTab, @@ -58,8 +58,8 @@ class EditEventRef(EditReference): self._init_event() def _local_init(self): - self.width_key = Config.EVENT_REF_WIDTH - self.height_key = Config.EVENT_REF_HEIGHT + self.width_key = 'interface.event-ref-width' + self.height_key = 'interface.event-ref-height' self.top = Glade() self.set_window(self.top.toplevel, diff --git a/src/Editors/_EditFamily.py b/src/Editors/_EditFamily.py index 1a8f867b6..6f96f56b2 100644 --- a/src/Editors/_EditFamily.py +++ b/src/Editors/_EditFamily.py @@ -55,7 +55,7 @@ import pango #------------------------------------------------------------------------- import Utils import const -import Config +import config from BasicUtils import name_displayer import gen.lib import Errors @@ -212,7 +212,7 @@ class ChildEmbedList(EmbeddedList): def add_button_clicked(self, obj): from Editors import EditPerson person = gen.lib.Person() - autoname = Config.get(Config.SURNAME_GUESSING) + autoname = config.get('behavior.surname-guessing') #_("Father's surname"), #_("None"), #_("Combination of mother's and father's surname"), @@ -421,7 +421,7 @@ class EditFamily(EditPrimary): self.obj.get_mother_handle() is None and \ len(self.obj.get_child_ref_list()) == 1: self.add_parent = True - if not Config.get(Config.FAMILY_WARN): + if not config.get('preferences.family-warn'): for i in self.hidden: i.set_sensitive(False) @@ -433,7 +433,7 @@ class EditFamily(EditPrimary): "are available when you create a new family. The " "remaining fields will become available after you " "attempt to select a parent."), - Config.FAMILY_WARN) + 'preferences.family-warn') else: self.add_parent = False @@ -558,8 +558,8 @@ class EditFamily(EditPrimary): return (_('Edit Family'), self.get_menu_title()) def build_interface(self): - self.width_key = Config.FAMILY_WIDTH - self.height_key = Config.FAMILY_HEIGHT + self.width_key = 'interface.family-width' + self.height_key = 'interface.family-height' self.top = Glade() self.set_window(self.top.toplevel, None, self.get_menu_title()) @@ -588,9 +588,9 @@ class EditFamily(EditPrimary): self.mbutton_del = self.top.get_object('mbutton_del') self.mbutton_edit = self.top.get_object('mbutton_edit') - mbutton_index.set_tooltip_text(_("Select a person as the mother")) - mbutton_add.set_tooltip_text(_("Add a new person as the mother")) - mbutton_del.set_tooltip_text(_("Remove the person as the mother")) + self.mbutton_index.set_tooltip_text(_("Select a person as the mother")) + self.mbutton_add.set_tooltip_text(_("Add a new person as the mother")) + self.mbutton_del.set_tooltip_text(_("Remove the person as the mother")) self.mbutton_edit.connect('button-press-event', self.edit_mother) self.mbutton_edit.connect('key-press-event', self.edit_mother) @@ -746,7 +746,7 @@ class EditFamily(EditPrimary): from Editors import EditPerson person = gen.lib.Person() person.set_gender(gen.lib.Person.FEMALE) - autoname = Config.get(Config.SURNAME_GUESSING) + autoname = config.get('behavior.surname-guessing') #_("Father's surname"), #_("None"), #_("Combination of mother's and father's surname"), @@ -764,7 +764,7 @@ class EditFamily(EditPrimary): from Editors import EditPerson person = gen.lib.Person() person.set_gender(gen.lib.Person.MALE) - autoname = Config.get(Config.SURNAME_GUESSING) + autoname = config.get('behavior.surname-guessing') #_("Father's surname"), #_("None"), #_("Combination of mother's and father's surname"), diff --git a/src/Editors/_EditLdsOrd.py b/src/Editors/_EditLdsOrd.py index a22b734b0..f119454e5 100644 --- a/src/Editors/_EditLdsOrd.py +++ b/src/Editors/_EditLdsOrd.py @@ -45,7 +45,7 @@ import gtk # #------------------------------------------------------------------------- import const -import Config +import config import gen.lib from BasicUtils import name_displayer import LdsUtils @@ -141,8 +141,8 @@ class EditLdsOrd(EditSecondary): EditSecondary.__init__(self, state, uistate, track, attrib, callback) def _local_init(self): - self.width_key = Config.LDS_WIDTH - self.height_key = Config.LDS_HEIGHT + self.width_key = 'interface.lds-width' + self.height_key = 'interface.lds-height' self.top = Glade() self.set_window(self.top.toplevel, diff --git a/src/Editors/_EditLocation.py b/src/Editors/_EditLocation.py index 6de8b6e7d..d455df5a0 100644 --- a/src/Editors/_EditLocation.py +++ b/src/Editors/_EditLocation.py @@ -27,7 +27,7 @@ # #------------------------------------------------------------------------- import const -import Config +import config from _EditSecondary import EditSecondary from glade import Glade from widgets import MonitoredEntry @@ -45,8 +45,8 @@ class EditLocation(EditSecondary): location, callback) def _local_init(self): - self.width_key = Config.LOCATION_WIDTH - self.height_key = Config.LOCATION_HEIGHT + self.width_key = 'interface.location-width' + self.height_key = 'interface.location-height' self.top = Glade() self.set_window(self.top.toplevel, None, _('Location Editor')) diff --git a/src/Editors/_EditMedia.py b/src/Editors/_EditMedia.py index 1d4e95463..68ca81fa6 100644 --- a/src/Editors/_EditMedia.py +++ b/src/Editors/_EditMedia.py @@ -42,7 +42,7 @@ import gtk #------------------------------------------------------------------------- from gui.utils import open_file_with_default_application import const -import Config +import config import gen.lib import Mime import ThumbNails @@ -91,8 +91,8 @@ class EditMedia(EditPrimary): def _local_init(self): assert(self.obj) - self.width_key = Config.MEDIA_WIDTH - self.height_key = Config.MEDIA_HEIGHT + self.width_key = 'interface.media-width' + self.height_key = 'interface.media-height' self.glade = Glade() self.set_window(self.glade.toplevel, diff --git a/src/Editors/_EditMediaRef.py b/src/Editors/_EditMediaRef.py index 804e14611..0cb7eeafb 100644 --- a/src/Editors/_EditMediaRef.py +++ b/src/Editors/_EditMediaRef.py @@ -43,7 +43,7 @@ import gtk #------------------------------------------------------------------------- from gui.utils import open_file_with_default_application import const -import Config +import config import Mime import ThumbNails import Utils @@ -71,8 +71,8 @@ class EditMediaRef(EditReference): self._update_addmedia) def _local_init(self): - self.width_key = Config.MEDIA_REF_WIDTH - self.height_key = Config.MEDIA_REF_HEIGHT + self.width_key = 'interface.media-ref-width' + self.height_key = 'interface.media-ref-height' self.top = Glade() self.set_window(self.top.toplevel, diff --git a/src/Editors/_EditName.py b/src/Editors/_EditName.py index 6fe64ec3d..4df8885d3 100644 --- a/src/Editors/_EditName.py +++ b/src/Editors/_EditName.py @@ -42,7 +42,7 @@ import gtk # #------------------------------------------------------------------------- import const -import Config +import config from BasicUtils import name_displayer from _EditSecondary import EditSecondary from gen.lib import NoteType @@ -107,8 +107,8 @@ class EditName(EditSecondary): track, name, callback) def _local_init(self): - self.width_key = Config.NAME_WIDTH - self.height_key = Config.NAME_HEIGHT + self.width_key = 'interface.name-width' + self.height_key = 'interface.name-height' self.top = Glade() diff --git a/src/Editors/_EditNote.py b/src/Editors/_EditNote.py index 45582a3bd..b1e44a514 100644 --- a/src/Editors/_EditNote.py +++ b/src/Editors/_EditNote.py @@ -45,7 +45,7 @@ import pango # GRAMPS modules # #------------------------------------------------------------------------- -import Config +import config import const from widgets import StyledTextEditor from Editors._EditPrimary import EditPrimary @@ -164,8 +164,8 @@ class EditNote(EditPrimary): and overridden here. """ - self.width_key = Config.NOTE_WIDTH - self.height_key = Config.NOTE_HEIGHT + self.width_key = 'interface.note-width' + self.height_key = 'interface.note-height' self.top = Glade() diff --git a/src/Editors/_EditPerson.py b/src/Editors/_EditPerson.py index eebbbd410..2d4ddcedc 100644 --- a/src/Editors/_EditPerson.py +++ b/src/Editors/_EditPerson.py @@ -58,7 +58,7 @@ from glade import Glade from gen.utils import set_birth_death_index from Editors._EditPrimary import EditPrimary -import Config +import config from QuestionDialog import ErrorDialog, ICON from DisplayTabs import (PersonEventEmbedList, NameEmbedList, SourceEmbedList, @@ -128,8 +128,8 @@ class EditPerson(EditPrimary): This is called by the base class of EditPrimary, and overridden here. """ - self.width_key = Config.PERSON_WIDTH - self.height_key = Config.PERSON_HEIGHT + self.width_key = 'interface.person-width' + self.height_key = 'interface.person-height' self.pname = self.obj.get_primary_name() self.should_guess_gender = (not self.obj.get_gramps_id() and self.obj.get_gender () == @@ -276,7 +276,7 @@ class EditPerson(EditPrimary): [_('Prefix'), _('Suffix')], [self.pname.set_surname_prefix, self.pname.set_suffix], [self.pname.get_surname_prefix, self.pname.get_suffix], - default = Config.get(Config.PREFIX_SUFFIX), + default = config.get('interface.prefix-suffix'), read_only = self.db.readonly) self.patro_title = widgets.MonitoredComboSelectedEntry( @@ -285,7 +285,7 @@ class EditPerson(EditPrimary): [_('Patronymic'), _('Person|Title')], [self.pname.set_patronymic, self.pname.set_title], [self.pname.get_patronymic, self.pname.get_title], - default = Config.get(Config.PATRO_TITLE), + default = config.get('interface.patro-title'), read_only = self.db.readonly) self.call = widgets.MonitoredEntry( @@ -892,9 +892,9 @@ class EditPerson(EditPrimary): return child_ref_list def _cleanup_on_exit(self): - Config.set(Config.PREFIX_SUFFIX, self.prefix_suffix.active_key) - Config.set(Config.PATRO_TITLE, self.patro_title.active_key) - Config.sync() + config.set('interface.prefix-suffix', self.prefix_suffix.active_key) + config.set('interface.patro-title', self.patro_title.active_key) + config.save() class GenderDialog(gtk.MessageDialog): diff --git a/src/Editors/_EditPersonRef.py b/src/Editors/_EditPersonRef.py index 42fe66db5..a91b30dbc 100644 --- a/src/Editors/_EditPersonRef.py +++ b/src/Editors/_EditPersonRef.py @@ -46,7 +46,7 @@ import gtk # #------------------------------------------------------------------------- import const -import Config +import config from BasicUtils import name_displayer from _EditSecondary import EditSecondary from gen.lib import NoteType @@ -74,8 +74,8 @@ class EditPersonRef(EditSecondary): EditSecondary.__init__(self, dbstate, uistate, track, addr, callback) def _local_init(self): - self.width_key = Config.PERSON_REF_WIDTH - self.height_key = Config.PERSON_REF_HEIGHT + self.width_key = 'interface.person-ref-width' + self.height_key = 'interface.person-ref-height' self.top = Glade() diff --git a/src/Editors/_EditPlace.py b/src/Editors/_EditPlace.py index caf34f23f..4b8aff87c 100644 --- a/src/Editors/_EditPlace.py +++ b/src/Editors/_EditPlace.py @@ -43,7 +43,7 @@ import gtk # #------------------------------------------------------------------------- import const -import Config +import config import gen.lib from Editors._EditPrimary import EditPrimary from DisplayTabs import (GrampsTab, LocationEmbedList, SourceEmbedList, @@ -113,8 +113,8 @@ class EditPlace(EditPrimary): return gen.lib.Place() def _local_init(self): - self.width_key = Config.PLACE_WIDTH - self.height_key = Config.PLACE_HEIGHT + self.width_key = 'interface.place-width' + self.height_key = 'interface.place-height' self.top = Glade() diff --git a/src/Editors/_EditPrimary.py b/src/Editors/_EditPrimary.py index 374e49f29..1818fa6e1 100644 --- a/src/Editors/_EditPrimary.py +++ b/src/Editors/_EditPrimary.py @@ -43,7 +43,7 @@ import gtk import ManagedWindow import DateHandler from BasicUtils import name_displayer -import Config +import config import GrampsDisplay from QuestionDialog import SaveDialog import gen.lib @@ -197,7 +197,7 @@ class EditPrimary(ManagedWindow.ManagedWindow, DbGUIElement): def close(self, *obj): """If the data has changed, give the user a chance to cancel the close window""" - if not Config.get(Config.DONT_ASK) and self.data_has_changed(): + if not config.get('interface.dont-ask') and self.data_has_changed(): SaveDialog( _('Save Changes?'), _('If you close without saving, the changes you ' diff --git a/src/Editors/_EditReference.py b/src/Editors/_EditReference.py index 98a392210..8c4c0d04f 100644 --- a/src/Editors/_EditReference.py +++ b/src/Editors/_EditReference.py @@ -35,7 +35,7 @@ import gtk #------------------------------------------------------------------------- import ManagedWindow from DisplayTabs import GrampsTab -import Config +import config from gui.dbguielement import DbGUIElement #------------------------------------------------------------------------- diff --git a/src/Editors/_EditRepoRef.py b/src/Editors/_EditRepoRef.py index c03fc48f0..8e7a89671 100644 --- a/src/Editors/_EditRepoRef.py +++ b/src/Editors/_EditRepoRef.py @@ -34,7 +34,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- import const -import Config +import config from gen.lib import NoteType @@ -56,8 +56,8 @@ class EditRepoRef(EditReference): source_ref, update) def _local_init(self): - self.width_key = Config.REPO_REF_WIDTH - self.height_key = Config.REPO_REF_HEIGHT + self.width_key = 'interface.repo-ref-width' + self.height_key = 'interface.repo-ref-height' self.top = Glade() self.set_window(self.top.toplevel, diff --git a/src/Editors/_EditRepository.py b/src/Editors/_EditRepository.py index 278b54845..7aa8caa45 100644 --- a/src/Editors/_EditRepository.py +++ b/src/Editors/_EditRepository.py @@ -41,7 +41,7 @@ import gtk # #------------------------------------------------------------------------- import const -import Config +import config import gen.lib from widgets import MonitoredEntry, MonitoredDataType, PrivacyButton @@ -73,8 +73,8 @@ class EditRepository(EditPrimary): return title def _local_init(self): - self.width_key = Config.REPO_WIDTH - self.height_key = Config.REPO_HEIGHT + self.width_key = 'interface.repo-width' + self.height_key = 'interface.repo-height' self.glade = Glade() diff --git a/src/Editors/_EditSecondary.py b/src/Editors/_EditSecondary.py index ccb649847..0126f22f6 100644 --- a/src/Editors/_EditSecondary.py +++ b/src/Editors/_EditSecondary.py @@ -23,7 +23,7 @@ import ManagedWindow import GrampsDisplay -import Config +import config from gui.dbguielement import DbGUIElement class EditSecondary(ManagedWindow.ManagedWindow, DbGUIElement): diff --git a/src/Editors/_EditSource.py b/src/Editors/_EditSource.py index ad6ffc1dd..a92a8685d 100644 --- a/src/Editors/_EditSource.py +++ b/src/Editors/_EditSource.py @@ -43,7 +43,7 @@ import gtk # #------------------------------------------------------------------------- import const -import Config +import config import gen.lib from Editors._EditPrimary import EditPrimary @@ -79,8 +79,8 @@ class EditSource(EditPrimary): return title def _local_init(self): - self.width_key = Config.SOURCE_WIDTH - self.height_key = Config.SOURCE_HEIGHT + self.width_key = 'interface.source-width' + self.height_key = 'interface.source-height' assert(self.obj) self.glade = Glade() diff --git a/src/Editors/_EditSourceRef.py b/src/Editors/_EditSourceRef.py index 782603789..5c6385cec 100644 --- a/src/Editors/_EditSourceRef.py +++ b/src/Editors/_EditSourceRef.py @@ -34,7 +34,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- import const -import Config +import config import gen.lib from glade import Glade from DisplayTabs import (NoteTab, GalleryTab, SourceBackRefList, @@ -56,8 +56,8 @@ class EditSourceRef(EditReference): source_ref, update) def _local_init(self): - self.width_key = Config.EVENT_REF_WIDTH - self.height_key = Config.EVENT_REF_HEIGHT + self.width_key = 'interface.event-ref-width' + self.height_key = 'interface.event-ref-height' self.top = Glade() diff --git a/src/Editors/_EditUrl.py b/src/Editors/_EditUrl.py index 8153da0b0..706b262ed 100644 --- a/src/Editors/_EditUrl.py +++ b/src/Editors/_EditUrl.py @@ -34,7 +34,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- import const -import Config +import config from _EditSecondary import EditSecondary from widgets import MonitoredEntry, PrivacyButton, MonitoredDataType from glade import Glade @@ -52,8 +52,8 @@ class EditUrl(EditSecondary): url, callback) def _local_init(self): - self.width_key = Config.URL_WIDTH - self.height_key = Config.URL_HEIGHT + self.width_key = 'interface.url-width' + self.height_key = 'interface.url-height' self.top = Glade() self.jump = self.top.get_object('jump') diff --git a/src/ExportAssistant.py b/src/ExportAssistant.py index 317fe8ad4..22320e67b 100644 --- a/src/ExportAssistant.py +++ b/src/ExportAssistant.py @@ -52,7 +52,7 @@ import gtk #------------------------------------------------------------------------- import const -import Config +import config from gen.plug import PluginManager import Utils import ManagedWindow @@ -199,7 +199,7 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) : table.set_col_spacings(6) group = None - recent_type = Config.get(Config.RECENT_EXPORT_TYPE) + recent_type = config.get('behavior.recent-export-type') for ix in range(len(self.__exporters)): title = self.__exporters[ix].get_name() @@ -541,9 +541,9 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) : ext = self.__exporters[ix].get_extension() # Suggested folder: try last export, then last import, then home. - default_dir = Config.get(Config.RECENT_EXPORT_DIR) + default_dir = config.get('paths.recent-export-dir') if len(default_dir)<=1: - default_dir = Config.get(Config.RECENT_IMPORT_DIR) + default_dir = config.get('paths.recent-import-dir') if len(default_dir)<=1: default_dir = const.USER_HOME @@ -563,9 +563,9 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) : """ filename = Utils.get_unicode_path(self.chooser.get_filename()) - Config.set(Config.RECENT_EXPORT_DIR, os.path.split(filename)[0]) + config.set('paths.recent-export-dir', os.path.split(filename)[0]) ix = self.get_selected_format_index() - Config.set(Config.RECENT_EXPORT_TYPE, ix) + config.set('behavior.recent-export-type', ix) export_function = self.__exporters[ix].get_export_function() success = export_function(self.dbstate.db, filename, diff --git a/src/ExportOptions.py b/src/ExportOptions.py index 87ad1b650..055aace87 100644 --- a/src/ExportOptions.py +++ b/src/ExportOptions.py @@ -36,7 +36,7 @@ import gobject # GRAMPS modules # #------------------------------------------------------------------------- -import Config +import config from BasicUtils import name_displayer from Filters import GenericFilter, Rules @@ -92,9 +92,9 @@ class WriterOptionBox(object): self.unlinked_check = gtk.CheckButton( _('_Do not include unlinked records')) - self.private_check.set_active(Config.get(Config.EXPORT_NO_PRIVATE)) - self.restrict_check.set_active(Config.get(Config.EXPORT_RESTRICT)) - self.unlinked_check.set_active(Config.get(Config.EXPORT_NO_UNLINKED)) + self.private_check.set_active(config.get('export.no-private')) + self.restrict_check.set_active(config.get('export.restrict-living')) + self.unlinked_check.set_active(config.get('export.no-unlinked')) table.set_border_width(12) table.set_row_spacings(6) @@ -185,10 +185,10 @@ class WriterOptionBox(object): self.private = self.private_check.get_active() self.unlinked = self.unlinked_check.get_active() - Config.set(Config.EXPORT_NO_PRIVATE, self.private) - Config.set(Config.EXPORT_RESTRICT, self.restrict) - Config.set(Config.EXPORT_NO_UNLINKED, self.unlinked) - Config.sync() + config.set('export.no-private', self.private) + config.set('export.restrict-living', self.restrict) + config.set('export.no-unlinked', self.unlinked) + config.save() model = self.filter_obj.get_model() node = self.filter_obj.get_active_iter() diff --git a/src/Filters/SideBar/_SidebarFilter.py b/src/Filters/SideBar/_SidebarFilter.py index 93488387c..d1ccf6485 100644 --- a/src/Filters/SideBar/_SidebarFilter.py +++ b/src/Filters/SideBar/_SidebarFilter.py @@ -25,7 +25,7 @@ import gtk import pango import widgets -import Config +import config _RETURN = gtk.gdk.keyval_from_name("Return") _KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter") @@ -91,8 +91,8 @@ class SidebarFilter(object): xoptions=gtk.FILL, yoptions=0) def btn_clicked(self, obj): - Config.set(Config.FILTER, False) - Config.sync() + config.set('interface.filter', False) + config.save() def get_widget(self): return self.table diff --git a/src/GrampsCfg.py b/src/GrampsCfg.py index 280d0fac3..806256efb 100644 --- a/src/GrampsCfg.py +++ b/src/GrampsCfg.py @@ -44,7 +44,7 @@ import gobject # gramps modules # #------------------------------------------------------------------------- -import Config +import config import const import DateHandler from BasicUtils import name_displayer as _nd @@ -167,14 +167,14 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): table.set_border_width(12) table.set_col_spacings(6) table.set_row_spacings(6) - self.add_entry(table, _('Name'), 0, Config.RESEARCHER_NAME) - self.add_entry(table, _('Address'), 1, Config.RESEARCHER_ADDR) - self.add_entry(table, _('City'), 2, Config.RESEARCHER_CITY) - self.add_entry(table, _('State/Province'), 3, Config.RESEARCHER_STATE) - self.add_entry(table, _('Country'), 4, Config.RESEARCHER_COUNTRY) - self.add_entry(table, _('ZIP/Postal Code'), 5, Config.RESEARCHER_POSTAL) - self.add_entry(table, _('Phone'), 6, Config.RESEARCHER_PHONE) - self.add_entry(table, _('Email'), 7, Config.RESEARCHER_EMAIL) + self.add_entry(table, _('Name'), 0, 'researcher.researcher-name') + self.add_entry(table, _('Address'), 1, 'researcher.researcher-addr') + self.add_entry(table, _('City'), 2, 'researcher.researcher-city') + self.add_entry(table, _('State/Province'), 3, 'researcher.researcher-state') + self.add_entry(table, _('Country'), 4, 'researcher.researcher-country') + self.add_entry(table, _('ZIP/Postal Code'), 5, 'researcher.researcher-postal') + self.add_entry(table, _('Phone'), 6, 'researcher.researcher-phone') + self.add_entry(table, _('Email'), 7, 'researcher.researcher-email') return table def add_prefix_panel(self): @@ -185,21 +185,21 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): table.set_border_width(12) table.set_col_spacings(6) table.set_row_spacings(6) - self.add_entry(table, _('Person'), 0, Config.IPREFIX, + self.add_entry(table, _('Person'), 0, 'preferences.iprefix', self.update_idformat_entry) - self.add_entry(table, _('Family'), 1, Config.FPREFIX, + self.add_entry(table, _('Family'), 1, 'preferences.fprefix', self.update_idformat_entry) - self.add_entry(table, _('Place'), 2, Config.PPREFIX, + self.add_entry(table, _('Place'), 2, 'preferences.pprefix', self.update_idformat_entry) - self.add_entry(table, _('Source'), 3, Config.SPREFIX, + self.add_entry(table, _('Source'), 3, 'preferences.sprefix', self.update_idformat_entry) - self.add_entry(table, _('Media Object'), 4, Config.OPREFIX, + self.add_entry(table, _('Media Object'), 4, 'preferences.oprefix', self.update_idformat_entry) - self.add_entry(table, _('Event'), 5, Config.EPREFIX, + self.add_entry(table, _('Event'), 5, 'preferences.eprefix', self.update_idformat_entry) - self.add_entry(table, _('Repository'), 6, Config.RPREFIX, + self.add_entry(table, _('Repository'), 6, 'preferences.rprefix', self.update_idformat_entry) - self.add_entry(table, _('Note'), 7, Config.NPREFIX, + self.add_entry(table, _('Note'), 7, 'preferences.nprefix', self.update_idformat_entry) return table @@ -210,20 +210,20 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): table.set_row_spacings(6) self.add_checkbox( table, _('Suppress warning when adding parents to a child'), - 0, Config.FAMILY_WARN) + 0, 'preferences.family-warn') self.add_checkbox( table, _('Suppress warning when cancelling with changed data'), - 1, Config.DONT_ASK) + 1, 'interface.dont-ask') self.add_checkbox( table, _('Suppress warning about missing researcher when' ' exporting to GEDCOM'), - 2, Config.OWNER_WARN) + 2, 'behavior.owner-warn') self.add_checkbox( table, _('Show plugin status dialog on plugin load error'), - 3, Config.POP_PLUGIN_STATUS) + 3, 'behavior.pop-plugin-status') return table @@ -234,11 +234,11 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): table.set_row_spacings(6) self.comp_color = self.add_color(table, _("Complete"), 0, - Config.COMPLETE_COLOR) + 'preferences.complete-color') self.todo_color = self.add_color(table, _("ToDo"), 1, - Config.TODO_COLOR) + 'preferences.todo-color') self.custom_color = self.add_color(table, _("Custom"), 2, - Config.CUSTOM_MARKER_COLOR) + 'preferences.custom-marker-color') button = gtk.Button(stock=gtk.STOCK_REVERT_TO_SAVED) button.connect('clicked', self.reset_colors) @@ -247,13 +247,13 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): def reset_colors(self, obj): - def_comp = Config.get_default(Config.COMPLETE_COLOR, '') - def_todo = Config.get_default(Config.TODO_COLOR, '') - def_cust = Config.get_default(Config.CUSTOM_MARKER_COLOR, '') + def_comp = config.get_default('preferences.complete-color') + def_todo = config.get_default('preferences.todo-color') + def_cust = config.get_default('preferences.custom-marker-color') - Config.set(Config.COMPLETE_COLOR, def_comp) - Config.set(Config.TODO_COLOR, def_todo) - Config.set(Config.CUSTOM_MARKER_COLOR, def_cust) + config.set('preferences.complete-color', def_comp) + config.set('preferences.todo-color', def_todo) + config.set('preferences.custom-marker-color', def_cust) self.comp_color.set_color(gtk.gdk.color_parse(def_comp)) self.todo_color.set_color(gtk.gdk.color_parse(def_todo)) @@ -275,7 +275,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): self.add_checkbox( table, _('Add GeoView to GRAMPS showing internet maps based on ' 'your data.'), - 1, Config.GEOVIEW) + 1, 'preferences.geoview') self.add_text( table, _('GeoView uses OpenStreetMap and one other map provider.\n' @@ -284,19 +284,19 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): maps=self.add_radiobox( table, _('Google Maps'), - 3, Config.GEOVIEW_GOOGLEMAPS, None, 1) + 3, 'preferences.googlemap', None, 1) self.add_radiobox( table, _('OpenLayers'), - 3, Config.GEOVIEW_OPENLAYERS, maps, 2) + 3, 'preferences.openlayers', maps, 2) self.add_radiobox( table, _('Yahoo! Maps'), - 4, Config.GEOVIEW_YAHOO, maps, 1) + 4, 'preferences.yahoo', maps, 1) self.add_radiobox( table, _('Microsoft Maps'), - 4, Config.GEOVIEW_MICROSOFT, maps, 2) + 4, 'preferences.microsoft', maps, 2) self.add_text( table, _('You need to restart GRAMPS for above settings to take' @@ -603,7 +603,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): the_list = obj.get_model() the_iter = obj.get_active_iter() new_idx = the_list.get_value(the_iter, COL_NUM) - Config.set(Config.NAME_FORMAT, new_idx) + config.set('preferences.name-format', new_idx) _nd.set_default_format(new_idx) self.uistate.emit('nameformat-changed') @@ -723,7 +723,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): formats = DateHandler.get_date_formats() for item in formats: obox.append_text(item) - active = Config.get(Config.DATE_FORMAT) + active = config.get('preferences.date-format') if active >= len(formats): active = 0 obox.set_active(active) @@ -738,9 +738,9 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): formats = _surname_styles for item in formats: obox.append_text(item) - obox.set_active(Config.get(Config.SURNAME_GUESSING)) + obox.set_active(config.get('behavior.surname-guessing')) obox.connect('changed', - lambda obj: Config.set(Config.SURNAME_GUESSING, + lambda obj: config.set('behavior.surname-guessing', obj.get_active())) lwidget = BasicLabel("%s: " % _('Surname guessing')) table.attach(lwidget, 0, 1, row, row+1, yoptions=0) @@ -753,13 +753,13 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): _("Relationship to home person")] for item in formats: obox.append_text(item) - active = Config.get(Config.STATUSBAR) + active = config.get('interface.statusbar') if active < 2: obox.set_active(0) else: obox.set_active(1) obox.connect('changed', - lambda obj: Config.set(Config.STATUSBAR, 2*obj.get_active())) + lambda obj: config.set('interface.statusbar', 2*obj.get_active())) lwidget = BasicLabel("%s: " % _('Status bar')) table.attach(lwidget, 0, 1, row, row+1, yoptions=0) table.attach(obox, 1, 3, row, row+1, yoptions=0) @@ -768,7 +768,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): # Text in sidebar: self.add_checkbox(table, _("Show text in sidebar buttons (requires restart)"), - row, Config.SIDEBAR_TEXT, stop=3) + row, 'interface.sidebar-text', stop=3) row += 1 return table @@ -779,22 +779,22 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): table.set_col_spacings(6) table.set_row_spacings(6) self.add_entry(table, _('Missing surname'), row, - Config.NO_SURNAME_TEXT) + 'preferences.no-surname-text') row += 1 self.add_entry(table, _('Missing given name'), row, - Config.NO_GIVEN_TEXT) + 'preferences.no-given-text') row += 1 self.add_entry(table, _('Missing record'), row, - Config.NO_RECORD_TEXT) + 'preferences.no-record-text') row += 1 self.add_entry(table, _('Private surname'), row, - Config.PRIVATE_SURNAME_TEXT) + 'preferences.private-surname-text') row += 1 self.add_entry(table, _('Private given name'), row, - Config.PRIVATE_GIVEN_TEXT) + 'preferences.private-given-text') row += 1 self.add_entry(table, _('Private record'), row, - Config.PRIVATE_RECORD_TEXT) + 'preferences.private-record-text') row += 1 return table @@ -807,7 +807,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): def date_format_changed(self, obj): from QuestionDialog import OkDialog - Config.set(Config.DATE_FORMAT, obj.get_active()) + config.set('preferences.date-format', obj.get_active()) OkDialog(_('Change is not immediate'), _('Changing the data format will not take ' 'effect until the next time GRAMPS is started.')) @@ -820,28 +820,28 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): self.add_pos_int_entry(table, _('Date about range'), - 0, Config.DATE_ABOUT_RANGE, self.update_entry) + 0, 'behavior.date-about-range', self.update_entry) self.add_pos_int_entry(table, _('Date after range'), - 1, Config.DATE_AFTER_RANGE, self.update_entry) + 1, 'behavior.date-after-range', self.update_entry) self.add_pos_int_entry(table, _('Date before range'), - 2, Config.DATE_BEFORE_RANGE, self.update_entry) + 2, 'behavior.date-before-range', self.update_entry) self.add_pos_int_entry(table, _('Maximum age probably alive'), - 3, Config.MAX_AGE_PROB_ALIVE, self.update_entry) + 3, 'behavior.max-age-prob-alive', self.update_entry) self.add_pos_int_entry(table, _('Maximum sibling age difference'), - 4, Config.MAX_SIB_AGE_DIFF, self.update_entry) + 4, 'behavior.max-sib-age-diff', self.update_entry) self.add_pos_int_entry(table, _('Minimum years between generations'), - 5, Config.MIN_GENERATION_YEARS, self.update_entry) + 5, 'behavior.min-generation-years', self.update_entry) self.add_pos_int_entry(table, _('Average years between generations'), - 6, Config.AVG_GENERATION_GAP, self.update_entry) + 6, 'behavior.avg-generation-gap', self.update_entry) self.add_pos_int_entry(table, _('Markup for invalid date format'), - 7, Config.INVALID_DATE_FORMAT, self.update_entry) + 7, 'preferences.invalid-date-format', self.update_entry) return table @@ -853,25 +853,25 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): self.add_checkbox(table, _('Add default source on import'), - 0, Config.DEFAULT_SOURCE) + 0, 'preferences.default-source') self.add_checkbox(table, _('Enable spelling checker'), - 1, Config.SPELLCHECK) + 1, 'behavior.spellcheck') self.add_checkbox(table, _('Display Tip of the Day'), - 2, Config.USE_TIPS) + 2, 'behavior.use-tips') self.add_checkbox(table, _('Use shading in Relationship View'), - 3, Config.RELATION_SHADE) + 3, 'preferences.relation-shade') self.add_checkbox(table, _('Display edit buttons on Relationship View'), - 4, Config.RELEDITBTN) + 4, 'interface.releditbtn') self.add_checkbox(table, _('Remember last view displayed'), - 5, Config.USE_LAST_VIEW) + 5, 'preferences.use-last-view') self.add_pos_int_entry(table, _('Max generations for relationships'), - 6, Config.GENERATION_DEPTH, self.update_gen_depth) + 6, 'behavior.generation-depth', self.update_gen_depth) self.path_entry = gtk.Entry() self.add_path_box(table, _('Base path for relative media paths'), @@ -888,22 +888,22 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): self.add_entry(table, _('Database path'), - 0, Config.DATABASE_PATH) + 0, 'behavior.database-path') self.add_checkbox(table, _('Automatically load last database'), - 1, Config.AUTOLOAD) + 1, 'behavior.autoload') return table def add_checkbox(self, table, label, index, constant, start=1, stop=9): checkbox = gtk.CheckButton(label) - checkbox.set_active(Config.get(constant)) + checkbox.set_active(config.get(constant)) checkbox.connect('toggled', self.update_checkbox, constant) table.attach(checkbox, start, stop, index, index+1, yoptions=0) def add_radiobox(self, table, label, index, constant, group, column): radiobox = gtk.RadioButton(group,label) - if Config.get(constant) == True: + if config.get(constant) == True: radiobox.set_active(True) radiobox.connect('toggled', self.update_radiobox, constant) table.attach(radiobox, column, column+1, index, index+1, yoptions=0) @@ -945,7 +945,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): callback = self.update_entry lwidget = BasicLabel("%s: " % label) entry = gtk.Entry() - entry.set_text(Config.get(constant)) + entry.set_text(config.get(constant)) entry.connect('changed', callback, constant) table.attach(lwidget, 0, 1, index, index+1, yoptions=0, xoptions=gtk.FILL) @@ -956,7 +956,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): """ lwidget = BasicLabel("%s: " % label) entry = gtk.Entry() - entry.set_text(str(Config.get(constant))) + entry.set_text(str(config.get(constant))) if callback: entry.connect('changed', callback, constant) table.attach(lwidget, 1, 2, index, index+1, yoptions=0, @@ -965,7 +965,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): def add_color(self, table, label, index, constant): lwidget = BasicLabel("%s: " % label) - hexval = Config.get(constant) + hexval = config.get(constant) color = gtk.gdk.color_parse(hexval) entry = gtk.ColorButton(color=color) color_hex_label = BasicLabel(hexval) @@ -1003,19 +1003,19 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): f.destroy() def update_entry(self, obj, constant): - Config.set(constant, unicode(obj.get_text())) + config.set(constant, unicode(obj.get_text())) def update_idformat_entry(self, obj, constant): - Config.set(constant, unicode(obj.get_text())) + config.set(constant, unicode(obj.get_text())) self.dbstate.db.set_prefixes( - Config.get(Config.IPREFIX), - Config.get(Config.OPREFIX), - Config.get(Config.FPREFIX), - Config.get(Config.SPREFIX), - Config.get(Config.PPREFIX), - Config.get(Config.EPREFIX), - Config.get(Config.RPREFIX), - Config.get(Config.NPREFIX) ) + config.get('preferences.iprefix'), + config.get('preferences.oprefix'), + config.get('preferences.fprefix'), + config.get('preferences.sprefix'), + config.get('preferences.pprefix'), + config.get('preferences.eprefix'), + config.get('preferences.rprefix'), + config.get('preferences.nprefix') ) def update_gen_depth(self, obj, constant): ok = True @@ -1024,13 +1024,13 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): try: intval = int(obj.get_text()) except: - intval = Config.get(constant) + intval = config.get(constant) ok = False if intval < 0 : - intval = Config.get(constant) + intval = config.get(constant) ok = False if ok: - Config.set(constant, intval) + config.set(constant, intval) #immediately use this value in displaystate. self.uistate.set_gendepth(intval) else: @@ -1042,13 +1042,13 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): color.green/256, color.blue/256) color_hex_label.set_text(hexval) - Config.set(constant, hexval) + config.set(constant, hexval) def update_checkbox(self, obj, constant): - Config.set(constant, obj.get_active()) + config.set(constant, obj.get_active()) def update_radiobox(self, obj, constant): - Config.set(constant, obj.get_active()) + config.set(constant, obj.get_active()) def build_menu_names(self, obj): return (_('Preferences'), None) diff --git a/src/ManagedWindow.py b/src/ManagedWindow.py index 92d360236..b58e9db0a 100644 --- a/src/ManagedWindow.py +++ b/src/ManagedWindow.py @@ -48,7 +48,7 @@ import gtk #------------------------------------------------------------------------- import const import Errors -import Config +import config from glade import Glade #------------------------------------------------------------------------- @@ -516,8 +516,8 @@ class ManagedWindow(object): Set the dimensions of the window """ if self.width_key is not None: - width = Config.get(self.width_key) - height = Config.get(self.height_key) + width = config.get(self.width_key) + height = config.get(self.height_key) self.window.resize(width, height) def _save_size(self): @@ -526,9 +526,9 @@ class ManagedWindow(object): """ if self.width_key is not None: (width, height) = self.window.get_size() - Config.set(self.width_key, width) - Config.set(self.height_key, height) - Config.sync() + config.set(self.width_key, width) + config.set(self.height_key, height) + config.save() def track_ref_for_deletion(self, ref): """ diff --git a/src/PageView.py b/src/PageView.py index e4f96bfe8..b3bcddae6 100644 --- a/src/PageView.py +++ b/src/PageView.py @@ -48,7 +48,7 @@ import pango # GRAMPS # #---------------------------------------------------------------- -import Config +import config import TreeTips import Bookmarks import Errors @@ -665,7 +665,7 @@ class ListView(BookMarkView): return hpaned def filter_toggle(self, client, cnxn_id, entry, data): - if Config.get(Config.FILTER): + if config.get('interface.filter'): self.search_bar.hide() self.filter_pane.show() else: @@ -674,7 +674,7 @@ class ListView(BookMarkView): def post(self): if self.filter_class: - if Config.get(Config.FILTER): + if config.get('interface.filter'): self.search_bar.hide() self.filter_pane.show() else: @@ -890,7 +890,7 @@ class ListView(BookMarkView): self.sort_order = order handle = self.first_selected() - if Config.get(Config.FILTER): + if config.get('interface.filter'): search = (True, self.generic_filter) else: search = (False, self.search_bar.get_value()) @@ -944,7 +944,7 @@ class ListView(BookMarkView): def build_tree(self): if self.active: cput = time.clock() - if Config.get(Config.FILTER): + if config.get('interface.filter'): filter_info = (True, self.generic_filter) else: filter_info = (False, self.search_bar.get_value()) @@ -995,7 +995,7 @@ class ListView(BookMarkView): self.search_bar.show() self.filter_pane.hide() active = False - Config.set(Config.FILTER, active) + config.set('interface.filter', active) self.build_tree() def filter_editor(self, obj): diff --git a/src/QuestionDialog.py b/src/QuestionDialog.py index 714579e18..126416326 100644 --- a/src/QuestionDialog.py +++ b/src/QuestionDialog.py @@ -41,7 +41,7 @@ from gtk.gdk import pixbuf_new_from_file # #------------------------------------------------------------------------- import const -import Config +import config from glade import Glade try: @@ -77,7 +77,7 @@ class SaveDialog(object): elif response == gtk.RESPONSE_YES: self.task2() - Config.set(Config.DONT_ASK, self.dontask.get_active()) + config.set('interface.dont-ask', self.dontask.get_active()) self.top.destroy() class QuestionDialog(object): @@ -329,7 +329,7 @@ class MessageHideDialog(object): self.top.set_title("%s - GRAMPS" % title) dont_show = self.xml.get_object('dont_show') - dont_show.set_active(Config.get(key)) + dont_show.set_active(config.get(key)) title_label = self.xml.get_object('title') title_label.set_text( '%s' % title) @@ -342,5 +342,5 @@ class MessageHideDialog(object): self.top.destroy() def update_checkbox(self, obj, constant): - Config.set(constant, obj.get_active()) - Config.sync() + config.set(constant, obj.get_active()) + config.save() diff --git a/src/Relationship.py b/src/Relationship.py index 64b3262e9..2862ef9b2 100644 --- a/src/Relationship.py +++ b/src/Relationship.py @@ -388,8 +388,8 @@ class RelationshipCalculator(object): self.__db_connected = False self.depth = 15 try: - import Config - self.set_depth(Config.get(Config.GENERATION_DEPTH)) + import config + self.set_depth(config.get('behavior.generation-depth')) except ImportError: pass diff --git a/src/ReportBase/_GraphvizReportDialog.py b/src/ReportBase/_GraphvizReportDialog.py index 55bf68003..1198b1c12 100644 --- a/src/ReportBase/_GraphvizReportDialog.py +++ b/src/ReportBase/_GraphvizReportDialog.py @@ -51,7 +51,7 @@ import gobject import Utils from gui.utils import ProgressMeter, open_file_with_default_application from gen.plug.docgen import BaseDoc, GVDoc -import Config +import config from ReportBase import CATEGORY_GRAPHVIZ from _ReportDialog import ReportDialog from _PaperMenu import PaperFrame diff --git a/src/ReportBase/_ReportDialog.py b/src/ReportBase/_ReportDialog.py index 8b4d0c216..c4de2678a 100644 --- a/src/ReportBase/_ReportDialog.py +++ b/src/ReportBase/_ReportDialog.py @@ -45,7 +45,7 @@ import gtk # GRAMPS modules # #------------------------------------------------------------------------- -import Config +import config import Errors from QuestionDialog import ErrorDialog, OptionDialog from ReportBase import (CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_BOOK, @@ -405,7 +405,7 @@ class ReportDialog(ManagedWindow.ManagedWindow): """Get the name of the directory to which the target dialog box should default. This value can be set in the preferences panel.""" - return Config.get(Config.REPORT_DIRECTORY) + return config.get('paths.report-directory') def set_default_directory(self, value): """Save the name of the current directory, so that any future @@ -415,7 +415,7 @@ class ReportDialog(ManagedWindow.ManagedWindow): This means that the last directory used will only be remembered for this session of gramps unless the user saves his/her preferences.""" - Config.set(Config.REPORT_DIRECTORY, value) + config.set('paths.report-directory', value) #------------------------------------------------------------------------ # diff --git a/src/ReportBase/_ReportOptions.py b/src/ReportBase/_ReportOptions.py index 324e7698b..7e4fbf001 100644 --- a/src/ReportBase/_ReportOptions.py +++ b/src/ReportBase/_ReportOptions.py @@ -54,7 +54,7 @@ except: # #------------------------------------------------------------------------- import const -import Config +import config from gen.plug.docgen import PAPER_PORTRAIT from PluginUtils import _Options, GuiMenuOptions @@ -244,8 +244,8 @@ class OptionListCollection(_Options.OptionListCollection): def init_common(self): # Default values for common options self.default_style_name = "default" - self.default_paper_metric = Config.get(Config.PAPER_METRIC) - self.default_paper_name = Config.get(Config.PAPER_PREFERENCE) + self.default_paper_metric = config.get('preferences.paper-metric') + self.default_paper_name = config.get('preferences.paper-preference') self.default_orientation = PAPER_PORTRAIT self.default_css_filename = "" self.default_custom_paper_size = [29.7, 21.0] diff --git a/src/ScratchPad.py b/src/ScratchPad.py index b615f46b2..292207890 100644 --- a/src/ScratchPad.py +++ b/src/ScratchPad.py @@ -44,7 +44,7 @@ from gtk.gdk import ACTION_COPY, BUTTON1_MASK, ACTION_MOVE # #------------------------------------------------------------------------- import const -import Config +import config import gen.lib import TreeTips import DateHandler @@ -1210,8 +1210,8 @@ class ScratchPadWindow(ManagedWindow.ManagedWindow): self.database_changed(self.dbstate.db) self.dbstate.connect('database-changed', self.database_changed) - self.width_key = Config.CLIPBOARD_WIDTH - self.height_key = Config.CLIPBOARD_HEIGHT + self.width_key = 'interface.clipboard-width' + self.height_key = 'interface.clipboard-height' self.top = Glade() self.set_window(self.top.toplevel, None, None, msg=_("Clipboard")) diff --git a/src/Selectors/_SelectEvent.py b/src/Selectors/_SelectEvent.py index 3452f53c8..b3ee61ea3 100644 --- a/src/Selectors/_SelectEvent.py +++ b/src/Selectors/_SelectEvent.py @@ -35,7 +35,7 @@ from gettext import gettext as _ #------------------------------------------------------------------------- from DisplayModels import EventModel from _BaseSelector import BaseSelector -import Config +import config #------------------------------------------------------------------------- # @@ -48,8 +48,8 @@ class SelectEvent(BaseSelector): """ Perform local initialisation for this class """ - self.width_key = Config.EVENT_SEL_WIDTH - self.height_key = Config.EVENT_SEL_HEIGHT + self.width_key = 'interface.event-sel-width' + self.height_key = 'interface.event-sel-height' def get_window_title(self): return _("Select Event") diff --git a/src/Selectors/_SelectFamily.py b/src/Selectors/_SelectFamily.py index 8e7651e41..d96cae55a 100644 --- a/src/Selectors/_SelectFamily.py +++ b/src/Selectors/_SelectFamily.py @@ -35,7 +35,7 @@ from gettext import gettext as _ #------------------------------------------------------------------------- from DisplayModels import FamilyModel from _BaseSelector import BaseSelector -import Config +import config #------------------------------------------------------------------------- # @@ -48,8 +48,8 @@ class SelectFamily(BaseSelector): """ Perform local initialisation for this class """ - self.width_key = Config.FAMILY_SEL_WIDTH - self.height_key = Config.FAMILY_SEL_HEIGHT + self.width_key = 'interface.family-sel-width' + self.height_key = 'interface.family-sel-height' def get_window_title(self): return _("Select Family") diff --git a/src/Selectors/_SelectNote.py b/src/Selectors/_SelectNote.py index aaeb8965a..b1f45c0fd 100644 --- a/src/Selectors/_SelectNote.py +++ b/src/Selectors/_SelectNote.py @@ -38,7 +38,7 @@ from gettext import gettext as _ #------------------------------------------------------------------------- from DisplayModels import NoteModel from _BaseSelector import BaseSelector -import Config +import config #------------------------------------------------------------------------- # @@ -53,8 +53,8 @@ class SelectNote(BaseSelector): """ Perform local initialisation for this class """ - self.width_key = Config.NOTE_SEL_WIDTH - self.height_key = Config.NOTE_SEL_HEIGHT + self.width_key = 'interface.note-sel-width' + self.height_key = 'interface.note-sel-height' def get_window_title(self): return _("Select Note") diff --git a/src/Selectors/_SelectObject.py b/src/Selectors/_SelectObject.py index 1ea4c97ca..394b6b397 100644 --- a/src/Selectors/_SelectObject.py +++ b/src/Selectors/_SelectObject.py @@ -49,7 +49,7 @@ from Utils import media_path_full import ThumbNails from DisplayModels import MediaModel from _BaseSelector import BaseSelector -import Config +import config #------------------------------------------------------------------------- # @@ -81,8 +81,8 @@ class SelectObject(BaseSelector): """ Perform local initialisation for this class """ - self.width_key = Config.MEDIA_SEL_WIDTH - self.height_key = Config.MEDIA_SEL_HEIGHT + self.width_key = 'interface.media-sel-width' + self.height_key = 'interface.media-sel-height' self.preview = gtk.Image() self.preview.set_size_request(int(const.THUMBSCALE), int(const.THUMBSCALE)) diff --git a/src/Selectors/_SelectPerson.py b/src/Selectors/_SelectPerson.py index 553131762..66e4a8fa5 100644 --- a/src/Selectors/_SelectPerson.py +++ b/src/Selectors/_SelectPerson.py @@ -36,7 +36,7 @@ import gtk #------------------------------------------------------------------------- from DisplayModels import PeopleModel from _BaseSelector import BaseSelector -import Config +import config #------------------------------------------------------------------------- # @@ -60,8 +60,8 @@ class SelectPerson(BaseSelector): """ Perform local initialisation for this class """ - self.width_key = Config.PERSON_SEL_WIDTH - self.height_key = Config.PERSON_SEL_HEIGHT + self.width_key = 'interface.person-sel-width' + self.height_key = 'interface.person-sel-height' self.tree.connect('key-press-event', self._key_press) self.showall.connect('toggled',self.show_toggle) diff --git a/src/Selectors/_SelectPlace.py b/src/Selectors/_SelectPlace.py index 039ba0332..9a03bfb50 100644 --- a/src/Selectors/_SelectPlace.py +++ b/src/Selectors/_SelectPlace.py @@ -35,7 +35,7 @@ from gettext import gettext as _ #------------------------------------------------------------------------- from DisplayModels import PlaceModel from _BaseSelector import BaseSelector -import Config +import config #------------------------------------------------------------------------- # @@ -48,8 +48,8 @@ class SelectPlace(BaseSelector): """ Perform local initialisation for this class """ - self.width_key = Config.PLACE_SEL_WIDTH - self.height_key = Config.PLACE_SEL_HEIGHT + self.width_key = 'interface.place-sel-width' + self.height_key = 'interface.place-sel-height' def get_window_title(self): return _("Select Place") diff --git a/src/Selectors/_SelectRepository.py b/src/Selectors/_SelectRepository.py index 29dd0bbf7..9489026a9 100644 --- a/src/Selectors/_SelectRepository.py +++ b/src/Selectors/_SelectRepository.py @@ -35,7 +35,7 @@ from gettext import gettext as _ #------------------------------------------------------------------------- from DisplayModels import RepositoryModel from _BaseSelector import BaseSelector -import Config +import config #------------------------------------------------------------------------- # @@ -48,8 +48,8 @@ class SelectRepository(BaseSelector): """ Perform local initialisation for this class """ - self.width_key = Config.REPO_SEL_WIDTH - self.height_key = Config.REPO_SEL_HEIGHT + self.width_key = 'interface.repo-sel-width' + self.height_key = 'interface.repo-sel-height' def get_window_title(self): return _("Select Repository") diff --git a/src/Selectors/_SelectSource.py b/src/Selectors/_SelectSource.py index 03cc22fcf..eb7c37ded 100644 --- a/src/Selectors/_SelectSource.py +++ b/src/Selectors/_SelectSource.py @@ -35,7 +35,7 @@ from gettext import gettext as _ #------------------------------------------------------------------------- from DisplayModels import SourceModel from _BaseSelector import BaseSelector -import Config +import config #------------------------------------------------------------------------- # @@ -48,8 +48,8 @@ class SelectSource(BaseSelector): """ Perform local initialisation for this class """ - self.width_key = Config.SOURCE_SEL_WIDTH - self.height_key = Config.SOURCE_SEL_HEIGHT + self.width_key = 'interface.source-sel-width' + self.height_key = 'interface.source-sel-height' def get_window_title(self): return _("Select Source") diff --git a/src/Simple/_SimpleAccess.py b/src/Simple/_SimpleAccess.py index 8cc5d5395..47b544ebf 100644 --- a/src/Simple/_SimpleAccess.py +++ b/src/Simple/_SimpleAccess.py @@ -31,7 +31,7 @@ import Utils from BasicUtils import name_displayer from ReportBase import ReportUtils from gen.lib import EventType -import Config +import config class SimpleAccess(object): """ @@ -136,7 +136,7 @@ class SimpleAccess(object): assert(isinstance(person, (gen.lib.Person, NoneType))) if person: surname = person.get_primary_name().get_surname() - return surname or Config.get(Config.NO_SURNAME_TEXT) + return surname or config.get('preferences.no-surname-text') else: return u'' diff --git a/src/Simple/_SimpleTable.py b/src/Simple/_SimpleTable.py index e4c63e032..038fb14f5 100644 --- a/src/Simple/_SimpleTable.py +++ b/src/Simple/_SimpleTable.py @@ -29,7 +29,7 @@ from gettext import gettext as _ import gen.lib import Errors -import Config +import config import DateHandler class SimpleTable(object): @@ -255,7 +255,7 @@ class SimpleTable(object): # sort before others: self.row_sort_val(col, -1) # give formatted version: - invalid_date_format = Config.get(Config.INVALID_DATE_FORMAT) + invalid_date_format = config.get('preferences.invalid-date-format') self.set_cell_markup(col, row, invalid_date_format % text) if (self.__link_col == col or link is None): diff --git a/src/Spell.py b/src/Spell.py index 524bba962..7a1aabc7a 100644 --- a/src/Spell.py +++ b/src/Spell.py @@ -70,7 +70,7 @@ if not HAVE_GTKSPELL: # GRAMPS classes # #------------------------------------------------------------------------- -import Config +import config #------------------------------------------------------------------------- # @@ -211,7 +211,7 @@ class Spell(object): def __init__(self, textview): self.textview = textview - if self.lang and Config.get(Config.SPELLCHECK): + if self.lang and config.get('behavior.spellcheck'): # if LANG is not a correct key (pt_BR or pt_PT), # try only the language part of LANG if self.lang not in self._installed_languages: diff --git a/src/TipOfDay.py b/src/TipOfDay.py index f6d31bb56..8988e8a90 100644 --- a/src/TipOfDay.py +++ b/src/TipOfDay.py @@ -46,7 +46,7 @@ import os # #------------------------------------------------------------------------- import const -import Config +import config import ManagedWindow from QuestionDialog import ErrorDialog from glade import Glade @@ -70,7 +70,7 @@ class TipOfDay(ManagedWindow.ManagedWindow): self.tip = xml.get_object("tip") self.use = xml.get_object('usetips') - self.use.set_active(Config.get(Config.USE_TIPS)) + self.use.set_active(config.get('behavior.use-tips')) image = xml.get_object('image') image.set_from_file(os.path.join(const.IMAGE_DIR, 'splash.jpg')) @@ -110,7 +110,7 @@ class TipOfDay(ManagedWindow.ManagedWindow): self.index = (self.index + 1) % len(self.tip_list) def close_cb(self, dummy=None): - Config.set(Config.USE_TIPS, self.use.get_active()) + config.set('behavior.use-tips', self.use.get_active()) self.close() def build_menu_names(self, obj): diff --git a/src/Utils.py b/src/Utils.py index dda50dbb7..56b03f2a5 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -58,11 +58,11 @@ from TransUtils import sgettext as _ #------------------------------------------------------------------------- # cache values; use refresh_constants() if they change try: - import Config - _MAX_AGE_PROB_ALIVE = Config.get(Config.MAX_AGE_PROB_ALIVE) - _MAX_SIB_AGE_DIFF = Config.get(Config.MAX_SIB_AGE_DIFF) - _MIN_GENERATION_YEARS = Config.get(Config.MIN_GENERATION_YEARS) - _AVG_GENERATION_GAP = Config.get(Config.AVG_GENERATION_GAP) + import config + _MAX_AGE_PROB_ALIVE = config.get('behavior.max-age-prob-alive') + _MAX_SIB_AGE_DIFF = config.get('behavior.max-sib-age-diff') + _MIN_GENERATION_YEARS = config.get('behavior.min-generation-years') + _AVG_GENERATION_GAP = config.get('behavior.avg-generation-gap') except ImportError: # Utils used as module not part of GRAMPS _MAX_AGE_PROB_ALIVE = 110 @@ -967,16 +967,16 @@ def get_translations(): #------------------------------------------------------------------------- def get_researcher(): import gen.lib - import Config + import config - n = Config.get(Config.RESEARCHER_NAME) - a = Config.get(Config.RESEARCHER_ADDR) - c = Config.get(Config.RESEARCHER_CITY) - s = Config.get(Config.RESEARCHER_STATE) - ct = Config.get(Config.RESEARCHER_COUNTRY) - p = Config.get(Config.RESEARCHER_POSTAL) - ph = Config.get(Config.RESEARCHER_PHONE) - e = Config.get(Config.RESEARCHER_EMAIL) + n = config.get('researcher.researcher-name') + a = config.get('researcher.researcher-addr') + c = config.get('researcher.researcher-city') + s = config.get('researcher.researcher-state') + ct = config.get('researcher.researcher-country') + p = config.get('researcher.researcher-postal') + ph = config.get('researcher.researcher-phone') + e = config.get('researcher.researcher-email') owner = gen.lib.Researcher() owner.set_name(n) @@ -994,13 +994,13 @@ def update_constants(): """ Used to update the constants that are cached in this module. """ - import Config + import config global _MAX_AGE_PROB_ALIVE, _MAX_SIB_AGE_DIFF, _MIN_GENERATION_YEARS, \ _AVG_GENERATION_GAP - _MAX_AGE_PROB_ALIVE = Config.get(Config.MAX_AGE_PROB_ALIVE) - _MAX_SIB_AGE_DIFF = Config.get(Config.MAX_SIB_AGE_DIFF) - _MIN_GENERATION_YEARS = Config.get(Config.MIN_GENERATION_YEARS) - _AVG_GENERATION_GAP = Config.get(Config.AVG_GENERATION_GAP) + _MAX_AGE_PROB_ALIVE = config.get('behavior.max-age-prob-alive') + _MAX_SIB_AGE_DIFF = config.get('behavior.max-sib-age-diff') + _MIN_GENERATION_YEARS = config.get('behavior.min-generation-years') + _AVG_GENERATION_GAP = config.get('behavior.avg-generation-gap') #------------------------------------------------------------------------- # diff --git a/src/cli/clidbman.py b/src/cli/clidbman.py index 9a60ea51c..4678d8ea7 100644 --- a/src/cli/clidbman.py +++ b/src/cli/clidbman.py @@ -50,7 +50,7 @@ LOG = logging.getLogger(".clidbman") #------------------------------------------------------------------------- import gen.db from gen.plug import PluginManager -import Config +import config #------------------------------------------------------------------------- # @@ -164,7 +164,7 @@ class CLIDbManager(object): """ Get the list of current names in the database dir """ # make the default directory if it does not exist - dbdir = os.path.expanduser(Config.get(Config.DATABASE_PATH)) + dbdir = os.path.expanduser(config.get('behavior.database-path')) make_dbdir(dbdir) self.current_names = [] @@ -350,7 +350,7 @@ def find_next_db_dir(): """ while True: base = "%x" % int(time.time()) - dbdir = os.path.expanduser(Config.get(Config.DATABASE_PATH)) + dbdir = os.path.expanduser(config.get('behavior.database-path')) new_path = os.path.join(dbdir, base) if not os.path.isdir(new_path): break diff --git a/src/cli/grampscli.py b/src/cli/grampscli.py index 36be53723..11ef55adc 100644 --- a/src/cli/grampscli.py +++ b/src/cli/grampscli.py @@ -46,7 +46,7 @@ LOG = logging.getLogger(".grampscli") # #------------------------------------------------------------------------- from BasicUtils import name_displayer -import Config +import config import const import Errors import DbState @@ -256,14 +256,14 @@ class CLIManager(object): self.dbstate.db.set_researcher(owner) name_displayer.set_name_format(self.dbstate.db.name_formats) - fmt_default = Config.get(Config.NAME_FORMAT) + fmt_default = config.get('preferences.name-format') if fmt_default < 0: name_displayer.set_default_format(fmt_default) self.dbstate.db.enable_signals() self.dbstate.signal_change() - Config.set(Config.RECENT_FILE, filename) + config.set('paths.recent-file', filename) try: self.dbstate.change_active_person( diff --git a/src/config.py b/src/config.py new file mode 100644 index 000000000..ae50e98c3 --- /dev/null +++ b/src/config.py @@ -0,0 +1,679 @@ +# +# 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 +# +# 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. +""" + +#--------------------------------------------------------------- +# +# System imports +# +#--------------------------------------------------------------- +import os +import time +import ConfigParser +import errno +from gettext import gettext as _ + +#--------------------------------------------------------------- +# +# Gramps imports +# +#--------------------------------------------------------------- +import const + +#--------------------------------------------------------------- +# +# Constants +# +#--------------------------------------------------------------- +INIFILE = os.path.join(const.HOME_DIR, "gramps32.ini") + +#--------------------------------------------------------------- +# +# Classes +# +#--------------------------------------------------------------- +class ConfigManager(object): + """ + Class to construct the singleton CONFIGMAN where all + settings are stored. + """ + def __init__(self, filename = None): + """ + Configure manager constructor takes an optional filename. + + The data dictionary stores the settings: + + self.data[section][setting] = value + + The value has a type that matches the default. It is an error + to attempt to set the setting to a different type. To change + the type, you must re-register the setting, and re-set the + value. + + The default values are given in Python code and stored here + on start-up: + + self.default[section][setting] = default_value + + Callbacks are stored as callables here: + + self.callbacks[section][setting] = (id, func) + + The default filename (usually the one you are reading from) + is stored as self.filename. However, you can save to another + filename using self.save(otherfilename). + """ + self._cb_id = 0 # callback id counter + self.filename = filename + self.callbacks = {} + self.default = {} + self.data = {} + self.reset() + + def reset(self, section=None): + """ + Resets all settings values to their defaults. + """ + if section is None: + self.data = {} + self.data.update(self.default) + else: + self.data[section] = {} + self.data[section].update(self.default[section]) + # Callbacks are still connected + + def get_sections(self): + """ + Return all section names. + """ + return self.data.keys() + + def get_section_settings(self, section): + """ + Return all section setting names. + """ + return self.data[section].keys() + + def load(self, filename=None, oldstyle=False): + """ + Loads an .ini into self.data. + """ + if filename is None: + filename = self.filename + if filename and os.path.exists(filename): + parser = ConfigParser.ConfigParser() + parser.read(filename) + for sec in parser.sections(): + name = sec.lower() + if name not in self.data: + # Add the setting from file + # These might be old settings, or third-party settings + self.data[name] = {} + for opt in parser.options(sec): + setting = parser.get(sec, opt).strip() + ####################### Upgrade from oldstyle < 3.2 + if oldstyle: + # if we know this setting, convert type + key = "%s.%s" % (name, opt) + if self.has_default(key): + vtype = type(self.get_default(key)) + if vtype == bool: + value = setting in ["1", "True"] + else: + value = vtype(setting) + else: + # else, ignore it + print "WARNING: ignoring old key '%s'" % key + continue # with next setting + ####################### End upgrade code + elif setting.startswith("'") and setting.endswith("'"): + value = setting[1:-1] + elif setting == "True": + value = True + elif setting == "False": + value = False + elif "." in setting: + value = float(setting) + else: + value = int(setting) + self.data[name][opt.lower()] = value + + def save(self, filename = None): + """ + Saves the current section/settings to an .ini file. Optional filename + will override the default filename to save to, if given. + """ + if filename is None: + filename = self.filename + if filename: + try: + head = os.path.split( filename )[0] + os.makedirs( head ) + except OSError, exp: + if exp.errno != errno.EEXIST: + raise + key_file = open(filename, "w") + key_file.write(";; Gramps key file\n") + key_file.write((";; Automatically created at %s" % + time.strftime("%Y/%m/%d %H:%M:%S")) + "\n\n") + sections = sorted(self.data) + for section in sections: + key_file.write(("[%s]\n") % section) + keys = sorted(self.data[section]) + for key in keys: + value = self.data[section][key] + if isinstance(value, long): + value = int(value) + key_file.write(("%s=%s\n")% (key, repr(value))) + key_file.write("\n") + key_file.close() + # else, no filename given; nothing to save so do nothing quietly + + def get(self, key): + """ + Get the setting's value. raise an error if an invalid section.setting. + Key is a sting in the "section.setting" format. + """ + if "." in key: + section, setting = key.split(".", 1) + else: + raise AttributeError("Invalid config section.setting name: '%s'" % + key) + if section not in self.data: + raise AttributeError("No such config section name: '%s'" % section) + if setting not in self.data[section]: + raise AttributeError("No such config setting name: '%s.%s'" % + (section, setting)) + return self.data[section][setting] + + def is_set(self, key): + """ + Does the setting exist? Returns True if does, False otherwise. + Key is a sting in the "section.setting" format. + """ + if "." in key: + section, setting = key.split(".", 1) + else: + return False + if section not in self.data: + return False + if setting not in self.data[section]: + return False + return True + + def has_default(self, key): + """ + Does the setting have a default value? Returns True if it does, + False otherwise. Key is a sting in the "section.setting" format. + """ + if "." in key: + section, setting = key.split(".", 1) + else: + return False + if section not in self.default: + return False + if setting not in self.default[section]: + return False + return True + + def get_default(self, key): + """ + Get the setting's default value. Raises an error if invalid key is + give. Key is a sting in the "section.setting" format. + """ + if "." in key: + section, setting = key.split(".", 1) + else: + raise AttributeError("Invalid config section.setting name: '%s'" % + key) + if section not in self.default: + raise AttributeError("No such config section name: '%s'" % section) + if setting not in self.default[section]: + raise AttributeError("No such config setting name: '%s.%s'" % + (section, setting)) + return self.default[section][setting] + + def register(self, key, default): + """ + Register a section.setting, and set the default. + Will overwrite any previously set default, and set setting if not one. + The default value deterimines the type of the setting. + """ + if "." in key: + section, setting = key.split(".", 1) + else: + raise AttributeError("Invalid config section.setting name: '%s'" % + key) + if section not in self.data: + self.data[section] = {} + if section not in self.default: + self.default[section] = {} + if section not in self.callbacks: + self.callbacks[section] = {} + if setting not in self.callbacks[section]: + self.callbacks[section][setting] = [] + # Add the default value to settings, if not exist: + if setting not in self.data[section]: + self.data[section][setting] = default + # Set the default, regardless: + self.default[section][setting] = default + + def connect(self, key, func): + """ + Connect a callback func that gets called when key is changed. + """ + if "." in key: + section, setting = key.split(".", 1) + else: + raise AttributeError("Invalid config section.setting name: '%s'" % + key) + if section not in self.data: + raise AttributeError("No such config section name: '%s'" % section) + if setting not in self.data[section]: + raise AttributeError("No such config setting name: '%s.%s'" % + (section, setting)) + self._cb_id += 1 + self.callbacks[section][setting].append((self._cb_id, func)) + return self._cb_id + + def disconnect(self, callback_id): + """ + """ + for section in self.callbacks: + for setting in self.callbacks[section]: + for (cbid, func) in self.callbacks[section][setting]: + if callback_id == cbid: + self.callbacks[section][setting].remove((cbid, func)) + + def set(self, key, value): + """ + Set the setting's value. There are only two ways to get into + the data dictionary: via the load() method that reads a file, + or from this method. + """ + if "." in key: + section, setting = key.split(".", 1) + else: + raise AttributeError("Invalid config section.setting name: '%s'" % + key) + if section not in self.data: + raise AttributeError("No such config section name: '%s'" % section) + if setting not in self.data[section]: + raise AttributeError("No such config setting name: '%s.%s'" % + (section, setting)) + # Check value to see if right type: + if type(value) == long: + value = int(value) + if type(value) == unicode: + value = str(value) + if self.has_default(key): + if type(self.get_default(key)) != type(value): + raise AttributeError("attempting to set '%s' to wrong type " + "'%s'; should be '%s'" % + (key, type(value), + type(self.get_default(key)))) + if (setting in self.data[section] and + self.data[section][setting] == value): + # Do nothing if existed and is the same + pass + else: + # Set the value: + self.data[section][setting] = value + # Only call callback if the value changed! + if (section in self.callbacks and + setting in self.callbacks[section]): + for (cbid, func) in self.callbacks[section][setting]: + # Call all callbacks for this key: + func(self, 0, str(self.data[section][setting]), None) + +#--------------------------------------------------------------- +# +# Convience functions to call ConfigManager instance methods +# +#--------------------------------------------------------------- + +def register(key, value): + """ Module shortcut to register key, value """ + CONFIGMAN.register(key, value) + +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) + +def set(key, value): + """ Module shortcut to set value from key """ + CONFIGMAN.set(key, value) + +def save(filename=None): + """ Module shortcut to save config file """ + CONFIGMAN.save(filename) + +def connect(key, func): + """ Module shortcut to callbacks """ + return CONFIGMAN.connect(key, func) + +#--------------------------------------------------------------- +# +# Register the system-wide settings in a singleton config manager +# +#--------------------------------------------------------------- + +CONFIGMAN = ConfigManager(INIFILE) + +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) +register('behavior.database-path', os.path.join( const.HOME_DIR, 'grampsdb')) +register('behavior.date-about-range', 10) +register('behavior.date-after-range', 10) +register('behavior.date-before-range', 10) +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) + +register('export.no-private', True) +register('export.no-unlinked', True) +register('export.restrict-living', True) + +register('geoview.latitude', "0.0") +register('geoview.lock', False) +register('geoview.longitude', "0.0") +register('geoview.map', "person") +register('geoview.stylesheet', "") +register('geoview.zoom', 0) + +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) +register('interface.data-views', + 'GrampletView,PersonView,RelationshipView,' + 'FamilyListView,PedigreeView,EventView,SourceView,' + 'PlaceView,MediaView,RepositoryView,NoteView') +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) +register('interface.patro-title', 0) +register('interface.pedview-layout', 0) +register('interface.pedview-show-images', True) +register('interface.pedview-show-marriage', False) +register('interface.pedview-tree-size', 0) +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.prefix-suffix', 0) +register('interface.releditbtn', False) +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) + +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) + +register('preferences.complete-color', '#008b00') +register('preferences.custom-marker-color', '#8b008b') +register('preferences.date-format', 0) +register('preferences.default-source', False) +register('preferences.eprefix', 'E%04d') +register('preferences.family-details', True) +register('preferences.family-siblings', True) +register('preferences.family-warn', True) +register('preferences.fprefix', 'F%04d') +register('preferences.geoview', False) +register('preferences.googlemap', True) +register('preferences.hide-ep-msg', False) +register('preferences.invalid-date-format', "%s") +register('preferences.iprefix', 'I%04d') +register('preferences.last-view', 0) +register('preferences.microsoft', False) +register('preferences.name-format', 1) +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.openlayers', 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.relation-display-theme', "CLASSIC") +register('preferences.relation-shade', True) +register('preferences.rprefix', 'R%04d') +register('preferences.sprefix', 'S%04d') +register('preferences.todo-color', '#ff0000') +register('preferences.use-last-view', True) +register('preferences.yahoo', False) +register('preferences.microsoft', False) + +register('researcher.researcher-addr', '') +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', '') + +#--------------------------------------------------------------- +# +# Now, load the settings from the config file +# +#--------------------------------------------------------------- + +#--------------------------------------------------------------- +# +# 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: + print "Importing old key file 'keys.ini'..." + CONFIGMAN.load(os.path.join(const.HOME_DIR, "keys.ini"), + oldstyle=True) + print "Done importing old key file 'keys.ini'" + # other version upgrades here... + +#--------------------------------------------------------------- +# +# Now, load the settings from the config file, if one +# +#--------------------------------------------------------------- +CONFIGMAN.load() + +if __name__ == "__main__": + CM = ConfigManager("./temp.ini") + CM.register("section.setting1", 1) # int + CM.register("section.setting2", 3.1415) # float + CM.register("section.setting3", "String") # string + CM.register("section.setting4", False) # boolean + + assert CM.get("section.setting1") == 1 + assert CM.get("section.setting2") == 3.1415 + assert CM.get("section.setting3") == "String" + assert CM.get("section.setting4") == False + + CM.set("section.setting1", 2) + CM.set("section.setting2", 8.6) + CM.set("section.setting3", "Another String") + CM.set("section.setting4", True) + + assert CM.get("section.setting1") == 2 + assert CM.get("section.setting2") == 8.6 + assert CM.get("section.setting3") == "Another String" + assert CM.get("section.setting4") == True + + try: + CM.set("section.setting1", 2.8) + except AttributeError: + pass + else: + raise AssertionError + + try: + CM.set("section.setting2", 2) + except AttributeError: + pass + else: + raise AssertionError + + try: + CM.set("section.setting3", 6) + except AttributeError: + pass + else: + raise AssertionError + + try: + CM.set("section.setting4", 1) + except AttributeError: + pass + else: + raise AssertionError + + assert CM.get("section.setting1") == 2 + assert CM.get("section.setting2") == 8.6 + assert CM.get("section.setting3") == "Another String" + assert CM.get("section.setting4") == True + + # Try to set one that doesn't exist: + try: + CM.set("section.setting5", 1) + except AttributeError: + pass + else: + raise AssertionError + + CM.save() + + CM.reset() + + assert CM.get("section.setting1") == 1 + assert CM.get("section.setting2") == 3.1415 + assert CM.get("section.setting3") == "String" + assert CM.get("section.setting4") == False + + x = None + def callback(*args): + # args: self, 0, str(setting), None + global x + x = args[2] + + cbid = CM.connect("section.setting1", callback) + assert x == None + + CM.set("section.setting1", 1024) + assert x == "1024" + + CM.disconnect(cbid) + + CM.set("section.setting1", -1) + assert x == "1024" + + CM.save("./test2.ini") diff --git a/src/gen/lib/date.py b/src/gen/lib/date.py index f55ab9d2e..b5b173329 100644 --- a/src/gen/lib/date.py +++ b/src/gen/lib/date.py @@ -57,7 +57,7 @@ from gen.lib.calendar import (gregorian_sdn, julian_sdn, hebrew_sdn, gregorian_ymd, julian_ymd, hebrew_ymd, french_ymd, persian_ymd, islamic_ymd, swedish_ymd) -import Config +import config #------------------------------------------------------------------------- # @@ -82,9 +82,9 @@ class Span(object): minmax = (min days, max days) """ - BEFORE = Config.get(Config.DATE_BEFORE_RANGE) - AFTER = Config.get(Config.DATE_AFTER_RANGE) - ABOUT = Config.get(Config.DATE_ABOUT_RANGE) + BEFORE = config.get('behavior.date-before-range') + AFTER = config.get('behavior.date-after-range') + ABOUT = config.get('behavior.date-about-range') def __init__(self, date1, date2): self.valid = (date1.sortval != 0 and date2.sortval != 0) self.date1 = date1 @@ -934,15 +934,15 @@ class Date(object): # if BEFORE, AFTER, or ABOUT/EST, adjust: if self.modifier == Date.MOD_BEFORE: stopmax = date_offset(startmin, -1) - fdiff = Config.get(Config.DATE_BEFORE_RANGE) + fdiff = config.get('behavior.date-before-range') startmin = (stopmax[0] - fdiff, stopmax[1], stopmax[2]) elif self.modifier == Date.MOD_AFTER: startmin = date_offset(stopmax, 1) - fdiff = Config.get(Config.DATE_AFTER_RANGE) + fdiff = config.get('behavior.date-after-range') stopmax = (startmin[0] + fdiff, startmin[1], startmin[2]) elif (self.modifier == Date.MOD_ABOUT or self.quality == Date.QUAL_ESTIMATED): - fdiff = Config.get(Config.DATE_ABOUT_RANGE) + fdiff = config.get('behavior.date-about-range') startmin = (startmin[0] - fdiff, startmin[1], startmin[2]) stopmax = (stopmax[0] + fdiff, stopmax[1], stopmax[2]) # return tuples not lists, for comparisons diff --git a/src/gen/lib/test/date_test.py b/src/gen/lib/test/date_test.py index a70fba040..d6575a140 100644 --- a/src/gen/lib/test/date_test.py +++ b/src/gen/lib/test/date_test.py @@ -45,7 +45,7 @@ except ValueError: from test import test_util test_util.path_append_parent() -import Config +import config import DateHandler from DateHandler import parser as _dp from DateHandler import displayer as _dd @@ -291,9 +291,9 @@ class Tester(unittest.TestCase): def suite(): """ interface to automated test runner test/regrtest.py """ - Config.set(Config.DATE_BEFORE_RANGE, 9999) - Config.set(Config.DATE_AFTER_RANGE, 9999) - Config.set(Config.DATE_ABOUT_RANGE, 10) + config.set('behavior.date-before-range', 9999) + config.set('behavior.date-after-range', 9999) + config.set('behavior.date-about-range', 10) # most are symmetric: #date1, date2, does d1 match d2? does d2 match d1? tests = [("before 1960", "before 1961", True), ("before 1960", "before 1960", True), @@ -386,9 +386,9 @@ class Assert(unittest.TestCase): def suite2(): """ interface to automated test runner test/regrtest.py """ - Config.set(Config.DATE_BEFORE_RANGE, 9999) - Config.set(Config.DATE_AFTER_RANGE, 9999) - Config.set(Config.DATE_ABOUT_RANGE, 10) + config.set('behavior.date-before-range', 9999) + config.set('behavior.date-after-range', 9999) + config.set('behavior.date-about-range', 10) tests = [ # Date +/- int/tuple -> Date ("Date(2008, 1, 1) - 1", "Date(2007, 1, 1)"), diff --git a/src/gen/proxy/living.py b/src/gen/proxy/living.py index 82978a304..bc16d4f90 100644 --- a/src/gen/proxy/living.py +++ b/src/gen/proxy/living.py @@ -38,7 +38,7 @@ Proxy class for the GRAMPS databases. Filter out all living people. from proxybase import ProxyDbBase from gen.lib import Date, Person, Name from Utils import probably_alive -import Config +import config #------------------------------------------------------------------------- # @@ -251,7 +251,7 @@ class LivingProxyDb(ProxyDbBase): new_name.set_surname_prefix(old_name.get_surname_prefix()) new_name.set_type(old_name.get_type()) if self.mode == self.MODE_INCLUDE_LAST_NAME_ONLY: - new_name.set_first_name(Config.get(Config.PRIVATE_GIVEN_TEXT)) + new_name.set_first_name(config.get('preferences.private-given-text')) else: # self.mode == self.MODE_INCLUDE_FULL_NAME_ONLY new_name.set_first_name(old_name.get_first_name()) new_name.set_suffix(old_name.get_suffix()) diff --git a/src/gui/dbloader.py b/src/gui/dbloader.py index 25745b8e9..c40f3ea71 100644 --- a/src/gui/dbloader.py +++ b/src/gui/dbloader.py @@ -56,7 +56,7 @@ import gobject #------------------------------------------------------------------------- from cli.grampscli import CLIDbLoader import const -import Config +import config import gen.db import Utils from gen.plug import PluginManager @@ -139,7 +139,7 @@ class DbLoader(CLIDbLoader): # Suggested folder: try last open file, import, then last export, # then home. - default_dir = Config.get(Config.RECENT_IMPORT_DIR) + default_dir = config.get('paths.recent-import-dir') if len(default_dir)<=1: default_dir = get_default_dir() @@ -155,7 +155,7 @@ class DbLoader(CLIDbLoader): continue (the_path, the_file) = os.path.split(filename) - Config.set(Config.RECENT_IMPORT_DIR, the_path) + config.set('paths.recent-import-dir', the_path) extension = type_selector.get_value() if extension == 'auto': @@ -232,7 +232,7 @@ class DbLoader(CLIDbLoader): self.import_info = importer(self.dbstate.db, filename, self.uistate.pulse_progressbar) dirname = os.path.dirname(filename) + os.path.sep - Config.set(Config.RECENT_IMPORT_DIR, dirname) + config.set('paths.recent-import-dir', dirname) except UnicodeError, msg: ErrorDialog( _("Could not import file: %s") % filename, @@ -260,13 +260,13 @@ class DbLoader(CLIDbLoader): def get_default_dir(): # Suggested folder: try last open file, last import, last export, # then home. - default_dir = os.path.dirname(Config.get(Config.RECENT_FILE)) + default_dir = os.path.dirname(config.get('paths.recent-file')) if default_dir: default_dir += os.path.sep if len(default_dir)<=1: - default_dir = Config.get(Config.RECENT_IMPORT_DIR) + default_dir = config.get('paths.recent-import-dir') if len(default_dir)<=1: - default_dir = Config.get(Config.RECENT_EXPORT_DIR) + default_dir = config.get('paths.recent-export-dir') if len(default_dir)<=1: default_dir = '~/' else: diff --git a/src/gui/grampsgui.py b/src/gui/grampsgui.py index e22ff9452..1100e8802 100644 --- a/src/gui/grampsgui.py +++ b/src/gui/grampsgui.py @@ -60,7 +60,7 @@ import gobject # #------------------------------------------------------------------------- from QuestionDialog import ErrorDialog -import Config +import config #------------------------------------------------------------------------- # @@ -198,7 +198,7 @@ def _display_welcome_message(): """ Display a welcome message to the user. """ - if not Config.get(Config.BETAWARN): + if not config.get('behavior.betawarn'): from QuestionDialog import WarningDialog WarningDialog( _('Danger: This is unstable code!'), @@ -217,9 +217,9 @@ def _display_welcome_message(): "BACKUP your existing databases before opening " "them with this version, and make sure to export your " "data to XML every now and then.")) - Config.set(Config.AUTOLOAD, False) -# Config.set(Config.BETAWARN, True) - Config.set(Config.BETAWARN, Config.get(Config.BETAWARN)) + config.set('behavior.autoload', False) +# config.set('behavior.betawarn', True) + config.set('behavior.betawarn', config.get('behavior.betawarn')) #------------------------------------------------------------------------- # @@ -257,9 +257,9 @@ class Gramps(object): if ah.open or ah.imp_db_path: # if we opened or imported something, only show the interface self.vm.post_init_interface(show_manager=False) - elif Config.get(Config.RECENT_FILE) and Config.get(Config.AUTOLOAD): + elif config.get('paths.recent-file') and config.get('behavior.autoload'): # if we need to autoload last seen file, do so - filename = Config.get(Config.RECENT_FILE) + filename = config.get('paths.recent-file') if os.path.isdir(filename) and \ os.path.isfile(os.path.join(filename, "name.txt")) and \ ah.check_db(filename): @@ -271,7 +271,7 @@ class Gramps(object): # open without fam tree loaded self.vm.post_init_interface() - if Config.get(Config.USE_TIPS): + if config.get('behavior.use-tips'): TipOfDay.TipOfDay(self.vm.uistate) def argerrorfunc(self, string): diff --git a/src/gui/viewmanager.py b/src/gui/viewmanager.py index 24ec2139b..85b7827b2 100644 --- a/src/gui/viewmanager.py +++ b/src/gui/viewmanager.py @@ -62,7 +62,7 @@ from PluginUtils import Tool, PluginWindows, \ import ReportBase import DisplayState import const -import Config +import config import GrampsCfg import Errors from QuestionDialog import (ErrorDialog, WarningDialog, QuestionDialog2, @@ -223,10 +223,10 @@ class ViewManager(CLIManager): self.merge_ids = [] self._key = None - self.show_sidebar = Config.get(Config.VIEW) - self.show_toolbar = Config.get(Config.TOOLBAR_ON) - self.show_filter = Config.get(Config.FILTER) - self.fullscreen = Config.get(Config.FULLSCREEN) + self.show_sidebar = config.get('interface.view') + self.show_toolbar = config.get('interface.toolbar-on') + self.show_filter = config.get('interface.filter') + self.fullscreen = config.get('interface.fullscreen') self.__build_main_window() self.__connect_signals() @@ -244,8 +244,8 @@ class ViewManager(CLIManager): """ Builds the GTK interface """ - width = Config.get(Config.WIDTH) - height = Config.get(Config.HEIGHT) + width = config.get('interface.width') + height = config.get('interface.height') self.window = gtk.Window() self.window.set_icon_from_file(const.ICON) @@ -553,10 +553,10 @@ class ViewManager(CLIManager): self.__rebuild_report_and_tool_menus) self.fileactions.set_sensitive(True) self.uistate.widget.set_sensitive(True) - Config.client.notify_add("/apps/gramps/interface/statusbar", - self.__statusbar_key_update) - Config.client.notify_add("/apps/gramps/interface/filter", - self.__filter_signal) + config.connect("interface.statusbar", + self.__statusbar_key_update) + config.connect("interface.filter", + self.__filter_signal) def __statusbar_key_update(self, client, cnxn_id, entry, data): """ @@ -568,8 +568,8 @@ class ViewManager(CLIManager): """ Callback function for statusbar key update """ - if self.filter_menu.get_active() != Config.get(Config.FILTER): - self.filter_menu.set_active(Config.get(Config.FILTER)) + if self.filter_menu.get_active() != config.get('interface.filter'): + self.filter_menu.set_active(config.get('interface.filter')) def post_init_interface(self, show_manager=True): """ @@ -601,7 +601,7 @@ class ViewManager(CLIManager): error = CLIManager.do_load_plugins(self) # get to see if we need to open the plugin status window - if error and Config.get(Config.POP_PLUGIN_STATUS): + if error and config.get('behavior.pop-plugin-status'): self.__plugin_status() self.uistate.push_message(self.dbstate, _('Ready')) @@ -622,9 +622,9 @@ class ViewManager(CLIManager): # save the current window size (width, height) = self.window.get_size() - Config.set(Config.WIDTH, width) - Config.set(Config.HEIGHT, height) - Config.sync() + config.set('interface.width', width) + config.set('interface.height', height) + config.save() gtk.main_quit() def __backup(self): @@ -742,14 +742,14 @@ class ViewManager(CLIManager): if obj.get_active(): self.ebox.show() self.notebook.set_show_tabs(False) - Config.set(Config.VIEW, True) + config.set('interface.view', True) self.show_sidebar = True else: self.ebox.hide() self.notebook.set_show_tabs(True) - Config.set(Config.VIEW, False) + config.set('interface.view', False) self.show_sidebar = False - Config.sync() + config.save() def toolbar_toggle(self, obj): """ @@ -758,11 +758,11 @@ class ViewManager(CLIManager): """ if obj.get_active(): self.toolbar.show() - Config.set(Config.TOOLBAR_ON, True) + config.set('interface.toolbar-on', True) else: self.toolbar.hide() - Config.set(Config.TOOLBAR_ON, False) - Config.sync() + config.set('interface.toolbar-on', False) + config.save() def fullscreen_toggle(self, obj): """ @@ -771,11 +771,11 @@ class ViewManager(CLIManager): """ if obj.get_active(): self.window.fullscreen() - Config.set(Config.FULLSCREEN, True) + config.set('interface.fullscreen', True) else: self.window.unfullscreen() - Config.set(Config.FULLSCREEN, False) - Config.sync() + config.set('interface.fullscreen', False) + config.save() def register_view(self, view): """ @@ -806,7 +806,7 @@ class ViewManager(CLIManager): self.pages = [] self.prev_nav = PageView.NAVIGATION_NONE - use_text = Config.get(Config.SIDEBAR_TEXT) + use_text = config.get('interface.sidebar-text') index = 0 for page_def in self.views: @@ -846,9 +846,9 @@ class ViewManager(CLIManager): button.drag_dest_set(0, [], 0) button.connect('drag_motion', self.__switch_page_on_dnd, page_no) - use_current = Config.get(Config.USE_LAST_VIEW) + use_current = config.get('preferences.use-last-view') if use_current: - current_page = Config.get(Config.LAST_VIEW) + current_page = config.get('preferences.last-view') if current_page >= len(self.pages): current_page = 0 else: @@ -905,7 +905,7 @@ class ViewManager(CLIManager): """ Called when the button causes a page change """ - if Config.get(Config.VIEW): + if config.get('interface.view'): self.__vb_handlers_block() self.notebook.set_current_page(index) @@ -1007,8 +1007,8 @@ class ViewManager(CLIManager): if len(self.pages) > 0: self.active_page = self.pages[num] self.active_page.set_active() - Config.set(Config.LAST_VIEW, num) - Config.sync() + config.set('preferences.last-view', num) + config.save() self.__setup_navigation() self.__connect_active_page() @@ -1368,8 +1368,8 @@ def filter_toggle(obj): """ Save the filter state to the config settings on change """ - Config.set(Config.FILTER, obj.get_active()) - Config.sync() + config.set('interface.filter', obj.get_active()) + config.save() def key_bindings(obj): """ diff --git a/src/gui/views/listview.py b/src/gui/views/listview.py index ef8daf28b..8a6ac4a4a 100644 --- a/src/gui/views/listview.py +++ b/src/gui/views/listview.py @@ -48,7 +48,7 @@ import pango # #---------------------------------------------------------------- from gui.views.navigationview import NavigationView -import Config +import config import TreeTips import Errors from Filters import SearchBar @@ -217,7 +217,7 @@ class ListView(NavigationView): def build_tree(self): if self.active: cput = time.clock() - if Config.get(Config.FILTER): + if config.get('interface.filter'): filter_info = (True, self.generic_filter) else: filter_info = (False, self.search_bar.get_value()) @@ -271,7 +271,7 @@ class ListView(NavigationView): return hpaned def filter_toggle(self, client, cnxn_id, entry, data): - if Config.get(Config.FILTER): + if config.get('interface.filter'): self.search_bar.hide() self.filter_pane.show() else: @@ -280,7 +280,7 @@ class ListView(NavigationView): def post(self): if self.filter_class: - if Config.get(Config.FILTER): + if config.get('interface.filter'): self.search_bar.hide() self.filter_pane.show() else: @@ -300,7 +300,7 @@ class ListView(NavigationView): self.search_bar.show() self.filter_pane.hide() active = False - Config.set(Config.FILTER, active) + config.set('interface.filter', active) self.build_tree() def filter_editor(self, obj): @@ -524,7 +524,7 @@ class ListView(NavigationView): self.sort_order = order handle = self.first_selected() - if Config.get(Config.FILTER): + if config.get('interface.filter'): search = (True, self.generic_filter) else: search = (False, self.search_bar.get_value()) diff --git a/src/gui/views/treemodels/flatbasemodel.py b/src/gui/views/treemodels/flatbasemodel.py index 1648d5d39..18921aa9c 100644 --- a/src/gui/views/treemodels/flatbasemodel.py +++ b/src/gui/views/treemodels/flatbasemodel.py @@ -73,7 +73,7 @@ import gtk # #------------------------------------------------------------------------- from Filters import SearchFilter -import Config +import config from Utils import conv_unicode_tosrtkey_ongtk #------------------------------------------------------------------------- @@ -394,16 +394,16 @@ class FlatBaseModel(gtk.GenericTreeModel): self._reverse = (order == gtk.SORT_DESCENDING) self.tooltip_column = tooltip_column - Config.client.notify_add("/apps/gramps/preferences/todo-color", - self.__update_todo) - Config.client.notify_add("/apps/gramps/preferences/custom-marker-color", - self.__update_custom) - Config.client.notify_add("/apps/gramps/preferences/complete-color", - self.__update_complete) + config.connect("preferences.todo-color", + self.__update_todo) + config.connect("preferences.custom-marker-color", + self.__update_custom) + config.connect("preferences.complete-color", + self.__update_complete) - self.complete_color = Config.get(Config.COMPLETE_COLOR) - self.todo_color = Config.get(Config.TODO_COLOR) - self.custom_color = Config.get(Config.CUSTOM_MARKER_COLOR) + self.complete_color = config.get('preferences.complete-color') + self.todo_color = config.get('preferences.todo-color') + self.custom_color = config.get('preferences.custom-marker-color') self.rebuild_data() _LOG.debug(self.__class__.__name__ + ' __init__ ' + str(time.clock() - cput) + ' sec') @@ -441,19 +441,19 @@ class FlatBaseModel(gtk.GenericTreeModel): """ Callback if preferences todo color changes """ - self.todo_color = Config.get(Config.TODO_COLOR) + self.todo_color = config.get('preferences.todo-color') def __update_custom(self, client, cnxn_id, entry, data): """ Callback if preferences todo color changes """ - self.custom_color = Config.get(Config.CUSTOM_MARKER_COLOR) + self.custom_color = config.get('preferences.custom-marker-color') def __update_complete(self, client, cnxn_id, entry, data): """ Callback if preferences todo color changes """ - self.complete_color = Config.get(Config.COMPLETE_COLOR) + self.complete_color = config.get('preferences.complete-color') def total(self): """ diff --git a/src/gui/views/treemodels/treebasemodel.py b/src/gui/views/treemodels/treebasemodel.py index 25847ce4a..19d7beac6 100644 --- a/src/gui/views/treemodels/treebasemodel.py +++ b/src/gui/views/treemodels/treebasemodel.py @@ -48,7 +48,7 @@ import gtk # GRAMPS modules # #------------------------------------------------------------------------- -import Config +import config from gen.utils.longop import LongOpStatus from Filters import SearchFilter # from Filters import ExactSearchFilter @@ -361,16 +361,16 @@ class TreeBaseModel(gtk.GenericTreeModel): self.lru_data = LRU(TreeBaseModel._CACHE_SIZE) - Config.client.notify_add("/apps/gramps/preferences/todo-color", - self.__update_todo) - Config.client.notify_add("/apps/gramps/preferences/custom-marker-color", - self.__update_custom) - Config.client.notify_add("/apps/gramps/preferences/complete-color", - self.__update_complete) + config.connect("preferences.todo-color", + self.__update_todo) + config.connect("preferences.custom-marker-color", + self.__update_custom) + config.connect("preferences.complete-color", + self.__update_complete) - self.complete_color = Config.get(Config.COMPLETE_COLOR) - self.todo_color = Config.get(Config.TODO_COLOR) - self.custom_color = Config.get(Config.CUSTOM_MARKER_COLOR) + self.complete_color = config.get('preferences.complete-color') + self.todo_color = config.get('preferences.todo-color') + self.custom_color = config.get('preferences.custom-marker-color') self.mapper = TreeNodeMap() self.set_search(search) @@ -388,13 +388,13 @@ class TreeBaseModel(gtk.GenericTreeModel): def __update_todo(self, *args): - self.todo_color = Config.get(Config.TODO_COLOR) + self.todo_color = config.get('preferences.todo-color') def __update_custom(self, *args): - self.custom_color = Config.get(Config.CUSTOM_MARKER_COLOR) + self.custom_color = config.get('preferences.custom-marker-color') def __update_complete(self, *args): - self.complete_color = Config.get(Config.COMPLETE_COLOR) + self.complete_color = config.get('preferences.complete-color') def displayed(self): return self.__displayed diff --git a/src/plugins/export/ExportGeneWeb.py b/src/plugins/export/ExportGeneWeb.py index 533a9e2cd..5e38d1a54 100644 --- a/src/plugins/export/ExportGeneWeb.py +++ b/src/plugins/export/ExportGeneWeb.py @@ -52,7 +52,7 @@ import Utils from QuestionDialog import ErrorDialog from gen.plug import PluginManager, ExportPlugin from glade import Glade -import Config +import config #------------------------------------------------------------------------- # @@ -453,7 +453,7 @@ class GeneWebWriter(object): def get_ref_name(self,person): surname = self.rem_spaces( person.get_primary_name().get_surname()) - firstname = Config.get(Config.PRIVATE_GIVEN_TEXT) + firstname = config.get('preferences.private-given-text') if not (Utils.probably_alive(person,self.db) and \ self.restrict and self.living): firstname = self.rem_spaces( person.get_primary_name().get_first_name()) @@ -464,7 +464,7 @@ class GeneWebWriter(object): def get_child_ref_name(self,person,father_lastname): surname = self.rem_spaces( person.get_primary_name().get_surname()) - firstname = Config.get(Config.PRIVATE_GIVEN_TEXT) + firstname = config.get('preferences.private-given-text') if not (Utils.probably_alive(person,self.db) and \ self.restrict and self.living): firstname = self.rem_spaces( person.get_primary_name().get_first_name()) diff --git a/src/plugins/gramplet/GivenNameGramplet.py b/src/plugins/gramplet/GivenNameGramplet.py index 2559fd6df..e6e59a7bc 100644 --- a/src/plugins/gramplet/GivenNameGramplet.py +++ b/src/plugins/gramplet/GivenNameGramplet.py @@ -23,7 +23,7 @@ from gettext import gettext as _ from DataViews import Gramplet, register -import Config +import config _YIELD_INTERVAL = 350 @@ -117,7 +117,7 @@ class GivenNameCloudGramplet(Gramplet): for (count, givensubname) in cloud_names: # givensubname_sort: if count > include_greater_than: if len(givensubname) == 0: - text = Config.get(Config.NO_SURNAME_TEXT) + text = config.get('preferences.no-surname-text') else: text = givensubname size = make_tag_size(count, counts) diff --git a/src/plugins/gramplet/SurnameCloudGramplet.py b/src/plugins/gramplet/SurnameCloudGramplet.py index 535b02078..8f497bb95 100644 --- a/src/plugins/gramplet/SurnameCloudGramplet.py +++ b/src/plugins/gramplet/SurnameCloudGramplet.py @@ -25,7 +25,7 @@ #------------------------------------------------------------------------ from DataViews import register, Gramplet from TransUtils import sgettext as _ -import Config +import config #------------------------------------------------------------------------ # @@ -134,7 +134,7 @@ class SurnameCloudGramplet(Gramplet): for (count, surname) in cloud_names: # surname_sort: if count > include_greater_than: if len(surname) == 0: - text = Config.get(Config.NO_SURNAME_TEXT) + text = config.get('preferences.no-surname-text') else: text = surname size = make_tag_size(count, counts) diff --git a/src/plugins/gramplet/TopSurnamesGramplet.py b/src/plugins/gramplet/TopSurnamesGramplet.py index 30160a389..4da43e0ca 100644 --- a/src/plugins/gramplet/TopSurnamesGramplet.py +++ b/src/plugins/gramplet/TopSurnamesGramplet.py @@ -25,7 +25,7 @@ #------------------------------------------------------------------------ from DataViews import register, Gramplet from TransUtils import sgettext as _ -import Config +import config #------------------------------------------------------------------------ # @@ -93,7 +93,7 @@ class TopSurnamesGramplet(Gramplet): line = 0 ### All done! self.set_text("") - nosurname = Config.get(Config.NO_SURNAME_TEXT) + nosurname = config.get('preferences.no-surname-text') for (count, surname) in surname_sort: text = "%s, " % (surname if surname else nosurname) text += "%d%% (%d)\n" % (int((float(count)/total) * 100), count) diff --git a/src/plugins/import/ImportGedcom.py b/src/plugins/import/ImportGedcom.py index 3c33be03d..42fa64fa3 100644 --- a/src/plugins/import/ImportGedcom.py +++ b/src/plugins/import/ImportGedcom.py @@ -51,8 +51,8 @@ from glade import Glade from libmixin import GrampsDbMixin try: - import Config - DEFAULT_SOURCE = Config.get(Config.DEFAULT_SOURCE) + import config + DEFAULT_SOURCE = config.get('preferences.default-source') except ImportError: LOG.warn("No Config module available using defaults.") DEFAULT_SOURCE = False diff --git a/src/plugins/quickview/AgeOnDate.py b/src/plugins/quickview/AgeOnDate.py index a35d7b509..2ecfc6f39 100644 --- a/src/plugins/quickview/AgeOnDate.py +++ b/src/plugins/quickview/AgeOnDate.py @@ -33,7 +33,7 @@ from gen.plug import PluginManager from ReportBase import CATEGORY_QR_DATE import DateHandler import gen.lib -import Config +import config def run(database, document, date): """ @@ -70,7 +70,7 @@ def run(database, document, date): diff_span = (date - birth_date) if ((death_date is not None) or (death_date is None and - int(diff_span) <= Config.get(Config.MAX_AGE_PROB_ALIVE) * 365)): + int(diff_span) <= config.get('behavior.max-age-prob-alive') * 365)): birth_str = str(diff_span) birth_sort = int(diff_span) if birth_str != "": diff --git a/src/plugins/tool/CalculateEstimatedDates.py b/src/plugins/tool/CalculateEstimatedDates.py index 55c1ce0ba..117aec9e5 100644 --- a/src/plugins/tool/CalculateEstimatedDates.py +++ b/src/plugins/tool/CalculateEstimatedDates.py @@ -41,7 +41,7 @@ from gen.plug import PluginManager from gen.plug.menu import BooleanOption, NumberOption, StringOption, \ FilterOption, PersonOption import gen.lib -import Config +import config from BasicUtils import name_displayer import Errors from ReportBase import ReportUtils @@ -98,25 +98,25 @@ class CalcEstDateOptions(MenuToolOptions): # ----------------------------------------------------- category_name = _("Config") num = NumberOption(_("Maximum age"), - Config.get(Config.MAX_AGE_PROB_ALIVE), + config.get('behavior.max-age-prob-alive'), 0, 200) num.set_help(_("Maximum age that one can live to")) menu.add_option(category_name, "MAX_AGE_PROB_ALIVE", num) num = NumberOption(_("Maximum sibling age difference"), - Config.get(Config.MAX_SIB_AGE_DIFF), + config.get('behavior.max-sib-age-diff'), 0, 200) num.set_help(_("Maximum age difference between siblings")) menu.add_option(category_name, "MAX_SIB_AGE_DIFF", num) num = NumberOption(_("Minimum years between generations"), - Config.get(Config.MIN_GENERATION_YEARS), + config.get('behavior.min-generation-years'), 0, 200) num.set_help(_("Minimum years between two generations")) menu.add_option(category_name, "MIN_GENERATION_YEARS", num) num = NumberOption(_("Average years between generations"), - Config.get(Config.AVG_GENERATION_GAP), + config.get('behavior.avg-generation-gap'), 0, 200) num.set_help(_("Average years between two generations")) menu.add_option(category_name, "AVG_GENERATION_GAP", num) diff --git a/src/plugins/tool/OwnerEditor.py b/src/plugins/tool/OwnerEditor.py index 6e9dcbf7c..f89c73254 100644 --- a/src/plugins/tool/OwnerEditor.py +++ b/src/plugins/tool/OwnerEditor.py @@ -36,7 +36,7 @@ import gtk # #------------------------------------------------------------------------- import const -import Config +import config from Utils import get_researcher import GrampsDisplay from widgets import MonitoredEntry @@ -60,14 +60,14 @@ WIKI_HELP_SEC = _('manual|Edit_Database_Owner_Information...') # #------------------------------------------------------------------------- config_keys = ( - Config.RESEARCHER_NAME, - Config.RESEARCHER_ADDR, - Config.RESEARCHER_CITY, - Config.RESEARCHER_STATE, - Config.RESEARCHER_COUNTRY, - Config.RESEARCHER_POSTAL, - Config.RESEARCHER_PHONE, - Config.RESEARCHER_EMAIL, + 'researcher.researcher-name', + 'researcher.researcher-addr', + 'researcher.researcher-city', + 'researcher.researcher-state', + 'researcher.researcher-country', + 'researcher.researcher-postal', + 'researcher.researcher-phone', + 'researcher.researcher-email', ) #------------------------------------------------------------------------- @@ -165,7 +165,7 @@ class OwnerEditor(Tool.Tool, ManagedWindow.ManagedWindow): elif menuitem.name == 'copy_from_db_to_preferences': for i in range(len(config_keys)): - Config.set(config_keys[i], self.owner.get()[i]) + config.set(config_keys[i], self.owner.get()[i]) #------------------------------------------------------------------------- # diff --git a/src/test/gedread_util.py b/src/test/gedread_util.py index 5f0983a67..156c6cab9 100644 --- a/src/test/gedread_util.py +++ b/src/test/gedread_util.py @@ -11,7 +11,7 @@ from test import test_util as tu from GrampsDbUtils import _ReadGedcom as RG import DbState import gen.db -import Config +import config # extraneous leading newlines do not seem to cause problems # (and actually make it convenient reading the test files!) diff --git a/src/widgets/labels.py b/src/widgets/labels.py index b9fd0de2f..fc15d62da 100644 --- a/src/widgets/labels.py +++ b/src/widgets/labels.py @@ -47,7 +47,7 @@ import pango # Gramps modules # #------------------------------------------------------------------------- -import Config +import config #------------------------------------------------------------------------- # @@ -73,7 +73,7 @@ class LinkLabel(gtk.EventBox): def __init__(self, label, func, handle, decoration=None): if decoration is None: - relation_display_theme = Config.get(Config.RELATION_DISPLAY_THEME) + relation_display_theme = config.get('preferences.relation-display-theme') if relation_display_theme == "CLASSIC": decoration = 'underline="single"' elif relation_display_theme == "WEBPAGE": @@ -90,7 +90,7 @@ class LinkLabel(gtk.EventBox): if func: msg = _('Click to make this person active\n' 'Right click to display the edit menu') - if not Config.get(Config.RELEDITBTN): + if not config.get('interface.releditbtn'): msg += "\n" + _('Edit icons can be enabled in the Preferences dialog') self.set_tooltip_text(msg) @@ -116,7 +116,7 @@ class LinkLabel(gtk.EventBox): self.label.set_padding(x, y) def enter_text(self, obj, event, handle): - relation_display_theme = Config.get(Config.RELATION_DISPLAY_THEME) + relation_display_theme = config.get('preferences.relation-display-theme') if relation_display_theme == "CLASSIC": text = '%s' % (self.decoration, self.orig_text) elif relation_display_theme == "WEBPAGE":