GNOME Bugzilla – Bug 65501
Message dialog constructor that takes markup
Last modified: 2011-02-04 16:12:26 UTC
The text passed to the message dialog constructor should be parsed as markup. This change can't be made compatibly if we don't do it for 2.0 though.
One problem with this is that if people use the message format they might forget they have to do this: s = g_markup_escape_text (string, -1); message_dialog_new ("%s", s); g_free (s); instead of using string directly. Blah.
Let's just add message_dialog_new_with_markup() someday.
*** Bug 91342 has been marked as a duplicate of this bug. ***
So, mark this for 2.2 API freeze?
*** Bug 94533 has been marked as a duplicate of this bug. ***
bug 95433 has a patch
*** Bug 100511 has been marked as a duplicate of this bug. ***
Owen, I see no patch in bug 95433.
Adding HIG keyword, because the HIG requires markup in alert dialogs.
If you look at the bug that was marked as a dup of this, you see that bug 94533 is the bug with the patch and I reversed the numbers in the comment.
*** Bug 109143 has been marked as a duplicate of this bug. ***
Just a few comments on the patch attached to bug 94533; it basically looks good: - I'm not sure that the average user actually really has a good idea what "varargs" are: + * Please note that markup in strings passed as varargs is also treated + * as markup! This means that you should use g_markup_escape_text() on + * all external strings that are passed as argument to this constructor. I'd rather say something like: "Please note that if you have strings in the printf arguments passed to this function, you need to protect against them being interpreted as markup. You can do this using g_markup_escape_text()" Then give a short example, demonstrating calling g_markup_escape_text(), gtk_message_dialog_new_with_markup() and g_free(). - gtk_message_dialog_new_with_markup() needs to duplicate the g_return_val_if_fail() checks from gtk_message_dialog_new() - we always want the checks at the entry point. - Extra blank line: + va_end (args); + + + gtk_label_set_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (widget)->label), - We never break lines like: +GtkWidget* gtk_message_dialog_new_with_markup + (GtkWindow *parent, - I don't think the gtk-demo change makes sense ... the markup doesn't serve any purpose there, it's just basically random so it's probably not a good piece of code to show as an example. If we want a gtk-demo example it should show a use of g_markup() for doing a HIG-style alert or something.
We might want to consider Christian's concerns about using markup, as they cause translator problems. i.e. it's right to use markup for substrings of a message but not around an entire message. So the API he wanted was e.g. gtk_label_set_weight() or something along those lines, instead of gtk_label_set_markup ("<b>foo</b>") It might be nice for translators if we provided a non-markup way to do standard HIG alerts. I do think the markup constructor should be added regardless but just throwing this in as a related issue.
Created attachment 15291 [details] [review] Updated patch
Owen: I have integrated your suggestions. Some notes: I included a "might" into "you need to protect against", since there are cases when such protection is not necessary or not wanted. I'm not completely happy with the example. The message way the message string is integrated is just clumsy. But I found no better alternative, given the physical layout constraints. Call to g_return_val_if_fail() could not be duplicated from gtk_message_dialog_new(), since the latter function did not include them either. The revised patch has included such checks in _new(), too. I will expand the dialogs and message boxes demo to also include an error dialog. This will be a separate patch.
*** Bug 112901 has been marked as a duplicate of this bug. ***
Looks good to go in to me.