From 18f908c9bd0b71c9cc85e55a94607f94008002cd Mon Sep 17 00:00:00 2001 From: Richard Taylor Date: Wed, 8 Feb 2006 15:29:46 +0000 Subject: [PATCH] fixed add button in object selector. svn: r5898 --- ChangeLog | 5 +++++ src/ObjectSelector/_FilterFrameBase.py | 3 ++- src/ObjectSelector/_ObjectSelectorWindow.py | 17 ++++++++++------- src/ObjectSelector/_PersonFrame.py | 15 +++++++-------- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index b70bba8f5..81c5c99f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-02-08 Richard Taylor + * src/ObjectSelector/_FilterFrameBase.py, + src/ObjectSelector/_ObjectSelectorWindow.py, + src/ObjectSelector/_PersonFrame.py: fixed add button in object selector. + 2006-02-08 Richard Taylor * src/EditFamily.py, src/Models/_FastFilterModel.py, src/Models/_FastModel.py, src/ObjectSelector/_FilterFrameBase.py, diff --git a/src/ObjectSelector/_FilterFrameBase.py b/src/ObjectSelector/_FilterFrameBase.py index 90b2696f5..156c12444 100644 --- a/src/ObjectSelector/_FilterFrameBase.py +++ b/src/ObjectSelector/_FilterFrameBase.py @@ -66,7 +66,8 @@ class FilterFrameBase(gtk.Frame): clear_button = gtk.Button(stock=gtk.STOCK_CLEAR) clear_button.connect('clicked',self.on_clear) - button_box = gtk.HBox() + button_box = gtk.HButtonBox() + button_box.set_layout(gtk.BUTTONBOX_SPREAD) button_box.pack_start(apply_button,False,False) button_box.pack_start(clear_button,False,False) diff --git a/src/ObjectSelector/_ObjectSelectorWindow.py b/src/ObjectSelector/_ObjectSelectorWindow.py index e6b756a5b..d59bbf521 100644 --- a/src/ObjectSelector/_ObjectSelectorWindow.py +++ b/src/ObjectSelector/_ObjectSelectorWindow.py @@ -42,7 +42,7 @@ class _ObjectTypeWidgets(object): def __init__(self): self.frame = None self.sel_label = None - self.selected_id = None + self.selected_obj = None self.new_button = None def show(self): @@ -55,8 +55,8 @@ class _ObjectTypeWidgets(object): self.sel_label.hide_all() self.new_button.hide() - def set_selected_id(self,id): - self.selected_id = id + def set_selected_obj(self,obj): + self.selected_obj = obj OBJECT_LIST = [ObjectTypes.PERSON, ObjectTypes.FAMILY, ObjectTypes.SOURCE, ObjectTypes.EVENT, @@ -217,12 +217,12 @@ class ObjectSelectorWindow(gtk.Window,ManagedWindow): # connect signals self._object_frames[object_type].frame.connect( 'selection-changed', - lambda widget,text,handle,label: label.set_text(text), + lambda widget,text,selected_object,label: label.set_text(text), self._object_frames[object_type].sel_label) self._object_frames[object_type].frame.connect( 'selection-changed', - lambda widget,text,handle,current_object: current_object.set_selected_id(handle), + lambda widget,text,selected_object,current_object: current_object.set_selected_obj(selected_object), self._object_frames[object_type]) self._object_frames[object_type].frame.connect( @@ -310,14 +310,17 @@ class ObjectSelectorWindow(gtk.Window,ManagedWindow): self._current_object_type = selected_object_type # Set the add button sensitivity - if self._object_frames[selected_object_type].selected_id: + if self._object_frames[selected_object_type].selected_obj: self._add_button.set_sensitive(True) else: self._add_button.set_sensitive(False) def on_add(self,widget=None,object=None): - self.emit('add-object',object) + if object is None: + self.emit('add-object',self._object_frames[self._current_object_type].selected_obj) + else: + self.emit('add-object',object) def on_selection_changed(self,widget,text,handle): if handle: diff --git a/src/ObjectSelector/_PersonFrame.py b/src/ObjectSelector/_PersonFrame.py index 458595913..104884fdc 100644 --- a/src/ObjectSelector/_PersonFrame.py +++ b/src/ObjectSelector/_PersonFrame.py @@ -46,7 +46,7 @@ class PersonFrame(ObjectFrameBase): 'selection-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, - gobject.TYPE_STRING)), + gobject.TYPE_PYOBJECT)), 'add-object': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, @@ -74,16 +74,15 @@ class PersonFrame(ObjectFrameBase): (person,rowref) = model.get_value(iter,0) if len(rowref) > 1 or model.is_list(): if person: - self.emit('selection-changed', "%s [%s]" % ( - display_name(person), - person.get_gramps_id()), - person.get_handle()) + self.emit('selection-changed', "%s [%s]" % (display_name(person), + person.get_gramps_id()), + person) else: - self.emit('selection-changed',"No Selection","") + self.emit('selection-changed',"No Selection",None) else: - self.emit('selection-changed',"No Selection","") + self.emit('selection-changed',"No Selection",None) else: - self.emit('selection-changed',"No Selection","") + self.emit('selection-changed',"No Selection",None) self._tree_frame.get_selection().connect('changed',handle_selection)