diff --git a/gramps2/src/DisplayTabs.py b/gramps2/src/DisplayTabs.py index cfe39e80f..7231ee984 100644 --- a/gramps2/src/DisplayTabs.py +++ b/gramps2/src/DisplayTabs.py @@ -75,6 +75,85 @@ class EmbeddedList(gtk.HBox): return gtk.Label('UNDEFINED') +class NoteTab(gtk.HBox): + + def __init__(self, note_obj): + gtk.HBox.__init__(self) + self.note_obj = note_obj + + self.text = gtk.TextView() + scroll = gtk.ScrolledWindow() + scroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) + scroll.add_with_viewport(self.text) + self.pack_start(scroll,True) + if note_obj: + self.text.get_buffer().insert_at_cursor(note_obj.get()) + + self.show_all() + + def rebuild(self): + pass + + def get_tab_widget(self): + return gtk.Label(_('Note')) + +class GalleryTab(gtk.HBox): + + def __init__(self,db, media_list): + gtk.HBox.__init__(self) + self.db = db + self.media_list = media_list + + self.hbox = gtk.HBox() + self.label = gtk.Label(_('Children')) + + self.iconmodel= gtk.ListStore(gtk.gdk.Pixbuf,str) + self.iconlist = gtk.IconView() + self.iconlist.set_pixbuf_column(0) + self.iconlist.set_text_column(1) + self.iconlist.set_model(self.iconmodel) + + scroll = gtk.ScrolledWindow() + scroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) + scroll.add_with_viewport(self.iconlist) + self.pack_start(scroll,True) + + self.rebuild() + self.show_all() + + def get_data(self): + return self.media_list + + def rebuild(self): + for ref in self.media_list: + obj = self.db.get_object_from_handle(ref.get_reference_handle()) + pixbuf = self.get_image(obj) + self.iconmodel.append(row=[pixbuf,obj.get_description()]) + self.set_label() + + def get_image(self,obj): + import ImgManip + + mtype = obj.get_mime_type() + if mtype[0:5] == "image": + image = ImgManip.get_thumbnail_image(obj.get_path()) + else: + image = GrampsMime.find_mime_type_pixbuf(mtype) + if not image: + image = gtk.gdk.pixbuf_new_from_file(const.icon) + return image + + def get_tab_widget(self): + return self.label + + def set_label(self): + if len(self.get_data()): + self.label.set_text("%s" % _('Gallery')) + self.label.set_use_markup(True) + else: + self.label.set_text(_('Gallery')) + + #------------------------------------------------------------------------- # # ChildModel @@ -203,3 +282,45 @@ class EventRefModel(gtk.ListStore): return self.db.get_place_from_handle(place_handle).get_title() return u"" + +#------------------------------------------------------------------------- +# +# EventRefModel +# +#------------------------------------------------------------------------- + +class AttrModel(gtk.ListStore): + + def __init__(self,attr_list,db): + gtk.ListStore.__init__(self,str,str) + self.db = db + index = 1 + for attr in attr_list: + self.append(row=[ + self.type_name(attr), + attr.get_value(), + ]) + index += 1 + + def type_name(self, attr): + t = attr.get_type() + if t[0] == RelLib.Attribute.CUSTOM: + return t[1] + else: + return Utils.personal_attributes[t[0]] + + +class FamilyAttrModel(AttrModel): + + def __init__(self,attr_list,db): + AttrModel.__init__(self,attr_list,db) + + def type_name(self, attr): + t = attr.get_type() + if t[0] == RelLib.Attribute.CUSTOM: + return t[1] + else: + return Utils.family_attributes[t[0]] + + + diff --git a/gramps2/src/EditFamily.py b/gramps2/src/EditFamily.py index 182b93cc3..c04c6b5aa 100644 --- a/gramps2/src/EditFamily.py +++ b/gramps2/src/EditFamily.py @@ -97,6 +97,37 @@ class EventEmbedList(DisplayTabs.EmbeddedList): def get_tab_widget(self): return self.label +class AttrEmbedList(DisplayTabs.EmbeddedList): + + column_names = [ + (_('Type'),0), + (_('Value'),1), + ] + + def __init__(self,db,data): + self.data = data + self.hbox = gtk.HBox() + self.label = gtk.Label(_('Attributes')) + self.hbox.show_all() + + DisplayTabs.EmbeddedList.__init__(self, db, DisplayTabs.FamilyAttrModel) + + def get_data(self): + return self.data + + def column_order(self): + return ((1,0),(1,1)) + + def set_label(self): + if len(self.get_data()): + self.label.set_text("%s" % _('Attributes')) + self.label.set_use_markup(True) + else: + self.label.set_text(_('Attributes')) + + def get_tab_widget(self): + return self.label + class ChildEmbedList(DisplayTabs.EmbeddedList): column_names = [ @@ -114,10 +145,28 @@ class ChildEmbedList(DisplayTabs.EmbeddedList): self.family = family self.hbox = gtk.HBox() self.label = gtk.Label(_('Children')) + self.add_btn = gtk.Button() + self.add_btn.add(gtk.image_new_from_stock(gtk.STOCK_ADD, + gtk.ICON_SIZE_BUTTON)) + self.edit_btn = gtk.Button() + self.edit_btn.add(gtk.image_new_from_stock(gtk.STOCK_EDIT, + gtk.ICON_SIZE_BUTTON)) + self.del_btn = gtk.Button() + self.del_btn.add(gtk.image_new_from_stock(gtk.STOCK_REMOVE, + gtk.ICON_SIZE_BUTTON)) self.hbox.show_all() - + DisplayTabs.EmbeddedList.__init__(self, db, DisplayTabs.ChildModel) + self.set_spacing(6) + vbox = gtk.VBox() + vbox.set_spacing(6) + vbox.pack_start(self.add_btn,False) + vbox.pack_start(self.edit_btn,False) + vbox.pack_start(self.del_btn,False) + vbox.show_all() + self.pack_start(vbox,False) + def get_data(self): return self.family.get_child_handle_list() @@ -202,6 +251,9 @@ class EditFamily(DisplayState.ManagedWindow): self.child_list = ChildEmbedList(self.dbstate.db, self.family) self.event_list = EventEmbedList(self.dbstate.db, self.family) + self.attr_list = AttrEmbedList(self.dbstate.db, self.family.get_attribute_list()) + self.note_tab = DisplayTabs.NoteTab(self.family.get_note_object()) + self.gallery_tab = DisplayTabs.GalleryTab(self.dbstate.db,self.family.get_media_list()) self.notebook.insert_page(self.child_list) self.notebook.set_tab_label(self.child_list,self.child_list.get_tab_widget()) @@ -209,6 +261,15 @@ class EditFamily(DisplayState.ManagedWindow): self.notebook.insert_page(self.event_list) self.notebook.set_tab_label(self.event_list,self.event_list.get_tab_widget()) + self.notebook.insert_page(self.attr_list) + self.notebook.set_tab_label(self.attr_list,self.attr_list.get_tab_widget()) + + self.notebook.insert_page(self.note_tab) + self.notebook.set_tab_label(self.note_tab,self.note_tab.get_tab_widget()) + + self.notebook.insert_page(self.gallery_tab) + self.notebook.set_tab_label(self.gallery_tab,self.gallery_tab.get_tab_widget()) + self.gid.set_text(self.family.get_gramps_id())