gui2: Implement Pango markup flag for tmessage and related wrappers

This allows enabling Pango markup in gui2::show_message() and
gui2::show_error_message(), as well as the gui2::tmessage dialog they
depend upon. This was a TODO item mentioned in the implementation of
gui2::show_message(). The default continues to be to not enable markup.
This commit is contained in:
Ignacio R. Morelle 2013-09-26 20:59:28 -03:00
parent cd69ae8e95
commit adf1e3f7d5
3 changed files with 13 additions and 9 deletions

View file

@ -86,6 +86,7 @@ void tmessage::pre_show(CVideo& /*video*/, twindow& window)
tcontrol& label = find_widget<tcontrol>(&window, "label", false);
label.set_label(message_);
label.set_use_markup(message_use_markup_);
// The label might not always be a scroll_label but the capturing
// shouldn't hurt.
@ -139,20 +140,19 @@ tmessage::tbutton_status::tbutton_status()
void show_message(CVideo& video, const std::string& title,
const std::string& message, const std::string& button_caption,
const bool auto_close)
const bool auto_close, const bool message_use_markup)
{
tmessage dlg(title, message, auto_close);
tmessage dlg(title, message, auto_close, message_use_markup);
dlg.set_button_caption(tmessage::ok, button_caption);
dlg.show(video);
}
int show_message(CVideo& video, const std::string& title,
const std::string& message, const tmessage::tbutton_style button_style,
bool /*message_use_markup*/,
bool message_use_markup,
bool /*message_title_mode*/)
{
/** @todo implement the markup mode. */
tmessage dlg(title, message, button_style == tmessage::auto_close);
tmessage dlg(title, message, button_style == tmessage::auto_close, message_use_markup);
switch(button_style) {
case tmessage::auto_close :

View file

@ -33,11 +33,12 @@ class tmessage : public tdialog
friend struct tmessage_implementation;
public:
tmessage(const std::string& title, const std::string& message,
const bool auto_close)
const bool auto_close, const bool message_use_markup)
: title_(title)
, image_()
, message_(message)
, auto_close_(auto_close)
, message_use_markup_(message_use_markup)
, buttons_(count)
{}
@ -111,6 +112,9 @@ private:
*/
bool auto_close_;
/** Whether to enable formatting markup for the dialog message. */
bool message_use_markup_;
struct tbutton_status
{
tbutton_status();
@ -144,7 +148,7 @@ private:
*/
void show_message(CVideo& video, const std::string& title,
const std::string& message, const std::string& button_caption = "",
const bool auto_close = true);
const bool auto_close = true, const bool message_use_markup = false);
/**
* Shows a message to the user.

View file

@ -424,7 +424,7 @@ BOOST_AUTO_TEST_CASE(test_make_test_fake)
video().make_test_fake(10, 10);
try {
gui2::tmessage dlg("title", "message", true);
gui2::tmessage dlg("title", "message", true, false);
dlg.show(video(), 1);
} catch(twml_exception& e) {
BOOST_CHECK(e.user_message == _("Failed to show a dialog, "
@ -596,7 +596,7 @@ struct twrapper<gui2::tmessage>
{
static gui2::tmessage* create()
{
return new gui2::tmessage("Title", "Message", false);
return new gui2::tmessage("Title", "Message", false, false);
}
};