diff --git a/ChangeLog b/ChangeLog index d6eaaa3e1..5978b100c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-11-22 Don Allingham + * src/EditSource.py: add in-place editing for key,value pairs + * src/ReadXML.py: add support for Source key,value pairs + * src/WriteXML.py: add support for Source key,value pairs + * src/RelLib.py: add support for Source key,value pairs + * src/gramps.glade: add support for Source key,value pairs + 2004-11-20 Don Allingham * src/plugins/ChangeNames.py: Add a plugin to change capitalization of family names diff --git a/src/EditSource.py b/src/EditSource.py index edf90580e..db4573947 100644 --- a/src/EditSource.py +++ b/src/EditSource.py @@ -129,6 +129,27 @@ class EditSource: self.top_window.get_widget("edit_photo").set_sensitive(0) self.top_window.get_widget("delete_photo").set_sensitive(0) + self.datalist = self.top_window.get_widget('datalist') + colno = 0 + for title in [ (_('Key'),0,175), (_('Value'),1,150)]: + renderer = gtk.CellRendererText() + renderer.set_property('editable',True) + renderer.connect('edited',self.edit_cb, colno) + column = gtk.TreeViewColumn(title[0], renderer, text=colno) + colno += 1 + column.set_clickable(True) + column.set_resizable(True) + column.set_min_width(title[2]) + column.set_sort_column_id(title[1]) + self.datalist.append_column(column) + + self.data_model = gtk.ListStore(str,str) + self.datalist.set_model(self.data_model) + dmap = self.source.get_data_map() + for item in dmap.keys(): + self.data_model.append(row=[item,dmap[item]]) + self.data_model.append(row=['','']) + if parent_window: self.top.set_transient_for(parent_window) @@ -138,6 +159,12 @@ class EditSource: self.add_itself_to_menu() self.top.show() + def edit_cb(self, cell, path, new_text, data): + iter = self.data_model.get_iter(path) + self.data_model.set_value(iter,data,new_text) + if int(path)+1 == len(self.data_model): + self.data_model.append(row=['','']) + def on_delete_event(self,obj,b): self.close_child_windows() self.remove_itself_from_menu() @@ -329,6 +356,15 @@ class EditSource: if format != self.source.get_note_format(): self.source.set_note_format(format) + new_map = {} + for val in range(0,len(self.data_model)-1): + node = self.data_model.get_iter(val) + key = self.data_model.get_value(node,0) + value = self.data_model.get_value(node,1) + new_map[key] = value + if new_map != self.source.get_data_map(): + self.source.set_data_map(new_map) + self.gallery_ok = 1 trans = self.db.transaction_begin() diff --git a/src/ReadXML.py b/src/ReadXML.py index b0630d3d4..2f4054699 100644 --- a/src/ReadXML.py +++ b/src/ReadXML.py @@ -369,6 +369,7 @@ class GrampsParser: "cause" : (None, self.stop_cause), "description": (None, self.stop_description), "event" : (self.start_event, self.stop_event), + "data_item" : (self.start_data_item, None), "families" : (None, self.stop_families), "family" : (self.start_family, self.stop_family), "father" : (self.start_father, None), @@ -578,6 +579,9 @@ class GrampsParser: def start_temple(self,attrs): self.ord.set_temple(attrs['val']) + def start_data_item(self,attrs): + self.source.set_data_item(attrs['key'],attrs['value']) + def start_status(self,attrs): self.ord.set_status(int(attrs['val'])) diff --git a/src/RelLib.py b/src/RelLib.py index c48a64a94..1d7ba456a 100644 --- a/src/RelLib.py +++ b/src/RelLib.py @@ -1191,12 +1191,13 @@ class Source(PrimaryObject): self.pubinfo = "" self.note = Note() self.media_list = [] + self.datamap = {} self.abbrev = "" def serialize(self): return (self.handle, self.gramps_id, self.title, self.author, self.pubinfo, self.note, self.media_list, self.abbrev, - self.change) + self.change,self.datamap) def unserialize(self,data): """ @@ -1205,7 +1206,7 @@ class Source(PrimaryObject): """ (self.handle, self.gramps_id, self.title, self.author, self.pubinfo, self.note, self.media_list, self.abbrev, - self.change) = data + self.change,self.datamap) = data def get_display_info(self): return [self.title,self.gramps_id,self.author, @@ -1223,6 +1224,18 @@ class Source(PrimaryObject): """Sets the list of MediaObject objects""" self.media_list = list + def get_data_map(self): + """Returns the data map of attributes for the source""" + return self.datamap + + def set_data_map(self,datamap): + """Sets the data map of attributes for the source""" + self.datamap = datamap + + def set_data_item(self,key,value): + """Sets the particular data item in the attribute data map""" + self.datamap[key] = value + def set_title(self,title): """sets the title of the Source""" self.title = title diff --git a/src/WriteXML.py b/src/WriteXML.py index 59ef96048..9ec8d84d7 100644 --- a/src/WriteXML.py +++ b/src/WriteXML.py @@ -375,7 +375,8 @@ class XmlWriter: self.callback(float(count)/float(total)) count = count + 1 self.g.write(" \n" % - (source.get_gramps_id(), source.get_handle(), source.get_change_time())) + (source.get_gramps_id(), source.get_handle(), + source.get_change_time())) self.write_force_line("stitle",source.get_title(),3) self.write_line("sauthor",source.get_author(),3) self.write_line("spubinfo",source.get_publication_info(),3) @@ -383,6 +384,7 @@ class XmlWriter: if source.get_note() != "": self.write_note("note",source.get_note_object(),3) self.write_media_list(source.get_media_list()) + self.write_data_map(source.get_data_map()) self.g.write(" \n") self.g.write(" \n") @@ -770,6 +772,15 @@ class XmlWriter: self.write_note("note",photo.get_note_object(),indent+1) self.g.write('%s\n' % sp) + def write_data_map(self,datamap,indent=3): + if len(datamap) == 0: + return + + sp = ' '*indent + for key in datamap.keys(): + self.g.write('%s' % + (sp,key,datamap[key])) + def write_url_list(self,list): for url in list: self.g.write(' + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + True + True + True + False + True + + + + + False + True + + + + + + True + Data + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + True @@ -5901,15 +5946,25 @@ Other + 36 True Add a new media object to the database and place it in this gallery - True True - _Add from file... - True GTK_RELIEF_NORMAL True + + + + True + gtk-add + 4 + 0.5 + 0.5 + 0 + 0 + + 0 @@ -5922,13 +5977,22 @@ Other True Select an existing media object from the database and place it in this gallery - True True - Add from _database... - True GTK_RELIEF_NORMAL True + + + + True + gtk-index + 4 + 0.5 + 0.5 + 0 + 0 + + 0 @@ -5942,11 +6006,21 @@ Other True Edit the properties of the selected object True - _Edit... - True GTK_RELIEF_NORMAL True + + + + 36 + True + edit_sm.png + 0.5 + 0.5 + 0 + 0 + + 0 @@ -5959,13 +6033,22 @@ Other True Remove selected object from this gallery only - True True - _Remove - True GTK_RELIEF_NORMAL True + + + + True + gtk-remove + 4 + 0.5 + 0.5 + 0 + 0 + + 0