gramps/gramps2/src/ObjectSelector/_FamilyFrame.py

75 lines
2.4 KiB
Python
Raw Normal View History

#for debug, remove later
import sys
sys.path.append("..")
import gtk
import gobject
from _ObjectFrameBase import ObjectFrameBase
from _FamilyFilterFrame import FamilyFilterFrame
from _FamilyPreviewFrame import FamilyPreviewFrame
from _FamilyTreeFrame import FamilyTreeFrame
class FamilyFrame(ObjectFrameBase):
__gproperties__ = {}
__gsignals__ = {
'selection-changed' : (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
(gobject.TYPE_STRING,
gobject.TYPE_STRING)),
2006-01-17 20:24:46 +05:30
'add-object': (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
())
}
__person_id_field = 0
def __init__(self,
dbstate,
uistate):
ObjectFrameBase.__init__(self,
dbstate=dbstate,
uistate=uistate,
filter_frame = FamilyFilterFrame(dbstate),
preview_frame = FamilyPreviewFrame(dbstate),
tree_frame = FamilyTreeFrame(dbstate))
2006-01-17 20:24:46 +05:30
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)
2006-01-17 20:24:46 +05:30
self._tree_frame.get_tree().connect('row-activated',self._on_row_activated)
def new_object(self,button):
pass
2006-01-17 20:24:46 +05:30
def _handle_selection(self,treeselection):
(model, iter) = treeselection.get_selected()
if iter and model.get_value(iter,self.__class__.__person_id_field):
2006-01-17 20:37:01 +05:30
self.emit('selection-changed', "%s / %s [%s]" % (
2006-01-17 20:24:46 +05:30
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')
2006-01-17 20:24:46 +05:30
if gtk.pygtk_version < (2,8,0):
gobject.type_register(FamilyFrame)
if __name__ == "__main__":
pass