From 2cec9800664fb11be3f9deaf2b6cb6685a002edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Rapinat?= Date: Thu, 2 May 2013 15:38:53 +0000 Subject: [PATCH] 6576: Set custom pango markup can generate GtkWarning, ValueError or TypeError svn: r22143 --- gramps/gui/configure.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/gramps/gui/configure.py b/gramps/gui/configure.py index 1bd231c1b..08baf06c7 100644 --- a/gramps/gui/configure.py +++ b/gramps/gui/configure.py @@ -220,6 +220,27 @@ class ConfigureDialog(ManagedWindow): except: print("WARNING: ignoring invalid value for '%s'" % constant) + def update_markup_entry(self, obj, constant): + """ + :param obj: an object with get_text method + :param constant: the config setting to which the text value must be + saved + """ + try: + obj.get_text() % 'test_markup' + except TypeError: + print("WARNING: ignoring invalid value for '%s'" % constant) + ErrorDialog(_("Invalid or incomplete format definition."), + obj.get_text()) + obj.set_text('%s') + except ValueError: + print("WARNING: ignoring invalid value for '%s'" % constant) + ErrorDialog(_("Invalid or incomplete format definition."), + obj.get_text()) + obj.set_text('%s') + + self.__config.set(constant, unicode(obj.get_text())) + def update_entry(self, obj, constant): """ :param obj: an object with get_text method @@ -1167,7 +1188,7 @@ class GrampsPreferences(ConfigureDialog): 6, 'behavior.avg-generation-gap', (10, 30)) self.add_pos_int_entry(table, _('Markup for invalid date format'), - 7, 'preferences.invalid-date-format', self.update_entry) + 7, 'preferences.invalid-date-format', self.update_markup_entry) return _('Dates'), table