* src/EditSource.py: handle add/delete data item buttons. Make

sure that data items with empty keys are not saved.
* src/gramps.glade: added add/delete buttons for Source Editor
* src/gramps_main.py: remove key-release-event
* src/RelLib.py: unicode conversions
* src/GrampsDbBase.py: make sure we are sorting by unicode values


svn: r3748
This commit is contained in:
Don Allingham 2004-11-24 18:01:49 +00:00
parent f7b653aa74
commit 9e63bff382
6 changed files with 138 additions and 34 deletions

View File

@ -1,3 +1,11 @@
2004-11-24 Don Allingham <dallingham@users.sourceforge.net>
* src/EditSource.py: handle add/delete data item buttons. Make
sure that data items with empty keys are not saved.
* src/gramps.glade: added add/delete buttons for Source Editor
* src/gramps_main.py: remove key-release-event
* src/RelLib.py: unicode conversions
* src/GrampsDbBase.py: make sure we are sorting by unicode values
2004-11-23 Don Allingham <dallingham@users.sourceforge.net> 2004-11-23 Don Allingham <dallingham@users.sourceforge.net>
* src/ReadGedcom.py: fix relative path filenames and build * src/ReadGedcom.py: fix relative path filenames and build
the thumbnail image the thumbnail image

View File

@ -123,6 +123,8 @@ class EditSource:
"on_sourceEditor_ok_clicked" : self.on_source_apply_clicked, "on_sourceEditor_ok_clicked" : self.on_source_apply_clicked,
"on_sourceEditor_cancel_clicked" : self.close, "on_sourceEditor_cancel_clicked" : self.close,
"on_sourceEditor_delete_event" : self.on_delete_event, "on_sourceEditor_delete_event" : self.on_delete_event,
"on_delete_data_clicked" : self.on_delete_data_clicked,
"on_add_data_clicked" : self.on_add_data_clicked,
}) })
if self.source.get_handle() == None: if self.source.get_handle() == None:
@ -131,6 +133,7 @@ class EditSource:
self.datalist = self.top_window.get_widget('datalist') self.datalist = self.top_window.get_widget('datalist')
colno = 0 colno = 0
first = True
for title in [ (_('Key'),0,175), (_('Value'),1,150)]: for title in [ (_('Key'),0,175), (_('Value'),1,150)]:
renderer = gtk.CellRendererText() renderer = gtk.CellRendererText()
renderer.set_property('editable',True) renderer.set_property('editable',True)
@ -142,13 +145,16 @@ class EditSource:
column.set_min_width(title[2]) column.set_min_width(title[2])
column.set_sort_column_id(title[1]) column.set_sort_column_id(title[1])
self.datalist.append_column(column) self.datalist.append_column(column)
if first:
first = False
self.key_cell = renderer
self.key_col = column
self.data_model = gtk.ListStore(str,str) self.data_model = gtk.ListStore(str,str)
self.datalist.set_model(self.data_model) self.datalist.set_model(self.data_model)
dmap = self.source.get_data_map() dmap = self.source.get_data_map()
for item in dmap.keys(): for item in dmap.keys():
self.data_model.append(row=[item,dmap[item]]) 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)
@ -158,12 +164,25 @@ class EditSource:
self.top.set_transient_for(parent_window) self.top.set_transient_for(parent_window)
self.add_itself_to_menu() self.add_itself_to_menu()
self.top.show() self.top.show()
self.data_sel = self.datalist.get_selection()
def on_add_data_clicked(self,widget):
node = self.data_model.append(row=['',''])
self.data_sel.select_iter(node)
path = self.data_model.get_path(node)
self.datalist.set_cursor_on_cell(path,
focus_column=self.key_col,
focus_cell=None,
start_editing=True)
def on_delete_data_clicked(self,widget):
(model,node) = self.data_sel.get_selected()
if node:
model.remove(node)
def edit_cb(self, cell, path, new_text, data): def edit_cb(self, cell, path, new_text, data):
iter = self.data_model.get_iter(path) iter = self.data_model.get_iter(path)
self.data_model.set_value(iter,data,new_text) 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()
@ -357,11 +376,12 @@ class EditSource:
self.source.set_note_format(format) self.source.set_note_format(format)
new_map = {} new_map = {}
for val in range(0,len(self.data_model)-1): for val in range(0,len(self.data_model)):
node = self.data_model.get_iter(val) node = self.data_model.get_iter(val)
key = self.data_model.get_value(node,0) key = self.data_model.get_value(node,0)
value = self.data_model.get_value(node,1) value = self.data_model.get_value(node,1)
new_map[key] = value if key:
new_map[unicode(key)] = unicode(value)
if new_map != self.source.get_data_map(): if new_map != self.source.get_data_map():
self.source.set_data_map(new_map) self.source.set_data_map(new_map)

