* 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


svn: r3746
This commit is contained in:
Don Allingham 2004-11-23 05:15:37 +00:00
parent 5b5db96852
commit c01cd56028
6 changed files with 168 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2004-11-22 Don Allingham <dallingham@users.sourceforge.net>
* 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 <dallingham@users.sourceforge.net> 2004-11-20 Don Allingham <dallingham@users.sourceforge.net>
* src/plugins/ChangeNames.py: Add a plugin to change capitalization * src/plugins/ChangeNames.py: Add a plugin to change capitalization
of family names of family names

View File

@ -129,6 +129,27 @@ class EditSource:
self.top_window.get_widget("edit_photo").set_sensitive(0) self.top_window.get_widget("edit_photo").set_sensitive(0)
self.top_window.get_widget("delete_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: if parent_window:
self.top.set_transient_for(parent_window) self.top.set_transient_for(parent_window)
@ -138,6 +159,12 @@ class EditSource:
self.add_itself_to_menu() self.add_itself_to_menu()
self.top.show() 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): def on_delete_event(self,obj,b):
self.close_child_windows() self.close_child_windows()
self.remove_itself_from_menu() self.remove_itself_from_menu()
@ -329,6 +356,15 @@ class EditSource:
if format != self.source.get_note_format(): if format != self.source.get_note_format():
self.source.set_note_format(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 self.gallery_ok = 1
trans = self.db.transaction_begin() trans = self.db.transaction_begin()

View File

@ -369,6 +369,7 @@ class GrampsParser:
"cause" : (None, self.stop_cause), "cause" : (None, self.stop_cause),
"description": (None, self.stop_description), "description": (None, self.stop_description),
"event" : (self.start_event, self.stop_event), "event" : (self.start_event, self.stop_event),
"data_item" : (self.start_data_item, None),
"families" : (None, self.stop_families), "families" : (None, self.stop_families),
"family" : (self.start_family, self.stop_family), "family" : (self.start_family, self.stop_family),
"father" : (self.start_father, None), "father" : (self.start_father, None),
@ -578,6 +579,9 @@ class GrampsParser:
def start_temple(self,attrs): def start_temple(self,attrs):
self.ord.set_temple(attrs['val']) 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): def start_status(self,attrs):
self.ord.set_status(int(attrs['val'])) self.ord.set_status(int(attrs['val']))

View File

