2006-05-30 Don Allingham <don@gramps-project.org>

* src/plugins/FilterEditor.py: start to bring into sync with
	code changes



svn: r6827
This commit is contained in:
Don Allingham 2006-05-31 04:32:19 +00:00
parent 737f5a36eb
commit 658a6d147f
2 changed files with 42 additions and 69 deletions

View File

@ -1,3 +1,7 @@
2006-05-30 Don Allingham <don@gramps-project.org>
* src/plugins/FilterEditor.py: start to bring into sync with
code changes
2006-05-30 Alex Roitman <shura@gramps-project.org> 2006-05-30 Alex Roitman <shura@gramps-project.org>
* various: break Report into a package. * various: break Report into a package.

View File

@ -58,6 +58,7 @@ import GrampsDisplay
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import const import const
import RelLib
from Filters import GenericFilter, FilterList, Rules, \ from Filters import GenericFilter, FilterList, Rules, \
reload_custom_filters, reload_system_filters reload_custom_filters, reload_system_filters
import AutoComp import AutoComp
@ -75,14 +76,14 @@ from PluginUtils import Tool, register_tool
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
_name2list = { _name2list = {
_('Personal event:') : Utils.personal_events.values(), _('Personal event:') : RelLib.EventType().get_map(),
_('Family event:') : Utils.family_events.values(), _('Family event:') : RelLib.EventType().get_map(),
_('Personal attribute:') : Utils.personal_attributes.values(), _('Personal attribute:') : RelLib.AttributeType().get_map(),
_('Family attribute:') : Utils.family_attributes.values(), _('Family attribute:') : RelLib.AttributeType().get_map(),
} }
_menulist = { _menulist = {
_('Relationship type:') : Utils.family_relations.values(), _('Relationship type:') : RelLib.FamilyRelType().get_map(),
} }
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -325,8 +326,7 @@ class MyEntry(gtk.Entry):
class FilterEditor(ManagedWindow.ManagedWindow): class FilterEditor(ManagedWindow.ManagedWindow):
def __init__(self, filterdb, db, uistate): def __init__(self, filterdb, db, uistate):
ManagedWindow.ManagedWindow.__init__(self, uistate, [], ManagedWindow.ManagedWindow.__init__(self, uistate, [], FilterEditor)
FilterEditor)
self.db = db self.db = db
self.filterdb = FilterList(filterdb) self.filterdb = FilterList(filterdb)
@ -352,7 +352,8 @@ class FilterEditor(ManagedWindow.ManagedWindow):
'on_filter_list_delete_event' : self.on_delete_event, 'on_filter_list_delete_event' : self.on_delete_event,
}) })
self.clist = ListModel.ListModel(self.filter_list, self.clist = ListModel.ListModel(
self.filter_list,
[(_('Filter'),0,150),(_('Comment'),1,150)], [(_('Filter'),0,150),(_('Comment'),1,150)],
self.filter_select_row, self.filter_select_row,
self.edit_filter) self.edit_filter)
@ -360,7 +361,7 @@ class FilterEditor(ManagedWindow.ManagedWindow):
self.show() self.show()
def build_menu_names(self, obj): def build_menu_names(self, obj):
return (_("Custom Filter Editor"),_("Custom Filter Editor")) return (_("Custom Filter Editor"), _("Custom Filter Editor"))
def on_help_clicked(self,obj): def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual""" """Display the relevant portion of GRAMPS manual"""
@ -371,28 +372,7 @@ class FilterEditor(ManagedWindow.ManagedWindow):
self.remove_itself_from_menu() self.remove_itself_from_menu()
reload_custom_filters() reload_custom_filters()
reload_system_filters() reload_system_filters()
# self.parent.init_filters() self.close()
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
self.parent_menu_item = gtk.MenuItem(_("Filter Editor tool"))
self.parent_menu_item.set_submenu(gtk.Menu())
self.parent_menu_item.show()
self.parent.winsmenu.append(self.parent_menu_item)
self.winsmenu = self.parent_menu_item.get_submenu()
self.menu_item = gtk.MenuItem(_('Filter List'))
self.menu_item.connect("activate",self.present)
self.menu_item.show()
self.winsmenu.append(self.menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.menu_item.destroy()
self.winsmenu.destroy()
self.parent_menu_item.destroy()
def present(self,obj):
self.window.present()
def filter_select_row(self,obj): def filter_select_row(self,obj):
store,iter = self.clist.get_selected() store,iter = self.clist.get_selected()
@ -410,7 +390,7 @@ class FilterEditor(ManagedWindow.ManagedWindow):
self.window.destroy() self.window.destroy()
reload_custom_filters() reload_custom_filters()
reload_system_filters() reload_system_filters()
# self.parent.init_filters() self.close()
def draw_filters(self): def draw_filters(self):
self.clist.clear() self.clist.clear()
@ -419,13 +399,13 @@ class FilterEditor(ManagedWindow.ManagedWindow):
def add_new_filter(self,obj): def add_new_filter(self,obj):
the_filter = GenericFilter() the_filter = GenericFilter()
EditFilter(self,the_filter) EditFilter(self.uistate, self.track, the_filter, self.filterdb)
def edit_filter(self,obj): def edit_filter(self,obj):
store,iter = self.clist.get_selected() store,iter = self.clist.get_selected()
if iter: if iter:
filter = self.clist.get_object(iter) filter = self.clist.get_object(iter)
EditFilter(self,filter) EditFilter(self.uistate, self.track, filter, self.filterdb)
def test_clicked(self,obj): def test_clicked(self,obj):
store,iter = self.clist.get_selected() store,iter = self.clist.get_selected()
@ -446,27 +426,26 @@ class FilterEditor(ManagedWindow.ManagedWindow):
# #
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class EditFilter: class EditFilter(ManagedWindow.ManagedWindow):
def __init__(self,parent,filter):
self.filter = filter
self.filterdb = parent.filterdb
self.parent = parent def __init__(self, uistate, track, filter, filterdb):
if self.parent.child_windows.has_key(self.filter):
self.parent.child_windows[self.filter].present(None) ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
return
else: self.filter = filter
self.win_key = self.filter self.filterdb = filterdb
self.child_windows = {}
self.glade = gtk.glade.XML(const.rule_glade,'define_filter',"gramps") self.glade = gtk.glade.XML(const.rule_glade,'define_filter',"gramps")
self.window = self.glade.get_widget('define_filter')
self.define_title = self.glade.get_widget('title') self.define_title = self.glade.get_widget('title')
Utils.set_titles(self.window,self.define_title,_('Define filter')) self.set_window(
self.glade.get_widget('define_filter'),
self.define_title,
_('Define filter'))
self.rule_list = self.glade.get_widget('rule_list') self.rule_list = self.glade.get_widget('rule_list')
self.rlist = ListModel.ListModel(self.rule_list, self.rlist = ListModel.ListModel(
self.rule_list,
[(_('Name'),-1,150),(_('Value'),-1,150)], [(_('Name'),-1,150),(_('Value'),-1,150)],
self.select_row, self.select_row,
self.on_edit_clicked) self.on_edit_clicked)
@ -482,16 +461,12 @@ class EditFilter:
self.del_btn = self.glade.get_widget('delete') self.del_btn = self.glade.get_widget('delete')
self.glade.signal_autoconnect({ self.glade.signal_autoconnect({
'on_ok_clicked' : self.on_ok_clicked, 'on_ok_clicked' : self.on_ok_clicked,
'on_cancel_clicked' : self.close, 'on_cancel_clicked' : self.close_window,
'on_filter_name_changed' : self.filter_name_changed, 'on_filter_name_changed' : self.filter_name_changed,
'on_delete_clicked' : self.on_delete_clicked,
'on_add_clicked' : self.on_add_clicked, 'on_add_clicked' : self.on_add_clicked,
"on_help_filtdef_clicked" : self.on_help_clicked, "on_help_filtdef_clicked" : self.on_help_clicked,
'on_edit_clicked' : self.on_edit_clicked, 'on_edit_clicked' : self.on_edit_clicked,
"on_edit_filter_delete_event" : self.on_delete_event,
}) })
if self.filter.get_invert():
self.log_not.set_active(1)
if self.filter.get_logical_op() == 'or': if self.filter.get_logical_op() == 'or':
self.log_or.set_active(1) self.log_or.set_active(1)
elif self.filter.get_logical_op() == 'one': elif self.filter.get_logical_op() == 'one':
@ -503,19 +478,14 @@ class EditFilter:
self.comment.set_text(self.filter.get_comment()) self.comment.set_text(self.filter.get_comment())
self.draw_rules() self.draw_rules()
self.window.set_transient_for(self.parent.window) self.show()
self.add_itself_to_menu()
self.window.show()
def on_help_clicked(self,obj): def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual""" """Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('tools-util-cfe') GrampsDisplay.help('tools-util-cfe')
def on_delete_event(self,obj,b): def close_window(self,obj):
pass self.close()
def close(self,obj):
self.window.destroy()
def filter_name_changed(self,obj): def filter_name_changed(self,obj):
name = unicode(self.fname.get_text()) name = unicode(self.fname.get_text())
@ -545,7 +515,6 @@ class EditFilter:
if n == f.get_name(): if n == f.get_name():
self.filterdb.get_filters().remove(f) self.filterdb.get_filters().remove(f)
break break
self.filter.set_invert(self.log_not.get_active())
if self.log_or.get_active(): if self.log_or.get_active():
op = 'or' op = 'or'
elif self.log_one.get_active(): elif self.log_one.get_active():