View File

@ -1004,8 +1004,8 @@ class GrampsDbBase:
self.place_map.get(str(s))[2]) self.place_map.get(str(s))[2])
def _sortbysource(self,f,s): def _sortbysource(self,f,s):
fp = self.source_map[str(f)][2] fp = unicode(self.source_map[str(f)][2])
sp = self.source_map[str(s)][2] sp = unicode(self.source_map[str(s)][2])
return locale.strcoll(fp,sp) return locale.strcoll(fp,sp)
def _sortbymedia(self,f,s): def _sortbymedia(self,f,s):

View File

@ -262,7 +262,7 @@ class Person(PrimaryObject,SourceNote):
a form that it can use. a form that it can use.
""" """
return (self.handle, self.gramps_id, self.gender, return (self.handle, self.gramps_id, self.gender,
self.primary_name, self.alternate_names, self.nickname, self.primary_name, self.alternate_names, unicode(self.nickname),
self.death_handle, self.birth_handle, self.event_list, self.death_handle, self.birth_handle, self.event_list,
self.family_list, self.parent_family_list, self.family_list, self.parent_family_list,
self.media_list, self.address_list, self.attribute_list, self.media_list, self.address_list, self.attribute_list,
@ -1195,8 +1195,9 @@ class Source(PrimaryObject):
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, unicode(self.title),
self.pubinfo, self.note, self.media_list, self.abbrev, unicode(self.author), unicode(self.pubinfo),
unicode(self.note), self.media_list, unicode(self.abbrev),
self.change,self.datamap) self.change,self.datamap)
def unserialize(self,data): def unserialize(self,data):
@ -1205,8 +1206,8 @@ class Source(PrimaryObject):
back into the data in an Event structure. back into the data in an Event structure.
""" """
(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.change,self.datamap) = data self.abbrev, 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,

View File

@ -5851,6 +5851,13 @@ Other</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkHBox" id="hbox100">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child> <child>
<widget class="GtkScrolledWindow" id="scrolledwindow83"> <widget class="GtkScrolledWindow" id="scrolledwindow83">
<property name="visible">True</property> <property name="visible">True</property>
@ -5871,6 +5878,83 @@ Other</property>
</widget> </widget>
</child> </child>
</widget> </widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox89">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="button178">
<property name="width_request">36</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="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_add_data_clicked" last_modification_time="Wed, 24 Nov 2004 16:59:34 GMT"/>
<child>
<widget class="GtkImage" id="image2292">
<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>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button181">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Remove selected object from this gallery only</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_delete_data_clicked" last_modification_time="Wed, 24 Nov 2004 16:59:58 GMT"/>
<child>
<widget class="GtkImage" id="image2295">
<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>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing> <packing>
<property name="tab_expand">False</property> <property name="tab_expand">False</property>
<property name="tab_fill">True</property> <property name="tab_fill">True</property>

View File

@ -354,7 +354,6 @@ class Gramps:
"on_export_activate" : self.on_export_activate, "on_export_activate" : self.on_export_activate,
"on_pedigree1_activate" : self.on_pedigree1_activate, "on_pedigree1_activate" : self.on_pedigree1_activate,
"on_person_list1_activate" : self.on_person_list1_activate, "on_person_list1_activate" : self.on_person_list1_activate,
"on_main_key_release_event" : self.on_main_key_release_event,
"on_media_activate" : self.on_media_activate, "on_media_activate" : self.on_media_activate,
"on_media_list_select_row" : self.media_view.on_select_row, "on_media_list_select_row" : self.media_view.on_select_row,
"on_media_list_drag_data_get" : self.media_view.on_drag_data_get, "on_media_list_drag_data_get" : self.media_view.on_drag_data_get,
@ -1646,14 +1645,6 @@ class Gramps:
if self.active_person: if self.active_person:
task(self.db,self.active_person,self.tool_callback,self) task(self.db,self.active_person,self.tool_callback,self)
def on_main_key_release_event(self,obj,event):
"""Respond to the insert and delete buttons in the person list"""
pass
#if event.keyval == GDK.Delete:
# self.on_delete_person_clicked(obj)
#elif event.keyval == GDK.Insert:
# self.load_new_person(obj)
def open_example(self,obj): def open_example(self,obj):
pass pass