After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 65501 - Message dialog constructor that takes markup
Message dialog constructor that takes markup
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.1.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 91342 94533 100511 109143 112901 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2001-11-27 14:51 UTC by Havoc Pennington
Modified: 2011-02-04 16:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Updated patch (6.93 KB, patch)
2003-03-29 04:43 UTC, Sebastian Rittau
none Details | Review

Description Havoc Pennington 2001-11-27 14:51:21 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.
Comment 1 Havoc Pennington 2001-11-27 15:20:31 UTC
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.
Comment 2 Havoc Pennington 2001-11-27 15:21:37 UTC
Let's just add message_dialog_new_with_markup() someday.
Comment 3 Owen Taylor 2002-08-21 19:25:31 UTC
*** Bug 91342 has been marked as a duplicate of this bug. ***
Comment 4 Sebastian Rittau 2002-08-22 00:10:09 UTC
So, mark this for 2.2 API freeze?
Comment 5 Owen Taylor 2002-09-30 18:27:02 UTC
*** Bug 94533 has been marked as a duplicate of this bug. ***
Comment 6 Owen Taylor 2002-09-30 18:27:31 UTC
bug 95433 has a patch
Comment 7 Matthias Clasen 2002-12-06 12:37:17 UTC
*** Bug 100511 has been marked as a duplicate of this bug. ***
Comment 8 Murray Cumming 2002-12-06 12:45:53 UTC
Owen, I see no patch in bug 95433.
Comment 9 Murray Cumming 2002-12-06 12:56:43 UTC
Adding HIG keyword, because the HIG requires markup in alert dialogs.
Comment 10 Owen Taylor 2002-12-06 13:54:30 UTC
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.
Comment 11 Matthias Clasen 2003-03-25 12:06:49 UTC
*** Bug 109143 has been marked as a duplicate of this bug. ***
Comment 12 Owen Taylor 2003-03-28 21:04:27 UTC
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.
Comment 13 Havoc Pennington 2003-03-28 23:53:30 UTC
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.
Comment 14 Sebastian Rittau 2003-03-29 04:43:50 UTC
Created attachment 15291 [details] [review]
Updated patch
Comment 15 Sebastian Rittau 2003-03-29 04:49:27 UTC
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.
Comment 16 Dave Bordoley [Not Reading Bug Mail] 2003-05-13 14:48:57 UTC
*** Bug 112901 has been marked as a duplicate of this bug. ***
Comment 17 Owen Taylor 2003-07-18 14:09:06 UTC
Looks good to go in to me.