From 0e48f23eb20592cd07d6f97fb9cb9000d877d24d Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 13 Jan 2006 22:28:54 +0000 Subject: [PATCH] * src/DisplayTabs.py: Move event list * src/EditFamily.py: add editing of people, add relationship type * src/EventEdit.py: move event list * src/FamilyView.py: remove common widgets * src/gramps.glade: EditFamily changes * src/GrampsWidgets.py: Common widgets svn: r5749 --- gramps2/ChangeLog | 8 ++ gramps2/src/DisplayTabs.py | 36 +++++- gramps2/src/EditFamily.py | 116 ++++++++++--------- gramps2/src/EventEdit.py | 20 ++-- gramps2/src/FamilyView.py | 123 +++++---------------- gramps2/src/gramps.glade | 221 ++++++++++++++++++------------------- 6 files changed, 255 insertions(+), 269 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 2c7a7810e..d2f66126c 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,11 @@ +2006-01-13 Don Allingham + * src/DisplayTabs.py: Move event list + * src/EditFamily.py: add editing of people, add relationship type + * src/EventEdit.py: move event list + * src/FamilyView.py: remove common widgets + * src/gramps.glade: EditFamily changes + * src/GrampsWidgets.py: Common widgets + 2006-01-13 Alex Roitman * src/ViewManager.py: Proper label change for Undo/Redo. diff --git a/gramps2/src/DisplayTabs.py b/gramps2/src/DisplayTabs.py index 7231ee984..bc71dd18e 100644 --- a/gramps2/src/DisplayTabs.py +++ b/gramps2/src/DisplayTabs.py @@ -52,8 +52,6 @@ class EmbeddedList(gtk.HBox): self.tree.remove_column(column) self.columns = [] - #for pair in self.parent.db.get_child_column_order(): - for pair in self.column_order(): if not pair[0]: continue @@ -74,6 +72,40 @@ class EmbeddedList(gtk.HBox): def get_tab_widget(self): return gtk.Label('UNDEFINED') +class EventEmbedList(EmbeddedList): + + column_names = [ + (_('Description'),0), + (_('ID'),1), + (_('Type'),2), + (_('Date'),3), + (_('Place'),4), + (_('Cause'),5), + ] + + def __init__(self,db,obj): + self.obj = obj + self.hbox = gtk.HBox() + self.label = gtk.Label(_('Events')) + self.hbox.show_all() + + EmbeddedList.__init__(self, db, EventRefModel) + + def get_data(self): + return self.obj.get_event_ref_list() + + def column_order(self): + return ((1,0),(1,1),(1,2),(1,3),(1,4),(1,5)) + + def set_label(self): + if len(self.get_data()): + self.label.set_text("%s" % _('Events')) + self.label.set_use_markup(True) + else: + self.label.set_text(_('Events')) + + def get_tab_widget(self): + return self.label class NoteTab(gtk.HBox): diff --git a/gramps2/src/EditFamily.py b/gramps2/src/EditFamily.py index c04c6b5aa..0b57a2985 100644 --- a/gramps2/src/EditFamily.py +++ b/gramps2/src/EditFamily.py @@ -49,53 +49,19 @@ import gtk.glade #------------------------------------------------------------------------- import const import Utils -import ImageSelect import NameDisplay import DisplayState import Spell import GrampsDisplay import RelLib -import ListModel import ReportUtils import DisplayTabs +import AutoComp +import GrampsWidgets from DdTargets import DdTargets from WindowUtils import GladeIf -class EventEmbedList(DisplayTabs.EmbeddedList): - - column_names = [ - (_('Description'),0), - (_('ID'),1), - (_('Type'),2), - (_('Date'),3), - (_('Place'),4), - (_('Cause'),5), - ] - - def __init__(self,db,family): - self.family = family - self.hbox = gtk.HBox() - self.label = gtk.Label(_('Events')) - self.hbox.show_all() - - DisplayTabs.EmbeddedList.__init__(self, db, DisplayTabs.EventRefModel) - - def get_data(self): - return self.family.get_event_ref_list() - - def column_order(self): - return ((1,0),(1,1),(1,2),(1,3),(1,4),(1,5)) - - def set_label(self): - if len(self.get_data()): - self.label.set_text("%s" % _('Events')) - self.label.set_use_markup(True) - else: - self.label.set_text(_('Events')) - - def get_tab_widget(self): - return self.label class AttrEmbedList(DisplayTabs.EmbeddedList): @@ -203,6 +169,9 @@ class EditFamily(DisplayState.ManagedWindow): if self.family: self.load_data() + self.mname = None + self.fname = None + self.show() def build_menu_names(self,obj): @@ -216,44 +185,57 @@ class EditFamily(DisplayState.ManagedWindow): self.gladeif = GladeIf(self.top) self.window = self.top.get_widget("marriageEditor") - self.fname = self.top.get_widget('fname') self.fbirth = self.top.get_widget('fbirth') self.fdeath = self.top.get_widget('fdeath') - self.mname = self.top.get_widget('mname') self.mbirth = self.top.get_widget('mbirth') self.mdeath = self.top.get_widget('mdeath') self.gid = self.top.get_widget('gid') - self.reltype= self.top.get_widget('relationship_type') + self.reltype= self.top.get_widget('marriage_type') self.mbutton= self.top.get_widget('mbutton') self.fbutton= self.top.get_widget('fbutton') + self.mbox = self.top.get_widget('mbox') + self.fbox = self.top.get_widget('fbox') + self.ok = self.top.get_widget('ok') self.cancel = self.top.get_widget('cancel') self.vbox = self.top.get_widget('vbox') - + self.child_list = self.top.get_widget('child_list') + + rel_types = dict(Utils.family_relations) + + mtype = self.family.get_relationship() + if mtype: + defval = mtype[0] + else: + defval = None + + self.type_sel = AutoComp.StandardCustomSelector( + rel_types, self.reltype, RelLib.Family.CUSTOM, defval) + self.notebook = gtk.Notebook() self.notebook.show() self.vbox.pack_start(self.notebook,True) - - self.child_list = self.top.get_widget('child_list') self.cancel.connect('clicked', self.close_window) def load_data(self): - self.load_parent(self.family.get_father_handle(),self.fname, - self.fbirth, self.fdeath, self.fbutton) - self.load_parent(self.family.get_mother_handle(),self.mname, - self.mbirth, self.mdeath, self.mbutton) + self.update_father(self.family.get_father_handle()) + self.update_mother(self.family.get_mother_handle()) + + self.mbutton.connect('clicked',self.mother_clicked) + self.fbutton.connect('clicked',self.father_clicked) self.child_list = ChildEmbedList(self.dbstate.db, self.family) - self.event_list = EventEmbedList(self.dbstate.db, self.family) + self.event_list = DisplayTabs.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.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()) @@ -272,10 +254,40 @@ class EditFamily(DisplayState.ManagedWindow): self.gid.set_text(self.family.get_gramps_id()) + def update_father(self,handle): + self.load_parent(handle, self.fbox, self.fbirth, self.fdeath, self.fbutton) - def load_parent(self,handle,name_obj,birth_obj,death_obj,btn_obj): + def update_mother(self,handle): + self.load_parent(handle, self.mbox, self.mbirth, self.mdeath, self.mbutton) + + def mother_clicked(self,obj): + handle = self.family.get_mother_handle() + if handle: + self.family.set_mother_handle(None) + self.update_mother(None) + else: + print "Call person selector" + + def father_clicked(self,obj): + handle = self.family.get_father_handle() + if handle: + self.family.set_father_handle(None) + self.update_father(None) + else: + print "Call person selector" + + def edit_person(self,obj,event,handle): + if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1: + import EditPerson + person = self.dbstate.db.get_person_from_handle(handle) + EditPerson.EditPerson(self.dbstate, self.uistate, self.track, person) + + def load_parent(self,handle,box,birth_obj,death_obj,btn_obj): is_used = handle != None + + for i in box.get_children(): + box.remove(i) btn_obj.remove(btn_obj.get_children()[0]) @@ -292,6 +304,11 @@ class EditFamily(DisplayState.ManagedWindow): del_image.show() del_image.set_from_stock(gtk.STOCK_REMOVE,gtk.ICON_SIZE_BUTTON) btn_obj.add(del_image) + + box.pack_start(GrampsWidgets.LinkBox( + GrampsWidgets.BasicLabel(name), + GrampsWidgets.IconButton(self.edit_person,person.handle) + )) else: name = "" birth = "" @@ -302,7 +319,6 @@ class EditFamily(DisplayState.ManagedWindow): add_image.set_from_stock(gtk.STOCK_ADD,gtk.ICON_SIZE_BUTTON) btn_obj.add(add_image) - name_obj.set_text(name) birth_obj.set_text(birth) death_obj.set_text(death) diff --git a/gramps2/src/EventEdit.py b/gramps2/src/EventEdit.py index f7b6063e3..ef72f4502 100644 --- a/gramps2/src/EventEdit.py +++ b/gramps2/src/EventEdit.py @@ -240,20 +240,20 @@ class EventEditor(DisplayState.ManagedWindow): date_stat, self.window) - self.icon_list = self.top.get_widget("iconlist") - self.gallery = ImageSelect.Gallery(event, self.db.commit_event, - self.path, self.icon_list, - self.db,self,self.window) +# self.icon_list = self.top.get_widget("iconlist") +# self.gallery = ImageSelect.Gallery(event, self.db.commit_event, +# self.path, self.icon_list, +# self.db,self,self.window) self.gladeif.connect('event_edit','delete_event',self.on_delete_event) self.gladeif.connect('button111','clicked',self.close) self.gladeif.connect('ok','clicked',self.on_event_edit_ok_clicked) self.gladeif.connect('button126','clicked',self.on_help_clicked) self.gladeif.connect('notebook','switch_page',self.on_switch_page) - self.gladeif.connect('add_obj','clicked',self.gallery.on_add_media_clicked) - self.gladeif.connect('sel_obj','clicked',self.gallery.on_select_media_clicked) - self.gladeif.connect('button172','clicked',self.gallery.on_edit_media_clicked) - self.gladeif.connect('del_obj','clicked',self.gallery.on_delete_media_clicked) +# self.gladeif.connect('add_obj','clicked',self.gallery.on_add_media_clicked) +# self.gladeif.connect('sel_obj','clicked',self.gallery.on_select_media_clicked) +# self.gladeif.connect('button172','clicked',self.gallery.on_edit_media_clicked) +# self.gladeif.connect('del_obj','clicked',self.gallery.on_delete_media_clicked) self.top.get_widget('del_obj').set_sensitive(not noedit) self.top.get_widget('sel_obj').set_sensitive(not noedit) @@ -285,12 +285,12 @@ class EventEditor(DisplayState.ManagedWindow): def on_delete_event(self,obj,b): self.gladeif.close() - self.gallery.close() +# self.gallery.close() gc.collect() def close(self,obj): self.gladeif.close() - self.gallery.close() +# self.gallery.close() self.window.destroy() gc.collect() diff --git a/gramps2/src/FamilyView.py b/gramps2/src/FamilyView.py index 8bc92c803..97eedf084 100644 --- a/gramps2/src/FamilyView.py +++ b/gramps2/src/FamilyView.py @@ -30,6 +30,7 @@ import DateHandler import ImgManip import ReportUtils import GrampsKeys +import GrampsWidgets _GenderCode = { RelLib.Person.MALE : u'\u2642', @@ -77,76 +78,6 @@ class AttachList: self.max_x = max(self.max_x,x1) self.max_y = max(self.max_y,y1) -class LinkLabel(gtk.EventBox): - - def __init__(self,label,func,handle): - gtk.EventBox.__init__(self) - self.orig_text = cgi.escape(label[0]) - self.gender = label[1] - text = '%s' % self.orig_text - if label[1]: - text += u' %s' % label[1] - - self.label = gtk.Label(text) - self.label.set_use_markup(True) - self.label.set_alignment(0,0.5) - - self.add(self.label) - self.set_visible_window(False) - - self.connect('button-press-event',func,handle) - self.connect('enter-notify-event',self.enter_text,handle) - self.connect('leave-notify-event',self.leave_text,handle) - - def enter_text(self,obj,event,handle): - text = '%s' % self.orig_text - if self.gender: - text += u" %s" % self.gender - self.label.set_text(text) - self.label.set_use_markup(True) - - def leave_text(self,obj,event,handle): - text = '%s' % self.orig_text - if self.gender: - text += u" %s" % self.gender - self.label.set_text(text) - self.label.set_use_markup(True) - -class IconButton(gtk.EventBox): - - def __init__(self,func,handle,icon=gtk.STOCK_EDIT): - gtk.EventBox.__init__(self) - image = gtk.Image() - image.set_from_stock(icon,gtk.ICON_SIZE_MENU) - image.show() - self.add(image) - self.show() - self.connect('button-press-event',func,handle) - -class LinkBox(gtk.HBox): - - def __init__(self,link,button): - gtk.HBox.__init__(self) - self.set_spacing(6) - self.pack_start(link,False) - self.pack_start(button,False) - self.show() - -class BasicLabel(gtk.Label): - - def __init__(self,text): - gtk.Label.__init__(self,text) - self.set_alignment(0,0.5) - self.show() - -class MarkupLabel(gtk.Label): - - def __init__(self,text): - gtk.Label.__init__(self,text) - self.set_alignment(0,0.5) - self.set_use_markup(True) - self.show() - class FamilyView(PageView.PersonNavView): def __init__(self,dbstate,uistate): @@ -322,10 +253,10 @@ class FamilyView(PageView.PersonNavView): name = NameDisplay.displayer.display(person) text = '%s %s' % (cgi.escape(name), _GenderCode[person.gender]) - label = MarkupLabel(text) - button = IconButton(self.edit_button_press,person.handle) + label = GrampsWidgets.MarkupLabel(text) + button = GrampsWidgets.IconButton(self.edit_button_press,person.handle) - hbox = LinkBox(label,button) + hbox = GrampsWidgets.LinkBox(label,button) # GRAMPS ID self.row = 1 @@ -397,33 +328,33 @@ class FamilyView(PageView.PersonNavView): self.write_person_data(ename,'') def write_person_data(self,title,data): - self.attach.attach(BasicLabel(title),_ALABEL_START, + self.attach.attach(GrampsWidgets.BasicLabel(title),_ALABEL_START, _ALABEL_STOP,self.row,self.row+1, xoptions=gtk.FILL|gtk.SHRINK) - self.attach.attach(BasicLabel(data),_ADATA_START,_ADATA_STOP, + self.attach.attach(GrampsWidgets.BasicLabel(data),_ADATA_START,_ADATA_STOP, self.row,self.row+1) self.row += 1 def write_label(self,title,family): msg = "%s" % cgi.escape(title) - self.attach.attach(MarkupLabel(msg),_LABEL_START,_LABEL_STOP, + self.attach.attach(GrampsWidgets.MarkupLabel(msg),_LABEL_START,_LABEL_STOP, self.row,self.row+1,gtk.SHRINK|gtk.FILL) if family: value = family.gramps_id else: value = "" - self.attach.attach(BasicLabel(value),_DATA_START,_DATA_STOP, + self.attach.attach(GrampsWidgets.BasicLabel(value),_DATA_START,_DATA_STOP, self.row,self.row+1,gtk.SHRINK|gtk.FILL) hbox = gtk.HBox() hbox.set_spacing(6) - add = IconButton(self.add_family,None,gtk.STOCK_ADD) + add = GrampsWidgets.IconButton(self.add_family,None,gtk.STOCK_ADD) hbox.pack_start(add,False) if family: - edit = IconButton(self.edit_family,family.handle,gtk.STOCK_EDIT) + edit = GrampsWidgets.IconButton(self.edit_family,family.handle,gtk.STOCK_EDIT) hbox.pack_start(edit,False) - delete = IconButton(self.delete_family,family.handle,gtk.STOCK_REMOVE) + delete = GrampsWidgets.IconButton(self.delete_family,family.handle,gtk.STOCK_REMOVE) hbox.pack_start(delete,False) self.attach.attach(hbox,_BTN_START,_BTN_STOP,self.row,self.row+1) self.row += 1 @@ -437,15 +368,15 @@ class FamilyView(PageView.PersonNavView): if self.show_details: value = self.info_string(family.get_father_handle()) if value: - self.attach.attach(BasicLabel(value),_PDTLS_START, + self.attach.attach(GrampsWidgets.BasicLabel(value),_PDTLS_START, _PDTLS_STOP,self.row, self.row+1) self.row += 1 self.write_person(_('Mother'),family.get_mother_handle()) if self.show_details: value = self.info_string(family.get_mother_handle()) if value: - self.attach.attach(BasicLabel(value),_PDTLS_START,_PDTLS_STOP, - self.row, self.row+1) + self.attach.attach(GrampsWidgets.BasicLabel(value),_PDTLS_START, + _PDTLS_STOP, self.row, self.row+1) self.row += 1 if self.show_siblings: @@ -466,13 +397,14 @@ class FamilyView(PageView.PersonNavView): else: format = "%s" - label = MarkupLabel(format % cgi.escape(title)) + label = GrampsWidgets.MarkupLabel(format % cgi.escape(title)) self.attach.attach(label,_PLABEL_START,_PLABEL_STOP,self.row,self.row+1, xoptions=gtk.FILL|gtk.SHRINK) - link_label = LinkLabel(self.get_name(handle,True),self.button_press,handle) - button = IconButton(self.edit_button_press,handle) - self.attach.attach(LinkBox(link_label,button),_PDATA_START, + link_label = GrampsWidgets.LinkLabel(self.get_name(handle,True), + self.button_press,handle) + button = GrampsWidgets.IconButton(self.edit_button_press,handle) + self.attach.attach(GrampsWidgets.LinkBox(link_label,button),_PDATA_START, _PDATA_STOP,self.row,self.row+1) self.row += 1 @@ -482,13 +414,14 @@ class FamilyView(PageView.PersonNavView): else: format = "%s" - label = MarkupLabel(format % cgi.escape(title)) + label = GrampsWidgets.MarkupLabel(format % cgi.escape(title)) self.attach.attach(label,_CLABEL_START,_CLABEL_STOP,self.row,self.row+1, xoptions=gtk.FILL|gtk.SHRINK) - link_label = LinkLabel(self.get_name(handle,True),self.button_press,handle) - button = IconButton(self.edit_button_press,handle) - self.attach.attach(LinkBox(link_label,button),_CDATA_START, + link_label = GrampsWidgets.LinkLabel(self.get_name(handle,True), + self.button_press,handle) + button = GrampsWidgets.IconButton(self.edit_button_press,handle) + self.attach.attach(GrampsWidgets.LinkBox(link_label,button),_CDATA_START, _CDATA_STOP,self.row,self.row+1, xoptions=gtk.EXPAND|gtk.FILL) @@ -497,13 +430,13 @@ class FamilyView(PageView.PersonNavView): if self.show_details: value = self.info_string(handle) if value: - self.attach.attach(BasicLabel(value),_CDTLS_START, + self.attach.attach(GrampsWidgets.BasicLabel(value),_CDTLS_START, _CDTLS_STOP,self.row, self.row+1) self.row += 1 def write_data(self,title,start_col=_SDATA_START,stop_col=_SDATA_STOP): - self.attach.attach(BasicLabel(title),start_col,stop_col,self.row, - self.row+1, xoptions=gtk.EXPAND|gtk.FILL) + self.attach.attach(GrampsWidgets.BasicLabel(title),start_col,stop_col, + self.row, self.row+1, xoptions=gtk.EXPAND|gtk.FILL) self.row += 1 def info_string(self,handle): @@ -604,7 +537,7 @@ class FamilyView(PageView.PersonNavView): value = self.info_string(handle) if value: - self.attach.attach(BasicLabel(value),_PDTLS_START, + self.attach.attach(GrampsWidgets.BasicLabel(value),_PDTLS_START, _PDTLS_STOP,self.row, self.row+1) self.row += 1 if not self.write_marriage(family): diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index 341ed41b9..911a1ce3b 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -1907,7 +1907,7 @@ 0 - + 6 True 4 @@ -2028,61 +2028,6 @@ - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 2 - 3 - 2 - 3 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 2 - 3 - 1 - 2 - - - - True @@ -2154,6 +2099,53 @@ + + + + True + False + 0 + + + + + + + 2 + 3 + 1 + 2 + fill + fill + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 2 + 3 + 2 + 3 + + + 0 @@ -2163,7 +2155,7 @@ - + 6 True 4 @@ -2256,34 +2248,6 @@ - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 2 - 3 - 2 - 3 - fill - - - - True @@ -2312,33 +2276,6 @@ - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 2 - 3 - 1 - 2 - - - - True @@ -2410,6 +2347,66 @@ fill + + + + True + False + 0 + + + + True + False + 0 + + + + + + + 0 + True + True + + + + + 2 + 3 + 1 + 2 + fill + fill + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 2 + 3 + 2 + 3 + + + 0