Commit 935b37eb authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Allow NULL for message_format, as described in the docs and as worked

Wed Oct 29 15:40:26 2003  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkmessagedialog.c (gtk_message_dialog_new/
        gtk_message_dialog_new_with_format): Allow NULL
        for message_format, as described in the docs and
        as worked previously. (#125759, Richard Hult)

        * gtk/gtkmessagedialog.c (gtk_message_dialog_new_with_markup):
        Use g_markup_vprintf_escaped() to escape argumetns.

        * gtk/gtkmessagedialog.[ch]: Add gtk_message_dialog_set_markup()
        so there is some way to set literal markup.
parent 6773cabf
Wed Oct 29 15:40:26 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmessagedialog.c (gtk_message_dialog_new/
gtk_message_dialog_new_with_format): Allow NULL
for message_format, as described in the docs and
as worked previously. (#125759, Richard Hult)
* gtk/gtkmessagedialog.c (gtk_message_dialog_new_with_markup):
Use g_markup_vprintf_escaped() to escape argumetns.
* gtk/gtkmessagedialog.[ch]: Add gtk_message_dialog_set_markup()
so there is some way to set literal markup.
Wed Oct 29 15:01:32 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkimage-x11.c (_gdk_x11_copy_to_image): Move
......
Wed Oct 29 15:40:26 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmessagedialog.c (gtk_message_dialog_new/
gtk_message_dialog_new_with_format): Allow NULL
for message_format, as described in the docs and
as worked previously. (#125759, Richard Hult)
* gtk/gtkmessagedialog.c (gtk_message_dialog_new_with_markup):
Use g_markup_vprintf_escaped() to escape argumetns.
* gtk/gtkmessagedialog.[ch]: Add gtk_message_dialog_set_markup()
so there is some way to set literal markup.
Wed Oct 29 15:01:32 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkimage-x11.c (_gdk_x11_copy_to_image): Move
......
Wed Oct 29 15:40:26 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmessagedialog.c (gtk_message_dialog_new/
gtk_message_dialog_new_with_format): Allow NULL
for message_format, as described in the docs and
as worked previously. (#125759, Richard Hult)
* gtk/gtkmessagedialog.c (gtk_message_dialog_new_with_markup):
Use g_markup_vprintf_escaped() to escape argumetns.
* gtk/gtkmessagedialog.[ch]: Add gtk_message_dialog_set_markup()
so there is some way to set literal markup.
Wed Oct 29 15:01:32 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkimage-x11.c (_gdk_x11_copy_to_image): Move
......
Wed Oct 29 15:40:26 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmessagedialog.c (gtk_message_dialog_new/
gtk_message_dialog_new_with_format): Allow NULL
for message_format, as described in the docs and
as worked previously. (#125759, Richard Hult)
* gtk/gtkmessagedialog.c (gtk_message_dialog_new_with_markup):
Use g_markup_vprintf_escaped() to escape argumetns.
* gtk/gtkmessagedialog.[ch]: Add gtk_message_dialog_set_markup()
so there is some way to set literal markup.
Wed Oct 29 15:01:32 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkimage-x11.c (_gdk_x11_copy_to_image): Move
......
Wed Oct 29 15:40:26 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmessagedialog.c (gtk_message_dialog_new/
gtk_message_dialog_new_with_format): Allow NULL
for message_format, as described in the docs and
as worked previously. (#125759, Richard Hult)
* gtk/gtkmessagedialog.c (gtk_message_dialog_new_with_markup):
Use g_markup_vprintf_escaped() to escape argumetns.
* gtk/gtkmessagedialog.[ch]: Add gtk_message_dialog_set_markup()
so there is some way to set literal markup.
Wed Oct 29 15:01:32 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkimage-x11.c (_gdk_x11_copy_to_image): Move
......
......@@ -305,7 +305,6 @@ gtk_message_dialog_new (GtkWindow *parent,
va_list args;
g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
g_return_val_if_fail (message_format != NULL, NULL);
widget = g_object_new (GTK_TYPE_MESSAGE_DIALOG,
"message_type", type,
......@@ -363,26 +362,25 @@ gtk_message_dialog_new (GtkWindow *parent,
* When the user clicks a button a "response" signal is emitted with
* response IDs from #GtkResponseType. See #GtkDialog for more details.
*
* Please note that if you have strings in the printf() arguments
* passed to this function, you might need to protect against
* them being interpreted as markup. You can do this using
* g_markup_escape_text() as in the following example:
* Special XML characters in the printf() arguments passed to this
* function will automatically be escaped as necessary.
* (See g_markup_printf_escaped() for how this is implemented.)
* Usually this is what you want, but if you have an existing
* Pango markup string that you want to use literally as the
* label, then you need to use gtk_message_dialog_set_markup()
* instead, since you can't pass the markup string either
* as the format (it might contain '%' characters) or as a string
* argument.
*
* <informalexample><programlisting>
* const gchar *error_text =
* "&lt;span weight=\"bold\" size=\"larger\"&gt;"
* "Could not open document '%s'."
* "&lt;/span&gt;\n\n"
* "You do not have appropriate permission to access this file.";
* gchar *tmp;
* GtkWidget *dialog;
*
* tmp = g_markup_escape_text (filename, -1);
* dialog = gtk_message_dialog_new_with_markup (main_application_window,
* GTK_DIALOG_DESTROY_WITH_PARENT,
* GTK_MESSAGE_ERROR,
* GTK_BUTTONS_CLOSE,
* error_text, tmp);
* g_free (tmp);
* GtkWidget *dialog;
* dialog = gtk_message_dialog_new (main_application_window,
* GTK_DIALOG_DESTROY_WITH_PARENT,
* GTK_MESSAGE_ERROR,
* GTK_BUTTON_CLOSE,
* NULL);
* gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
* markup);
* </programlisting></informalexample>
*
* Return value: a new #GtkMessageDialog
......@@ -402,18 +400,16 @@ gtk_message_dialog_new_with_markup (GtkWindow *parent,
va_list args;
g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
g_return_val_if_fail (message_format != NULL, NULL);
widget = gtk_message_dialog_new (parent, flags, type, buttons, "");
widget = gtk_message_dialog_new (parent, flags, type, buttons, NULL);
if (message_format)
{
va_start (args, message_format);
msg = g_strdup_vprintf(message_format, args);
msg = g_markup_vprintf_escaped (message_format, args);
va_end (args);
gtk_label_set_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (widget)->label),
msg);
gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (widget), msg);
g_free (msg);
}
......@@ -421,6 +417,26 @@ gtk_message_dialog_new_with_markup (GtkWindow *parent,
return widget;
}
/**
* gtk_message_dialog_set_markup:
* @message_dialog: a #GtkMessageDialog
* @str: markup string (see <link linkend="PangoMarkupFormat">Pango markup format</link>)
*
* Sets the text of the message dialog to be @str, which is marked
* up with the <link linkend="PangoMarkupFormat">Pango text markup
* language</link>.
*
* Since: 2.4
**/
void
gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog,
const gchar *str)
{
g_return_if_fail (GTK_IS_MESSAGE_DIALOG (message_dialog));
gtk_label_set_markup (GTK_LABEL (message_dialog->label), str);
}
static void
gtk_message_dialog_add_buttons (GtkMessageDialog* message_dialog,
GtkButtonsType buttons)
......
......@@ -98,9 +98,10 @@ GtkWidget* gtk_message_dialog_new_with_markup (GtkWindow *parent,
GtkButtonsType buttons,
const gchar *message_format,
...) G_GNUC_PRINTF (5, 6);
void gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog,
const gchar *str);
#ifdef __cplusplus
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment