diff --git a/ChangeLog b/ChangeLog index fa959d6af..8f0d59164 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-01-17 Richard Taylor + * src/ObjectSelector/_FamilyFrame.py src/ObjectSelector/_FamilyPreviewFrame.py + src/ObjectSelector/_FamilyTreeFrame.py src/ObjectSelector/_ObjectSelectorWindow.py + src/ObjectSelector/_PersonFrame.py src/ObjectSelector/_PersonPreviewFrame.py + src/ObjectSelector/_PersonTreeFrame.py: UI improvements to object selector + 2006-01-17 Richard Taylor * src/ObjectSelector/_FamilyFrame.py, src/ObjectSelector/_FamilyPreviewFrame.py, src/ObjectSelector/_ObjectFrameBase.py, src/ObjectSelector/_ObjectSelectorWindow.py, diff --git a/src/ObjectSelector/_FamilyFrame.py b/src/ObjectSelector/_FamilyFrame.py index 236d90718..7dd97f60e 100644 --- a/src/ObjectSelector/_FamilyFrame.py +++ b/src/ObjectSelector/_FamilyFrame.py @@ -19,6 +19,10 @@ class FamilyFrame(ObjectFrameBase): gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_STRING)), + + 'add-object': (gobject.SIGNAL_RUN_LAST, + gobject.TYPE_NONE, + ()) } __person_id_field = 0 @@ -32,23 +36,29 @@ class FamilyFrame(ObjectFrameBase): preview_frame = FamilyPreviewFrame(dbstate), tree_frame = FamilyTreeFrame(dbstate)) - def handle_selection(treeselection): - (model, iter) = treeselection.get_selected() - if iter and model.get_value(iter,0): - self.emit('selection-changed', "%s / %s (%s)" % ( - str(model.get_value(iter,1)), - str(model.get_value(iter,2)), - str(model.get_value(iter,0))), - model.get_value(iter,0)) - else: - self.emit('selection-changed',"No Selection","") - - - self._tree_frame.get_selection().connect('changed',handle_selection) + self._tree_frame.get_selection().connect('changed',self._handle_selection) self._tree_frame.get_selection().connect('changed',self.set_preview,self.__class__.__person_id_field) + self._tree_frame.get_tree().connect('row-activated',self._on_row_activated) + + def _handle_selection(self,treeselection): + (model, iter) = treeselection.get_selected() + if iter and model.get_value(iter,self.__class__.__person_id_field): + self.emit('selection-changed', "%s / %s (%s)" % ( + str(model.get_value(iter,1)), + str(model.get_value(iter,2)), + str(model.get_value(iter,0))), + model.get_value(iter,self.__class__.__person_id_field)) + else: + self.emit('selection-changed',"No Selection","") + + def _on_row_activated(self,widget,path,col): + (model, iter) = widget.get_selection().get_selected() + if iter and model.get_value(iter,self.__class__.__person_id_field): + self.emit('add-object') + diff --git a/src/ObjectSelector/_FamilyPreviewFrame.py b/src/ObjectSelector/_FamilyPreviewFrame.py index daede31de..83be2f9c5 100644 --- a/src/ObjectSelector/_FamilyPreviewFrame.py +++ b/src/ObjectSelector/_FamilyPreviewFrame.py @@ -29,10 +29,6 @@ class FamilyPreviewFrame(gtk.Frame): image_box.pack_start(self._image_l) image_box.pack_start(self._image_r) - # test image - image_frame = gtk.Frame() - image_frame.add(image_box) - # Text label = gtk.Label() label.set_use_markup(True) @@ -45,7 +41,7 @@ class FamilyPreviewFrame(gtk.Frame): # box box = gtk.VBox() - box.pack_start(image_frame) + box.pack_start(image_box,False,False) box.pack_start(label) diff --git a/src/ObjectSelector/_FamilyTreeFrame.py b/src/ObjectSelector/_FamilyTreeFrame.py index b475852bb..3b4857569 100644 --- a/src/ObjectSelector/_FamilyTreeFrame.py +++ b/src/ObjectSelector/_FamilyTreeFrame.py @@ -65,7 +65,10 @@ class FamilyTreeFrame(gtk.Frame): def get_selection(self): return self._selection - + + def get_tree(self): + return self._list + if gtk.pygtk_version < (2,8,0): gobject.type_register(FamilyTreeFrame) diff --git a/src/ObjectSelector/_ObjectSelectorWindow.py b/src/ObjectSelector/_ObjectSelectorWindow.py index c208dfdf2..894a14669 100644 --- a/src/ObjectSelector/_ObjectSelectorWindow.py +++ b/src/ObjectSelector/_ObjectSelectorWindow.py @@ -56,12 +56,22 @@ class ObjectSelectorWindow(gtk.Window): self._dbstate = dbstate self._object_list = object_list self._current_object_type = None - + + # Create objects to hold the information about + # each object type + self._object_frames = {} + for object_type in object_list: + self._object_frames[object_type] = _ObjectTypeWidgets() + self.set_title("Add Person") # Selected object label - label = gtk.Label("Selected:") - label.set_alignment(xalign=1,yalign=0.5) + label = gtk.Label("Selected:") + label.set_use_markup(True) + label.set_alignment(xalign=0.9,yalign=0.5) + label.set_padding(self.__class__.__default_border_width, + self.__class__.__default_border_width) + label.show() sel_frame = gtk.Frame() @@ -70,12 +80,8 @@ class ObjectSelectorWindow(gtk.Window): sel_label_box = gtk.HBox() sel_label_box.show() - - self._object_frames = {} - + for object_type in object_list: - self._object_frames[object_type] = _ObjectTypeWidgets() - sel_label = gtk.Label("No Selected Object") sel_label.set_alignment(xalign=0,yalign=0.5) sel_label_box.pack_start(sel_label) @@ -91,10 +97,12 @@ class ObjectSelectorWindow(gtk.Window): label_box.show() # Object select + obj_label = gtk.Label("Show") + obj_label.set_use_markup(True) + obj_label.set_alignment(xalign=0.9,yalign=0.5) + obj_label.set_padding(self.__class__.__default_border_width, + self.__class__.__default_border_width) - obj_label = gtk.Label("Show") - obj_label.set_alignment(xalign=1,yalign=0.5) - obj_label.show() person_pixbuf = gtk.gdk.pixbuf_new_from_file("../person.svg") flist_pixbuf = gtk.gdk.pixbuf_new_from_file("../flist.svg") @@ -120,15 +128,20 @@ class ObjectSelectorWindow(gtk.Window): self._tool_combo.add_attribute(label_cell, 'text', 1) self._tool_combo.set_active(0) - self._tool_combo.show() self._tool_combo.connect('changed', lambda c: self._set_object_type(self._tool_list.get_value(c.get_active_iter(),2))) tool_box = gtk.HBox() tool_box.pack_start(obj_label,False,False) tool_box.pack_start(self._tool_combo,False,False) - tool_box.show() - + + # only show the object_list if there is more than + # one object_type requested. + if len(self._object_list) > 1: + self._tool_combo.show() + obj_label.show() + tool_box.show() + # Top box top_box = gtk.HBox() @@ -163,6 +176,10 @@ class ObjectSelectorWindow(gtk.Window): self._object_frames[object_type].frame.connect( 'selection-changed', self.on_selection_changed) + + self._object_frames[object_type].frame.connect( + 'add-object', + self.on_add) frame_box.pack_start(self._object_frames[object_type].frame,True,True) @@ -244,7 +261,7 @@ class ObjectSelectorWindow(gtk.Window): result.set_gramps_id(self._object_frames[self._current_object_type].selected_id) return result - def on_add(self,button): + def on_add(self,button=None): self.emit('add-object',self.get_result()) def on_selection_changed(self,widget,text,handle): diff --git a/src/ObjectSelector/_PersonFrame.py b/src/ObjectSelector/_PersonFrame.py index 3e8834357..ade75c350 100644 --- a/src/ObjectSelector/_PersonFrame.py +++ b/src/ObjectSelector/_PersonFrame.py @@ -19,6 +19,11 @@ class PersonFrame(ObjectFrameBase): gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_STRING)), + + 'add-object': (gobject.SIGNAL_RUN_LAST, + gobject.TYPE_NONE, + ()) + } __person_id_field = 1 @@ -43,12 +48,15 @@ class PersonFrame(ObjectFrameBase): self.emit('selection-changed',"No Selection","") - self._tree_frame.get_selection().connect('changed',handle_selection) - - + self._tree_frame.get_selection().connect('changed',handle_selection) self._tree_frame.get_selection().connect('changed',self.set_preview,self.__class__.__person_id_field) + self._tree_frame.get_tree().connect('row-activated',self._on_row_activated) - + def _on_row_activated(self,widget,path,col): + (model, iter) = widget.get_selection().get_selected() + if iter and model.get_value(iter,self.__class__.__person_id_field): + self.emit('add-object') + if gtk.pygtk_version < (2,8,0): gobject.type_register(PersonFrame) diff --git a/src/ObjectSelector/_PersonPreviewFrame.py b/src/ObjectSelector/_PersonPreviewFrame.py index b1256198e..d52df36ff 100644 --- a/src/ObjectSelector/_PersonPreviewFrame.py +++ b/src/ObjectSelector/_PersonPreviewFrame.py @@ -26,8 +26,6 @@ class PersonPreviewFrame(gtk.Frame): # test image self._image.set_from_file("../person.svg") - image_frame = gtk.Frame() - image_frame.add(self._image) # Text label = gtk.Label() @@ -41,7 +39,7 @@ class PersonPreviewFrame(gtk.Frame): # box box = gtk.VBox() - box.pack_start(image_frame) + box.pack_start(self._image,False,False) box.pack_start(label) diff --git a/src/ObjectSelector/_PersonTreeFrame.py b/src/ObjectSelector/_PersonTreeFrame.py index 61553b862..4445eed36 100644 --- a/src/ObjectSelector/_PersonTreeFrame.py +++ b/src/ObjectSelector/_PersonTreeFrame.py @@ -80,6 +80,9 @@ class PersonTreeFrame(gtk.Frame): def get_selection(self): return self._selection + def get_tree(self): + return self._tree + if gtk.pygtk_version < (2,8,0): gobject.type_register(PersonTreeFrame)