2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-01-19 23:10:39 +05:30
|
|
|
# Copyright (C) 2000-2004 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
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import os
|
2003-10-16 10:12:21 +05:30
|
|
|
import string
|
2004-07-15 08:24:04 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gobject
|
2002-11-14 11:01:42 +05:30
|
|
|
import gtk
|
2002-10-20 19:55:16 +05:30
|
|
|
import gtk.glade
|
2003-01-10 10:51:32 +05:30
|
|
|
import gnome
|
2003-04-09 08:59:08 +05:30
|
|
|
import gnome.ui
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-09-25 10:42:15 +05:30
|
|
|
import GrampsGconfKeys
|
2003-01-10 10:51:32 +05:30
|
|
|
import RelLib
|
2002-10-20 19:55:16 +05:30
|
|
|
import const
|
|
|
|
import Utils
|
2004-07-15 08:24:04 +05:30
|
|
|
import PaperMenu
|
|
|
|
import Plugins
|
2004-09-17 09:00:04 +05:30
|
|
|
import DateHandler
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-15 08:24:04 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
INDEX = "i"
|
|
|
|
OBJECT = "o"
|
|
|
|
DATA = "d"
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
_surname_styles = [
|
|
|
|
_("Father's surname"),
|
|
|
|
_("None"),
|
|
|
|
_("Combination of mother's and father's surname"),
|
|
|
|
_("Icelandic style"),
|
|
|
|
]
|
|
|
|
|
|
|
|
_name_format_list = [
|
2004-02-14 11:10:30 +05:30
|
|
|
(_("Firstname Surname"), Utils.normal_name, Utils.phonebook_name, lambda x: x.get_surname()),
|
|
|
|
(_("Surname, Firstname"), Utils.phonebook_name, Utils.phonebook_name, lambda x: x.get_surname()),
|
|
|
|
(_("Firstname SURNAME"), Utils.upper_name, Utils.phonebook_upper_name, lambda x : x.get_upper_surname()),
|
|
|
|
(_("SURNAME, Firstname"), Utils.phonebook_upper_name, Utils.phonebook_upper_name, lambda x: x.get_upper_surname()),
|
2002-10-20 19:55:16 +05:30
|
|
|
]
|
|
|
|
|
|
|
|
panellist = [
|
|
|
|
(_("Database"),
|
|
|
|
[( _("General"), 1),
|
2004-05-12 09:28:14 +05:30
|
|
|
( _("Media Objects"), 7),
|
2004-09-17 09:00:04 +05:30
|
|
|
( _("GRAMPS IDs"), 8)]),
|
2002-10-20 19:55:16 +05:30
|
|
|
(_("Display"),
|
2004-05-12 09:28:14 +05:30
|
|
|
[( _("General"), 3),
|
2004-09-17 09:00:04 +05:30
|
|
|
( _("Dates and Names"), 4),
|
2004-05-12 09:28:14 +05:30
|
|
|
( _("Toolbar and Statusbar"), 2)]),
|
2002-10-20 19:55:16 +05:30
|
|
|
(_("Usage"),
|
2004-05-12 09:28:14 +05:30
|
|
|
[( _("Report Preferences"), 6),
|
|
|
|
( _("Researcher Information"), 5),
|
|
|
|
( _("Data Guessing"), 9)]),
|
2002-10-20 19:55:16 +05:30
|
|
|
]
|
|
|
|
|
2004-07-15 08:24:04 +05:30
|
|
|
|
2004-07-20 07:57:55 +05:30
|
|
|
# Not exactly gconf keys, but the functions directly dependent on them
|
2004-07-15 08:24:04 +05:30
|
|
|
def get_nameof():
|
2004-09-25 10:42:15 +05:30
|
|
|
return _name_format_list[GrampsGconfKeys.get_name_format(_name_format_list)][1]
|
2004-07-15 08:24:04 +05:30
|
|
|
|
|
|
|
def get_display_name():
|
2004-09-25 10:42:15 +05:30
|
|
|
return _name_format_list[GrampsGconfKeys.get_name_format(_name_format_list)][2]
|
2004-07-15 08:24:04 +05:30
|
|
|
|
|
|
|
def get_display_surname():
|
2004-09-25 10:42:15 +05:30
|
|
|
return _name_format_list[GrampsGconfKeys.get_name_format(_name_format_list)][3]
|
2004-07-15 08:24:04 +05:30
|
|
|
|
2004-07-20 07:57:55 +05:30
|
|
|
def get_toolbar_style():
|
2004-09-25 10:42:15 +05:30
|
|
|
saved_toolbar = GrampsGconfKeys.get_toolbar()
|
2004-07-20 07:57:55 +05:30
|
|
|
if saved_toolbar in range(4):
|
|
|
|
return saved_toolbar
|
|
|
|
else:
|
|
|
|
try:
|
2004-09-25 10:42:15 +05:30
|
|
|
gnome_toolbar_str = GrampsGconfKeys.client.get_string("/desktop/gnome/interface/toolbar_style")
|
2004-07-20 07:57:55 +05:30
|
|
|
gnome_toolbar = eval("gtk.TOOLBAR_%s" %
|
|
|
|
gnome_toolbar_str.replace('-','_').upper())
|
|
|
|
except:
|
|
|
|
gnome_toolbar = 2
|
|
|
|
return gnome_toolbar
|
|
|
|
|
|
|
|
def set_calendar_date_format():
|
2004-09-25 10:42:15 +05:30
|
|
|
format_list = DateHandler.get_date_formats()
|
|
|
|
DateHandler.set_format(GrampsGconfKeys.get_date_format(format_list))
|
2004-07-20 07:57:55 +05:30
|
|
|
|
2004-07-15 08:24:04 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# make_path -
|
|
|
|
# Creates a directory if it does not already exist. Assumes that the
|
|
|
|
# parent directory already exits
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def make_path(path):
|
|
|
|
if not os.path.isdir(path):
|
|
|
|
os.mkdir(path)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-15 08:24:04 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def loadConfig():
|
|
|
|
"""
|
|
|
|
Load preferences on startup. Not much to do, since all the prefs
|
|
|
|
are in gconf and can be retrieved any time.
|
|
|
|
"""
|
|
|
|
make_path(os.path.expanduser("~/.gramps"))
|
|
|
|
make_path(os.path.expanduser("~/.gramps/filters"))
|
|
|
|
make_path(os.path.expanduser("~/.gramps/plugins"))
|
|
|
|
make_path(os.path.expanduser("~/.gramps/templates"))
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def get_researcher():
|
2004-09-25 10:42:15 +05:30
|
|
|
n = GrampsGconfKeys.get_researcher_name()
|
|
|
|
a = GrampsGconfKeys.get_researcher_addr()
|
|
|
|
c = GrampsGconfKeys.get_researcher_city()
|
|
|
|
s = GrampsGconfKeys.get_researcher_state()
|
|
|
|
ct = GrampsGconfKeys.get_researcher_country()
|
|
|
|
p = GrampsGconfKeys.get_researcher_postal()
|
|
|
|
ph = GrampsGconfKeys.get_researcher_phone()
|
|
|
|
e = GrampsGconfKeys.get_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
|
|
|
|
|
2004-07-15 08:24:04 +05:30
|
|
|
ext_items = []
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2004-07-15 08:24:04 +05:30
|
|
|
#
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class ConfigWidget:
|
|
|
|
def __init__(self,panel,key,label,default):
|
|
|
|
self.p = panel
|
|
|
|
self.k = key
|
|
|
|
self.l = label
|
|
|
|
self.w = None
|
|
|
|
self.d = default
|
2002-11-14 11:01:42 +05:30
|
|
|
self.tag = "/apps/gramps/%s/%s" % (panel,key)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def set(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class ConfigEntry(ConfigWidget):
|
|
|
|
|
|
|
|
def get_widgets(self):
|
|
|
|
l = gtk.Label(self.l)
|
|
|
|
l.show()
|
|
|
|
self.w = gtk.Entry()
|
|
|
|
self.w.show()
|
|
|
|
|
|
|
|
val = get_string(self.tag)
|
|
|
|
if val == None:
|
|
|
|
self.w.set_text(self.d)
|
|
|
|
else:
|
|
|
|
self.w.set_text(val)
|
|
|
|
return [l,self.w]
|
|
|
|
|
|
|
|
def set(self):
|
2003-12-17 10:53:16 +05:30
|
|
|
val = unicode(self.w.get_text())
|
2004-09-25 10:42:15 +05:30
|
|
|
GrampsGconfKeys.client.set_string(self.tag,val)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
class ConfigInt(ConfigWidget):
|
|
|
|
|
|
|
|
def set_range(self,lower,upper):
|
|
|
|
self.lower = lower
|
|
|
|
self.upper = upper
|
|
|
|
|
|
|
|
def get_widgets(self):
|
|
|
|
l = gtk.Label(self.l)
|
|
|
|
l.show()
|
|
|
|
self.w = gtk.SpinButton(digits=0)
|
|
|
|
self.w.show()
|
|
|
|
|
|
|
|
val = get_string(self.tag)
|
|
|
|
if val == None:
|
|
|
|
val = int(self.d)
|
|
|
|
else:
|
|
|
|
val = int(val)
|
|
|
|
|
|
|
|
adj = gtk.Adjustment(val,self.lower,self.upper,1,1,1)
|
|
|
|
|
|
|
|
self.w.set_adjustment(adj)
|
|
|
|
return [l,self.w]
|
|
|
|
|
|
|
|
def set(self):
|
|
|
|
val = self.w.get_value_as_int()
|
2004-09-25 10:42:15 +05:30
|
|
|
GrampsGconfKeys.client.set_int(self.tag,val)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
class ConfigCheckbox(ConfigWidget):
|
|
|
|
|
|
|
|
def get_widgets(self):
|
|
|
|
self.w = gtk.CheckButton(self.l)
|
|
|
|
self.w.show()
|
|
|
|
val = get_bool(self.tag)
|
|
|
|
if val == None:
|
|
|
|
self.w.set_active(self.d)
|
|
|
|
else:
|
|
|
|
self.w.set_active(val)
|
|
|
|
return [self.w]
|
|
|
|
|
|
|
|
def set(self):
|
|
|
|
val = self.w.get_active()
|
2004-09-25 10:42:15 +05:30
|
|
|
GrampsGconfKeys.client.set_bool(self.tag,val)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
|
|
|
|
class ConfigFile(ConfigWidget):
|
|
|
|
|
|
|
|
def get_widgets(self):
|
2003-02-05 19:23:00 +05:30
|
|
|
self.w = gnome.ui.FileEntry(self.tag)
|
2002-10-20 19:55:16 +05:30
|
|
|
lbl = gtk.Label(self.l)
|
|
|
|
self.w.show()
|
|
|
|
lbl.show()
|
|
|
|
val = get_string(self.tag)
|
|
|
|
self.w.set_title("%s -- GRAMPS" % (self.l))
|
|
|
|
if val == None:
|
|
|
|
self.w.gtk_entry().set_text(self.d)
|
|
|
|
else:
|
|
|
|
self.w.gtk_entry().set_text(val)
|
|
|
|
return [lbl,self.w]
|
|
|
|
|
|
|
|
def set(self):
|
|
|
|
val = self.w.get_full_path(0)
|
2004-09-25 10:42:15 +05:30
|
|
|
GrampsGconfKeys.client.set_string(self.tag,val)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
|
|
|
|
def add_text(category,panel,frame,config_tag,label,default):
|
|
|
|
ext_items.append((category,panel,frame,ConfigEntry(panel,config_tag,label,default)))
|
|
|
|
|
|
|
|
def add_file_entry(category,panel,frame,config_tag,label,default):
|
|
|
|
ext_items.append((category,panel,frame,ConfigFile(panel,config_tag,label,default)))
|
|
|
|
|
|
|
|
def add_int(category,panel,frame,config_tag,label,default,range=(0,100)):
|
|
|
|
cfgint = ConfigInt(panel,config_tag,label,default)
|
|
|
|
cfgint.set_range(range[0],range[1])
|
|
|
|
ext_items.append((category,panel,frame,cfgint))
|
|
|
|
|
|
|
|
def add_checkbox(category,panel,frame,config_tag,label,default):
|
|
|
|
ext_items.append((category,panel,frame,ConfigCheckbox(panel,config_tag,label,default)))
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class GrampsPreferences:
|
|
|
|
def __init__(self,db):
|
2003-10-16 22:13:07 +05:30
|
|
|
self.built = 0
|
2002-10-20 19:55:16 +05:30
|
|
|
self.db = db
|
2003-08-17 07:44:33 +05:30
|
|
|
self.top = gtk.glade.XML(const.prefsFile,"preferences","gramps")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.top.signal_autoconnect({
|
|
|
|
"on_close_clicked" : self.on_close_clicked,
|
|
|
|
"on_help_clicked" : self.on_propertybox_help,
|
|
|
|
"on_tree_select_row" : self.select
|
|
|
|
})
|
|
|
|
|
|
|
|
self.window = self.top.get_widget("preferences")
|
|
|
|
self.tree = self.top.get_widget("tree")
|
|
|
|
self.store = gtk.TreeStore(gobject.TYPE_STRING)
|
|
|
|
self.selection = self.tree.get_selection()
|
|
|
|
self.selection.connect('changed',self.select)
|
|
|
|
col = gtk.TreeViewColumn('',gtk.CellRendererText(),text=0)
|
|
|
|
self.tree.append_column(col)
|
|
|
|
self.tree.set_model(self.store)
|
|
|
|
self.panel = self.top.get_widget("panel")
|
|
|
|
self.ofmt = self.top.get_widget("output_format")
|
|
|
|
self.gfmt = self.top.get_widget("graphical_format")
|
|
|
|
|
|
|
|
self.imap = {}
|
|
|
|
self.build_tree()
|
|
|
|
self.build()
|
|
|
|
self.build_ext()
|
2003-10-16 22:13:07 +05:30
|
|
|
self.built = 1
|
2003-06-14 20:17:41 +05:30
|
|
|
self.window.show()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def build_tree(self):
|
|
|
|
prev = None
|
|
|
|
ilist = []
|
2004-08-20 17:41:56 +05:30
|
|
|
for (name,lst) in panellist:
|
2002-10-20 19:55:16 +05:30
|
|
|
node = self.store.insert_after(None, prev)
|
|
|
|
self.store.set(node,0,name)
|
|
|
|
next = None
|
2004-08-20 17:41:56 +05:30
|
|
|
for (subname,tab) in lst:
|
2002-10-20 19:55:16 +05:30
|
|
|
next = self.store.insert_after(node,next)
|
|
|
|
ilist.append((next,tab))
|
|
|
|
self.store.set(next,0,subname)
|
|
|
|
for next,tab in ilist:
|
|
|
|
path = self.store.get_path(next)
|
|
|
|
self.imap[path] = tab
|
|
|
|
|
|
|
|
def build(self):
|
2004-07-20 07:57:55 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
auto = self.top.get_widget("autoload")
|
2004-09-25 10:42:15 +05:30
|
|
|
auto.set_active(GrampsGconfKeys.get_autoload())
|
|
|
|
auto.connect('toggled',lambda obj: GrampsGconfKeys.save_autoload(obj.get_active()))
|
2004-07-20 07:57:55 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
lds = self.top.get_widget("uselds")
|
2004-09-25 10:42:15 +05:30
|
|
|
lds.set_active(GrampsGconfKeys.get_uselds())
|
|
|
|
lds.connect('toggled',lambda obj: GrampsGconfKeys.save_uselds(obj.get_active()))
|
2004-07-20 07:57:55 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
mr = self.top.get_widget("mediaref")
|
|
|
|
mc = self.top.get_widget("mediacopy")
|
2004-09-25 10:42:15 +05:30
|
|
|
if GrampsGconfKeys.get_media_reference():
|
2002-10-20 19:55:16 +05:30
|
|
|
mr.set_active(1)
|
|
|
|
else:
|
|
|
|
mc.set_active(1)
|
2004-07-20 07:57:55 +05:30
|
|
|
mr.connect('toggled',lambda obj: save_media_reference(obj.get_active()))
|
|
|
|
|
|
|
|
dg = self.top.get_widget("globalprop")
|
2004-09-25 10:42:15 +05:30
|
|
|
dg.set_active(GrampsGconfKeys.get_media_global())
|
|
|
|
dg.connect('toggled',lambda obj: GrampsGconfKeys.save_media_global(obj.get_active()))
|
2004-07-20 07:57:55 +05:30
|
|
|
|
|
|
|
dl = self.top.get_widget("localprop")
|
2004-09-25 10:42:15 +05:30
|
|
|
dl.set_active(GrampsGconfKeys.get_media_local())
|
|
|
|
dl.connect('toggled',lambda obj: GrampsGconfKeys.save_media_local(obj.get_active()))
|
2004-07-20 07:57:55 +05:30
|
|
|
|
|
|
|
index_vis = self.top.get_widget("show_child_id")
|
2004-09-25 10:42:15 +05:30
|
|
|
index_vis.set_active(GrampsGconfKeys.get_index_visible())
|
|
|
|
index_vis.connect('toggled',lambda obj: GrampsGconfKeys.save_index_visible(obj.get_active()))
|
2004-07-20 07:57:55 +05:30
|
|
|
|
|
|
|
ipr = self.top.get_widget("iprefix")
|
2004-09-25 10:42:15 +05:30
|
|
|
ipr.set_text(GrampsGconfKeys.get_person_id_prefix())
|
|
|
|
ipr.connect('changed',lambda obj: GrampsGconfKeys.save_iprefix(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
opr = self.top.get_widget("oprefix")
|
2004-09-25 10:42:15 +05:30
|
|
|
opr.set_text(GrampsGconfKeys.get_object_id_prefix())
|
|
|
|
opr.connect('changed',lambda obj: GrampsGconfKeys.save_oprefix(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
fpr = self.top.get_widget("fprefix")
|
2004-09-25 10:42:15 +05:30
|
|
|
fpr.set_text(GrampsGconfKeys.get_family_id_prefix())
|
|
|
|
fpr.connect('changed',lambda obj: GrampsGconfKeys.save_fprefix(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
spr = self.top.get_widget("sprefix")
|
2004-09-25 10:42:15 +05:30
|
|
|
spr.set_text(GrampsGconfKeys.get_source_id_prefix())
|
|
|
|
spr.connect('changed',lambda obj: GrampsGconfKeys.save_sprefix(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
ppr = self.top.get_widget("pprefix")
|
2004-09-25 10:42:15 +05:30
|
|
|
ppr.set_text(GrampsGconfKeys.get_place_id_prefix())
|
|
|
|
ppr.connect('changed',lambda obj: GrampsGconfKeys.save_pprefix(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
|
|
|
|
sb2 = self.top.get_widget("stat2")
|
|
|
|
sb3 = self.top.get_widget("stat3")
|
2004-09-25 10:42:15 +05:30
|
|
|
if GrampsGconfKeys.get_statusbar() == 0 or GrampsGconfKeys.get_statusbar() == 1:
|
2004-07-20 07:57:55 +05:30
|
|
|
sb2.set_active(1)
|
2003-03-23 01:56:44 +05:30
|
|
|
else:
|
2004-07-20 07:57:55 +05:30
|
|
|
sb3.set_active(1)
|
|
|
|
sb2.connect('toggled',
|
2004-09-25 10:42:15 +05:30
|
|
|
lambda obj: GrampsGconfKeys.save_statusbar(2-obj.get_active()))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-20 07:57:55 +05:30
|
|
|
toolbarmenu = self.top.get_widget("tooloptmenu")
|
2004-09-25 10:42:15 +05:30
|
|
|
toolbarmenu.set_history(GrampsGconfKeys.get_toolbar())
|
|
|
|
toolbarmenu.connect('changed',lambda obj: GrampsGconfKeys.save_toolbar(obj.get_history()))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-20 07:57:55 +05:30
|
|
|
pvbutton = self.top.get_widget('pvbutton')
|
|
|
|
fvbutton = self.top.get_widget('fvbutton')
|
2004-09-25 10:42:15 +05:30
|
|
|
if GrampsGconfKeys.get_default_view() == 0:
|
2004-07-20 07:57:55 +05:30
|
|
|
pvbutton.set_active(1)
|
2003-08-12 08:31:17 +05:30
|
|
|
else:
|
2004-07-20 07:57:55 +05:30
|
|
|
fvbutton.set_active(1)
|
2004-09-25 10:42:15 +05:30
|
|
|
fvbutton.connect('toggled',lambda obj: GrampsGconfKeys.save_default_view(obj.get_active()))
|
2003-08-12 08:31:17 +05:30
|
|
|
|
2004-07-20 07:57:55 +05:30
|
|
|
familyview1 = self.top.get_widget('familyview1')
|
|
|
|
familyview2 = self.top.get_widget('familyview2')
|
2004-09-25 10:42:15 +05:30
|
|
|
if GrampsGconfKeys.get_family_view() == 0:
|
2004-07-20 07:57:55 +05:30
|
|
|
familyview1.set_active(1)
|
2003-08-26 09:15:41 +05:30
|
|
|
else:
|
2004-07-20 07:57:55 +05:30
|
|
|
familyview2.set_active(1)
|
2004-09-25 10:42:15 +05:30
|
|
|
familyview2.connect('toggled',lambda obj: GrampsGconfKeys.save_family_view(obj.get_active()))
|
2003-08-26 09:15:41 +05:30
|
|
|
|
2004-07-20 07:57:55 +05:30
|
|
|
usetips = self.top.get_widget('usetips')
|
2004-09-25 10:42:15 +05:30
|
|
|
usetips.set_active(GrampsGconfKeys.get_usetips())
|
|
|
|
usetips.connect('toggled',lambda obj: GrampsGconfKeys.save_usetips(obj.get_active()))
|
2004-05-18 12:30:34 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
paper_obj = self.top.get_widget("paper_size")
|
|
|
|
menu = gtk.Menu()
|
|
|
|
choice = 0
|
|
|
|
for index in range(0,len(PaperMenu.paper_sizes)):
|
|
|
|
name = PaperMenu.paper_sizes[index].get_name()
|
2004-09-25 10:42:15 +05:30
|
|
|
if name == GrampsGconfKeys.get_paper_preference():
|
2002-10-20 19:55:16 +05:30
|
|
|
choice = index
|
|
|
|
item = gtk.MenuItem(name)
|
|
|
|
item.set_data(DATA,name)
|
|
|
|
item.show()
|
|
|
|
menu.append(item)
|
|
|
|
menu.set_active(choice)
|
|
|
|
paper_obj.set_menu(menu)
|
2004-07-20 07:57:55 +05:30
|
|
|
paper_obj.connect("changed",
|
2004-09-25 10:42:15 +05:30
|
|
|
lambda obj: GrampsGconfKeys.save_paper_preference(obj.get_menu().get_active().get_data(DATA)))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
lastnamegen_obj = self.top.get_widget("lastnamegen")
|
|
|
|
menu = gtk.Menu()
|
|
|
|
choice = 0
|
|
|
|
for index in range(0,len(_surname_styles)):
|
|
|
|
name = _surname_styles[index]
|
|
|
|
item = gtk.MenuItem(name)
|
|
|
|
item.set_data(DATA,index)
|
|
|
|
item.show()
|
|
|
|
menu.append(item)
|
2004-09-25 10:42:15 +05:30
|
|
|
menu.set_active(GrampsGconfKeys.get_lastnamegen(_surname_styles))
|
2002-10-20 19:55:16 +05:30
|
|
|
lastnamegen_obj.set_menu(menu)
|
2004-07-20 07:57:55 +05:30
|
|
|
lastnamegen_obj.connect("changed",
|
2004-09-25 10:42:15 +05:30
|
|
|
lambda obj: GrampsGconfKeys.save_lastnamegen(obj.get_menu().get_active().get_data(DATA)),_surname_styles)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.osubmenu = gtk.Menu()
|
|
|
|
choice = 0
|
|
|
|
index = 0
|
|
|
|
for name in [ _("No default format") ] + Plugins.get_text_doc_list():
|
2004-09-25 10:42:15 +05:30
|
|
|
if name == GrampsGconfKeys.get_output_preference():
|
2002-10-20 19:55:16 +05:30
|
|
|
choice = index
|
|
|
|
item = gtk.MenuItem(name)
|
|
|
|
item.set_data(DATA,name)
|
|
|
|
item.show()
|
|
|
|
self.osubmenu.append(item)
|
|
|
|
index = index + 1
|
|
|
|
self.osubmenu.set_active(choice)
|
|
|
|
self.ofmt.set_menu(self.osubmenu)
|
2004-07-20 07:57:55 +05:30
|
|
|
self.ofmt.connect("changed",
|
2004-09-25 10:42:15 +05:30
|
|
|
lambda obj: GrampsGconfKeys.save_output_preference(obj.get_menu().get_active().get_data(DATA)))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.gsubmenu = gtk.Menu()
|
|
|
|
choice = 0
|
|
|
|
index = 0
|
|
|
|
for name in [ _("No default format") ] + Plugins.get_draw_doc_list():
|
2004-09-25 10:42:15 +05:30
|
|
|
if name == GrampsGconfKeys.get_goutput_preference():
|
2002-10-20 19:55:16 +05:30
|
|
|
choice = index
|
|
|
|
item = gtk.MenuItem(name)
|
|
|
|
item.set_data(DATA,name)
|
|
|
|
item.show()
|
|
|
|
self.gsubmenu.append(item)
|
|
|
|
index = index + 1
|
|
|
|
self.gsubmenu.set_active(choice)
|
|
|
|
self.gfmt.set_menu(self.gsubmenu)
|
2004-07-20 07:57:55 +05:30
|
|
|
self.gfmt.connect("changed",
|
2004-09-25 10:42:15 +05:30
|
|
|
lambda obj: GrampsGconfKeys.save_goutput_preference(obj.get_menu().get_active().get_data(DATA)))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
date_option = self.top.get_widget("date_format")
|
|
|
|
date_menu = gtk.Menu()
|
2004-09-17 09:00:04 +05:30
|
|
|
dlist = DateHandler.get_date_formats()
|
|
|
|
for index in range(0,len(dlist)):
|
|
|
|
item = gtk.MenuItem(dlist[index])
|
2002-10-20 19:55:16 +05:30
|
|
|
item.set_data(INDEX,index)
|
|
|
|
item.show()
|
|
|
|
date_menu.append(item)
|
2004-09-25 10:42:15 +05:30
|
|
|
try:
|
|
|
|
# Technically, a selected format might me out of range
|
|
|
|
# for this locale's format list.
|
|
|
|
date_menu.set_active(GrampsGconfKeys.get_date_format(dlist))
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
date_option.set_menu(date_menu)
|
2004-07-20 07:57:55 +05:30
|
|
|
date_option.connect("changed",
|
2004-09-25 10:42:15 +05:30
|
|
|
lambda obj: GrampsGconfKeys.save_date_format(obj.get_menu().get_active().get_data(INDEX),dlist))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
name_option = self.top.get_widget("name_format")
|
|
|
|
name_menu = gtk.Menu()
|
|
|
|
for index in range(0,len(_name_format_list)):
|
|
|
|
name_tuple = _name_format_list[index]
|
|
|
|
item = gtk.MenuItem(name_tuple[0])
|
|
|
|
item.set_data(INDEX,index)
|
|
|
|
item.show()
|
|
|
|
name_menu.append(item)
|
2004-09-25 10:42:15 +05:30
|
|
|
name_menu.set_active(GrampsGconfKeys.get_name_format(_name_format_list))
|
2002-10-20 19:55:16 +05:30
|
|
|
name_option.set_menu(name_menu)
|
2004-07-20 07:57:55 +05:30
|
|
|
name_option.connect("changed",
|
2004-09-25 10:42:15 +05:30
|
|
|
lambda obj: GrampsGconfKeys.save_name_format(obj.get_menu().get_active().get_data(INDEX),_name_format_list))
|
2004-07-20 07:57:55 +05:30
|
|
|
|
|
|
|
resname = self.top.get_widget("resname")
|
2004-09-25 10:42:15 +05:30
|
|
|
resname.set_text(GrampsGconfKeys.get_researcher_name())
|
|
|
|
resname.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_name(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
resaddr = self.top.get_widget("resaddr")
|
2004-09-25 10:42:15 +05:30
|
|
|
resaddr.set_text(GrampsGconfKeys.get_researcher_addr())
|
|
|
|
resaddr.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_addr(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
rescity = self.top.get_widget("rescity")
|
2004-09-25 10:42:15 +05:30
|
|
|
rescity.set_text(GrampsGconfKeys.get_researcher_city())
|
|
|
|
rescity.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_city(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
resstate = self.top.get_widget("resstate")
|
2004-09-25 10:42:15 +05:30
|
|
|
resstate.set_text(GrampsGconfKeys.get_researcher_state())
|
|
|
|
resstate.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_state(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
rescountry = self.top.get_widget("rescountry")
|
2004-09-25 10:42:15 +05:30
|
|
|
rescountry.set_text(GrampsGconfKeys.get_researcher_country())
|
|
|
|
rescountry.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_country(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
respostal = self.top.get_widget("respostal")
|
2004-09-25 10:42:15 +05:30
|
|
|
respostal.set_text(GrampsGconfKeys.get_researcher_postal())
|
|
|
|
respostal.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_postal(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
resphone = self.top.get_widget("resphone")
|
2004-09-25 10:42:15 +05:30
|
|
|
resphone.set_text(GrampsGconfKeys.get_researcher_phone())
|
|
|
|
resphone.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_phone(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
resemail = self.top.get_widget("resemail")
|
2004-09-25 10:42:15 +05:30
|
|
|
resemail.set_text(GrampsGconfKeys.get_researcher_email())
|
|
|
|
resemail.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_email(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
|
|
|
|
repdir = self.top.get_widget("repdir").gtk_entry()
|
2004-09-25 10:42:15 +05:30
|
|
|
repdir.set_text(GrampsGconfKeys.get_report_dir())
|
|
|
|
repdir.connect('changed',lambda obj: GrampsGconfKeys.save_report_dir(obj.get_text()))
|
2004-07-20 07:57:55 +05:30
|
|
|
webdir = self.top.get_widget("htmldir").gtk_entry()
|
2004-09-25 10:42:15 +05:30
|
|
|
webdir.set_text(GrampsGconfKeys.get_web_dir())
|
|
|
|
webdir.connect('changed',lambda obj: GrampsGconfKeys.save_web_dir(obj.get_text()))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def build_ext(self):
|
|
|
|
self.c = {}
|
|
|
|
self.ext_list = []
|
|
|
|
for (c,p,f,o) in ext_items:
|
|
|
|
self.ext_list.append(o)
|
|
|
|
if self.c.has_key(c):
|
|
|
|
if self.c[c][p].has_key(f):
|
|
|
|
self.c[c][p][f].append(o)
|
|
|
|
else:
|
|
|
|
self.c[c][p][f] = [o]
|
|
|
|
else:
|
|
|
|
self.c[c] = {}
|
|
|
|
self.c[c][p] = {}
|
|
|
|
self.c[c][p][f] = [o]
|
|
|
|
|
|
|
|
next_panel=13
|
|
|
|
for c in self.c.keys():
|
|
|
|
node = self.tree.insert_node(None,None,[c],is_leaf=0,expanded=1)
|
|
|
|
self.tree.node_set_row_data(node,0)
|
|
|
|
next = None
|
|
|
|
for panel in self.c[c].keys():
|
|
|
|
next = self.tree.insert_node(node,next,[panel],is_leaf=1,expanded=1)
|
|
|
|
self.tree.node_set_row_data(next,next_panel)
|
|
|
|
next_panel = next_panel + 1
|
|
|
|
box = gtk.VBox()
|
|
|
|
box.show()
|
|
|
|
col = 0
|
|
|
|
panel_label = gtk.Label("")
|
|
|
|
panel_label.show()
|
|
|
|
self.panel.append_page(box,panel_label)
|
|
|
|
for frame in self.c[c][panel].keys():
|
|
|
|
pairs = self.c[c][panel][frame]
|
|
|
|
fr = gtk.Frame(frame)
|
|
|
|
fr.show()
|
|
|
|
box.pack_start(fr,gtk.FALSE,gtk.FALSE)
|
|
|
|
table = gtk.Table(len(pairs),2)
|
|
|
|
table.show()
|
|
|
|
fr.add(table)
|
|
|
|
for wobj in pairs:
|
|
|
|
w = wobj.get_widgets()
|
|
|
|
if len(w) == 2:
|
|
|
|
table.attach(w[0],0,1,col,col+1,
|
|
|
|
gtk.FILL,gtk.SHRINK,5,5)
|
|
|
|
table.attach(w[1],1,2,col,col+1,
|
|
|
|
gtk.FILL|gtk.EXPAND,gtk.SHRINK,5,5)
|
|
|
|
else:
|
|
|
|
table.attach(w[0],0,2,col,col+1,
|
|
|
|
gtk.FILL|gtk.EXPAND,gtk.SHRINK,5,5)
|
|
|
|
col = col + 1
|
|
|
|
|
|
|
|
def select(self,obj):
|
2004-08-20 17:41:56 +05:30
|
|
|
store,node = self.selection.get_selected()
|
|
|
|
if node:
|
|
|
|
path = store.get_path(node)
|
|
|
|
if node and self.imap.has_key(path):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.panel.set_current_page(self.imap[path])
|
|
|
|
|
|
|
|
def on_propertybox_help(self,obj):
|
2003-12-02 09:57:23 +05:30
|
|
|
gnome.help_display('gramps-manual','gramps-prefs')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def on_close_clicked(self,obj):
|
2003-12-18 05:15:43 +05:30
|
|
|
self.save_data()
|
2002-10-20 19:55:16 +05:30
|
|
|
Utils.destroy_passed_object(self.window)
|
|
|
|
|
|
|
|
def on_propertybox_apply(self,obj):
|
2003-12-18 05:15:43 +05:30
|
|
|
self.save_data()
|
|
|
|
|
|
|
|
def save_data(self):
|
2002-10-20 19:55:16 +05:30
|
|
|
for o in self.ext_list:
|
|
|
|
o.set()
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Create the property box, and set the elements off the current values
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def display_preferences_box(db):
|
|
|
|
GrampsPreferences(db)
|