UI improvements

svn: r5775
This commit is contained in:
Richard Taylor 2006-01-17 14:54:46 +00:00
parent 345b35c3b9
commit d5ec08247d
8 changed files with 82 additions and 41 deletions

View File

@ -1,3 +1,9 @@
2006-01-17 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* 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 <rjt-gramps@thegrindstone.me.uk>
* src/ObjectSelector/_FamilyFrame.py, src/ObjectSelector/_FamilyPreviewFrame.py,
src/ObjectSelector/_ObjectFrameBase.py, src/ObjectSelector/_ObjectSelectorWindow.py,

View File

@ -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')

View File

@ -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)

View File

@ -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)

View File

@ -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("<b>Selected:</b>")
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("<b>Show</b>")
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):

View File

@ -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)

View File

@ -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)

View File

@ -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)