Fixes for bug #2416: added proper name format in gtk tree model, and update on canceled edit; undid previous hack
svn: r11584
This commit is contained in:
parent
4704f01093
commit
01c4b0e81c
@ -417,14 +417,37 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
|
|||||||
"%s %s, %s" % (_("Given"), _("SURNAME"), _("Suffix")),
|
"%s %s, %s" % (_("Given"), _("SURNAME"), _("Suffix")),
|
||||||
"%s /%s/" % (_("Given"), _("SURNAME")),
|
"%s /%s/" % (_("Given"), _("SURNAME")),
|
||||||
]
|
]
|
||||||
f = lyst[int(random.random() * len(lyst))]
|
fmtlyst = ["%s, %s %s (%s)" % ("Surname", "Given", "Suffix",
|
||||||
i = _nd.add_name_format(f, f.lower())
|
"Common"),
|
||||||
node = self.fmt_model.append(row=[i, f, f.lower(),
|
"%s, %s %s (%s)" % ("Surname", "Given", "Suffix",
|
||||||
_nd.format_str(self.examplename, f)])
|
"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)
|
path = self.fmt_model.get_path(node)
|
||||||
self.format_list.set_cursor(path,
|
self.format_list.set_cursor(path,
|
||||||
focus_column=self.name_column,
|
focus_column=self.name_column,
|
||||||
start_editing=True)
|
start_editing=True)
|
||||||
|
self.__current_path = path
|
||||||
|
self.__current_text = f
|
||||||
|
|
||||||
def __edit_name(self, obj):
|
def __edit_name(self, obj):
|
||||||
store, node = self.format_list.get_selection().get_selected()
|
store, node = self.format_list.get_selection().get_selected()
|
||||||
@ -452,6 +475,9 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
|
|||||||
iter = model.iter_next(iter)
|
iter = model.iter_next(iter)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def __cancel_change(self, obj):
|
||||||
|
self.__change_name("", self.__current_path, self.__current_text)
|
||||||
|
|
||||||
def __change_name(self, text, path, new_text):
|
def __change_name(self, text, path, new_text):
|
||||||
"""
|
"""
|
||||||
If the new string is empty, do nothing. Otherwise, renaming the
|
If the new string is empty, do nothing. Otherwise, renaming the
|
||||||
@ -514,6 +540,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
|
|||||||
text=COL_NAME)
|
text=COL_NAME)
|
||||||
name_renderer.set_property('editable', False)
|
name_renderer.set_property('editable', False)
|
||||||
name_renderer.connect('edited', self.__change_name)
|
name_renderer.connect('edited', self.__change_name)
|
||||||
|
name_renderer.connect('editing-canceled', self.__cancel_change)
|
||||||
self.name_renderer = name_renderer
|
self.name_renderer = name_renderer
|
||||||
format_tree.append_column(name_column)
|
format_tree.append_column(name_column)
|
||||||
example_renderer = gtk.CellRendererText()
|
example_renderer = gtk.CellRendererText()
|
||||||
|
@ -376,7 +376,7 @@ class GrampsDbXmlWriter(UpdateCallback):
|
|||||||
for number, name,fmt_str,active in self.db.name_formats:
|
for number, name,fmt_str,active in self.db.name_formats:
|
||||||
self.g.write('%s<format number="%d" name="%s" '
|
self.g.write('%s<format number="%d" name="%s" '
|
||||||
'fmt_str="%s" active="%d"/>\n'
|
'fmt_str="%s" active="%d"/>\n'
|
||||||
% (' ', number, fmt_str, fmt_str, int(active)) )
|
% (' ', number, name, fmt_str, int(active)) )
|
||||||
self.g.write(" </name-formats>\n")
|
self.g.write(" </name-formats>\n")
|
||||||
|
|
||||||
def fix(self,line):
|
def fix(self,line):
|
||||||
|
@ -1061,7 +1061,7 @@ class GrampsParser(UpdateCallback):
|
|||||||
if number in self.taken_name_format_numbers:
|
if number in self.taken_name_format_numbers:
|
||||||
number = self.remap_name_format(number)
|
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):
|
def remap_name_format(self, old_number):
|
||||||
if old_number in self.name_formats_map: # This should not happen
|
if old_number in self.name_formats_map: # This should not happen
|
||||||
|
Loading…
Reference in New Issue
Block a user