2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-06-15 01:50:39 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2003-12-02 09:57:23 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-11-14 11:01:42 +05:30
|
|
|
import gtk
|
2002-10-20 19:55:16 +05:30
|
|
|
import gtk.glade
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-03-03 05:40:52 +05:30
|
|
|
import Config
|
2004-09-17 09:00:04 +05:30
|
|
|
import DateHandler
|
2006-06-15 01:50:39 +05:30
|
|
|
import NameDisplay
|
2006-04-26 07:14:03 +05:30
|
|
|
import ManagedWindow
|
|
|
|
from GrampsWidgets import *
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-15 08:24:04 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
_surname_styles = [
|
|
|
|
_("Father's surname"),
|
|
|
|
_("None"),
|
|
|
|
_("Combination of mother's and father's surname"),
|
|
|
|
_("Icelandic style"),
|
|
|
|
]
|
2006-05-13 00:19:12 +05:30
|
|
|
|
2004-07-20 07:57:55 +05:30
|
|
|
def set_calendar_date_format():
|
2004-09-25 10:42:15 +05:30
|
|
|
format_list = DateHandler.get_date_formats()
|
2006-03-03 05:40:52 +05:30
|
|
|
DateHandler.set_format(Config.get_date_format(format_list))
|
2004-07-20 07:57:55 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def get_researcher():
|
2006-04-26 07:14:03 +05:30
|
|
|
import RelLib
|
|
|
|
|
2006-04-25 02:34:01 +05:30
|
|
|
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)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-01-10 10:51:32 +05:30
|
|
|
owner = RelLib.Researcher()
|
2002-10-20 19:55:16 +05:30
|
|
|
owner.set(n,a,c,s,ct,p,ph,e)
|
|
|
|
return owner
|
2006-04-26 07:14:03 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-26 07:14:03 +05:30
|
|
|
class GrampsPreferences(ManagedWindow.ManagedWindow):
|
|
|
|
def __init__(self, uistate):
|
|
|
|
|
2006-06-15 01:50:39 +05:30
|
|
|
ManagedWindow.ManagedWindow.__init__(self,uistate,[],GrampsPreferences)
|
2006-04-26 07:14:03 +05:30
|
|
|
|
|
|
|
tlabel = gtk.Label()
|
2006-06-15 01:50:39 +05:30
|
|
|
self.set_window(
|
|
|
|
gtk.Dialog(_('Preferences'),
|
|
|
|
flags=gtk.DIALOG_NO_SEPARATOR,
|
|
|
|
buttons=(gtk.STOCK_CLOSE,gtk.RESPONSE_CLOSE)),
|
|
|
|
tlabel, _('Preferences'), None)
|
2006-04-26 07:14:03 +05:30
|
|
|
|
|
|
|
panel = gtk.Notebook()
|
|
|
|
self.window.vbox.pack_start(tlabel, padding=12)
|
|
|
|
self.window.vbox.add(panel)
|
|
|
|
self.window.connect('response',self.done)
|
|
|
|
panel.append_page(self.add_behavior_panel(),
|
2006-04-26 08:16:09 +05:30
|
|
|
MarkupLabel("<b>%s</b>" % _('General')))
|
|
|
|
panel.append_page(self.add_formats_panel(),
|
|
|
|
MarkupLabel("<b>%s</b>" % _('Display')))
|
2006-06-15 01:50:39 +05:30
|
|
|
panel.append_page(self.add_name_panel(),
|
|
|
|
MarkupLabel("<b>%s</b>" % _('Name Display')))
|
2006-04-26 07:14:03 +05:30
|
|
|
panel.append_page(self.add_prefix_panel(),
|
2006-04-26 09:16:33 +05:30
|
|
|
MarkupLabel("<b>%s</b>" % _('ID Formats')))
|
2006-04-26 07:14:03 +05:30
|
|
|
panel.append_page(self.add_advanced_panel(),
|
2006-04-26 08:16:09 +05:30
|
|
|
MarkupLabel("<b>%s</b>" % _('Warnings')))
|
|
|
|
panel.append_page(self.add_researcher_panel(),
|
|
|
|
MarkupLabel("<b>%s</b>" % _('Researcher')))
|
2006-05-12 23:50:18 +05:30
|
|
|
panel.append_page(self.add_color_panel(),
|
|
|
|
MarkupLabel("<b>%s</b>" % _('Marker Colors')))
|
2006-04-26 07:14:03 +05:30
|
|
|
|
|
|
|
self.window.show_all()
|
|
|
|
self.show()
|
|
|
|
|
|
|
|
def done(self, obj, value):
|
|
|
|
self.close()
|
|
|
|
|
|
|
|
def add_researcher_panel(self):
|
|
|
|
table = gtk.Table(3,8)
|
|
|
|
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)
|
|
|
|
return table
|
|
|
|
|
|
|
|
def add_prefix_panel(self):
|
|
|
|
table = gtk.Table(3,8)
|
|
|
|
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, _('Family'), 1, Config.FPREFIX)
|
|
|
|
self.add_entry(table, _('Place'), 2, Config.PPREFIX)
|
|
|
|
self.add_entry(table, _('Source'), 3, Config.SPREFIX)
|
|
|
|
self.add_entry(table, _('Media Object'), 4, Config.OPREFIX)
|
|
|
|
self.add_entry(table, _('Event'), 5, Config.EPREFIX)
|
|
|
|
self.add_entry(table, _('Repository'), 6, Config.RPREFIX)
|
|
|
|
return table
|
|
|
|
|
|
|
|
def add_advanced_panel(self):
|
|
|
|
table = gtk.Table(3,8)
|
|
|
|
table.set_border_width(12)
|
|
|
|
table.set_col_spacings(6)
|
|
|
|
table.set_row_spacings(6)
|
2006-05-13 09:23:06 +05:30
|
|
|
self.add_checkbox(
|
|
|
|
table, _('Warn when adding parents to a child'),
|
|
|
|
0, Config.FAMILY_WARN)
|
2006-03-06 05:09:20 +05:30
|
|
|
|
2006-05-13 09:23:06 +05:30
|
|
|
self.add_checkbox(
|
|
|
|
table, _('Suppress warning when cancelling with changed data'),
|
|
|
|
1, Config.DONT_ASK)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-05-13 09:23:06 +05:30
|
|
|
self.add_checkbox(
|
|
|
|
table, _('Show plugin status dialog on plugin load error'),
|
|
|
|
2, Config.POP_PLUGIN_STATUS)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2006-04-26 07:14:03 +05:30
|
|
|
return table
|
|
|
|
|
2006-05-12 23:50:18 +05:30
|
|
|
def add_color_panel(self):
|
|
|
|
table = gtk.Table(3,8)
|
|
|
|
table.set_border_width(12)
|
2006-05-13 09:23:06 +05:30
|
|
|
table.set_col_spacings(12)
|
2006-05-12 23:50:18 +05:30
|
|
|
table.set_row_spacings(6)
|
|
|
|
|
2006-05-13 10:42:19 +05:30
|
|
|
self.comp_color = self.add_color(table, _("Complete"), 0,
|
|
|
|
Config.COMPLETE_COLOR)
|
|
|
|
self.todo_color = self.add_color(table, _("ToDo"), 1,
|
|
|
|
Config.TODO_COLOR)
|
|
|
|
self.custom_color = self.add_color(table, _("Custom"), 2,
|
|
|
|
Config.CUSTOM_MARKER_COLOR)
|
|
|
|
|
|
|
|
button = gtk.Button(stock=gtk.STOCK_REVERT_TO_SAVED)
|
|
|
|
button.connect('clicked', self.reset_colors)
|
|
|
|
table.attach(button, 1, 2, 3, 4, yoptions=0, xoptions=0)
|
2006-05-12 23:50:18 +05:30
|
|
|
return table
|
|
|
|
|
2006-05-13 10:42:19 +05:30
|
|
|
def reset_colors(self, obj):
|
|
|
|
|
2006-05-13 11:23:47 +05:30
|
|
|
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,'')
|
2006-05-13 10:42:19 +05:30
|
|
|
|
|
|
|
Config.set(Config.COMPLETE_COLOR, def_comp)
|
|
|
|
Config.set(Config.TODO_COLOR, def_todo)
|
|
|
|
Config.set(Config.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))
|
|
|
|
self.custom_color.set_color(gtk.gdk.color_parse(def_cust))
|
2006-05-13 11:23:47 +05:30
|
|
|
for widget in [self.comp_color,self.todo_color,self.custom_color]:
|
|
|
|
widget.emit('color-set')
|
2006-05-13 10:42:19 +05:30
|
|
|
|
2006-06-15 01:50:39 +05:30
|
|
|
def add_name_panel(self):
|
|
|
|
table = gtk.Table(3,3)
|
|
|
|
table.set_border_width(12)
|
|
|
|
table.set_col_spacings(6)
|
|
|
|
table.set_row_spacings(6)
|
|
|
|
|
|
|
|
obox = gtk.combo_box_new_text()
|
|
|
|
for key,value in NameDisplay.formats.items():
|
|
|
|
obox.append_text(value)
|
|
|
|
|
|
|
|
active = Config.get(Config.NAME_FORMAT)
|
|
|
|
if active >= len(NameDisplay.formats):
|
|
|
|
active = 0
|
|
|
|
obox.set_active(active)
|
|
|
|
obox.connect('changed',
|
|
|
|
lambda obj: Config.set(Config.NAME_FORMAT,
|
|
|
|
obj.get_active()))
|
|
|
|
|
|
|
|
lwidget = BasicLabel("%s: " % _('Preset format'))
|
|
|
|
|
|
|
|
table.attach(lwidget, 0, 1, 0, 1, yoptions=0)
|
|
|
|
table.attach(obox, 1,3,0, 1, yoptions=0)
|
|
|
|
return table
|
|
|
|
|
2006-04-26 07:14:03 +05:30
|
|
|
def add_formats_panel(self):
|
|
|
|
table = gtk.Table(3,8)
|
|
|
|
table.set_border_width(12)
|
|
|
|
table.set_col_spacings(6)
|
|
|
|
table.set_row_spacings(6)
|
|
|
|
|
|
|
|
obox = gtk.combo_box_new_text()
|
|
|
|
formats = DateHandler.get_date_formats()
|
|
|
|
for item in formats:
|
|
|
|
obox.append_text(item)
|
|
|
|
|
|
|
|
active = Config.get(Config.DATE_FORMAT)
|
|
|
|
if active >= len(formats):
|
|
|
|
active = 0
|
|
|
|
obox.set_active(active)
|
|
|
|
obox.connect('changed',
|
|
|
|
lambda obj: Config.set(Config.DATE_FORMAT, obj.get_active()))
|
|
|
|
|
|
|
|
lwidget = BasicLabel("%s: " % _('Date format'))
|
|
|
|
table.attach(lwidget, 0, 1, 0, 1, yoptions=0)
|
|
|
|
table.attach(obox, 1, 3, 0, 1, yoptions=0)
|
|
|
|
|
|
|
|
obox = gtk.combo_box_new_text()
|
|
|
|
formats = _surname_styles
|
|
|
|
for item in formats:
|
|
|
|
obox.append_text(item)
|
|
|
|
obox.set_active(Config.get(Config.SURNAME_GUESSING))
|
|
|
|
obox.connect('changed',
|
|
|
|
lambda obj: Config.set(Config.SURNAME_GUESSING, obj.get_active()))
|
|
|
|
|
|
|
|
lwidget = BasicLabel("%s: " % _('Surname Guessing'))
|
|
|
|
table.attach(lwidget, 0, 1, 1, 2, yoptions=0)
|
|
|
|
table.attach(obox, 1, 3, 1, 2, yoptions=0)
|
|
|
|
|
|
|
|
obox = gtk.combo_box_new_text()
|
|
|
|
formats = [_("Active person's name and ID"),
|
|
|
|
_("Relationship to home person")]
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2006-04-26 07:14:03 +05:30
|
|
|
for item in formats:
|
|
|
|
obox.append_text(item)
|
|
|
|
active = Config.get(Config.STATUSBAR)
|
2006-05-04 03:51:59 +05:30
|
|
|
|
2006-04-26 07:14:03 +05:30
|
|
|
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()))
|
|
|
|
|
|
|
|
lwidget = BasicLabel("%s: " % _('Status bar'))
|
|
|
|
table.attach(lwidget, 0, 1, 2, 3, yoptions=0)
|
|
|
|
table.attach(obox, 1, 3, 2, 3, yoptions=0)
|
2006-05-04 03:51:59 +05:30
|
|
|
|
|
|
|
self.add_checkbox(table, _("Show text in sidebar buttons (takes effect on restart)"),
|
|
|
|
4, Config.SIDEBAR_TEXT)
|
2006-04-26 07:14:03 +05:30
|
|
|
|
|
|
|
return table
|
|
|
|
|
|
|
|
# status bar
|
|
|
|
|
|
|
|
def add_behavior_panel(self):
|
|
|
|
table = gtk.Table(3,8)
|
|
|
|
table.set_border_width(12)
|
|
|
|
table.set_col_spacings(6)
|
|
|
|
table.set_row_spacings(6)
|
|
|
|
|
|
|
|
self.add_checkbox(table, _('Automatically load last database'), 0, Config.AUTOLOAD)
|
|
|
|
self.add_checkbox(table, _('Enable spelling checker'), 1, Config.SPELLCHECK)
|
|
|
|
self.add_checkbox(table, _('Display Tip of the Day'), 2, Config.USE_TIPS)
|
2006-05-20 07:19:38 +05:30
|
|
|
self.add_checkbox(table, _('Download maps online'), 3, Config.ONLINE_MAPS)
|
2006-05-24 10:19:05 +05:30
|
|
|
self.add_checkbox(table, _('Use shading in Relationship View'), 4, Config.RELATION_SHADE)
|
2006-04-26 07:14:03 +05:30
|
|
|
|
|
|
|
return table
|
|
|
|
|
|
|
|
def add_checkbox(self, table, label, index, constant):
|
|
|
|
checkbox = gtk.CheckButton(label)
|
|
|
|
checkbox.set_active(Config.get(constant))
|
|
|
|
checkbox.connect('toggled',self.update_checkbox, constant)
|
|
|
|
table.attach(checkbox, 1, 3, index, index+1, yoptions=0)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-04-26 07:14:03 +05:30
|
|
|
def add_entry(self, table, label, index, constant):
|
|
|
|
lwidget = BasicLabel("%s: " % label)
|
|
|
|
entry = gtk.Entry()
|
|
|
|
entry.set_text(Config.get(constant))
|
|
|
|
entry.connect('changed', self.update_entry, constant)
|
2006-05-13 09:23:06 +05:30
|
|
|
table.attach(lwidget, 0, 1, index, index+1, yoptions=0,
|
|
|
|
xoptions=gtk.FILL)
|
|
|
|
table.attach(entry, 1, 2, index, index+1, yoptions=0)
|
2006-04-26 07:14:03 +05:30
|
|
|
|
2006-05-12 23:50:18 +05:30
|
|
|
def add_color(self, table, label, index, constant):
|
|
|
|
lwidget = BasicLabel("%s: " % label)
|
|
|
|
hexval = Config.get(constant)
|
|
|
|
color = gtk.gdk.color_parse(hexval)
|
|
|
|
entry = gtk.ColorButton(color=color)
|
2006-05-13 10:00:47 +05:30
|
|
|
color_hex_label = BasicLabel(hexval)
|
|
|
|
entry.connect('color-set',self.update_color,constant,color_hex_label)
|
2006-05-13 09:23:06 +05:30
|
|
|
table.attach(lwidget, 0, 1, index, index+1, yoptions=0,
|
|
|
|
xoptions=gtk.FILL)
|
|
|
|
table.attach(entry, 1, 2, index, index+1, yoptions=0, xoptions=0)
|
2006-05-13 10:00:47 +05:30
|
|
|
table.attach(color_hex_label, 2, 3, index, index+1, yoptions=0)
|
2006-05-13 10:42:19 +05:30
|
|
|
return entry
|
2006-05-12 23:50:18 +05:30
|
|
|
|
2006-04-26 07:14:03 +05:30
|
|
|
def update_entry(self, obj, constant):
|
|
|
|
Config.set(constant, unicode(obj.get_text()))
|
|
|
|
|
2006-05-13 10:00:47 +05:30
|
|
|
def update_color(self, obj, constant, color_hex_label):
|
2006-05-12 23:50:18 +05:30
|
|
|
color = obj.get_color()
|
|
|
|
hexval = "#%02x%02x%02x" % (color.red/256,
|
|
|
|
color.green/256,
|
|
|
|
color.blue/256)
|
2006-05-13 10:00:47 +05:30
|
|
|
color_hex_label.set_text(hexval)
|
2006-05-12 23:50:18 +05:30
|
|
|
Config.set(constant, hexval)
|
|
|
|
|
2006-04-26 07:14:03 +05:30
|
|
|
def update_checkbox(self, obj, constant):
|
|
|
|
Config.set(constant, obj.get_active())
|
|
|
|
|
|
|
|
def build_menu_names(self,obj):
|
|
|
|
return (_('Preferences'),None)
|