2006-06-03 Don Allingham <don@gramps-project.org>

* src/FilterEditor/_ShowResults.py: move glade functions to 
	ManagedWindow
	* src/FilterEditor/_EditFilter.py: move glade functions to 
	ManagedWindow
	* src/FilterEditor/_FilterEditor.py: move glade functions to 
	ManagedWindow
	* src/FilterEditor/_EditRule.py: move glade functions to 
	ManagedWindow
	* src/ManagedWindow.py: move glade functions to ManagedWindow



svn: r6852
This commit is contained in:
Don Allingham 2006-06-03 19:08:09 +00:00
parent 79921262dd
commit f40c352aa4
7 changed files with 90 additions and 76 deletions

View File

@ -1,3 +1,14 @@
2006-06-03 Don Allingham <don@gramps-project.org>
* src/FilterEditor/_ShowResults.py: move glade functions to
ManagedWindow
* src/FilterEditor/_EditFilter.py: move glade functions to
ManagedWindow
* src/FilterEditor/_FilterEditor.py: move glade functions to
ManagedWindow
* src/FilterEditor/_EditRule.py: move glade functions to
ManagedWindow
* src/ManagedWindow.py: move glade functions to ManagedWindow
2006-06-02 Brian Matherly <brian@gramps-project.org>
* src/docgen/*: use IndexMark
* src/plugins/DetDecendantReport: use IndexMark

View File

@ -48,7 +48,6 @@ log = logging.getLogger(".FilterEdit")
#
#-------------------------------------------------------------------------
import gtk
import gtk.glade
import GrampsDisplay
#-------------------------------------------------------------------------
@ -70,7 +69,8 @@ import ManagedWindow
#-------------------------------------------------------------------------
class EditFilter(ManagedWindow.ManagedWindow):
def __init__(self, space, dbstate, uistate, track, gfilter, filterdb, update):
def __init__(self, space, dbstate, uistate, track, gfilter,
filterdb, update):
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
@ -81,36 +81,36 @@ class EditFilter(ManagedWindow.ManagedWindow):
self.filter = gfilter
self.filterdb = filterdb
self.glade = gtk.glade.XML(const.rule_glade,'define_filter',"gramps")
self.define_title = self.glade.get_widget('title')
self.define_glade('define_filter', const.rule_glade)
self.set_window(
self.glade.get_widget('define_filter'),
self.define_title,
self.get_widget('define_filter'),
self.get_widget('title'),
_('Define filter'))
self.rule_list = self.glade.get_widget('rule_list')
self.rlist = ListModel.ListModel(
self.rule_list,
self.get_widget('rule_list'),
[(_('Name'),-1,150),(_('Values'),-1,150)],
self.select_row,
self.on_edit_clicked)
self.fname = self.glade.get_widget('filter_name')
self.logical = self.glade.get_widget('rule_apply')
self.comment = self.glade.get_widget('comment')
self.ok = self.glade.get_widget('ok')
self.edit_btn = self.glade.get_widget('edit')
self.del_btn = self.glade.get_widget('delete')
self.add_btn = self.glade.get_widget('add')
self.fname = self.get_widget('filter_name')
self.logical = self.get_widget('rule_apply')
self.comment = self.get_widget('comment')
self.ok_btn = self.get_widget('ok')
self.edit_btn = self.get_widget('edit')
self.del_btn = self.get_widget('delete')
self.add_btn = self.get_widget('add')
self.ok.connect('clicked', self.on_ok_clicked)
self.ok_btn.connect('clicked', self.on_ok_clicked)
self.edit_btn.connect('clicked', self.on_edit_clicked)
self.del_btn.connect('clicked', self.on_delete_clicked)
self.add_btn.connect('clicked', self.on_add_clicked)
self.glade.get_widget('help').connect('clicked', self.on_help_clicked)
self.glade.get_widget('cancel').connect('clicked', self.close_window)
self.get_widget('help').connect('clicked',
self.on_help_clicked)
self.get_widget('cancel').connect('clicked',
self.close_window)
self.fname.connect('changed', self.filter_name_changed)
if self.filter.get_logical_op() == 'or':
@ -135,7 +135,7 @@ class EditFilter(ManagedWindow.ManagedWindow):
def filter_name_changed(self,obj):
name = unicode(self.fname.get_text())
self.ok.set_sensitive(len(name) != 0)
self.ok_btn.set_sensitive(len(name) != 0)
def select_row(self,obj):
store,node = self.rlist.get_selected()
@ -180,7 +180,6 @@ class EditFilter(ManagedWindow.ManagedWindow):
self.filterdb, None, _('Add Rule'), self.update_rule)
def on_edit_clicked(self,obj):
print "ON EDIT"
store, node = self.rlist.get_selected()
if node:
from _EditRule import EditRule

View File

@ -48,7 +48,6 @@ log = logging.getLogger(".FilterEdit")
#
#-------------------------------------------------------------------------
import gtk
import gtk.glade
import gobject
import GrampsDisplay
@ -335,13 +334,14 @@ class EditRule(ManagedWindow.ManagedWindow):
self.update_rule = update
self.active_rule = val
self.rule = gtk.glade.XML(const.rule_glade,'rule_editor',"gramps")
self.set_window(self.rule.get_widget('rule_editor'),
self.rule.get_widget('title'),label)
self.define_glade('rule_editor', const.rule_glade)
self.set_window(self.get_widget('rule_editor'),
self.get_widget('title'),label)
self.window.hide()
self.valuebox = self.rule.get_widget('valuebox')
self.rname = self.rule.get_widget('ruletree')
self.rule_name = self.rule.get_widget('rulename')
self.valuebox = self.get_widget('valuebox')
self.rname = self.get_widget('ruletree')
self.rule_name = self.get_widget('rulename')
self.notebook = gtk.Notebook()
self.notebook.set_show_tabs(0)
@ -470,9 +470,9 @@ class EditRule(ManagedWindow.ManagedWindow):
tlist[i].set_text(r[i])
self.selection.connect('changed', self.on_node_selected)
self.rule.get_widget('ok').connect('clicked',self.rule_ok)
self.rule.get_widget('cancel').connect('clicked', self.close_window)
self.rule.get_widget('help').connect('clicked',self.on_help_clicked)
self.get_widget('ok').connect('clicked',self.rule_ok)
self.get_widget('cancel').connect('clicked', self.close_window)
self.get_widget('help').connect('clicked',self.on_help_clicked)
self.show()
@ -495,14 +495,14 @@ class EditRule(ManagedWindow.ManagedWindow):
except:
self.valuebox.set_sensitive(0)
self.rule_name.set_text(_('No rule selected'))
self.rule.get_widget('description').set_text('')
self.get_widget('description').set_text('')
def display_values(self,class_obj):
page = self.class2page[class_obj]
self.notebook.set_current_page(page)
self.valuebox.set_sensitive(1)
self.rule_name.set_text(class_obj.name)
self.rule.get_widget('description').set_text(class_obj.description)
self.get_widget('description').set_text(class_obj.description)
def rule_ok(self,obj):
if self.rule_name.get_text() == _('No rule selected'):

View File

@ -48,7 +48,6 @@ log = logging.getLogger(".FilterEdit")
#
#-------------------------------------------------------------------------
import gtk
import gtk.glade
import GrampsDisplay
#-------------------------------------------------------------------------
@ -58,7 +57,7 @@ import GrampsDisplay
#-------------------------------------------------------------------------
import const
import RelLib
from Filters import GenericFilter, FilterList, Rules, \
from Filters import GenericFilter, FilterList, \
reload_custom_filters, reload_system_filters
import ListModel
import ManagedWindow
@ -71,7 +70,8 @@ import ManagedWindow
class FilterEditor(ManagedWindow.ManagedWindow):
def __init__(self, space, filterdb, dbstate, uistate):
ManagedWindow.ManagedWindow.__init__(self, uistate, [], FilterEditor)
ManagedWindow.ManagedWindow.__init__(self, uistate, [],
FilterEditor)
self.dbstate = dbstate
self.db = dbstate.db
@ -79,30 +79,28 @@ class FilterEditor(ManagedWindow.ManagedWindow):
self.filterdb.load()
self.space = space
self.editor = gtk.glade.XML(const.rule_glade,'filter_list',"gramps")
self.filter_list = self.editor.get_widget('filters')
self.edit = self.editor.get_widget('edit')
self.delete = self.editor.get_widget('delete')
self.test = self.editor.get_widget('test')
self.define_glade('filter_list', const.rule_glade)
self.filter_list = self.get_widget('filters')
self.edit = self.get_widget('edit')
self.delete = self.get_widget('delete')
self.test = self.get_widget('test')
self.edit.set_sensitive(False)
self.delete.set_sensitive(False)
self.test.set_sensitive(False)
self.set_window(self.editor.get_widget('filter_list'),
self.editor.get_widget('title'),
self.set_window(self.get_widget('filter_list'),
self.get_widget('title'),
_('%s filters') % _(self.space))
self.editor.signal_autoconnect({
'on_add_clicked' : self.add_new_filter,
'on_edit_clicked' : self.edit_filter,
'on_test_clicked' : self.test_clicked,
'on_close_clicked' : self.close_filter_editor,
"on_help_filters_clicked" : self.on_help_clicked,
'on_delete_clicked' : self.delete_filter,
'on_filter_list_delete_event' : self.on_delete_event,
})
self.edit.connect('clicked', self.edit_filter)
self.test.connect('clicked', self.test_clicked)
self.delete.connect('clicked', self.delete_filter)
self.connect_button('help', self.help_clicked)
self.connect_button('close', self.close_window)
self.connect_button('add', self.add_new_filter)
self.clist = ListModel.ListModel(
self.filter_list,
[(_('Filter'),0,150),(_('Comment'),1,150)],
@ -114,16 +112,10 @@ class FilterEditor(ManagedWindow.ManagedWindow):
def build_menu_names(self, obj):
return (_("Custom Filter Editor"), _("Custom Filter Editor"))
def on_help_clicked(self,obj):
def help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('tools-util-cfe')
def on_delete_event(self,obj,b):
self.filterdb.save()
reload_custom_filters()
reload_system_filters()
self.close()
def filter_select_row(self,obj):
store,node = self.clist.get_selected()
if node:
@ -135,7 +127,7 @@ class FilterEditor(ManagedWindow.ManagedWindow):
self.delete.set_sensitive(False)
self.test.set_sensitive(False)
def close_filter_editor(self,obj):
def close_window(self,obj):
self.filterdb.save()
reload_custom_filters()
reload_system_filters()

View File

@ -48,7 +48,6 @@ log = logging.getLogger(".FilterEdit")
#
#-------------------------------------------------------------------------
import gtk
import gtk.glade
#-------------------------------------------------------------------------
#
@ -70,30 +69,28 @@ class ShowResults(ManagedWindow.ManagedWindow):
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
self.filtname = filtname
self.glade = gtk.glade.XML(const.rule_glade,'test',"gramps")
self.define_glade('test', const.rule_glade,)
self.set_window(
self.glade.get_widget('test'),
self.glade.get_widget('title'),
self.get_widget('test'),
self.get_widget('title'),
_('Filter Test'))
nd = NameDisplay.displayer
render = gtk.CellRendererText()
tree = self.glade.get_widget('list')
tree = self.get_widget('list')
model = gtk.ListStore(str, str)
tree.set_model(model)
column_n = gtk.TreeViewColumn(
_('Name'), gtk.CellRendererText(), text=0)
column_n = gtk.TreeViewColumn(_('Name'), render, text=0)
tree.append_column(column_n)
column_n = gtk.TreeViewColumn(
_('ID'), gtk.CellRendererText(), text=1)
column_n = gtk.TreeViewColumn(_('ID'), render, text=1)
tree.append_column(column_n)
self.glade.get_widget('close').connect('clicked',self.close_window)
self.get_widget('close').connect('clicked',self.close_window)
new_list = [ self.sort_val_from_handle(db, h) for h in handle_list ]
new_list = [self.sort_val_from_handle(db, h) for h in handle_list]
new_list.sort()
handle_list = [ h[1] for h in new_list ]

View File

@ -33,6 +33,7 @@ from cStringIO import StringIO
#
#-------------------------------------------------------------------------
import gtk
import gtk.glade
#-------------------------------------------------------------------------
#
@ -305,6 +306,7 @@ class ManagedWindow:
"""
window_key = self.build_window_key(obj)
menu_label,submenu_label = self.build_menu_names(obj)
self._gladeobj = None
if uistate.gwm.get_item_from_id(window_key):
uistate.gwm.get_item_from_id(window_key).present()
@ -347,6 +349,20 @@ class ManagedWindow:
def build_window_key(self,obj):
return id(obj)
def define_glade(self, top_module, glade_file=None):
if glade_file == None:
glade_file = const.gladeFile
self._gladeobj = gtk.glade.XML(glade_file, top_module, "gramps")
return self._gladeobj
def get_widget(self, name):
assert(self._gladeobj)
return self._gladeobj.get_widget(name)
def connect_button(self, button_name, function):
assert(self._gladeobj)
self.get_widget(button_name).connect('clicked',function)
def show(self):
assert self.window, "ManagedWindow: self.window does not exist!"
self.window.set_transient_for(self.parent_window)

View File

@ -509,7 +509,6 @@ Exactly one rule must apply</property>
</widget>
<widget class="GtkDialog" id="filter_list">
<property name="visible">True</property>
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
@ -540,7 +539,7 @@ Exactly one rule must apply</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button1">
<widget class="GtkButton" id="close">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
@ -554,7 +553,7 @@ Exactly one rule must apply</property>
</child>
<child>
<widget class="GtkButton" id="button10">
<widget class="GtkButton" id="help">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
@ -649,7 +648,7 @@ Exactly one rule must apply</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="button3">
<widget class="GtkButton" id="add">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Add a new filter</property>
<property name="can_default">True</property>