diff --git a/ChangeLog b/ChangeLog index de354fef4..37ab864ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-11-24 Don Allingham + * 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 * src/ReadGedcom.py: fix relative path filenames and build the thumbnail image diff --git a/src/EditSource.py b/src/EditSource.py index db4573947..94af5dab9 100644 --- a/src/EditSource.py +++ b/src/EditSource.py @@ -123,6 +123,8 @@ class EditSource: "on_sourceEditor_ok_clicked" : self.on_source_apply_clicked, "on_sourceEditor_cancel_clicked" : self.close, "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: @@ -131,6 +133,7 @@ class EditSource: self.datalist = self.top_window.get_widget('datalist') colno = 0 + first = True for title in [ (_('Key'),0,175), (_('Value'),1,150)]: renderer = gtk.CellRendererText() renderer.set_property('editable',True) @@ -142,14 +145,17 @@ class EditSource: column.set_min_width(title[2]) column.set_sort_column_id(title[1]) 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.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) @@ -158,12 +164,25 @@ class EditSource: self.top.set_transient_for(parent_window) self.add_itself_to_menu() 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): 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() @@ -357,11 +376,12 @@ class EditSource: self.source.set_note_format(format) 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) key = self.data_model.get_value(node,0) - value = self.data_model.get_value(node,1) - new_map[key] = value + value = self.data_model.get_value(node,1) + if key: + new_map[unicode(key)] = unicode(value) if new_map != self.source.get_data_map(): self.source.set_data_map(new_map) diff --git a/src/GrampsDbBase.py b/src/GrampsDbBase.py index f888047b9..370e40dc3 100644 --- a/src/GrampsDbBase.py +++ b/src/GrampsDbBase.py @@ -1004,8 +1004,8 @@ class GrampsDbBase: self.place_map.get(str(s))[2]) def _sortbysource(self,f,s): - fp = self.source_map[str(f)][2] - sp = self.source_map[str(s)][2] + fp = unicode(self.source_map[str(f)][2]) + sp = unicode(self.source_map[str(s)][2]) return locale.strcoll(fp,sp) def _sortbymedia(self,f,s): diff --git a/src/RelLib.py b/src/RelLib.py index 1d7ba456a..214dee527 100644 --- a/src/RelLib.py +++ b/src/RelLib.py @@ -262,7 +262,7 @@ class Person(PrimaryObject,SourceNote): a form that it can use. """ 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.family_list, self.parent_family_list, self.media_list, self.address_list, self.attribute_list, @@ -1195,8 +1195,9 @@ class Source(PrimaryObject): self.abbrev = "" def serialize(self): - return (self.handle, self.gramps_id, self.title, self.author, - self.pubinfo, self.note, self.media_list, self.abbrev, + return (self.handle, self.gramps_id, unicode(self.title), + unicode(self.author), unicode(self.pubinfo), + unicode(self.note), self.media_list, unicode(self.abbrev), self.change,self.datamap) def unserialize(self,data): @@ -1205,8 +1206,8 @@ class Source(PrimaryObject): back into the data in an Event structure. """ (self.handle, self.gramps_id, self.title, self.author, - self.pubinfo, self.note, self.media_list, self.abbrev, - self.change,self.datamap) = data + self.pubinfo, self.note, self.media_list, + self.abbrev, self.change, self.datamap) = data def get_display_info(self): return [self.title,self.gramps_id,self.author, diff --git a/src/gramps.glade b/src/gramps.glade index 77b9baae3..03708a52a 100644 --- a/src/gramps.glade +++ b/src/gramps.glade @@ -5852,23 +5852,107 @@ Other - + + 6 True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT + False + 6 - + True True - True - True - False - True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + True + True + True + False + True + + + + 0 + True + True + + + + + + True + False + 6 + + + + 36 + True + Add a new media object to the database and place it in this gallery + True + GTK_RELIEF_NORMAL + True + + + + + True + gtk-add + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + + True + Remove selected object from this gallery only + True + GTK_RELIEF_NORMAL + True + + + + + True + gtk-remove + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + 0 + False + True + diff --git a/src/gramps_main.py b/src/gramps_main.py index 7e7bb8614..a540658dc 100755 --- a/src/gramps_main.py +++ b/src/gramps_main.py @@ -354,7 +354,6 @@ class Gramps: "on_export_activate" : self.on_export_activate, "on_pedigree1_activate" : self.on_pedigree1_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_list_select_row" : self.media_view.on_select_row, "on_media_list_drag_data_get" : self.media_view.on_drag_data_get, @@ -1646,14 +1645,6 @@ class Gramps: if self.active_person: 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): pass