Hob: Interpret some special characters for label markup

Interpret some special characters for label markup, such as &, <, >, etc.
Otherwise, the message dialog can't show them, and worsely, it makes the
whole message blank.

[Yocto #2492]

(Bitbake rev: fb82f6eb5405274f702bd6d64cbe995fd4b74145)

Signed-off-by: Shane Wang <shane.wang@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Shane Wang 2012-06-02 12:54:38 +08:00 committed by Richard Purdie
parent 25785d8ddf
commit c0b92702d3
1 changed files with 11 additions and 2 deletions

View File

@ -374,6 +374,15 @@ class Builder(gtk.Window):
END_NOOP : None,
}
@classmethod
def interpret_markup(cls, msg):
msg = msg.replace('&', '&amp;')
msg = msg.replace('<', '&lt;')
msg = msg.replace('>', '&gt;')
msg = msg.replace('"', '&quot;')
msg = msg.replace("'", "&acute;")
return msg
def __init__(self, hobHandler, recipe_model, package_model):
super(Builder, self).__init__()
@ -729,7 +738,7 @@ class Builder(gtk.Window):
def show_error_dialog(self, msg):
lbl = "<b>Error</b>\n"
lbl = lbl + "%s\n\n" % msg
lbl = lbl + "%s\n\n" % Builder.interpret_markup(msg)
dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_ERROR)
button = dialog.add_button("Close", gtk.RESPONSE_OK)
HobButton.style_button(button)
@ -909,7 +918,7 @@ class Builder(gtk.Window):
self.build_failed()
def handler_no_provider_cb(self, running_build, msg):
dialog = CrumbsMessageDialog(self, msg, gtk.STOCK_DIALOG_INFO)
dialog = CrumbsMessageDialog(self, Builder.interpret_markup(msg), gtk.STOCK_DIALOG_INFO)
button = dialog.add_button("Close", gtk.RESPONSE_OK)
HobButton.style_button(button)
dialog.run()