From a167440cc6173220239afc3ed33bbdacce7032e1 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 21 Feb 2006 05:13:15 +0000 Subject: [PATCH] * src/GrampsWidgets.py: Add monitored widgets for type and combo * src/EditFamily.py: use MonitoredType * src/EditSourceRef.py: complete monitoring of values * src/gramps.glade: add text field svn: r5966 --- gramps2/ChangeLog | 6 ++++ gramps2/src/EditFamily.py | 17 +++-------- gramps2/src/EditSourceRef.py | 17 ++++++++--- gramps2/src/GrampsWidgets.py | 58 ++++++++++++++++++++++++++++++++++++ gramps2/src/gramps.glade | 58 ++++++++++++++++++++++++++++++++++++ 5 files changed, 139 insertions(+), 17 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index d13a1cc46..2b3286702 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2006-02-20 Don Allingham + * src/GrampsWidgets.py: Add monitored widgets for type and combo + * src/EditFamily.py: use MonitoredType + * src/EditSourceRef.py: complete monitoring of values + * src/gramps.glade: add text field + 2006-02-19 Don Allingham * src/DisplayTabs.py: connect new EditSourceRef editor * src/EditSourceRef.py: update data on save diff --git a/gramps2/src/EditFamily.py b/gramps2/src/EditFamily.py index c69277620..389ab7df6 100644 --- a/gramps2/src/EditFamily.py +++ b/gramps2/src/EditFamily.py @@ -303,20 +303,11 @@ class EditFamily(DisplayState.ManagedWindow): self.family.set_gramps_id, self.family.get_gramps_id) - rel_types = dict(Utils.family_relations) + self.data_type = GrampsWidgets.MonitoredType( + self.top.get_widget('marriage_type'), self.family.set_relationship, + self.family.get_relationship, dict(Utils.family_relations), + RelLib.Family.CUSTOM) - mtype = self.family.get_relationship() - if mtype: - defval = mtype[0] - else: - defval = None - - reltype = self.top.get_widget('marriage_type') - self.type_sel = AutoComp.StandardCustomSelector( - rel_types, reltype, RelLib.Family.CUSTOM, defval) - reltype.connect('changed', - lambda x: self.family.set_relationship(self.type_sel.get_values())) - def load_data(self): fhandle = self.family.get_father_handle() self.update_father(fhandle) diff --git a/gramps2/src/EditSourceRef.py b/gramps2/src/EditSourceRef.py index 8bfc7e186..1b9c7f851 100644 --- a/gramps2/src/EditSourceRef.py +++ b/gramps2/src/EditSourceRef.py @@ -160,6 +160,19 @@ class EditSourceRef(DisplayState.ManagedWindow): self.top.get_widget('pub_info'), self.source.set_publication_info, self.source.get_publication_info,False) + self.text_data = MonitoredText( + self.top.get_widget('text'), self.source_ref.set_text, + self.source_ref.get_text,False) + + self.type_mon = MonitoredMenu( + self.top.get_widget('confidence'), self.source_ref.set_confidence_level, + self.source_ref.get_confidence_level, [ + (_('Very Low'), RelLib.SourceRef.CONF_VERY_LOW), + (_('Low'), RelLib.SourceRef.CONF_LOW), + (_('Normal'), RelLib.SourceRef.CONF_NORMAL), + (_('High'), RelLib.SourceRef.CONF_HIGH), + (_('Very High'), RelLib.SourceRef.CONF_VERY_HIGH)]) + def _add_source_page(self,page): self.notebook_src.insert_page(page) self.notebook_src.set_tab_label(page,page.get_tab_widget()) @@ -209,10 +222,6 @@ class EditSourceRef(DisplayState.ManagedWindow): def ok_clicked(self,obj): - # first, save source if changed -# etype = self.type_selector.get_values() -# self.update_source(etype,self.date,eplace_obj) - trans = self.db.transaction_begin() self.db.commit_source(self.source,trans) if self.source_added: diff --git a/gramps2/src/GrampsWidgets.py b/gramps2/src/GrampsWidgets.py index 890a72097..3031f18aa 100644 --- a/gramps2/src/GrampsWidgets.py +++ b/gramps2/src/GrampsWidgets.py @@ -31,6 +31,8 @@ from gettext import gettext as _ import gobject import gtk +import AutoComp + class LinkLabel(gtk.EventBox): def __init__(self,label,func,handle): @@ -232,3 +234,59 @@ class MonitoredEntry: self.obj.set_text(get_val()) self.obj.connect('changed', lambda x: self.set_val(unicode(x.get_text()))) self.obj.set_editable(not read_only) + +class MonitoredText: + + def __init__(self,obj,set_val,get_val,read_only=False): + self.buf = obj.get_buffer() + self.set_val = set_val + self.get_val = get_val + + if get_val(): + self.buf.set_text(get_val()) + self.buf.connect('changed', self.on_change) + obj.set_editable(not read_only) + + def on_change(self,obj): + s,e = self.buf.get_bounds() + self.set_val(unicode(self.buf.get_text(s,e,False))) + +class MonitoredType: + + def __init__(self,obj,set_val,get_val,mapping,custom): + self.set_val = set_val + self.get_val = get_val + + self.obj = obj + + val = get_val() + if val: + default = val[0] + else: + default = None + + self.sel = AutoComp.StandardCustomSelector( + mapping, obj, custom, default) + + self.obj.connect('changed', self.on_change) + + def on_change(self, obj): + self.set_val(self.sel.get_values()) + +class MonitoredMenu: + + def __init__(self,obj,set_val,get_val,mapping): + self.set_val = set_val + self.get_val = get_val + + self.obj = obj + self.model = gtk.ListStore(str,int) + for t,v in mapping: + self.model.append(row=[t,v]) + self.obj.set_model(self.model) + self.obj.set_active(get_val()) + self.obj.connect('changed',self.on_change) + + def on_change(self, obj): + self.set_val(self.model.get_value(obj.get_active_iter(),1)) + diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index 55f073d72..66a2e411b 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -17872,6 +17872,64 @@ Very High tab + + + + True + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + False + True + + + + + + True + Text + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + 0