ListModel improvements, GenericFilter moved to GNOME 2

svn: r1188
This commit is contained in:
Don Allingham 2002-11-14 05:31:42 +00:00
parent 0869dbaa92
commit 70256ded9c
5 changed files with 1097 additions and 1197 deletions

View File

@ -608,6 +608,9 @@ class GenericFilter:
def get_rules(self):
return self.flist
def delete_rule(self,r):
self.flist.remove(r)
def check_or(self,p):
test = 0
for rule in self.flist:

View File

@ -36,8 +36,8 @@ import Plugins
#
#-------------------------------------------------------------------------
import gobject
import gtk
import gconf
import gtk
import gtk.glade
#-------------------------------------------------------------------------
@ -126,11 +126,8 @@ autocomp = 1
usevc = 0
vc_comment = 0
uncompress = 0
hide_altnames = 0
lastfile = None
nameof = Utils.normal_name
display_attr = 0
attr_name = ""
status_bar = 0
toolbar = 2
calendar = 0
@ -160,11 +157,6 @@ _callback = None
# Constants
#
#-------------------------------------------------------------------------
ODDFGCOLOR = "oddfg"
ODDBGCOLOR = "oddbg"
EVENFGCOLOR = "evenfg"
EVENBGCOLOR = "evenbg"
ANCESTORFGCOLOR = "ancestorfg"
INDEX = "i"
OBJECT = "o"
DATA = "d"
@ -192,16 +184,17 @@ def loadConfig(call):
global autocomp
global calendar
global usevc
global iprefix, fprefix, pprefix, oprefix, sprefix
global iprefix
global fprefix
global pprefix
global oprefix
global sprefix
global vc_comment
global uncompress
global id_edit
global index_visible
global hide_altnames
global lastfile
global nameof
global display_attr
global attr_name
global _name_format
global _callback
global paper_preference
@ -218,43 +211,40 @@ def loadConfig(call):
global localprop
_callback = call
lastfile = get_string("/gramps/data/LastFile")
uselds = get_bool("/gramps/config/UseLDS")
ac = get_bool("/gramps/config/DisableAutoComplete",0)
mediaref = get_bool("/gramps/config/MakeReference",1)
globalprop = get_bool("/gramps/config/DisplayGlobal",1)
localprop = get_bool("/gramps/config/DisplayLocal",1)
calendar = get_bool("/gramps/config/ShowCalendar")
usevc = get_bool("/gramps/config/UseVersionControl")
vc_comment = get_bool("/gramps/config/UseComment")
uncompress = get_bool("/gramps/config/DontCompressXML")
id_edit = get_bool("/gramps/config/IdEdit")
index_visible = get_bool("/gramps/config/IndexVisible")
status_bar = get_int("/gramps/config/StatusBar")
toolbar = get_int("/gramps/config/ToolBar",2)
display_attr = get_bool("/gramps/config/DisplayAttr")
attr_name = get_string("/gramps/config/DisplayAttrName")
lastfile = get_string("/apps/gramps/last-file")
uselds = get_bool("/apps/gramps/use-lds")
ac = get_bool("/apps/gramps/disable-auto-complete",0)
mediaref = get_bool("/apps/gramps/make-reference",1)
globalprop = get_bool("/apps/gramps/media-global",1)
localprop = get_bool("/apps/gramps/media-local",1)
calendar = get_bool("/apps/gramps/show-calendar")
usevc = get_bool("/apps/gramps/version-control")
vc_comment = get_bool("/apps/gramps/use-comment")
uncompress = get_bool("/apps/gramps/dont-compress-xml")
id_edit = get_bool("/apps/gramps/id-edit")
index_visible = get_bool("/apps/gramps/index-visible")
status_bar = get_int("/apps/gramps/statusbar")
toolbar = get_int("/apps/gramps/toolbar",2)
hide_altnames = get_bool("/gramps/config/DisplayAltNames")
autoload = get_bool("/gramps/config/autoLoad",0)
autosave_int = get_int("/gramps/config/autoSaveInterval")
dateFormat = get_int("/gramps/config/dateFormat")
dateEntry = get_int("/gramps/config/dateEntry")
paper_preference = get_string("/gramps/config/paperPreference")
output_preference = get_string("/gramps/config/outputPreference")
goutput_preference = get_string("/gramps/config/goutputPreference")
lastnamegen = get_int("/gramps/config/surnameGuessing")
_name_format = get_int("/gramps/config/nameFormat")
autoload = get_bool("/apps/gramps/autoload",0)
autosave_int = get_int("/apps/gramps/auto-save-interval")
dateFormat = get_int("/apps/gramps/date-format")
dateEntry = get_int("/apps/gramps/date-entry")
paper_preference = get_string("/apps/gramps/paper-preference")
output_preference = get_string("/apps/gramps/output-preference")
goutput_preference = get_string("/apps/gramps/goutput-preference")
lastnamegen = get_int("/apps/gramps/surname-guessing")
_name_format = get_int("/apps/gramps/nameFormat")
iprefix = get_string("/gramps/config/iprefix")
fprefix = get_string("/gramps/config/fprefix")
sprefix = get_string("/gramps/config/sprefix")
oprefix = get_string("/gramps/config/oprefix")
pprefix = get_string("/gramps/config/pprefix")
iprefix = get_string("/apps/gramps/iprefix")
fprefix = get_string("/apps/gramps/fprefix")
sprefix = get_string("/apps/gramps/sprefix")
oprefix = get_string("/apps/gramps/oprefix")
pprefix = get_string("/apps/gramps/pprefix")
report_dir = get_string("/gramps/config/ReportDirectory")
web_dir = get_string("/gramps/config/WebsiteDirectory")
db_dir = get_string("/gramps/config/DbDirectory")
report_dir = get_string("/apps/gramps/report-directory")
web_dir = get_string("/apps/gramps/website-directory")
db_dir = get_string("/apps/gramps/db-directory")
if report_dir == None:
report_dir = "./"
@ -271,10 +261,6 @@ def loadConfig(call):
else:
db_dir = os.path.normpath(db_dir) + os.sep
en = get_bool("/gramps/color/enableColors")
if en == None:
en = 0
if paper_preference == None:
paper_preference = "Letter"
@ -295,12 +281,6 @@ def loadConfig(call):
if oprefix == None:
oprefix = "O"
if display_attr == None:
display_attr = 0
if attr_name == None:
attr_name = ""
autocomp = not ac
set_format_code(dateFormat)
@ -355,7 +335,7 @@ def sync():
#
#-------------------------------------------------------------------------
def save_last_file(file):
set_string("/gramps/data/LastFile",file)
set_string("/apps/gramps/last-file",file)
sync()
#-------------------------------------------------------------------------
@ -364,29 +344,19 @@ def save_last_file(file):
#
#-------------------------------------------------------------------------
def get_researcher():
n = get_string("/gramps/researcher/name")
a = get_string("/gramps/researcher/addr")
c = get_string("/gramps/researcher/city")
s = get_string("/gramps/researcher/state")
ct = get_string("/gramps/researcher/country")
p = get_string("/gramps/researcher/postal")
ph = get_string("/gramps/researcher/phone")
e = get_string("/gramps/researcher/email")
n = get_string("/apps/gramps/researcher-name")
a = get_string("/apps/gramps/researcher-addr")
c = get_string("/apps/gramps/researcher-city")
s = get_string("/apps/gramps/researcher-state")
ct = get_string("/apps/gramps/researcher-country")
p = get_string("/apps/gramps/researcher-postal")
ph = get_string("/apps/gramps/researcher-phone")
e = get_string("/apps/gramps/researcher-email")
owner = Researcher()
owner.set(n,a,c,s,ct,p,ph,e)
return owner
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def save_config_color(name,color):
set_int("/gramps/color/" + name + ".r",color[0])
set_int("/gramps/color/" + name + ".g",color[1])
set_int("/gramps/color/" + name + ".b",color[2])
#-------------------------------------------------------------------------
#
#
@ -394,17 +364,17 @@ def save_config_color(name,color):
#-------------------------------------------------------------------------
def get_config_text(panel,key):
val = get_string("/gramps/%s/%s" % (panel,key))
val = get_string("/apps/gramps/%s/%s" % (panel,key))
if val:
return val
else:
return ""
def get_config_bool(panel,key):
return get_bool("/gramps/%s/%s" % (panel,key))
return get_bool("/apps/gramps/%s/%s" % (panel,key))
def get_config_int(panel,key):
return get_int("/gramps/%s/%s" % (panel,key))
return get_int("/apps/gramps/%s/%s" % (panel,key))
ext_items = []
@ -415,7 +385,7 @@ class ConfigWidget:
self.l = label
self.w = None
self.d = default
self.tag = "/gramps/%s/%s" % (panel,key)
self.tag = "/apps/gramps/%s/%s" % (panel,key)
def set(self):
pass
@ -531,8 +501,6 @@ class GrampsPreferences:
"on_ok_clicked" : self.on_ok_clicked,
"on_apply_clicked" : self.on_propertybox_apply,
"on_help_clicked" : self.on_propertybox_help,
"on_color_toggled" : self.on_color_toggled,
"on_color_set" : self.on_color_set,
"on_object_toggled" : self.on_object_toggled,
"on_tree_select_row" : self.select
})
@ -587,8 +555,6 @@ class GrampsPreferences:
vcom = self.top.get_widget("vc_comment")
compress = self.top.get_widget("uncompress")
detail = self.top.get_widget("showdetail")
display_attr_obj = self.top.get_widget("attr_display")
display_altnames = self.top.get_widget("display_altnames")
auto.set_active(autoload)
asave_int.set_value(int(autosave_int))
@ -627,11 +593,6 @@ class GrampsPreferences:
else:
self.top.get_widget("tool3").set_active(1)
display_attr_obj.set_active(display_attr)
self.top.get_widget("attr_name").set_text(attr_name)
display_altnames.set_active(hide_altnames)
paper_obj = self.top.get_widget("paper_size")
menu = gtk.Menu()
choice = 0
@ -724,14 +685,14 @@ class GrampsPreferences:
name_menu.set_active(_name_format)
name_option.set_menu(name_menu)
cname = get_string("/gramps/researcher/name")
caddr = get_string("/gramps/researcher/addr")
ccity = get_string("/gramps/researcher/city")
cstate = get_string("/gramps/researcher/state")
ccountry = get_string("/gramps/researcher/country")
cpostal = get_string("/gramps/researcher/postal")
cphone = get_string("/gramps/researcher/phone")
cemail = get_string("/gramps/researcher/email")
cname = get_string("/apps/gramps/researcher-name")
caddr = get_string("/apps/gramps/researcher-addr")
ccity = get_string("/apps/gramps/researcher-city")
cstate = get_string("/apps/gramps/researcher-state")
ccountry = get_string("/apps/gramps/researcher-country")
cpostal = get_string("/apps/gramps/researcher-postal")
cphone = get_string("/apps/gramps/researcher-phone")
cemail = get_string("/apps/gramps/researcher-email")
self.top.get_widget("resname").set_text(cname)
self.top.get_widget("resaddr").set_text(caddr)
@ -834,9 +795,6 @@ class GrampsPreferences:
global index_visible
global status_bar
global toolbar
global display_attr
global attr_name
global hide_altnames
global paper_preference
global output_preference
global goutput_preference
@ -848,8 +806,6 @@ class GrampsPreferences:
autoload = self.top.get_widget("autoload").get_active()
autosave_int = self.top.get_widget("autosave_interval").get_value_as_int()
display_attr = self.top.get_widget("attr_display").get_active()
attr_name = string.strip(self.top.get_widget("attr_name").get_text())
uselds = self.top.get_widget("uselds").get_active()
autocomp = self.top.get_widget("autocomp").get_active()
mediaref = self.top.get_widget("mediaref").get_active()
@ -861,7 +817,6 @@ class GrampsPreferences:
uncompress = self.top.get_widget("uncompress").get_active()
id_edit = self.top.get_widget("gid_edit").get_active()
index_visible = self.top.get_widget("show_child_id").get_active()
hide_altnames = self.top.get_widget("display_altnames").get_active()
paper_obj = self.top.get_widget("paper_size").get_menu().get_active()
output_obj = self.osubmenu.get_active()
@ -913,54 +868,51 @@ class GrampsPreferences:
output_preference = output_obj.get_data(DATA)
goutput_preference = goutput_obj.get_data(DATA)
set_bool("/gramps/config/UseLDS",uselds)
set_bool("/gramps/config/DisableAutoComplete",not autocomp)
set_bool("/gramps/config/MakeReference",mediaref)
set_bool("/gramps/config/DisplayGlobal",globalprop)
set_bool("/gramps/config/DisplayLocal",localprop)
set_bool("/gramps/config/ShowCalendar",calendar)
set_bool("/gramps/config/UseVersionControl",usevc)
set_bool("/gramps/config/UseComment",vc_comment)
set_bool("/gramps/config/DontCompressXML",uncompress)
set_bool("/gramps/config/IdEdit",id_edit)
set_bool("/gramps/config/IndexVisible",index_visible)
set_int("/gramps/config/StatusBar",status_bar)
set_int("/gramps/config/ToolBar",toolbar+1)
set_bool("/gramps/config/DisplayAttr",display_attr)
set_string("/gramps/config/DisplayAttrName",attr_name)
set_string("/gramps/config/paperPreference",paper_preference)
set_string("/gramps/config/outputPreference",output_preference)
set_string("/gramps/config/goutputPreference",goutput_preference)
set_bool("/gramps/config/autoLoad",autoload)
set_int("/gramps/config/autoSaveInterval",autosave_int)
set_bool("/apps/gramps/use-lds",uselds)
set_bool("/apps/gramps/disable-auto-complete",not autocomp)
set_bool("/apps/gramps/make-reference",mediaref)
set_bool("/apps/gramps/media-global",globalprop)
set_bool("/apps/gramps/media-local",localprop)
set_bool("/apps/gramps/show-calendar",calendar)
set_bool("/apps/gramps/version-control",usevc)
set_bool("/apps/gramps/use-comment",vc_comment)
set_bool("/apps/gramps/dont-compress-xml",uncompress)
set_bool("/apps/gramps/id-edit",id_edit)
set_bool("/apps/gramps/index-visible",index_visible)
set_int("/apps/gramps/statusbar",status_bar)
set_int("/apps/gramps/toolbar",toolbar+1)
set_string("/apps/gramps/paper-preference",paper_preference)
set_string("/apps/gramps/output-preference",output_preference)
set_string("/apps/gramps/goutput-preference",goutput_preference)
set_bool("/apps/gramps/autoload",autoload)
set_int("/apps/gramps/auto-save-interval",autosave_int)
if autosave_int != 0:
Utils.enable_autosave(None,autosave_int)
else:
Utils.disable_autosave()
set_bool("/gramps/config/DisplayAltNames",hide_altnames)
set_string("/gramps/config/ReportDirectory",report_dir)
set_string("/gramps/config/WebsiteDirectory",web_dir)
set_string("/gramps/config/DbDirectory",db_dir)
set_string("/gramps/config/iprefix",iprefix)
set_string("/gramps/config/fprefix",fprefix)
set_string("/gramps/config/pprefix",pprefix)
set_string("/gramps/config/oprefix",oprefix)
set_string("/gramps/config/sprefix",sprefix)
set_string("/apps/gramps/report-directory",report_dir)
set_string("/apps/gramps/website-directory",web_dir)
set_string("/apps/gramps/db-directory",db_dir)
set_string("/apps/gramps/iprefix",iprefix)
set_string("/apps/gramps/fprefix",fprefix)
set_string("/apps/gramps/pprefix",pprefix)
set_string("/apps/gramps/oprefix",oprefix)
set_string("/apps/gramps/sprefix",sprefix)
# search for the active date format selection
format_menu = self.top.get_widget("date_format").get_menu()
active = format_menu.get_active().get_data(INDEX)
set_format_code(active)
set_int("/gramps/config/dateFormat",active)
set_int("/apps/gramps/date-format",active)
format_menu = self.top.get_widget("date_entry_format").get_menu()
entry_active = format_menu.get_active().get_data(INDEX)
Date.entryCode = entry_active
set_int("/gramps/config/dateEntry",entry_active)
set_int("/apps/gramps/date-entry",entry_active)
# get the name format
@ -969,11 +921,11 @@ class GrampsPreferences:
name_tuple = _name_format_list[active_name]
nameof = name_tuple[1]
set_int("/gramps/config/nameFormat",active_name)
set_int("/apps/gramps/nameFormat",active_name)
format_menu = self.top.get_widget("lastnamegen").get_menu()
lastnamegen = format_menu.get_active().get_data(DATA)
set_int("/gramps/config/surnameGuessing",lastnamegen)
set_int("/apps/gramps/surname-guessing",lastnamegen)
name = self.top.get_widget("resname").get_text()
addr = self.top.get_widget("resaddr").get_text()
@ -984,14 +936,14 @@ class GrampsPreferences:
phone = self.top.get_widget("resphone").get_text()
email = self.top.get_widget("resemail").get_text()
set_string("/gramps/researcher/name",name)
set_string("/gramps/researcher/addr",addr)
set_string("/gramps/researcher/city",city)
set_string("/gramps/researcher/state",state)
set_string("/gramps/researcher/country",country)
set_string("/gramps/researcher/postal",postal)
set_string("/gramps/researcher/phone",phone)
set_string("/gramps/researcher/email",email)
set_string("/apps/gramps/researcher-name",name)
set_string("/apps/gramps/researcher-addr",addr)
set_string("/apps/gramps/researcher-city",city)
set_string("/apps/gramps/researcher-state",state)
set_string("/apps/gramps/researcher-country",country)
set_string("/apps/gramps/researcher-postal",postal)
set_string("/apps/gramps/researcher-phone",phone)
set_string("/apps/gramps/researcher-email",email)
self.db.set_iprefix(iprefix)
self.db.set_fprefix(fprefix)
@ -1017,22 +969,6 @@ class GrampsPreferences:
so that the property box knows to set the Apply button"""
self.apply.set_sensitive(1)
def on_color_toggled(self,obj):
"""Called by the elements on the property box to set the changed flag,
so that the property box knows to set the Apply button"""
active = self.top.get_widget("enableColors").get_active()
self.top.get_widget(ODDFGCOLOR).set_sensitive(active)
self.top.get_widget(ODDBGCOLOR).set_sensitive(active)
self.top.get_widget(EVENFGCOLOR).set_sensitive(active)
self.top.get_widget(EVENBGCOLOR).set_sensitive(active)
self.top.get_widget(ANCESTORFGCOLOR).set_sensitive(active)
self.apply.set_sensitive(1)
def on_color_set(self,obj,r,g,b,a):
"""Called by the elements on the property box to set the changed flag,
so that the property box knows to set the Apply button"""
self.apply.set_sensitive(1)
#-------------------------------------------------------------------------
#
# Create the property box, and set the elements off the current values
@ -1041,43 +977,15 @@ class GrampsPreferences:
def display_preferences_box(db):
GrampsPreferences(db)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def get_config_color(name,defval):
r = get_int("/gramps/color/" + name + ".r")
g = get_int("/gramps/color/" + name + ".g")
b = get_int("/gramps/color/" + name + ".b")
if r == None:
return defval
else:
return (r,g,b)
def get_sort_cols(name,col,dir):
c = get_int("/gramps/sort/%s_col" % name)
if c == None:
c = col
d = get_int("/gramps/sort/%s_dir" % name)
if d == None:
d = dir
return (c,d)
def save_sort_cols(name,col,dir):
set_int("/gramps/sort/%s_col" % name, col)
set_int("/gramps/sort/%s_dir" % name, dir)
sync()
def save_view(val):
set_bool("/gramps/config/view",val)
set_bool("/apps/gramps/view",val)
def get_view():
return get_bool("/gramps/config/view",1)
return get_bool("/apps/gramps/view",1)
def save_filter(val):
set_bool("/gramps/config/filter",val)
set_bool("/apps/gramps/filter",val)
def get_filter():
return get_bool("/gramps/config/filter")
return get_bool("/apps/gramps/filter")

View File

@ -18,18 +18,21 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
from gobject import TYPE_STRING
from gobject import TYPE_STRING, TYPE_PYOBJECT
import gtk
class ListModel:
def __init__(self,tree,dlist,select_func=None,event_func=None):
self.tree = tree
l = len(dlist)
self.model = gtk.ListStore(*[TYPE_STRING]*l)
mylist = [TYPE_STRING]*l + [TYPE_PYOBJECT]
self.model = gtk.ListStore(*mylist)
self.selection = self.tree.get_selection()
self.tree.set_model(self.model)
self.data_index = l
cnum = 0
for name in dlist:
renderer = gtk.CellRendererText()
@ -46,6 +49,7 @@ class ListModel:
num = 0
for name in dlist:
column = tree.get_column(num)
if name[1] != -1:
column.set_sort_column_id(name[1])
if num == 0:
column.clicked()
@ -54,15 +58,27 @@ class ListModel:
if select_func:
self.selection.connect('changed',select_func)
if event_func:
self.tree.connect('event',event_func)
self.double_click = event_func
self.tree.connect('event',self.button_press)
def get_selected(self):
return self.selection.get_selected()
def clear(self):
self.model.clear()
def add(self,data):
def get_object(self,iter):
return self.model.get_value(iter,self.data_index)
def add(self,data,info=None):
iter = self.model.append()
col = 0
for object in data:
self.model.set_value(iter,col,object)
col = col + 1
self.model.set_value(iter,col,info)
def button_press(self,obj,event):
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
self.double_click(obj)
return 1

View File

@ -32,8 +32,8 @@ import const
from RelLib import *
import GenericFilter
import AutoComp
import intl
_ = intl.gettext
import ListModel
from intl import gettext as _
_name2list = {
_('Personal Event') : const.personalEvents,
@ -49,7 +49,7 @@ class FilterEditor:
self.filterdb = GenericFilter.GenericFilterList(filterdb)
self.filterdb.load()
self.editor = libglade.GladeXML(const.filterFile,'filter_list')
self.editor = gtk.glade.XML(const.filterFile,'filter_list')
self.editor_top = self.editor.get_widget('filter_list')
self.filter_list = self.editor.get_widget('filters')
self.edit = self.editor.get_widget('edit')
@ -59,24 +59,27 @@ class FilterEditor:
self.editor.signal_autoconnect({
'on_add_clicked' : self.add_new_filter,
'on_edit_clicked' : self.edit_filter,
'on_filters_select_row' : self.filter_select_row,
'on_filters_unselect_row' : self.filter_unselect_row,
'on_test_clicked' : self.test_clicked,
'on_close_clicked' : self.close_filter_editor,
'on_delete_clicked' : self.delete_filter,
})
self.clist = ListModel.ListModel(self.filter_list,
[(_('Filter'),0,150),(_('Comment'),1,150)],
self.filter_select_row,
self.edit_filter)
self.draw_filters()
def filter_select_row(self,obj,a,b,c):
def filter_select_row(self,obj):
store,iter = self.clist.get_selected()
if iter:
self.edit.set_sensitive(1)
self.delete.set_sensitive(1)
self.test.set_sensitive(1)
def filter_unselect_row(self,obj,a,b,c):
enable = (len(obj.selection) > 0)
self.edit.set_sensitive(enable)
self.delete.set_sensitive(enable)
self.test.set_sensitive(enable)
else:
self.edit.set_sensitive(0)
self.delete.set_sensitive(0)
self.test.set_sensitive(0)
def close_filter_editor(self,obj):
self.filterdb.save()
@ -85,48 +88,44 @@ class FilterEditor:
GenericFilter.reload_system_filters()
def draw_filters(self):
row = 0
self.filter_list.freeze()
self.filter_list.clear()
self.clist.clear()
for f in self.filterdb.get_filters():
self.filter_list.append([f.get_name(),f.get_comment()])
self.filter_list.set_row_data(row,f)
row = row + 1
self.filter_list.sort()
self.filter_list.thaw()
self.clist.add([f.get_name(),f.get_comment()],f)
def add_new_filter(self,obj):
filter = GenericFilter.GenericFilter()
self.filter_editor(filter)
def edit_filter(self,obj):
sel = self.filter_list.selection
if len(sel) != 1:
return
filter = self.filter_list.get_row_data(sel[0])
store,iter = self.clist.get_selected()
if iter:
filter = self.clist.get_object(iter)
self.filter_editor(GenericFilter.GenericFilter(filter))
def test_clicked(self,obj):
sel = self.filter_list.selection
if len(sel) != 1:
return
filt = self.filter_list.get_row_data(sel[0])
store,iter = self.clist.get_selected()
if iter:
filt = self.clist.get_object(iter)
list = filt.apply(self.db.getPersonMap().values())
ShowResults(list)
def delete_filter(self,obj):
sel = self.filter_list.selection
if len(sel) != 1:
return
filter = self.filter_list.get_row_data(sel[0])
store,iter = self.clist.get_selected()
if iter:
fil = self.clist.get_object(iter)
self.filterdb.get_filters().remove(filter)
self.draw_filters()
def filter_editor(self,filter):
self.filter = filter
self.glade = libglade.GladeXML(const.filterFile,'define_filter')
self.glade = gtk.glade.XML(const.filterFile,'define_filter')
self.top = self.glade.get_widget('define_filter')
self.rule_list = self.glade.get_widget('rule_list')
self.rlist = ListModel.ListModel(self.rule_list,
[(_('Name'),-1,150),(_('Value'),-1,150)],
self.select_row,
self.on_edit_clicked)
self.fname = self.glade.get_widget('filter_name')
self.log_not = self.glade.get_widget('logical_not')
self.log_and = self.glade.get_widget('logical_and')
@ -139,8 +138,6 @@ class FilterEditor:
self.glade.signal_autoconnect({
'on_ok_clicked' : self.on_ok_clicked,
'on_cancel_clicked' : self.on_cancel_clicked,
'on_rule_select_row' : self.select_row,
'on_rule_unselect_row' : self.unselect_row,
'on_filter_name_changed' : self.filter_name_changed,
'on_delete_clicked' : self.on_delete_clicked,
'on_add_clicked' : self.on_add_clicked,
@ -164,22 +161,19 @@ class FilterEditor:
name = self.fname.get_text()
self.ok.set_sensitive(len(name) != 0)
def select_row(self,obj,a,b,c):
def select_row(self,obj):
store,iter = self.clist.get_selected()
if iter:
self.edit_btn.set_sensitive(1)
self.del_btn.set_sensitive(1)
def unselect_row(self,obj,a,b,c):
enable = (len(obj.selection) == 1)
self.edit_btn.set_sensitive(enable)
self.del_btn.set_sensitive(enable)
else:
self.edit_btn.set_sensitive(0)
self.del_btn.set_sensitive(0)
def draw_rules(self):
self.rule_list.clear()
row = 0
self.rlist.clear()
for r in self.filter.get_rules():
self.rule_list.append([r.trans_name(),r.display_values()])
self.rule_list.set_row_data(row,r)
row = row + 1
self.rlist.add([r.trans_name(),r.display_values()],r)
def on_cancel_clicked(self,obj):
self.top.destroy()
@ -210,10 +204,9 @@ class FilterEditor:
self.edit_rule(None)
def on_edit_clicked(self,obj):
if len(self.rule_list.selection) != 1:
return
row = self.rule_list.selection[0]
d = self.rule_list.get_row_data(row)
store,iter = self.rlist.get_selected()
if iter:
d = self.rlist.get_object(iter)
self.edit_rule(d)
def edit_rule(self,val):
@ -224,7 +217,7 @@ class FilterEditor:
self.pmap[p.get_title()] = p
self.active_rule = val
self.rule = libglade.GladeXML(const.filterFile,'add_rule')
self.rule = gtk.glade.XML(const.filterFile,'add_rule')
self.rule_top = self.rule.get_widget('add_rule')
self.frame = self.rule.get_widget('values')
self.rname = self.rule.get_widget('rule_name')
@ -278,8 +271,8 @@ class FilterEditor:
t = gtk.Entry()
tlist.append(t)
t.show()
table.attach(l,0,1,pos,pos+1,gtk.gdk.FILL,0,5,5)
table.attach(t,1,2,pos,pos+1,gtk.gdk.EXPAND|gtk.gdk.FILL,0,5,5)
table.attach(l,0,1,pos,pos+1,gtk.FILL,0,5,5)
table.attach(t,1,2,pos,pos+1,gtk.EXPAND|gtk.FILL,0,5,5)
pos = pos + 1
self.notebook.append_page(table,gtk.Label(name))
self.name2page[name] = self.page_num
@ -294,7 +287,7 @@ class FilterEditor:
if self.active_rule:
page = self.name2page[self.active_rule.name()]
self.rname.entry.set_text(self.active_rule.name())
self.notebook.set_page(page)
self.notebook.set_current_page(page)
(n,c,v,t) = self.page[page]
r = self.active_rule.values()
for i in range(0,len(t)):
@ -305,16 +298,16 @@ class FilterEditor:
self.rule.get_widget('cancel').connect('clicked',self.rule_cancel)
def on_delete_clicked(self,obj):
if len(self.rule_list.selection) != 1:
return
row = self.rule_list.selection[0]
del self.filter.get_rules()[row]
store,iter = self.rlist.get_selected()
if iter:
filter = self.rlist.get_object(iter)
self.filter.delete_rule(filter)
self.draw_rules()
def rule_changed(self,obj):
name = obj.get_text()
page = self.name2page[name]
self.notebook.set_page(page)
self.notebook.set_current_page(page)
def rule_ok(self,obj):
name = self.rname.entry.get_text()
@ -324,10 +317,10 @@ class FilterEditor:
for x in t:
value_list.append(x.get_text())
new_rule = c(value_list)
if self.active_rule:
index = self.rule_list.selection[0]
self.filter.get_rules()[index] = new_rule
else:
store,iter = self.rlist.get_selected()
if iter:
rule = self.rlist.get_object(iter)
self.filter.delete_rule(rule)
self.filter.add_rule(new_rule)
self.draw_rules()
self.rule_top.destroy()
@ -337,16 +330,18 @@ class FilterEditor:
class ShowResults:
def __init__(self,plist):
self.glade = libglade.GladeXML(const.filterFile,'test')
self.glade = gtk.glade.XML(const.filterFile,'test')
self.top = self.glade.get_widget('test')
text = self.glade.get_widget('text')
self.glade.signal_autoconnect({
'on_close_clicked' : self.close,
})
n = ""
for p in plist:
n = "%s [%s]\n" % (p.getPrimaryName().getName(),p.getId())
text.insert_defaults(n)
n = n + "%s [%s]\n" % (p.getPrimaryName().getName(),p.getId())
text.get_buffer().set_text(n)
def close(self,obj):
self.top.destroy()

File diff suppressed because it is too large Load Diff