6576: Set custom pango markup can generate GtkWarning, ValueError or TypeError

svn: r22143
This commit is contained in:
Jérôme Rapinat 2013-05-02 15:38:53 +00:00
parent 8b452f95cb
commit 2cec980066

View File

@ -220,6 +220,27 @@ class ConfigureDialog(ManagedWindow):
except: except:
print("WARNING: ignoring invalid value for '%s'" % constant) 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('<b>%s</b>')
except ValueError:
print("WARNING: ignoring invalid value for '%s'" % constant)
ErrorDialog(_("Invalid or incomplete format definition."),
obj.get_text())
obj.set_text('<b>%s</b>')
self.__config.set(constant, unicode(obj.get_text()))
def update_entry(self, obj, constant): def update_entry(self, obj, constant):
""" """
:param obj: an object with get_text method :param obj: an object with get_text method
@ -1167,7 +1188,7 @@ class GrampsPreferences(ConfigureDialog):
6, 'behavior.avg-generation-gap', (10, 30)) 6, 'behavior.avg-generation-gap', (10, 30))
self.add_pos_int_entry(table, self.add_pos_int_entry(table,
_('Markup for invalid date format'), _('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 return _('Dates'), table