@ -1191,12 +1191,13 @@ class Source(PrimaryObject):
self.pubinfo = "" self.pubinfo = ""
self.note = Note() self.note = Note()
self.media_list = [] self.media_list = []
self.datamap = {}
self.abbrev = "" self.abbrev = ""
def serialize(self): def serialize(self):
return (self.handle, self.gramps_id, self.title, self.author, return (self.handle, self.gramps_id, self.title, self.author,
self.pubinfo, self.note, self.media_list, self.abbrev, self.pubinfo, self.note, self.media_list, self.abbrev,
self.change) self.change,self.datamap)
def unserialize(self,data): def unserialize(self,data):
""" """
@ -1205,7 +1206,7 @@ class Source(PrimaryObject):
""" """
(self.handle, self.gramps_id, self.title, self.author, (self.handle, self.gramps_id, self.title, self.author,
self.pubinfo, self.note, self.media_list, self.abbrev, self.pubinfo, self.note, self.media_list, self.abbrev,
self.change) = data self.change,self.datamap) = data
def get_display_info(self): def get_display_info(self):
return [self.title,self.gramps_id,self.author, return [self.title,self.gramps_id,self.author,
@ -1223,6 +1224,18 @@ class Source(PrimaryObject):
"""Sets the list of MediaObject objects""" """Sets the list of MediaObject objects"""
self.media_list = list 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): def set_title(self,title):
"""sets the title of the Source""" """sets the title of the Source"""
self.title = title self.title = title

View File

@ -375,7 +375,8 @@ class XmlWriter:
self.callback(float(count)/float(total)) self.callback(float(count)/float(total))
count = count + 1 count = count + 1
self.g.write(" <source id=\"%s\" handle=\"%s\" change=\"%d\">\n" % self.g.write(" <source id=\"%s\" handle=\"%s\" change=\"%d\">\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_force_line("stitle",source.get_title(),3)
self.write_line("sauthor",source.get_author(),3) self.write_line("sauthor",source.get_author(),3)
self.write_line("spubinfo",source.get_publication_info(),3) self.write_line("spubinfo",source.get_publication_info(),3)
@ -383,6 +384,7 @@ class XmlWriter:
if source.get_note() != "": if source.get_note() != "":
self.write_note("note",source.get_note_object(),3) self.write_note("note",source.get_note_object(),3)
self.write_media_list(source.get_media_list()) self.write_media_list(source.get_media_list())
self.write_data_map(source.get_data_map())
self.g.write(" </source>\n") self.g.write(" </source>\n")
self.g.write(" </sources>\n") self.g.write(" </sources>\n")
@ -770,6 +772,15 @@ class XmlWriter:
self.write_note("note",photo.get_note_object(),indent+1) self.write_note("note",photo.get_note_object(),indent+1)
self.g.write('%s</objref>\n' % sp) self.g.write('%s</objref>\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<data_item key="%s" value="%s"/>' %
(sp,key,datamap[key]))
def write_url_list(self,list): def write_url_list(self,list):
for url in list: for url in list:
self.g.write(' <url priv="%d" href="%s"' % \ self.g.write(' <url priv="%d" href="%s"' % \

View File

@ -5851,6 +5851,51 @@ Other</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow83">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="datalist">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">True</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label432">
<property name="visible">True</property>
<property name="label" translatable="yes">Data</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child> <child>
<widget class="GtkVBox" id="vbox64"> <widget class="GtkVBox" id="vbox64">
<property name="visible">True</property> <property name="visible">True</property>
@ -5901,15 +5946,25 @@ Other</property>
<child> <child>
<widget class="GtkButton" id="add_photo"> <widget class="GtkButton" id="add_photo">
<property name="width_request">36</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Add a new media object to the database and place it in this gallery</property> <property name="tooltip" translatable="yes">Add a new media object to the database and place it in this gallery</property>
<property name="can_default">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">_Add from file...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
<signal name="clicked" handler="on_addphoto_clicked" object="sourceEditor"/> <signal name="clicked" handler="on_addphoto_clicked" object="sourceEditor"/>
<child>
<widget class="GtkImage" id="image2288">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -5922,13 +5977,22 @@ Other</property>
<widget class="GtkButton" id="button169"> <widget class="GtkButton" id="button169">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Select an existing media object from the database and place it in this gallery</property> <property name="tooltip" translatable="yes">Select an existing media object from the database and place it in this gallery</property>
<property name="can_default">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">Add from _database...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
<signal name="clicked" handler="on_selectphoto_clicked" object="sourceEditor" last_modification_time="Fri, 12 Dec 2003 05:21:39 GMT"/> <signal name="clicked" handler="on_selectphoto_clicked" object="sourceEditor" last_modification_time="Fri, 12 Dec 2003 05:21:39 GMT"/>
<child>
<widget class="GtkImage" id="image2289">
<property name="visible">True</property>
<property name="stock">gtk-index</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -5942,11 +6006,21 @@ Other</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Edit the properties of the selected object</property> <property name="tooltip" translatable="yes">Edit the properties of the selected object</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">_Edit...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
<signal name="clicked" handler="on_editphoto_clicked" object="sourceEditor" last_modification_time="Fri, 06 Feb 2004 20:06:09 GMT"/> <signal name="clicked" handler="on_editphoto_clicked" object="sourceEditor" last_modification_time="Fri, 06 Feb 2004 20:06:09 GMT"/>
<child>
<widget class="GtkImage" id="image2290">
<property name="width_request">36</property>
<property name="visible">True</property>
<property name="pixbuf">edit_sm.png</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -5959,13 +6033,22 @@ Other</property>
<widget class="GtkButton" id="delete_photo"> <widget class="GtkButton" id="delete_photo">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Remove selected object from this gallery only</property> <property name="tooltip" translatable="yes">Remove selected object from this gallery only</property>
<property name="can_default">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">_Remove</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
<signal name="clicked" handler="on_deletephoto_clicked" object="sourceEditor"/> <signal name="clicked" handler="on_deletephoto_clicked" object="sourceEditor"/>
<child>
<widget class="GtkImage" id="image2291">
<property name="visible">True</property>
<property name="stock">gtk-remove</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>