diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 4ac9923c4..512b2fef4 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2005-04-27 Don Allingham + * src/EditPerson.py: rewrite of tabbed lists + * src/EventEdit.py: bold the label + * src/ListModel.py: allow column types to be specified + * src/edit_person.glade: tab improvements + 2005-04-27 Martin Hawlisch * src/gramps_main.py (__init__): Avoid TypeError in schema error message diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index 7ef776c02..a787edf89 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -39,7 +39,7 @@ import gtk import gtk.glade import gobject import gnome -from gtk.gdk import ACTION_COPY, BUTTON1_MASK, INTERP_BILINEAR, pixbuf_new_from_file +import gtk.gdk #------------------------------------------------------------------------- # @@ -60,6 +60,12 @@ import Date import DateHandler import TransTable import NameDisplay +import UrlEdit +import NameEdit +import NoteEdit +import AttrEdit +import EventEdit +import AddrEdit from QuestionDialog import WarningDialog, ErrorDialog, SaveDialog, QuestionDialog2 @@ -112,8 +118,6 @@ class EditPerson: self.not_loaded = True self.lds_not_loaded = True self.lists_changed = False - self.update_birth = False - self.update_death = False self.pdmap = {} self.add_places = [] self.name_display = NameDisplay.displayer @@ -143,16 +147,21 @@ class EditPerson: self.gender.set_sensitive(mod) self.private = self.get_widget('private') self.private.set_sensitive(mod) - self.name_delete_btn = self.top.get_widget('aka_delete') - self.name_edit_btn = self.top.get_widget('aka_edit') - self.web_delete_btn = self.top.get_widget('delete_url') - self.web_edit_btn = self.top.get_widget('edit_url') - self.event_delete_btn = self.top.get_widget('event_del') - self.event_edit_btn = self.top.get_widget('event_edit') - self.attr_delete_btn = self.top.get_widget('attr_del') - self.attr_edit_btn = self.top.get_widget('attr_edit_btn') - self.addr_delete_btn = self.top.get_widget('addr_del') - self.addr_edit_btn = self.top.get_widget('addr_edit_btn') + name_delete_btn = self.top.get_widget('aka_del') + name_add_btn = self.top.get_widget('aka_add') + name_edit_btn = self.top.get_widget('aka_edit') + web_delete_btn = self.top.get_widget('url_del') + web_edit_btn = self.top.get_widget('url_edit') + web_add_btn = self.top.get_widget('url_add') + event_delete_btn = self.top.get_widget('event_del') + event_add_btn = self.top.get_widget('event_add') + event_edit_btn = self.top.get_widget('event_edit') + attr_add_btn = self.top.get_widget('attr_add') + attr_delete_btn = self.top.get_widget('attr_del') + attr_edit_btn = self.top.get_widget('attr_edit') + addr_add_btn = self.top.get_widget('addr_add') + addr_delete_btn = self.top.get_widget('addr_del') + addr_edit_btn = self.top.get_widget('addr_edit') self.notes_field = self.get_widget("personNotes") self.notes_field.set_editable(mod) @@ -160,38 +169,15 @@ class EditPerson: self.flowed.set_sensitive(mod) self.preform = self.get_widget("preform") self.preform.set_sensitive(mod) - self.attr_conf_field = self.get_widget("attr_conf") - self.addr_conf_field = self.get_widget("addr_conf") - self.name_conf_field = self.get_widget("name_conf") - self.attr_src_field = self.get_widget("attr_srcinfo") - self.name_src_field = self.get_widget("name_srcinfo") - self.addr_src_field = self.get_widget("addr_srcinfo") self.attr_list = self.get_widget("attr_list") - self.attr_type = self.get_widget("attr_type") - self.attr_value = self.get_widget("attr_value") self.web_list = self.get_widget("web_list") - self.web_url = self.get_widget("web_url") self.web_go = self.get_widget("web_go") - self.web_description = self.get_widget("url_des") self.addr_list = self.get_widget("address_list") - self.addr_start = self.get_widget("address_start") - self.addr_street = self.get_widget("street") - self.addr_city = self.get_widget("city") - self.addr_state = self.get_widget("state") - self.addr_country = self.get_widget("country") - self.addr_postal = self.get_widget("postal") - self.addr_phone = self.get_widget("phone") self.event_list = self.get_widget("eventList") self.edit_person = self.get_widget("editPerson") self.name_list = self.get_widget("nameList") - self.alt_given_field = self.get_widget("alt_given") - self.alt_last_field = self.get_widget("alt_last") - self.alt_title_field = self.get_widget("alt_title") - self.alt_suffix_field = self.get_widget("alt_suffix") - self.alt_prefix_field = self.get_widget("alt_prefix") self.name_type_field = self.get_widget("name_type") self.ntype_field = self.get_widget("ntype") - self.ntype_field.set_sensitive(mod) self.suffix = self.get_widget("suffix") self.suffix.set_editable(mod) self.prefix = self.get_widget("prefix") @@ -202,27 +188,20 @@ class EditPerson: self.title.set_editable(mod) self.surname = self.get_widget("surname") self.surname.set_editable(mod) - self.addr_note = self.get_widget("addr_note") - self.addr_source = self.get_widget("addr_source") - self.attr_note = self.get_widget("attr_note") - self.attr_source = self.get_widget("attr_source") - self.name_note = self.get_widget("name_note") - self.name_source = self.get_widget("name_source") self.gid = self.get_widget("gid") self.gid.set_editable(mod) self.slist = self.get_widget("slist") - self.names_label = self.get_widget("names_label") - self.attr_label = self.get_widget("attr_label") - self.addr_label = self.get_widget("addr_label") + names_label = self.get_widget("names_label") + events_label = self.get_widget("events_label") + attr_label = self.get_widget("attr_label") + addr_label = self.get_widget("addr_label") + web_label = self.get_widget("inet_label") self.notes_label = self.get_widget("notes_label") self.sources_label = self.get_widget("sources_label") - self.events_label = self.get_widget("events_label") - self.inet_label = self.get_widget("inet_label") self.gallery_label = self.get_widget("gallery_label") self.lds_tab = self.get_widget("lds_tab") self.person_photo = self.get_widget("personPix") self.eventbox = self.get_widget("eventbox1") - self.prefix_label = self.get_widget('prefix_label') if self.use_patronymic: @@ -248,11 +227,6 @@ class EditPerson: self.pname = RelLib.Name(person.get_primary_name()) self.gender.set_active(person.get_gender()) - - self.elist = [] - for val in [birth_handle, death_handle] + person.get_event_list(): - if val: - self.elist.append(val) self.nlist = person.get_alternate_names()[:] self.alist = person.get_attribute_list()[:] @@ -264,91 +238,32 @@ class EditPerson: else: self.srcreflist = [] - if self.event_list: - Utils.bold_label(self.events_label) if self.srcreflist: Utils.bold_label(self.sources_label) - if self.nlist: - Utils.bold_label(self.names_label) - if self.alist: - Utils.bold_label(self.attr_label) - if self.ulist: - Utils.bold_label(self.inet_label) - if self.plist: - Utils.bold_label(self.addr_label) if self.person.get_media_list(): Utils.bold_label(self.gallery_label) # event display - event_default = [ 'Event', 'Description', 'Date', 'Place', - 'Source', 'Note' ] - self.event_trans = TransTable.TransTable(event_default) - evalues = { - 'Event' : (_('Event'),-1,125), - 'Description' : (_('Description'),-1,150), - 'Date' : (_('Date'),-1,100), - 'Place' : (_('Place'),-1,100), - 'Source' : (_(':Source'),-1,50), - 'Note' : (_(':Note'),-1,50) - } + self.event_box = EventListBox( + self, self.person, self.event_list, events_label, + [event_add_btn,event_edit_btn,event_delete_btn]) - if not self.db.readonly: - values = self.db.metadata.get('event_order',event_default) - else: - values = event_default + self.attr_box = AttrListBox( + self, self.person, self.attr_list, attr_label, + [attr_add_btn, attr_edit_btn, attr_delete_btn]) - etitles = [] - for val in values: - etitles.append(evalues[val]) - - self.etree = ListModel.ListModel(self.event_list,etitles, - self.on_event_select_row, - self.on_event_update_clicked) + self.addr_box = AddressListBox( + self, self.person, self.addr_list, addr_label, + [addr_add_btn, addr_edit_btn, addr_delete_btn]) - # attribute display - atitles = [ - (_('Attribute'),-1,200), - (_('Value'),-1,350), - (_(':Source'),-1,50), - (_(':Note'),-1,50), - ] - self.atree = ListModel.ListModel(self.attr_list,atitles, - self.on_attr_select_row, - self.on_update_attr_clicked) - - # address display - ptitles = [ - (_('Date'),-1,175), - (_('Address'),-1,150), - (_('City'),-1,100), - (_('State/Province'),-1,75), - (_('Country'),-1,100), - (_(':Source'),-1,50), - (_(':Note'),-1,50), - ] - self.ptree = ListModel.ListModel(self.addr_list, ptitles, - self.on_addr_select_row, - self.on_update_addr_clicked) + self.name_box = NameListBox( + self, self.person, self.name_list, names_label, + [name_add_btn, name_edit_btn, name_delete_btn]) - # name display - ntitles = [ - (_('Family Name'),-1,225), - (_('Prefix'),-1,50), - (_('Given Name'),-1,200), - (_('Suffix'),-1,50), - (_('Type'),-1,100), - (_(':Source'),-1,50), (_(':Note'),-1,50), - ] - self.ntree = ListModel.ListModel(self.name_list,ntitles, - self.on_name_select_row) - self.ntree.tree.connect('event',self.aka_double_click) - - # web display - wtitles = [(_('Path'),-1,250),(_('Description'),-1,100)] - self.wtree = ListModel.ListModel(self.web_list,wtitles, - self.on_web_select_row, - self.on_update_url_clicked) + self.url_box = UrlListBox( + self, self.person, self.web_list, web_label, + [web_add_btn, web_edit_btn, web_delete_btn]) self.place_list = self.pdmap.keys() self.place_list.sort() @@ -358,7 +273,7 @@ class EditPerson: gid = person.get_gramps_id() if gid: self.gid.set_text(gid) - self.gid.set_editable(1) + self.gid.set_editable(True) self.lds_baptism = RelLib.LdsOrd(self.person.get_lds_baptism()) self.lds_endowment = RelLib.LdsOrd(self.person.get_lds_endowment()) @@ -388,84 +303,18 @@ class EditPerson: self.flowed.set_active(1) Utils.bold_label(self.notes_label) - self.name_list.drag_dest_set(gtk.DEST_DEFAULT_ALL, - [DdTargets.NAME.target()], - ACTION_COPY) - self.name_list.drag_source_set(BUTTON1_MASK, - [DdTargets.NAME.target()], - ACTION_COPY) - self.name_list.connect('drag_data_get', self.name_drag_data_get) - self.name_list.connect('drag_begin', self.name_drag_begin) - self.name_list.connect('drag_data_received', - self.name_drag_data_received) - - self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL, - [DdTargets.EVENT.target()], - ACTION_COPY) - self.event_list.drag_source_set(BUTTON1_MASK, - [DdTargets.EVENT.target()], - ACTION_COPY) - self.event_list.connect('drag_data_get', self.ev_drag_data_get) - self.event_list.connect('drag_begin', self.ev_drag_begin) - self.event_list.connect('drag_data_received', - self.ev_drag_data_received) - - self.web_list.drag_dest_set(gtk.DEST_DEFAULT_ALL, - [DdTargets.URL.target()], - ACTION_COPY) - self.web_list.drag_source_set(BUTTON1_MASK, - [DdTargets.URL.target()], - ACTION_COPY) - self.web_list.connect('drag_data_get', self.url_drag_data_get) - self.web_list.connect('drag_begin', self.url_drag_begin) - self.web_list.connect('drag_data_received',self.url_drag_data_received) - - self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL, - [DdTargets.ATTRIBUTE.target()], - ACTION_COPY) - self.attr_list.drag_source_set(BUTTON1_MASK, - [DdTargets.ATTRIBUTE.target()], - ACTION_COPY) - self.attr_list.connect('drag_data_get', self.at_drag_data_get) - self.attr_list.connect('drag_data_received',self.at_drag_data_received) - self.attr_list.connect('drag_begin', self.at_drag_begin) - - self.addr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL, - [DdTargets.ADDRESS.target()], - ACTION_COPY) - self.addr_list.drag_source_set(BUTTON1_MASK, - [DdTargets.ADDRESS.target()], - ACTION_COPY) - self.addr_list.connect('drag_data_get', self.ad_drag_data_get) - self.addr_list.connect('drag_data_received',self.ad_drag_data_received) - self.addr_list.connect('drag_begin', self.ad_drag_begin) - self.top.signal_autoconnect({ "destroy_passed_object" : self.on_cancel_edit, "on_up_clicked" : self.on_up_clicked, "on_down_clicked" : self.on_down_clicked, - "on_add_address_clicked" : self.on_add_addr_clicked, - "on_add_aka_clicked" : self.on_add_aka_clicked, - "on_add_attr_clicked" : self.on_add_attr_clicked, - "on_add_url_clicked" : self.on_add_url_clicked, # "on_addphoto_clicked" : self.gallery.on_add_media_clicked, # "on_selectphoto_clicked" : self.gallery.on_select_media_clicked, - "on_aka_delete_clicked" : self.on_aka_delete_clicked, - "on_aka_update_clicked" : self.on_aka_update_clicked, "on_apply_person_clicked" : self.on_apply_person_clicked, - "on_edit_birth_clicked" : self.on_edit_birth_clicked, - "on_edit_death_clicked" : self.on_edit_death_clicked, - "on_delete_address_clicked" : self.on_delete_addr_clicked, - "on_delete_attr_clicked" : self.on_delete_attr_clicked, "on_delete_event" : self.on_delete_event, - "on_delete_url_clicked" : self.on_delete_url_clicked, # "on_deletephoto_clicked" : self.gallery.on_delete_media_clicked, # "on_edit_properties_clicked": self.gallery.popup_change_description, # "on_editphoto_clicked" : self.gallery.on_edit_media_clicked, "on_editperson_switch_page" : self.on_switch_page, - "on_event_add_clicked" : self.on_event_add_clicked, - "on_event_delete_clicked" : self.on_event_delete_clicked, - "on_event_update_clicked" : self.on_event_update_clicked, "on_edit_name_clicked" : self.on_edit_name_clicked, "on_ldsbap_note_clicked" : self.on_ldsbap_note_clicked, "on_ldsendow_note_clicked" : self.on_ldsendow_note_clicked, @@ -473,9 +322,6 @@ class EditPerson: "on_ldsbap_src_clicked" : self.on_ldsbap_source_clicked, "on_ldsendow_src_clicked" : self.on_ldsendow_source_clicked, "on_ldsseal_src_clicked" : self.on_ldsseal_source_clicked, - "on_update_address_clicked" : self.on_update_addr_clicked, - "on_update_attr_clicked" : self.on_update_attr_clicked, - "on_update_url_clicked" : self.on_update_url_clicked, "on_web_go_clicked" : self.on_web_go_clicked, "on_gender_activate" : self.on_gender_activate, "on_given_focus_out" : self.on_given_focus_out_event, @@ -492,20 +338,21 @@ class EditPerson: self.eventbox.connect('button-press-event',self.image_button_press) - self.redraw_event_list() - self.redraw_attr_list() - self.redraw_addr_list() - self.redraw_name_list() - self.redraw_url_list() + self.event_box.redraw() + self.attr_box.redraw() + self.addr_box.redraw() + self.name_box.redraw() + self.url_box.redraw() self.get_widget("notebook").set_current_page(0) self.surname.grab_focus() self.add_itself_to_winsmenu() - for i in ["ok", "add_aka", "aka_delete", "event_add", "event_del", - "attr_add", "attr_del", "addr_add", - "addr_del", "media_add", "media_sel", "media_del", - "add_url", "delete_url", "add_src", "del_src" ]: - self.get_widget(i).set_sensitive(not self.db.readonly) + if self.db.readonly: + for i in ["ok", "aka_add", "aka_del", "event_add", "event_del", + "attr_add", "attr_del", "addr_add", + "addr_del", "media_add", "media_sel", "media_del", + "url_add", "url_del", "add_src", "del_src" ]: + self.get_widget(i).set_sensitive(False) self.window.show() @@ -570,7 +417,8 @@ class EditPerson: ph = media_list[0] object_handle = ph.get_reference_handle() obj = self.db.get_object_from_handle(object_handle) - ImageSelect.LocalMediaProperties(ph,obj.get_path(),self,self.window) + ImageSelect.LocalMediaProperties(ph,obj.get_path(),self, + self.window) def close_child_windows(self): for child_window in self.child_windows.values(): @@ -579,10 +427,10 @@ class EditPerson: def close(self): event_list = [] - for col in self.event_list.get_columns(): - event_list.append(self.event_trans.find_key(col.get_title())) - if not self.db.readonly: - self.db.metadata['event_order'] = event_list + #for col in self.event_list.get_columns(): + # event_list.append(self.event_trans.find_key(col.get_title())) + #if not self.db.readonly: + # self.db.metadata['event_order'] = event_list #self.gallery.close() self.close_child_windows() @@ -788,71 +636,6 @@ class EditPerson: def set_lds_seal(self,obj): self.lds_sealing.set_status(obj.get_active()) - def name_drag_data_get(self,widget, context, sel_data, info, time): - name = self.ntree.get_selected_objects() - - bits_per = 8; # we're going to pass a string - pickled = pickle.dumps(name[0]); - data = str((DdTargets.NAME.drag_type,self.person.get_handle(),pickled)); - sel_data.set(sel_data.target, bits_per, data) - - def name_drag_begin(self, context, a): - return - icon = self.ntree.get_icon() - t = self.ntree.tree - (x,y) = icon.get_size() - mask = gtk.gdk.Pixmap(self.window.window,x,y,1) - mask.draw_rectangle(t.get_style().white_gc, True, 0,0,x,y) - t.drag_source_set_icon(t.get_colormap(),icon,mask) - - def name_drag_data_received(self,widget,context,x,y,sel_data,info,time): - row = self.ntree.get_row_at(x,y) - - if sel_data and sel_data.data: - exec 'data = %s' % sel_data.data - exec 'mytype = "%s"' % data[0] - exec 'person = "%s"' % data[1] - if mytype != DdTargets.NAME.drag_type: - return - elif person == self.person.get_handle(): - self.move_element(self.nlist,self.ntree.get_selected_row(),row) - else: - foo = pickle.loads(data[2]); - for src in foo.get_source_references(): - base_handle = src.get_base_handle() - newbase = self.db.get_source_from_handle(base_handle) - src.set_base_handle(newbase.get_handle()) - - self.nlist.insert(row,foo) - - self.lists_changed = True - self.redraw_name_list() - - def ev_drag_data_received(self,widget,context,x,y,sel_data,info,time): - row = self.etree.get_row_at(x,y) - - if sel_data and sel_data.data: - exec 'data = %s' % sel_data.data - exec 'mytype = "%s"' % data[0] - exec 'person = "%s"' % data[1] - if mytype != DdTargets.EVENT.drag_type: - return - elif person == self.person.get_handle(): - self.move_element(self.elist,self.etree.get_selected_row(),row) - else: - foo = pickle.loads(data[2]); - for src in foo.get_source_references(): - base_handle = src.get_base_handle() - newbase = self.db.get_source_from_handle(base_handle) - src.set_base_handle(newbase.get_handle()) - place = foo.get_place_handle() - if place: - foo.set_place_handle(place.get_handle()) - self.elist.insert(row,foo.get_handle()) - - self.lists_changed = True - self.redraw_event_list() - def move_element(self,list,src,dest): if src == -1: return @@ -860,121 +643,6 @@ class EditPerson: list.remove(obj) list.insert(dest,obj) - def ev_drag_data_get(self,widget, context, sel_data, info, time): - ev = self.etree.get_selected_objects() - - bits_per = 8; # we're going to pass a string - pickled = pickle.dumps(ev[0]); - data = str((DdTargets.EVENT.drag_type,self.person.get_handle(),pickled)); - sel_data.set(sel_data.target, bits_per, data) - - def ev_drag_begin(self, context, a): - return - icon = self.etree.get_icon() - t = self.etree.tree - (x,y) = icon.get_size() - mask = gtk.gdk.Pixmap(self.window.window,x,y,1) - mask.draw_rectangle(t.get_style().white_gc, True, 0,0,x,y) - t.drag_source_set_icon(t.get_colormap(),icon,mask) - - def url_drag_data_received(self,widget,context,x,y,sel_data,info,time): - row = self.wtree.get_row_at(x,y) - - if sel_data and sel_data.data: - exec 'data = %s' % sel_data.data - exec 'mytype = "%s"' % data[0] - exec 'person = "%s"' % data[1] - if mytype != DdTargets.URL.drag_type: - return - elif person == self.person.get_handle(): - self.move_element(self.ulist,self.wtree.get_selected_row(),row) - else: - foo = pickle.loads(data[2]); - self.ulist.append(foo) - self.lists_changed = True - self.redraw_url_list() - - def url_drag_begin(self, context, a): - return - - def url_drag_data_get(self,widget, context, sel_data, info, time): - ev = self.wtree.get_selected_objects() - - if len(ev): - bits_per = 8; # we're going to pass a string - pickled = pickle.dumps(ev[0]); - data = str((DdTargets.URL.drag_type,self.person.get_handle(),pickled)); - sel_data.set(sel_data.target, bits_per, data) - - def at_drag_data_received(self,widget,context,x,y,sel_data,info,time): - row = self.atree.get_row_at(x,y) - - if sel_data and sel_data.data: - exec 'data = %s' % sel_data.data - exec 'mytype = "%s"' % data[0] - exec 'person = "%s"' % data[1] - if mytype != DdTargets.ATTRIBUTE.drag_type: - return - elif person == self.person.get_handle(): - self.move_element(self.alist,self.atree.get_selected_row(),row) - else: - foo = pickle.loads(data[2]); - for src in foo.get_source_references(): - base_handle = src.get_base_handle() - newbase = self.db.get_source_from_handle(base_handle) - src.set_base_handle(newbase.get_handle()) - self.alist.append(foo) - self.lists_changed = True - self.redraw_attr_list() - - def at_drag_begin(self, context, a): - return - - def at_drag_data_get(self,widget, context, sel_data, info, time): - ev = self.atree.get_selected_objects() - - if len(ev): - bits_per = 8; # we're going to pass a string - pickled = pickle.dumps(ev[0]); - data = str((DdTargets.ATTRIBUTE.drag_type, - self.person.get_handle(),pickled)); - sel_data.set(sel_data.target, bits_per, data) - - def ad_drag_data_received(self,widget,context,x,y,sel_data,info,time): - row = self.ptree.get_row_at(x,y) - - if sel_data and sel_data.data: - exec 'data = %s' % sel_data.data - exec 'mytype = "%s"' % data[0] - exec 'person = "%s"' % data[1] - if mytype != DdTargets.ADDRESS.drag_type: - return - elif person == self.person.get_handle(): - self.move_element(self.plist,self.ptree.get_selected_row(),row) - else: - foo = pickle.loads(data[2]); - for src in foo.get_source_references(): - base_handle = src.get_base_handle() - newbase = self.db.get_source_from_handle(base_handle) - src.set_base_handle(newbase.get_handle()) - self.plist.insert(row,foo) - - self.lists_changed = True - self.redraw_addr_list() - - def ad_drag_data_get(self,widget, context, sel_data, info, time): - ev = self.ptree.get_selected_objects() - - if len(ev): - bits_per = 8; # we're going to pass a string - pickled = pickle.dumps(ev[0]); - data = str((DdTargets.ADDRESS.drag_type, - self.person.get_handle(),pickled)); - sel_data.set(sel_data.target, bits_per, data) - - def ad_drag_begin(self, context, a): - return - def menu_changed(self,obj): self.ldsfam = self.lds_fam_list[obj.get_active()] @@ -982,125 +650,6 @@ class EditPerson: """returns the widget related to the passed string""" return self.top.get_widget(str) - def redraw_name_list(self): - """redraws the name list""" - self.ntree.clear() - self.nmap = {} - for name in self.nlist: - has_note = name.get_note() - has_source = len(name.get_source_references())> 0 - node = self.ntree.add([ - name.get_surname(),name.get_surname_prefix(), - name.get_first_name(), name.get_suffix(), - _(name.get_type()),has_source,has_note],name) - self.nmap[str(name)] = node - if self.nlist: - self.ntree.select_row(0) - Utils.bold_label(self.names_label) - else: - Utils.unbold_label(self.names_label) - - def redraw_url_list(self): - """redraws the url list, disabling the go button if no url - is selected""" - self.wtree.clear() - self.wmap = {} - for url in self.ulist: - node = self.wtree.add([url.get_path(),url.get_description()],url) - self.wmap[str(url)] = node - - if len(self.ulist) > 0: - self.web_go.set_sensitive(False) - self.wtree.select_row(0) - Utils.bold_label(self.inet_label) - else: - self.web_go.set_sensitive(False) - Utils.unbold_label(self.inet_label) - - def redraw_addr_list(self): - """Redraws the address list""" - self.ptree.clear() - self.pmap = {} - for addr in self.plist: - has_note = addr.get_note() - has_source = len(addr.get_source_references())> 0 - location = "%s %s %s %s" % (addr.get_street(),addr.get_city(), - addr.get_state(),addr.get_country()) - node = self.ptree.add([addr.get_date(),addr.get_street(), - addr.get_city(),addr_get_state(), - addr_get_country(),has_source,has_note], - addr) - self.pmap[str(addr)] = node - if self.plist: - self.ptree.select_row(0) - Utils.bold_label(self.addr_label) - else: - Utils.unbold_label(self.addr_label) - - def redraw_attr_list(self): - """redraws the attribute list for the person""" - self.atree.clear() - self.amap = {} - for attr in self.alist: - has_note = attr.get_note() - has_source = len(attr.get_source_references())> 0 - node = self.atree.add([ - const.display_pattr(attr.get_type()), attr.get_value(), - has_source, has_note, - ],attr) - self.amap[str(attr)] = node - if self.alist: - self.atree.select_row(0) - Utils.bold_label(self.attr_label) - else: - Utils.unbold_label(self.attr_label) - - def name_edit_callback(self,name): - self.redraw_name_list() - self.ntree.select_iter(self.nmap[str(name)]) - - def addr_edit_callback(self,addr): - self.redraw_addr_list() - self.ptree.select_iter(self.pmap[str(addr)]) - - def url_edit_callback(self,url): - self.redraw_url_list() - self.wtree.select_iter(self.wmap[str(url)]) - - def event_edit_callback(self,event): - """Birth and death events may not be in the map""" - self.redraw_event_list() - try: - self.etree.select_iter(self.emap[str(event)]) - except: - pass - - def attr_edit_callback(self,attr): - self.redraw_attr_list() - self.atree.select_iter(self.amap[str(attr)]) - - def redraw_event_list(self): - """redraw_event_list - Update both the birth and death place combo - boxes for any changes that occurred in the 'Event Edit' window. - Make sure not to allow the editing of a birth event to change - any values in the death event, and vice versa. Since updating a - combo list resets its present value, this code will have to save - and restore the value for the event *not* being edited.""" - - self.etree.clear() - self.emap = {} - for event_handle in self.elist: - event = self.db.get_event_from_handle(event_handle) - pname = place_title(self.db,event) - has_note = event.get_note() - has_source = len(event.get_source_references())> 0 - data = [const.display_pevent(event.get_name()), - event.get_description(), event.get_date(), - pname, has_source, has_note] - node = self.etree.add(data, event) - self.emap[str(event)] = node - node = self.etree.add(["","","","",False,False],None) - def strip_id(self,text): index = text.rfind('[') if (index > 0): @@ -1108,29 +657,6 @@ class EditPerson: text = text.rstrip() return text - def on_add_addr_clicked(self,obj): - """Invokes the address editor to add a new address""" - import AddrEdit - AddrEdit.AddressEditor(self,None,self.addr_edit_callback,self.window) - - def on_add_aka_clicked(self,obj): - """Invokes the name editor to add a new name""" - import NameEdit - NameEdit.NameEditor(self, None, self.name_edit_callback, self.window) - - def on_add_url_clicked(self,obj): - """Invokes the url editor to add a new name""" - import UrlEdit - pname = self.name_display.display(self.person) - UrlEdit.UrlEditor(self,pname,None,self.url_edit_callback,self.window) - - def on_add_attr_clicked(self,obj): - """Brings up the AttributeEditor for a new attribute""" - import AttrEdit - pname = self.name_display.display(self.person) - AttrEdit.AttributeEditor(self,None,pname,const.personalAttributes, - self.attr_edit_callback,self.window) - def on_up_clicked(self,obj): sel = obj.get_selection() store,node = sel.get_selected() @@ -1145,58 +671,6 @@ class EditPerson: row = store.get_path(node) sel.select_path((row[0]+1)) - def on_event_add_clicked(self,obj): - """Brings up the EventEditor for a new event""" - import EventEdit - pname = self.name_display.display(self.person) - EventEdit.EventEditor( - self,pname,const.personalEvents, - const.personal_events,None,None,0, - self.event_edit_callback, - noedit=self.db.readonly) - - def on_edit_birth_clicked(self,obj): - """Brings up the EventEditor for the birth record, event - name cannot be changed""" - pass - - def on_edit_death_clicked(self,obj): - """Brings up the EventEditor for the death record, event - name cannot be changed""" - pass - - def on_aka_delete_clicked(self,obj): - """Deletes the selected name from the name list""" - store,node = self.ntree.get_selected() - if node: - self.nlist.remove(self.ntree.get_object(node)) - self.lists_changed = True - self.redraw_name_list() - - def on_delete_url_clicked(self,obj): - """Deletes the selected URL from the URL list""" - store,node = self.wtree.get_selected() - if node: - self.ulist.remove(self.wtree.get_object(node)) - self.lists_changed = True - self.redraw_url_list() - - def on_delete_attr_clicked(self,obj): - """Deletes the selected attribute from the attribute list""" - store,node = self.atree.get_selected() - if node: - self.alist.remove(self.atree.get_object(node)) - self.lists_changed = True - self.redraw_attr_list() - - def on_delete_addr_clicked(self,obj): - """Deletes the selected address from the address list""" - store,node = self.ptree.get_selected() - if node: - self.plist.remove(self.ptree.get_object(node)) - self.lists_changed = True - self.redraw_addr_list() - def on_web_go_clicked(self,obj): """Attempts to display the selected URL in a web browser""" text = obj.get() @@ -1340,100 +814,6 @@ class EditPerson: self.lds_sealing.set_family_handle(self.ldsfam) self.lds_sealing.set_place_handle(self.get_place(self.ldssealplace,1)) - def on_event_delete_clicked(self,obj): - """Delete the selected event""" - if Utils.delete_selected(obj,self.elist): - self.lists_changed = True - self.redraw_event_list() - - def update_birth_death(self): - pass - - def on_update_attr_clicked(self,obj): - import AttrEdit - store,node = self.atree.get_selected() - if node: - attr = self.atree.get_object(node) - pname = self.name_display.display(self.person) - AttrEdit.AttributeEditor(self,attr,pname,const.personalAttributes, - self.attr_edit_callback,self.window) - - def on_update_addr_clicked(self,obj): - import AddrEdit - store,node = self.ptree.get_selected() - if node: - AddrEdit.AddressEditor( - self, self.ptree.get_object(node), self.addr_edit_callback, - self.window) - - def on_update_url_clicked(self,obj): - import UrlEdit - store,node = self.wtree.get_selected() - if node: - pname = self.name_display.display(self.person) - url = self.wtree.get_object(node) - UrlEdit.UrlEditor(self,pname,url,self.url_edit_callback,self.window) - - def on_event_update_clicked(self,obj): - import EventEdit - - store,node = self.etree.get_selected() - if not node: - return - pname = self.name_display.display(self.person) - event = self.etree.get_object(node) - EventEdit.EventEditor( - self,pname,const.personalEvents, - const.personal_events,event,None,0, - self.event_edit_callback,noedit=self.db.readonly) - - def on_event_select_row(self,obj): - store,iter = obj.get_selected() - if iter: - self.event_delete_btn.set_sensitive(True) - self.event_edit_btn.set_sensitive(True) - else: - self.event_delete_btn.set_sensitive(True) - self.event_edit_btn.set_sensitive(True) - - def on_addr_select_row(self,obj): - store,node = self.ptree.get_selected() - if node: - self.addr_delete_btn.set_sensitive(True) - self.addr_edit_btn.set_sensitive(True) - else: - self.addr_delete_btn.set_sensitive(False) - self.addr_edit_btn.set_sensitive(False) - - def on_name_select_row(self,obj): - store,node = self.ntree.get_selected() - if node: - self.name_delete_btn.set_sensitive(True) - self.name_edit_btn.set_sensitive(True) - else: - self.name_delete_btn.set_sensitive(False) - self.name_edit_btn.set_sensitive(False) - - def on_web_select_row(self,obj): - store,node = self.wtree.get_selected() - if node: - self.web_go.set_sensitive(True) - self.web_delete_btn.set_sensitive(True) - self.web_edit_btn.set_sensitive(True) - else: - self.web_go.set_sensitive(False) - self.web_delete_btn.set_sensitive(False) - self.web_edit_btn.set_sensitive(False) - - def on_attr_select_row(self,obj): - store,node = self.atree.get_selected() - if node: - self.attr_delete_btn.set_sensitive(True) - self.attr_edit_btn.set_sensitive(True) - else: - self.attr_delete_btn.set_sensitive(False) - self.attr_edit_btn.set_sensitive(False) - def aka_double_click(self,obj,event): if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: self.on_aka_update_clicked(obj) @@ -1447,13 +827,6 @@ class EditPerson: Utils.add_menuitem(menu,msg,None,self.change_name) menu.popup(None,None,None,event.button,event.time) - def on_aka_update_clicked(self,obj): - import NameEdit - store,node = self.ntree.get_selected() - if node: - NameEdit.NameEditor(self, self.ntree.get_object(node), - self.name_edit_callback, self.window) - def load_photo(self,photo): """loads, scales, and displays the person's main photo""" self.load_obj = photo @@ -1461,12 +834,12 @@ class EditPerson: self.person_photo.hide() else: try: - i = pixbuf_new_from_file(photo) + i = gtk.gdk.pixbuf_new_from_file(photo) ratio = float(max(i.get_height(),i.get_width())) scale = float(100.0)/ratio x = int(scale*(i.get_width())) y = int(scale*(i.get_height())) - i = i.scale_simple(x,y,INTERP_BILINEAR) + i = i.scale_simple(x,y,gtk.gdk.INTERP_BILINEAR) self.person_photo.set_from_pixbuf(i) self.person_photo.show() except: @@ -1475,7 +848,7 @@ class EditPerson: def update_lists(self): """Updates the person's lists if anything has changed""" if self.lists_changed: - self.person.set_event_list(self.elist) + #self.person.set_event_list(self.elist) self.person.set_alternate_names(self.nlist) self.person.set_url_list(self.ulist) self.person.set_attribute_list(self.alist) @@ -1624,8 +997,9 @@ class EditPerson: "the person's marriages.") ErrorDialog(msg) - text = unicode(self.notes_buffer.get_text(self.notes_buffer.get_start_iter(), - self.notes_buffer.get_end_iter(),False)) + start = self.notes_buffer.get_start_iter() + stop = self.notes_buffer.get_end_iter() + text = unicode(self.notes_buffer.get_text(start,stop,False)) if text != self.person.get_note(): self.person.set_note(text) @@ -1688,8 +1062,6 @@ class EditPerson: return u"" def on_edit_name_clicked(self,obj): - import NameEdit - ntype = unicode(self.ntype_field.child.get_text()) self.pname.set_type(const.NameTypesMap.find_value(ntype)) self.pname.set_suffix(unicode(self.suffix.get_text())) @@ -1715,7 +1087,6 @@ class EditPerson: self.lists_changed = True def on_ldsbap_note_clicked(self,obj): - import NoteEdit NoteEdit.NoteEditor(self.lds_baptism,self,self.window, readonly=self.db.readonly) @@ -1728,7 +1099,6 @@ class EditPerson: self.lists_changed = True def on_ldsendow_note_clicked(self,obj): - import NoteEdit NoteEdit.NoteEditor(self.lds_endowment,self,self.window, readonly=self.db.readonly) @@ -1741,7 +1111,6 @@ class EditPerson: self.lists_changed = True def on_ldsseal_note_clicked(self,obj): - import NoteEdit NoteEdit.NoteEditor(self.lds_sealing,self,self.window, readonly=self.db.readonly) @@ -1759,16 +1128,10 @@ class EditPerson: else: self.load_photo(None) - def update_birth_info(self): - pass - - def update_death_info(self): - pass - def on_switch_page(self,obj,a,page): if page == 0: self.load_person_image() - self.redraw_event_list() + self.event_box.redraw() elif page == 6 and self.not_loaded: self.not_loaded = False elif page == 8 and self.lds_not_loaded: @@ -1784,9 +1147,8 @@ class EditPerson: if not self.lds_not_loaded: self.check_lds() - if self.lds_baptism.is_empty() \ - and self.lds_endowment.is_empty() \ - and self.lds_sealing.is_empty(): + if (self.lds_baptism.is_empty() and self.lds_endowment.is_empty() + and self.lds_sealing.is_empty()): Utils.unbold_label(self.lds_tab) else: Utils.bold_label(self.lds_tab) @@ -1798,16 +1160,12 @@ class EditPerson: new = sel_objs[0] self.nlist.remove(new) self.nlist.append(old) - self.redraw_name_list() + self.name_box.redraw() self.pname = RelLib.Name(new) self.lists_changed = True self.write_primary_name() def write_primary_name(self): - # initial values - name = '%s' % self.name_display.display(self.person) -# self.get_widget("activepersonTitle").set_text(name) -# self.get_widget("activepersonTitle").set_use_markup(True) self.suffix.set_text(self.pname.get_suffix()) if self.use_patronymic: self.prefix.set_text(self.pname.get_patronymic()) @@ -1893,12 +1251,6 @@ class EditPerson: list.insert(target,person.get_handle()) return list -def short(val,size=60): - if len(val) > size: - return "%s..." % val[0:size] - else: - return val - def place_title(db,event): pid = event.get_place_handle() if pid: @@ -1925,3 +1277,357 @@ def build_combo(entry,strings): node = store.append() store.set(node,0,unicode(value)) entry.set_model(store) + +class ListBox: + def __init__(self, parent, person, obj, label, button_list, titles): + self.person = person + self.label = label + self.name = NameDisplay.displayer.display(self.person) + self.db = parent.db + self.parent = parent + self.list_model = ListModel.ListModel( + obj, titles, self.select_row, self.update) + self.blist = button_list + self.node_map = {} + self.tree = obj + self.changed = False + self.blist[0].connect('clicked',self.add) + self.blist[1].connect('clicked',self.update) + self.blist[2].connect('clicked',self.delete) + + def select_row(self,obj): + store, node = obj.get_selected() + enable = node != None + for button in self.blist[1:]: + button.set_sensitive(enable) + + def delete(self,obj): + """Delete the selected event""" + if Utils.delete_selected(obj,self.data): + self.changed = True + self.redraw() + + def update(self,obj): + raise NotImplementedError + + def redraw(self): + self.list_model.clear() + self.node_map = {} + for item in self.data: + node = self.list_model.add(self.display_data(item),item) + self.node_map[str(item)] = node + if self.data: + self.list_model.select_row(0) + self.set_label() + + def display_data(self,item): + raise NotImplementedError + + def delete(self,obj): + """Deletes the selected name from the name list""" + store,node = self.list_model.get_selected() + if node: + self.list_model.remove(self.list_model.get_object(node)) + self.changed = True + self.redraw() + + def edit_callback(self,data): + self.data.append(data) + self.redraw() + try: + self.list_model.select_iter(self.node_map[str(data)]) + except: + print "Edit callback failed" + + def set_label(self): + if self.data: + self.list_model.select_row(0) + Utils.bold_label(self.label) + self.blist[1].set_sensitive(True) + self.blist[2].set_sensitive(True) + else: + Utils.unbold_label(self.label) + self.blist[1].set_sensitive(False) + self.blist[2].set_sensitive(False) + +class ReorderListBox(ListBox): + + def __init__(self,parent,person,obj,label,button_list,evalues, dnd_type): + + ListBox.__init__(self,parent,person,obj,label,button_list,evalues) + + self.dnd_type = dnd_type + + obj.drag_dest_set(gtk.DEST_DEFAULT_ALL, [dnd_type.target()], + gtk.gdk.ACTION_COPY) + obj.drag_source_set(gtk.gdk.BUTTON1_MASK, [dnd_type.target()], + gtk.gdk.ACTION_COPY) + obj.connect('drag_data_get', self.drag_data_get) + obj.connect('drag_data_received',self.drag_data_received) + + def drag_data_get(self,widget, context, sel_data, info, time): + node = self.list_model.get_selected_objects() + + bits_per = 8; # we're going to pass a string + pickled = pickle.dumps(node[0]); + data = str((self.dnd_type.drag_type, self.person.get_handle(), + pickled)); + sel_data.set(sel_data.target, bits_per, data) + + def unpickle(self, data): + self.data.insert(pickle.loads(data)) + + def drag_data_received(self,widget,context,x,y,sel_data,info,time): + row = self.list_model.get_row_at(x,y) + + if sel_data and sel_data.data: + exec 'data = %s' % sel_data.data + exec 'mytype = "%s"' % data[0] + exec 'person = "%s"' % data[1] + if mytype != self.dnd_type.drag_type: + return + elif person == self.person.get_handle(): + self.move_element(self.list_model.get_selected_row(),row) + else: + self.unpickle(data[2]) + self.changed = True + self.redraw() + + def move_element(self,src,dest): + if src != -1: + obj = self.data[src] + self.data.remove(obj) + self.data.insert(dest,obj) + +class AttrListBox(ListBox): + + titles = [ + # Title Sort Column Min Width, Type + (_('Attribute'), ListModel.NOSORT, 200, ListModel.TEXT), + (_('Value'), ListModel.NOSORT, 350, ListModel.TEXT), + (_('Source'), ListModel.NOSORT, 50, ListModel.TOGGLE), + (_('Note'), ListModel.NOSORT, 50, ListModel.TOGGLE), + ] + + def __init__(self, parent, person, obj, label, button_list): + self.data = person.get_attribute_list()[:] + ListBox.__init__(self, parent, person, obj, label, + button_list, self.titles) + + def add(self,obj): + """Brings up the AttributeEditor for a new attribute""" + AttrEdit.AttributeEditor(self.parent, None, self.name, + const.personalAttributes, + self.edit_callback,self.parent.window) + + def update(self,obj): + store,node = self.list_model.get_selected() + if node: + attr = self.list_model.get_object(node) + AttrEdit.AttributeEditor(self.parent, attr, self.name, + const.personalAttributes, + self.edit_callback,self.parent.window) + + def display_data(self,attr): + has_note = attr.get_note() + has_source = len(attr.get_source_references())> 0 + return [const.display_pattr(attr.get_type()), attr.get_value(), + has_source, has_note] + + +class EventListBox(ReorderListBox): + + evalues = [ + # Title Sort Column Min Width, Type + (_('Event'), ListModel.NOSORT, 125, ListModel.COMBO), + (_('Description'), ListModel.NOSORT, 150, ListModel.TEXT), + (_('Date'), ListModel.NOSORT, 100, ListModel.TEXT), + (_('Place'), ListModel.NOSORT, 100, ListModel.TEXT), + (_('Source'), ListModel.NOSORT, 50, ListModel.TOGGLE), + (_('Note'), ListModel.NOSORT, 50, ListModel.TOGGLE) + ] + + titles = ['Event', 'Description','Date','Place','Source','Note'] + + def __init__(self,parent,person,obj,label,button_list): + + self.trans = TransTable.TransTable(self.titles) + + self.data = [] + if person.get_birth_handle(): + self.data.append(person.get_birth_handle()) + if person.get_death_handle(): + self.data.append(person.get_death_handle()) + for val in person.get_event_list(): + self.data.append(val) + + ReorderListBox.__init__(self, parent, person, obj, label, + button_list, self.evalues, DdTargets.EVENT) + + def add(self,obj): + """Brings up the EventEditor for a new event""" + EventEdit.EventEditor( + self.parent, self.name, const.personalEvents, + const.personal_events, None, None, 0, + self.edit_callback, noedit=self.db.readonly) + + def update(self,obj): + store,node = self.list_model.get_selected() + if not node: + return + event = self.list_model.get_object(node) + EventEdit.EventEditor( + self.parent, self.name, const.personalEvents, + const.personal_events,event, None, 0, + self.edit_callback, noedit=self.db.readonly) + + def redraw(self): + """redraw_event_list - Update both the birth and death place combo + boxes for any changes that occurred in the 'Event Edit' window. + Make sure not to allow the editing of a birth event to change + any values in the death event, and vice versa. Since updating a + combo list resets its present value, this code will have to save + and restore the value for the event *not* being edited.""" + + self.list_model.clear() + self.node_map = {} + for handle in self.data: + event = self.db.get_event_from_handle(handle) + pname = place_title(self.db,event) + has_note = event.get_note() + has_source = len(event.get_source_references())> 0 + data = [const.display_pevent(event.get_name()), + event.get_description(), event.get_date(), + pname, has_source, has_note] + node = self.list_model.add(data, event) + self.node_map[str(event)] = node + if self.data: + self.list_model.select_row(0) + self.set_label() + + def unpickle(self, data): + foo = pickle.loads(data); + for src in foo.get_source_references(): + base_handle = src.get_base_handle() + newbase = self.db.get_source_from_handle(base_handle) + src.set_base_handle(newbase.get_handle()) + place = foo.get_place_handle() + if place: + foo.set_place_handle(place.get_handle()) + self.data.insert(row,foo.get_handle()) + +class NameListBox(ReorderListBox): + + titles = [ + # Title Sort Column Min Width, Type + (_('Family Name'), ListModel.NOSORT, 225, ListModel.TEXT), + (_('Prefix'), ListModel.NOSORT, 50, ListModel.TEXT), + (_('Given Name'), ListModel.NOSORT, 200, ListModel.TEXT), + (_('Suffix'), ListModel.NOSORT, 50, ListModel.TEXT), + (_('Type'), ListModel.NOSORT, 100, ListModel.TEXT), + (_('Source'), ListModel.NOSORT, 50, ListModel.TOGGLE), + (_('Note'), ListModel.NOSORT, 50, ListModel.TOGGLE), + ] + + def __init__(self,parent,person,obj,label,button_list): + self.data = person.get_alternate_names()[:] + ReorderListBox.__init__(self, parent, person, obj, label, + button_list, self.titles, DdTargets.NAME) + + def add(self,obj): + NameEdit.NameEditor(self.parent, None, self.edit_callback, + self.parent.window) + + def update(self,obj): + store,node = self.list_model.get_selected() + if node: + NameEdit.NameEditor(self.parent, self.list_model.get_object(node), + self.edit_callback, self.window) + + def display_data(self,name): + has_note = name.get_note() + has_source = len(name.get_source_references())> 0 + return [name.get_surname(),name.get_surname_prefix(), + name.get_first_name(), name.get_suffix(), + _(name.get_type()),has_source,has_note] + + def unpickle(self, data): + foo = pickle.loads(data); + for src in foo.get_source_references(): + base_handle = src.get_base_handle() + newbase = self.db.get_source_from_handle(base_handle) + src.set_base_handle(newbase.get_handle()) + self.data.insert(row,foo) + +class AddressListBox(ReorderListBox): + + titles = [ + # Title Sort Column Min Width, Type + (_('Date'), ListModel.NOSORT, 175, ListModel.TEXT), + (_('Address'), ListModel.NOSORT, 150, ListModel.TEXT), + (_('City'), ListModel.NOSORT, 100, ListModel.TEXT), + (_('State/Province'),ListModel.NOSORT, 75, ListModel.TEXT), + (_('Country'), ListModel.NOSORT, 100, ListModel.TEXT), + (_('Source'), ListModel.NOSORT, 50, ListModel.TOGGLE), + (_('Note'), ListModel.NOSORT, 50, ListModel.TOGGLE), + ] + + def __init__(self,parent,person,obj,label,button_list): + self.data = person.get_address_list()[:] + ReorderListBox.__init__(self, parent, person, obj, label, + button_list, self.titles, DdTargets.ADDRESS) + + def add(self,obj): + AddrEdit.AddressEditor(self.parent, None, self.edit_callback, + self.parent.window) + + def update(self,obj): + store,node = self.list_model.get_selected() + if node: + item = self.list_model.get_object(node) + AddrEdit.AddressEditor(self.parent, item, + self.edit_callback, self.parent.window) + + def display_data(self,item): + has_note = item.get_note() + has_source = len(item.get_source_references())> 0 + return [item.get_date(),item.get_street(), + item.get_city(), item.get_state(), + item.get_country(), has_source,has_note] + + def unpickle(self,data): + foo = pickle.loads(data); + for src in foo.get_source_references(): + base_handle = src.get_base_handle() + newbase = self.db.get_source_from_handle(base_handle) + src.set_base_handle(newbase.get_handle()) + self.data.insert(row,foo) + +class UrlListBox(ReorderListBox): + + titles = [ + # Title Sort Column Min Width, Type + (_('Path'), ListModel.NOSORT, 250, ListModel.TEXT), + (_('Description'), ListModel.NOSORT, 100, ListModel.TEXT), + ] + + def __init__(self,parent,person,obj,label,button_list): + self.data = person.get_url_list()[:] + ReorderListBox.__init__(self, parent, person, obj, label, + button_list, self.titles, DdTargets.URL) + + def add(self,obj): + UrlEdit.UrlEditor(self.parent, self.name, None, + self.edit_callback, self.parent.window) + + def update(self,obj): + store,node = self.list_model.get_selected() + if node: + UrlEdit.UrlEditor(self.parent, self.name, + self.list_model.get_object(node), + self.edit_callback, self.window) + + def display_data(self,url): + return [url.get_path(), url.get_description()] + + diff --git a/gramps2/src/EventEdit.py b/gramps2/src/EventEdit.py index b6b2ecd83..8577be07d 100644 --- a/gramps2/src/EventEdit.py +++ b/gramps2/src/EventEdit.py @@ -244,6 +244,8 @@ class EventEditor: self.top.get_widget('sel_obj').set_sensitive(not noedit) self.top.get_widget('add_obj').set_sensitive(not noedit) + Utils.bold_label(self.general_label) + try: self.window.set_transient_for(self.parent.window) except AttributeError: diff --git a/gramps2/src/ListModel.py b/gramps2/src/ListModel.py index 114f571f5..0406f034b 100644 --- a/gramps2/src/ListModel.py +++ b/gramps2/src/ListModel.py @@ -24,19 +24,25 @@ import const gtk26 = gtk.pygtk_version >= (2,6,0) +TEXT = 0 +TOGGLE = 1 +COMBO = 2 + +NOSORT = -1 #------------------------------------------------------------------------- # # ListModel # #------------------------------------------------------------------------- class ListModel: + def __init__(self,tree,dlist,select_func=None, event_func=None,mode=gtk.SELECTION_SINGLE): self.tree = tree self.mylist = [] self.data_index = 0 for l in dlist: - if l[0] and l[0][0] == ':': + if len(l) == 4 and l[3] == TOGGLE: self.mylist.append(TYPE_BOOLEAN) else: self.mylist.append(TYPE_STRING) @@ -66,11 +72,14 @@ class ListModel: cnum = 0 for name in dlist: - if name[0] and name[0][0] == ':': + if len(name) == 3: + name = (name[0],name[1],name[2],TEXT) + + if name[0] and name[3] == TOGGLE: renderer = gtk.CellRendererToggle() - column = gtk.TreeViewColumn(name[0][1:],renderer) + column = gtk.TreeViewColumn(name[0],renderer) column.add_attribute(renderer,'active',cnum) - elif gtk26 and cnum == 0: + elif gtk26 and name[3] == COMBO: renderer = gtk.CellRendererCombo() renderer.set_property('model',model) renderer.set_property('text_column',0) diff --git a/gramps2/src/edit_person.glade b/gramps2/src/edit_person.glade index a94868010..e6781a515 100644 --- a/gramps2/src/edit_person.glade +++ b/gramps2/src/edit_person.glade @@ -949,7 +949,7 @@ Unknown 6 - + True Create an alternate name for this person True @@ -1005,7 +1005,7 @@ Unknown - + True False Delete the selected name @@ -1187,7 +1187,7 @@ Unknown - + True False Edit the selected attribute @@ -1399,7 +1399,7 @@ Unknown - + True False Edit the selected address @@ -2190,7 +2190,7 @@ Unknown 6 - + True Add an internet reference about this person True @@ -2218,7 +2218,7 @@ Unknown - + True False Edit the selected internet address @@ -2274,7 +2274,7 @@ Unknown - + True False Delete selected reference