* src/GrampsCfg.py: Remove unused code.

* src/TipOfDay.py (TipParser.escape): Add method.


svn: r3610
This commit is contained in:
Alex Roitman 2004-10-08 17:59:34 +00:00
parent acc5370e28
commit 13d5991528
3 changed files with 78 additions and 208 deletions

View File

@ -1,6 +1,9 @@
2004-10-08 Alex Roitman <shura@alex.neuro.umn.edu>
* src/GrampsCfg.py (build): Typo.
* src/GrampsCfg.py: Remove unused code.
* src/TipOfDay.py (TipParser.escape): Add method.
2004-10-07 Don Allingham <dallingham@users.sourceforge.net>
* src/AddMedia.py: pychecker fixes
* src/DbPrompter.py: pychecker fixes

View File

@ -37,7 +37,6 @@ import gobject
import gtk
import gtk.glade
import gnome
import gnome.ui
#-------------------------------------------------------------------------
#
@ -164,122 +163,6 @@ def get_researcher():
owner.set(n,a,c,s,ct,p,ph,e)
return owner
ext_items = []
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class ConfigWidget:
def __init__(self,panel,key,label,default):
self.p = panel
self.k = key
self.l = label
self.w = None
self.d = default
self.tag = "/apps/gramps/%s/%s" % (panel,key)
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):
val = unicode(self.w.get_text())
GrampsGconfKeys.client.set_string(self.tag,val)
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()
GrampsGconfKeys.client.set_int(self.tag,val)
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()
GrampsGconfKeys.client.set_bool(self.tag,val)
class ConfigFile(ConfigWidget):
def get_widgets(self):
self.w = gnome.ui.FileEntry(self.tag)
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)
GrampsGconfKeys.client.set_string(self.tag,val)
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)))
#-------------------------------------------------------------------------
#
#
@ -311,7 +194,6 @@ class GrampsPreferences:
self.imap = {}
self.build_tree()
self.build()
self.build_ext()
self.built = 1
self.window.show()
@ -334,11 +216,13 @@ class GrampsPreferences:
auto = self.top.get_widget("autoload")
auto.set_active(GrampsGconfKeys.get_autoload())
auto.connect('toggled',lambda obj: GrampsGconfKeys.save_autoload(obj.get_active()))
auto.connect('toggled',
lambda obj: GrampsGconfKeys.save_autoload(obj.get_active()))
lds = self.top.get_widget("uselds")
lds.set_active(GrampsGconfKeys.get_uselds())
lds.connect('toggled',lambda obj: GrampsGconfKeys.save_uselds(obj.get_active()))
lds.connect('toggled',
lambda obj: GrampsGconfKeys.save_uselds(obj.get_active()))
mr = self.top.get_widget("mediaref")
mc = self.top.get_widget("mediacopy")
@ -346,35 +230,44 @@ class GrampsPreferences:
mr.set_active(1)
else:
mc.set_active(1)
mr.connect('toggled',lambda obj: GrampsGconfKeys.save_media_reference(obj.get_active()))
mr.connect('toggled',
lambda obj: GrampsGconfKeys.save_media_reference(obj.get_active()))
dg = self.top.get_widget("globalprop")
dg.set_active(GrampsGconfKeys.get_media_global())
dg.connect('toggled',lambda obj: GrampsGconfKeys.save_media_global(obj.get_active()))
dg.connect('toggled',
lambda obj: GrampsGconfKeys.save_media_global(obj.get_active()))
dl = self.top.get_widget("localprop")
dl.set_active(GrampsGconfKeys.get_media_local())
dl.connect('toggled',lambda obj: GrampsGconfKeys.save_media_local(obj.get_active()))
dl.connect('toggled',
lambda obj: GrampsGconfKeys.save_media_local(obj.get_active()))
index_vis = self.top.get_widget("show_child_id")
index_vis.set_active(GrampsGconfKeys.get_index_visible())
index_vis.connect('toggled',lambda obj: GrampsGconfKeys.save_index_visible(obj.get_active()))
index_vis.connect('toggled',
lambda obj: GrampsGconfKeys.save_index_visible(obj.get_active()))
ipr = self.top.get_widget("iprefix")
ipr.set_text(GrampsGconfKeys.get_person_id_prefix())
ipr.connect('changed',lambda obj: GrampsGconfKeys.save_iprefix(obj.get_text()))
ipr.connect('changed',
lambda obj: GrampsGconfKeys.save_iprefix(obj.get_text()))
opr = self.top.get_widget("oprefix")
opr.set_text(GrampsGconfKeys.get_object_id_prefix())
opr.connect('changed',lambda obj: GrampsGconfKeys.save_oprefix(obj.get_text()))
opr.connect('changed',
lambda obj: GrampsGconfKeys.save_oprefix(obj.get_text()))
fpr = self.top.get_widget("fprefix")
fpr.set_text(GrampsGconfKeys.get_family_id_prefix())
fpr.connect('changed',lambda obj: GrampsGconfKeys.save_fprefix(obj.get_text()))
fpr.connect('changed',
lambda obj: GrampsGconfKeys.save_fprefix(obj.get_text()))
spr = self.top.get_widget("sprefix")
spr.set_text(GrampsGconfKeys.get_source_id_prefix())
spr.connect('changed',lambda obj: GrampsGconfKeys.save_sprefix(obj.get_text()))
spr.connect('changed',
lambda obj: GrampsGconfKeys.save_sprefix(obj.get_text()))
ppr = self.top.get_widget("pprefix")
ppr.set_text(GrampsGconfKeys.get_place_id_prefix())
ppr.connect('changed',lambda obj: GrampsGconfKeys.save_pprefix(obj.get_text()))
ppr.connect('changed',
lambda obj: GrampsGconfKeys.save_pprefix(obj.get_text()))
sb2 = self.top.get_widget("stat2")
sb3 = self.top.get_widget("stat3")
@ -387,7 +280,8 @@ class GrampsPreferences:
toolbarmenu = self.top.get_widget("tooloptmenu")
toolbarmenu.set_history(GrampsGconfKeys.get_toolbar())
toolbarmenu.connect('changed',lambda obj: GrampsGconfKeys.save_toolbar(obj.get_history()))
toolbarmenu.connect('changed',
lambda obj: GrampsGconfKeys.save_toolbar(obj.get_history()))
pvbutton = self.top.get_widget('pvbutton')
fvbutton = self.top.get_widget('fvbutton')
@ -395,7 +289,8 @@ class GrampsPreferences:
pvbutton.set_active(1)
else:
fvbutton.set_active(1)
fvbutton.connect('toggled',lambda obj: GrampsGconfKeys.save_default_view(obj.get_active()))
fvbutton.connect('toggled',
lambda obj: GrampsGconfKeys.save_default_view(obj.get_active()))
familyview1 = self.top.get_widget('familyview1')
familyview2 = self.top.get_widget('familyview2')
@ -403,11 +298,13 @@ class GrampsPreferences:
familyview1.set_active(1)
else:
familyview2.set_active(1)
familyview2.connect('toggled',lambda obj: GrampsGconfKeys.save_family_view(obj.get_active()))
familyview2.connect('toggled',
lambda obj: GrampsGconfKeys.save_family_view(obj.get_active()))
usetips = self.top.get_widget('usetips')
usetips.set_active(GrampsGconfKeys.get_usetips())
usetips.connect('toggled',lambda obj: GrampsGconfKeys.save_usetips(obj.get_active()))
usetips.connect('toggled',
lambda obj: GrampsGconfKeys.save_usetips(obj.get_active()))
paper_obj = self.top.get_widget("paper_size")
menu = gtk.Menu()
@ -423,7 +320,9 @@ class GrampsPreferences:
menu.set_active(choice)
paper_obj.set_menu(menu)
paper_obj.connect("changed",
lambda obj: GrampsGconfKeys.save_paper_preference(obj.get_menu().get_active().get_data(DATA)))
lambda obj:
GrampsGconfKeys.save_paper_preference(obj.get_menu().get_active().get_data(DATA))
)
lastnamegen_obj = self.top.get_widget("lastnamegen")
menu = gtk.Menu()
@ -437,7 +336,9 @@ class GrampsPreferences:
menu.set_active(GrampsGconfKeys.get_lastnamegen(_surname_styles))
lastnamegen_obj.set_menu(menu)
lastnamegen_obj.connect("changed",
lambda obj: GrampsGconfKeys.save_lastnamegen(obj.get_menu().get_active().get_data(DATA)),_surname_styles)
lambda obj:
GrampsGconfKeys.save_lastnamegen(obj.get_menu().get_active().get_data(DATA),_surname_styles)
)
self.osubmenu = gtk.Menu()
choice = 0
@ -469,7 +370,9 @@ class GrampsPreferences:
self.gsubmenu.set_active(choice)
self.gfmt.set_menu(self.gsubmenu)
self.gfmt.connect("changed",
lambda obj: GrampsGconfKeys.save_goutput_preference(obj.get_menu().get_active().get_data(DATA)))
lambda obj:
GrampsGconfKeys.save_goutput_preference(obj.get_menu().get_active().get_data(DATA))
)
date_option = self.top.get_widget("date_format")
date_menu = gtk.Menu()
@ -480,7 +383,7 @@ class GrampsPreferences:
item.show()
date_menu.append(item)
try:
# Technically, a selected format might me out of range
# Technically, a selected format might be out of range
# for this locale's format list.
date_menu.set_active(GrampsGconfKeys.get_date_format(dlist))
except:
@ -488,7 +391,9 @@ class GrampsPreferences:
date_option.set_menu(date_menu)
date_option.connect("changed",
lambda obj: GrampsGconfKeys.save_date_format(obj.get_menu().get_active().get_data(INDEX),dlist))
lambda obj:
GrampsGconfKeys.save_date_format(obj.get_menu().get_active().get_data(INDEX),dlist)
)
name_option = self.top.get_widget("name_format")
name_menu = gtk.Menu()
@ -501,89 +406,51 @@ class GrampsPreferences:
name_menu.set_active(GrampsGconfKeys.get_name_format(_name_format_list))
name_option.set_menu(name_menu)
name_option.connect("changed",
lambda obj: GrampsGconfKeys.save_name_format(obj.get_menu().get_active().get_data(INDEX),_name_format_list))
lambda obj:
GrampsGconfKeys.save_name_format(obj.get_menu().get_active().get_data(INDEX),_name_format_list)
)
resname = self.top.get_widget("resname")
resname.set_text(GrampsGconfKeys.get_researcher_name())
resname.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_name(obj.get_text()))
resname.connect('changed',
lambda obj: GrampsGconfKeys.save_researcher_name(obj.get_text()))
resaddr = self.top.get_widget("resaddr")
resaddr.set_text(GrampsGconfKeys.get_researcher_addr())
resaddr.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_addr(obj.get_text()))
resaddr.connect('changed',
lambda obj: GrampsGconfKeys.save_researcher_addr(obj.get_text()))
rescity = self.top.get_widget("rescity")
rescity.set_text(GrampsGconfKeys.get_researcher_city())
rescity.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_city(obj.get_text()))
rescity.connect('changed',
lambda obj: GrampsGconfKeys.save_researcher_city(obj.get_text()))
resstate = self.top.get_widget("resstate")
resstate.set_text(GrampsGconfKeys.get_researcher_state())
resstate.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_state(obj.get_text()))
resstate.connect('changed',
lambda obj: GrampsGconfKeys.save_researcher_state(obj.get_text()))
rescountry = self.top.get_widget("rescountry")
rescountry.set_text(GrampsGconfKeys.get_researcher_country())
rescountry.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_country(obj.get_text()))
rescountry.connect('changed',
lambda obj: GrampsGconfKeys.save_researcher_country(obj.get_text()))
respostal = self.top.get_widget("respostal")
respostal.set_text(GrampsGconfKeys.get_researcher_postal())
respostal.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_postal(obj.get_text()))
respostal.connect('changed',
lambda obj: GrampsGconfKeys.save_researcher_postal(obj.get_text()))
resphone = self.top.get_widget("resphone")
resphone.set_text(GrampsGconfKeys.get_researcher_phone())
resphone.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_phone(obj.get_text()))
resphone.connect('changed',
lambda obj: GrampsGconfKeys.save_researcher_phone(obj.get_text()))
resemail = self.top.get_widget("resemail")
resemail.set_text(GrampsGconfKeys.get_researcher_email())
resemail.connect('changed',lambda obj: GrampsGconfKeys.save_researcher_email(obj.get_text()))
resemail.connect('changed',
lambda obj: GrampsGconfKeys.save_researcher_email(obj.get_text()))
repdir = self.top.get_widget("repdir").gtk_entry()
repdir.set_text(GrampsGconfKeys.get_report_dir())
repdir.connect('changed',lambda obj: GrampsGconfKeys.save_report_dir(obj.get_text()))
repdir.connect('changed',
lambda obj: GrampsGconfKeys.save_report_dir(obj.get_text()))
webdir = self.top.get_widget("htmldir").gtk_entry()
webdir.set_text(GrampsGconfKeys.get_web_dir())
webdir.connect('changed',lambda obj: GrampsGconfKeys.save_web_dir(obj.get_text()))
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
webdir.connect('changed',
lambda obj: GrampsGconfKeys.save_web_dir(obj.get_text()))
def select(self,obj):
store,node = self.selection.get_selected()
@ -596,16 +463,8 @@ class GrampsPreferences:
gnome.help_display('gramps-manual','gramps-prefs')
def on_close_clicked(self,obj):
self.save_data()
Utils.destroy_passed_object(self.window)
def on_propertybox_apply(self,obj):
self.save_data()
def save_data(self):
for o in self.ext_list:
o.set()
#-------------------------------------------------------------------------
#
# Create the property box, and set the elements off the current values

View File

@ -125,7 +125,7 @@ class TipParser:
def endElement(self,tag):
if tag == "tip":
text = ''.join(self.tlist)
text = self.escape(''.join(self.tlist))
self.mylist.append(' '.join(text.split()))
elif tag != "tips":
# let all the other tags through, except for the "tips" tag
@ -133,3 +133,11 @@ class TipParser:
def characters(self, data):
self.tlist.append(data)
def escape(self,text):
"""
The tip's text will be interpreted as a markup, so we need to escape
some special chars.
"""
text = text.replace('&','&amp;'); # Must be first
return text