From 01c4b0e81c0dbe0fe8c8ce0485e8dfdacf95e424 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Thu, 8 Jan 2009 02:12:53 +0000 Subject: [PATCH] Fixes for bug #2416: added proper name format in gtk tree model, and update on canceled edit; undid previous hack svn: r11584 --- src/GrampsCfg.py | 35 +++++++++++++++++++++++++++++++---- src/plugins/ExportXml.py | 2 +- src/plugins/ImportXml.py | 2 +- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/GrampsCfg.py b/src/GrampsCfg.py index ba497e96f..fcb5df539 100644 --- a/src/GrampsCfg.py +++ b/src/GrampsCfg.py @@ -417,14 +417,37 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): "%s %s, %s" % (_("Given"), _("SURNAME"), _("Suffix")), "%s /%s/" % (_("Given"), _("SURNAME")), ] - f = lyst[int(random.random() * len(lyst))] - i = _nd.add_name_format(f, f.lower()) - node = self.fmt_model.append(row=[i, f, f.lower(), - _nd.format_str(self.examplename, f)]) + fmtlyst = ["%s, %s %s (%s)" % ("Surname", "Given", "Suffix", + "Common"), + "%s, %s %s (%s)" % ("Surname", "Given", "Suffix", + "Call"), + "%s, %s %s (%s)" % ("SURNAME", "Given", "Suffix", + "Call"), + "%s, %s (%s)" % ("Surname", "Given", "Common"), + "%s, %s (%s)" % ("Surname", "Given", "Call"), + "%s %s" % ("Given", "Surname"), + "%s %s, %s" % ("Given", "Surname", "Suffix"), + "%s %s %s" % ("Given", "Surname", "Patronymic"), + "%s, %s %s (%s)" % ("SURNAME", "Given", "Suffix", + "Common"), + "%s, %s (%s)" % ("SURNAME", "Given", "Common"), + "%s, %s (%s)" % ("SURNAME", "Given", "Call"), + "%s %s" % ("Given", "SURNAME"), + "%s %s, %s" % ("Given", "SURNAME", "Suffix"), + "%s /%s/" % ("Given", "SURNAME"), + ] + rand = int(random.random() * len(lyst)) + f = lyst[rand] + fmt = fmtlyst[rand] + i = _nd.add_name_format(f, fmt) + node = self.fmt_model.append(row=[i, f, fmt, + _nd.format_str(self.examplename, fmt)]) path = self.fmt_model.get_path(node) self.format_list.set_cursor(path, focus_column=self.name_column, start_editing=True) + self.__current_path = path + self.__current_text = f def __edit_name(self, obj): store, node = self.format_list.get_selection().get_selected() @@ -452,6 +475,9 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): iter = model.iter_next(iter) return False + def __cancel_change(self, obj): + self.__change_name("", self.__current_path, self.__current_text) + def __change_name(self, text, path, new_text): """ If the new string is empty, do nothing. Otherwise, renaming the @@ -514,6 +540,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): text=COL_NAME) name_renderer.set_property('editable', False) name_renderer.connect('edited', self.__change_name) + name_renderer.connect('editing-canceled', self.__cancel_change) self.name_renderer = name_renderer format_tree.append_column(name_column) example_renderer = gtk.CellRendererText() diff --git a/src/plugins/ExportXml.py b/src/plugins/ExportXml.py index 51cbea161..f28fd47e0 100644 --- a/src/plugins/ExportXml.py +++ b/src/plugins/ExportXml.py @@ -376,7 +376,7 @@ class GrampsDbXmlWriter(UpdateCallback): for number, name,fmt_str,active in self.db.name_formats: self.g.write('%s\n' - % (' ', number, fmt_str, fmt_str, int(active)) ) + % (' ', number, name, fmt_str, int(active)) ) self.g.write(" \n") def fix(self,line): diff --git a/src/plugins/ImportXml.py b/src/plugins/ImportXml.py index 0603d86b3..ca2ef11c1 100644 --- a/src/plugins/ImportXml.py +++ b/src/plugins/ImportXml.py @@ -1061,7 +1061,7 @@ class GrampsParser(UpdateCallback): if number in self.taken_name_format_numbers: number = self.remap_name_format(number) - self.name_formats.append((number, fmt_str, fmt_str, active)) + self.name_formats.append((number, name, fmt_str, active)) def remap_name_format(self, old_number): if old_number in self.name_formats_map: # This should not happen