From efee07a0e2695b55c688b64ae75dd10206d678c8 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Thu, 14 Nov 2002 05:31:42 +0000 Subject: [PATCH] ListModel improvements, GenericFilter moved to GNOME 2 svn: r1188 --- gramps2/src/GenericFilter.py | 3 + gramps2/src/GrampsCfg.py | 292 ++--- gramps2/src/ListModel.py | 32 +- gramps2/src/plugins/FilterEditor.py | 153 ++- gramps2/src/rule.glade | 1814 +++++++++++++-------------- 5 files changed, 1097 insertions(+), 1197 deletions(-) diff --git a/gramps2/src/GenericFilter.py b/gramps2/src/GenericFilter.py index 74cf07777..91216b8f4 100644 --- a/gramps2/src/GenericFilter.py +++ b/gramps2/src/GenericFilter.py @@ -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: diff --git a/gramps2/src/GrampsCfg.py b/gramps2/src/GrampsCfg.py index 9f02271fb..2b54704fe 100644 --- a/gramps2/src/GrampsCfg.py +++ b/gramps2/src/GrampsCfg.py @@ -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") diff --git a/gramps2/src/ListModel.py b/gramps2/src/ListModel.py index d3b106665..bcda3ae7c 100644 --- a/gramps2/src/ListModel.py +++ b/gramps2/src/ListModel.py @@ -18,17 +18,20 @@ # 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: @@ -46,23 +49,36 @@ class ListModel: num = 0 for name in dlist: column = tree.get_column(num) - column.set_sort_column_id(name[1]) - if num == 0: - column.clicked() - num = num + 1 + if name[1] != -1: + column.set_sort_column_id(name[1]) + if num == 0: + column.clicked() + num = num + 1 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 get_object(self,iter): + return self.model.get_value(iter,self.data_index) - def add(self,data): + 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 diff --git a/gramps2/src/plugins/FilterEditor.py b/gramps2/src/plugins/FilterEditor.py index b5dae5f64..99891fcb2 100644 --- a/gramps2/src/plugins/FilterEditor.py +++ b/gramps2/src/plugins/FilterEditor.py @@ -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): - 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) + 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) + 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]) - self.filter_editor(GenericFilter.GenericFilter(filter)) + 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]) - list = filt.apply(self.db.getPersonMap().values()) - ShowResults(list) + 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]) - self.filterdb.get_filters().remove(filter) - self.draw_filters() + 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): - self.edit_btn.set_sensitive(1) - self.del_btn.set_sensitive(1) + 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) + else: + self.edit_btn.set_sensitive(0) + self.del_btn.set_sensitive(0) - 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) - 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,11 +204,10 @@ 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) - self.edit_rule(d) + store,iter = self.rlist.get_selected() + if iter: + d = self.rlist.get_object(iter) + self.edit_rule(d) def edit_rule(self,val): self.pmap = {} @@ -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] - self.draw_rules() + 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,11 +317,11 @@ 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: - self.filter.add_rule(new_rule) + 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() diff --git a/gramps2/src/rule.glade b/gramps2/src/rule.glade index 620032c31..92091e14b 100644 --- a/gramps2/src/rule.glade +++ b/gramps2/src/rule.glade @@ -1,960 +1,938 @@ - - + + - - Rule - rule - - src - pixmaps - C - True - True - + - - GnomeDialog - define_filter - Define Filter - GRAMPS - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - False - False + + True + Define Filter - GRAMPS + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 450 + 400 + True + False + True - - GtkVBox - GnomeDialog:vbox - dialog-vbox1 - False - 8 - - 4 - True - True - + + + True + False + 8 - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area1 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END + + + True + GTK_BUTTONBOX_END + + + + True + False + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + 0 + + + + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + 0 + + + + + + 0 + False + True + GTK_PACK_END + - - GtkButton - ok - False - True - True - - clicked - on_ok_clicked - Mon, 01 Apr 2002 02:49:31 GMT - - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button6 - True - True - - clicked - on_cancel_clicked - Thu, 04 Apr 2002 18:31:55 GMT - - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkVBox - vbox1 - False - 0 - 0 - True - True + + True + False + 0 + + + + True + Define Filter + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + + + 5 + False + True + + + + + + True + 6 + 2 + False + 0 + 0 + + + + True + Name + False + False + GTK_JUSTIFY_CENTER + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + 5 + 5 + fill + + + + + + + True + Comment + False + False + GTK_JUSTIFY_CENTER + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + 5 + 5 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + + 1 + 2 + 0 + 1 + 5 + 5 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 1 + 2 + 5 + 5 + + + + + + + True + True + Exactly one rule must apply + True + GTK_RELIEF_NORMAL + False + False + True + + + 1 + 2 + 5 + 6 + fill + + + + + + + True + True + At least one rule must apply + True + GTK_RELIEF_NORMAL + False + False + True + logical_one + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + True + All rules must apply + True + GTK_RELIEF_NORMAL + True + False + True + logical_one + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + True + Invert + True + GTK_RELIEF_NORMAL + False + False + True + + + 1 + 2 + 2 + 3 + fill + + + + + + 0 + False + True + + + + + + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_SPREAD + 30 + + + + True + True + True + gtk-add + True + GTK_RELIEF_NORMAL + + + + + + + True + False + True + True + Edit + True + GTK_RELIEF_NORMAL + + + + + + + True + False + True + True + gtk-remove + True + GTK_RELIEF_NORMAL + + + + + + 0 + False + True + + + + + 0 + True + True + - - - GtkLabel - label1 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkHSeparator - hseparator1 - - 5 - False - True - - - - - GtkTable - table1 - 6 - 2 - False - 0 - 0 - - 0 - True - True - - - - GtkLabel - label2 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 0 - 0 - - 0 - 1 - 0 - 1 - 5 - 5 - False - False - False - False - True - False - - - - - GtkLabel - label10 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 0 - 0 - - 0 - 1 - 1 - 2 - 5 - 5 - False - False - False - False - True - False - - - - - GtkEntry - filter_name - True - - changed - on_filter_name_changed - Sun, 07 Apr 2002 19:28:31 GMT - - True - True - 0 - - - 1 - 2 - 0 - 1 - 5 - 5 - True - False - False - False - True - False - - - - - GtkEntry - comment - True - True - True - 0 - - - 1 - 2 - 1 - 2 - 5 - 5 - True - False - False - False - True - False - - - - - GtkRadioButton - logical_one - True - - False - True - logic - - 1 - 2 - 5 - 6 - 0 - 0 - False - False - False - False - True - False - - - - - GtkRadioButton - logical_or - True - - False - True - logic - - 1 - 2 - 4 - 5 - 0 - 0 - False - False - False - False - True - False - - - - - GtkRadioButton - logical_and - True - - True - True - logic - - 1 - 2 - 3 - 4 - 0 - 0 - False - False - False - False - True - False - - - - - GtkCheckButton - logical_not - True - - False - True - - 1 - 2 - 2 - 3 - 0 - 0 - False - False - False - False - True - False - - - - - - GtkScrolledWindow - scrolledwindow1 - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkCList - rule_list - 450 - 200 - True - - select_row - on_rule_select_row - Sun, 07 Apr 2002 19:29:31 GMT - - - unselect_row - on_rule_unselect_row - Sun, 07 Apr 2002 19:30:23 GMT - - 2 - 147,80 - GTK_SELECTION_SINGLE - True - GTK_SHADOW_IN - - - GtkLabel - CList:title - label3 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - CList:title - label4 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - GtkHButtonBox - hbuttonbox1 - GTK_BUTTONBOX_SPREAD - 30 - 85 - 27 - 7 - 0 - - 0 - False - True - - - - GtkButton - add - True - True - - clicked - on_add_clicked - Mon, 01 Apr 2002 02:47:47 GMT - - - GTK_RELIEF_NORMAL - - - - GtkButton - edit - False - True - True - - clicked - on_edit_clicked - Mon, 01 Apr 2002 02:48:18 GMT - - - GTK_RELIEF_NORMAL - - - - GtkButton - delete - False - True - True - - clicked - on_delete_clicked - Mon, 01 Apr 2002 02:48:53 GMT - - - GTK_RELIEF_NORMAL - - - + - - GnomeDialog - add_rule - Add Rule - GRAMPS - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - False - False + + True + Add Rule - GRAMPS + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True - - GtkVBox - GnomeDialog:vbox - dialog-vbox2 - False - 8 - - 4 - True - True - + + + True + False + 8 - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area2 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - + + + True + GTK_BUTTONBOX_END - - GtkButton - ok - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - cancel - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkVBox - vbox2 - False - 0 - - 0 - True - True - - - - GtkLabel - label5 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 5 - False - False - - - - - GtkHSeparator - hseparator2 - - 5 - False - True - - - - - GtkHBox - hbox2 - False - 0 - - 5 - False - True - - - - GtkLabel - label6 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - 5 - False - True - - - - - GtkCombo - rule_name - True - False - False - True - False - - - 5 - True - True + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + 0 + - - GtkEntry - GtkCombo:entry - combo-entry1 - True - False - True - 0 - - + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + 0 + + - + + 0 + False + True + GTK_PACK_END + + - - GtkFrame - values - 425 - 200 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - + + + True + False + 0 - - Placeholder + + + True + Add Rule + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + + + 5 + False + False + + + + + + True + + + 5 + False + True + + + + + + True + False + 0 + + + + True + Rule + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + + + 5 + False + True + + + + + + True + True + False + False + True + False + + + + True + True + False + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + True + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + + + + + + + 5 + True + True + + + + + 5 + False + True + + + + + + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + + + + + True + Values + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + True + True + + - + + 0 + True + True + + - + - - GnomeDialog - filter_list - User Defined Filters - GRAMPS - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - False - False + + True + User Defined Filters - GRAMPS + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 350 + True + False + True - - GtkVBox - GnomeDialog:vbox - dialog-vbox3 - False - 8 - - 4 - True - True - + + + True + False + 8 - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area3 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + 0 + + + + + + 0 + False + True + GTK_PACK_END + - - GtkButton - button1 - True - True - - clicked - on_close_clicked - Thu, 04 Apr 2002 02:05:50 GMT - - GNOME_STOCK_BUTTON_CLOSE - - - - - GtkVBox - vbox3 - False - 0 - 0 - True - True + + True + False + 0 + + + + True + User Defined Filters + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + + + 5 + False + False + + + + + + True + + + 0 + False + True + + + + + + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + + + + + 5 + True + True + + + + + + True + GTK_BUTTONBOX_SPREAD + 30 + + + + True + Add a new filter + True + True + gtk-add + True + GTK_RELIEF_NORMAL + + + + + + + True + False + Edit the selected filter + True + True + Edit + True + GTK_RELIEF_NORMAL + + + + + + + True + False + Delete the selected filter + True + True + gtk-remove + True + GTK_RELIEF_NORMAL + + + + + + + True + False + Display people matching the filter + True + True + GTK_RELIEF_NORMAL + + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-execute + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Test + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + 0 + False + True + + + + + 0 + True + True + - - - GtkLabel - label7 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 5 - False - False - - - - - GtkHSeparator - hseparator3 - - 0 - True - True - - - - - GtkScrolledWindow - scrolledwindow2 - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 5 - True - True - - - - GtkCList - filters - 450 - 150 - True - - select_row - on_filters_select_row - Sun, 07 Apr 2002 22:15:34 GMT - - - unselect_row - on_filters_unselect_row - Sun, 07 Apr 2002 22:15:44 GMT - - 2 - 117,80 - GTK_SELECTION_SINGLE - True - GTK_SHADOW_IN - - - GtkLabel - CList:title - label8 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - CList:title - label9 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - GtkHButtonBox - hbuttonbox2 - GTK_BUTTONBOX_SPREAD - 30 - 85 - 27 - 7 - 0 - - 0 - True - True - - - - GtkButton - button3 - Add a new filter - True - True - - clicked - on_add_clicked - Thu, 04 Apr 2002 02:04:34 GMT - - - GTK_RELIEF_NORMAL - - - - GtkButton - edit - False - Edit the selected filter - True - True - - clicked - on_edit_clicked - Thu, 04 Apr 2002 02:04:53 GMT - - - GTK_RELIEF_NORMAL - - - - GtkButton - delete - False - Delete the selected filter - True - True - - clicked - on_delete_clicked - Thu, 04 Apr 2002 02:05:15 GMT - - - GTK_RELIEF_NORMAL - - - - GtkButton - test - False - Display people matching the filter - True - True - - clicked - on_test_clicked - Sat, 06 Apr 2002 18:34:08 GMT - - - GTK_RELIEF_NORMAL - - - + - - GnomeDialog - test - Test Filter - GRAMPS - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - False - False + + True + Test Filter - GRAMPS + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True - - GtkVBox - GnomeDialog:vbox - dialog-vbox4 - False - 8 - - 4 - True - True - + + + True + False + 8 - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area4 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + 0 + + + + + + 0 + False + True + GTK_PACK_END + - - GtkButton - button9 - True - True - - clicked - on_close_clicked - Sat, 06 Apr 2002 19:05:56 GMT - - GNOME_STOCK_BUTTON_CLOSE - - - - - GtkScrolledWindow - scrolledwindow3 - GTK_POLICY_NEVER - GTK_POLICY_ALWAYS - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - 0 - True - True - + + True + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT - - GtkText - text - 350 - 250 - True - False - - + + + True + True + False + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0 + True + True + + - + - +