diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 7cb729976..e97c6811c 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,6 +1,7 @@ 2006-01-18 Don Allingham * src/DisplayTabs.py: mediatab improvements - * src/EditFamily.py: monitor for changed people and update if needed. + * src/EditFamily.py: monitor for changed people and update if needed, + CellRendererCombo for child relations 2006-01-18 Alex Roitman * src/GrampsDb/_GrampsBSDDB.py (load): Use BTREE for diff --git a/gramps2/src/DisplayTabs.py b/gramps2/src/DisplayTabs.py index f99d922c3..f2cd332da 100644 --- a/gramps2/src/DisplayTabs.py +++ b/gramps2/src/DisplayTabs.py @@ -95,7 +95,7 @@ class ButtonTab(GrampsTab): self.pack_start(vbox,False) def double_click(self, obj, event): - if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1: + if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: self.edit_button_clicked(obj) def add_button_clicked(self,obj): @@ -341,16 +341,19 @@ class ChildModel(gtk.ListStore): _HANDLE_COL = -8 - def __init__(self, child_list,db): - gtk.ListStore.__init__(self,int,str,str,str,str,str,str,str,str,str,int,int) + def __init__(self, family,db): + self.family = family + gtk.ListStore.__init__(self,int,str,str,str,str,str,str,str,str,str,str,str,int,int) self.db = db index = 1 - for child_handle in child_list: + for child_handle in family.get_child_handle_list(): child = db.get_person_from_handle(child_handle) self.append(row=[index, child.get_gramps_id(), NameDisplay.displayer.display(child), _GENDER[child.get_gender()], + self.column_father_rel(child), + self.column_mother_rel(child), self.column_birth_day(child), self.column_death_day(child), self.column_birth_place(child), @@ -362,6 +365,28 @@ class ChildModel(gtk.ListStore): ]) index += 1 + def display_rel(self,rtype): + if rtype[0] == RelLib.Family.CUSTOM: + return unicode(rtype[1]) + else: + return Utils.child_relations[rtype[0]] + + def column_father_rel(self,data): + chandle = data.handle + fhandle = self.family.handle + for (handle, mrel, frel) in data.get_parent_family_handle_list(): + if handle == fhandle: + return self.display_rel(frel) + return "" + + def column_mother_rel(self,data): + chandle = data.handle + fhandle = self.family.handle + for (handle, mrel, frel) in data.get_parent_family_handle_list(): + if handle == fhandle: + return self.display_rel(mrel) + return "" + def column_birth_day(self,data): event_ref = data.get_birth_ref() if event_ref and event_ref.ref: diff --git a/gramps2/src/EditFamily.py b/gramps2/src/EditFamily.py index 465932e6c..1781a89b4 100644 --- a/gramps2/src/EditFamily.py +++ b/gramps2/src/EditFamily.py @@ -90,13 +90,15 @@ class AttrEmbedList(EmbeddedList): class ChildEmbedList(EmbeddedList): - _HANDLE_COL = 8 + _HANDLE_COL = 10 column_names = [ (_('#'),0) , (_('ID'),1) , (_('Name'),9), (_('Gender'),3), + (_('Paternal'),12), + (_('Maternal'),13), (_('Birth Date'),10), (_('Death Date'),11), (_('Birth Place'),6), @@ -108,14 +110,51 @@ class ChildEmbedList(EmbeddedList): EmbeddedList.__init__(self, dbstate, uistate, track, _('Children'), ChildModel) + def build_columns(self): + for column in self.columns: + self.tree.remove_column(column) + self.columns = [] + + for pair in self.column_order(): + if not pair[0]: + continue + name = self.column_names[pair[1]][0] + if pair[1] == 4 or pair[1] == 5: + model = gtk.ListStore(str,int) + for x in Utils.child_relations.keys(): + model.append(row=[Utils.child_relations[x],x]) + render = gtk.CellRendererCombo() + render.set_property('editable',True) + render.set_property('model',model) + render.set_property('text-column',0) + else: + render = gtk.CellRendererText() + + column = gtk.TreeViewColumn(name, render, text=pair[1]) + column = gtk.TreeViewColumn(name, render, text=pair[1]) + column.set_resizable(True) + column.set_min_width(40) + column.set_sort_column_id(self.column_names[pair[1]][1]) + self.columns.append(column) + self.tree.append_column(column) + def get_icon_name(self): return 'gramps-person' + def set_label(self): + if len(self.family.get_child_handle_list()): + self.tab_image.show() + self.label.set_text("%s" % self.tab_name) + self.label.set_use_markup(True) + else: + self.tab_image.hide() + self.label.set_text(self.tab_name) + def get_data(self): - return self.family.get_child_handle_list() + return self.family def column_order(self): - return self.dbstate.db.get_child_column_order() + return [(1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(0,8),(0,9)] def add_button_clicked(self,obj): print "Add Button Clicked"