mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 14:10:30 +00:00
messagedialog: Convert docs
Convert link format, add an example image, add property annotations. General cleanup.
This commit is contained in:
parent
e999773566
commit
f3b16d0e9d
@ -38,62 +38,63 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:gtkmessagedialog
|
* GtkMessageDialog:
|
||||||
* @Short_description: A convenient message window
|
|
||||||
* @Title: GtkMessageDialog
|
|
||||||
* @See_also:#GtkDialog
|
|
||||||
*
|
*
|
||||||
* #GtkMessageDialog presents a dialog with some message text. It’s simply a
|
* `GtkMessageDialog` presents a dialog with some message text.
|
||||||
* convenience widget; you could construct the equivalent of #GtkMessageDialog
|
*
|
||||||
* from #GtkDialog without too much effort, but #GtkMessageDialog saves typing.
|
* ![An example GtkMessageDialog](messagedialog.png)
|
||||||
|
*
|
||||||
|
* It’s simply a convenience widget; you could construct the equivalent of
|
||||||
|
* `GtkMessageDialog` from `GtkDialog` without too much effort, but
|
||||||
|
* `GtkMessageDialog` saves typing.
|
||||||
*
|
*
|
||||||
* The easiest way to do a modal message dialog is to use the %GTK_DIALOG_MODAL
|
* The easiest way to do a modal message dialog is to use the %GTK_DIALOG_MODAL
|
||||||
* flag, which will call gtk_window_set_modal() internally. The dialog will
|
* flag, which will call [method@Gtk.Window.set_modal] internally. The dialog will
|
||||||
* prevent interaction with the parent window until it's hidden or destroyed.
|
* prevent interaction with the parent window until it's hidden or destroyed.
|
||||||
* You can use the #GtkDialog::response signal to know when the user dismissed
|
* You can use the [signal@Gtk.Dialog::response] signal to know when the user
|
||||||
* the dialog.
|
* dismissed the dialog.
|
||||||
*
|
*
|
||||||
* An example for using a modal dialog:
|
* An example for using a modal dialog:
|
||||||
* |[<!-- language="C" -->
|
* ```c
|
||||||
* GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL;
|
* GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL;
|
||||||
* dialog = gtk_message_dialog_new (parent_window,
|
* dialog = gtk_message_dialog_new (parent_window,
|
||||||
* flags,
|
* flags,
|
||||||
* GTK_MESSAGE_ERROR,
|
* GTK_MESSAGE_ERROR,
|
||||||
* GTK_BUTTONS_CLOSE,
|
* GTK_BUTTONS_CLOSE,
|
||||||
* "Error reading “%s”: %s",
|
* "Error reading “%s”: %s",
|
||||||
* filename,
|
* filename,
|
||||||
* g_strerror (errno));
|
* g_strerror (errno));
|
||||||
* // Destroy the dialog when the user responds to it
|
* // Destroy the dialog when the user responds to it
|
||||||
* // (e.g. clicks a button)
|
* // (e.g. clicks a button)
|
||||||
*
|
*
|
||||||
* g_signal_connect (dialog, "response",
|
* g_signal_connect (dialog, "response",
|
||||||
* G_CALLBACK (gtk_window_destroy),
|
* G_CALLBACK (gtk_window_destroy),
|
||||||
* NULL);
|
* NULL);
|
||||||
* ]|
|
* ```
|
||||||
*
|
*
|
||||||
* You might do a non-modal #GtkMessageDialog simply by omitting the
|
* You might do a non-modal `GtkMessageDialog` simply by omitting the
|
||||||
* %GTK_DIALOG_MODAL flag:
|
* %GTK_DIALOG_MODAL flag:
|
||||||
*
|
*
|
||||||
* |[<!-- language="C" -->
|
* ```c
|
||||||
* GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
|
* GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
|
||||||
* dialog = gtk_message_dialog_new (parent_window,
|
* dialog = gtk_message_dialog_new (parent_window,
|
||||||
* flags,
|
* flags,
|
||||||
* GTK_MESSAGE_ERROR,
|
* GTK_MESSAGE_ERROR,
|
||||||
* GTK_BUTTONS_CLOSE,
|
* GTK_BUTTONS_CLOSE,
|
||||||
* "Error reading “%s”: %s",
|
* "Error reading “%s”: %s",
|
||||||
* filename,
|
* filename,
|
||||||
* g_strerror (errno));
|
* g_strerror (errno));
|
||||||
*
|
*
|
||||||
* // Destroy the dialog when the user responds to it
|
* // Destroy the dialog when the user responds to it
|
||||||
* // (e.g. clicks a button)
|
* // (e.g. clicks a button)
|
||||||
* g_signal_connect (dialog, "response",
|
* g_signal_connect (dialog, "response",
|
||||||
* G_CALLBACK (gtk_window_destroy),
|
* G_CALLBACK (gtk_window_destroy),
|
||||||
* NULL);
|
* NULL);
|
||||||
* ]|
|
* ```
|
||||||
*
|
*
|
||||||
* # GtkMessageDialog as GtkBuildable
|
* # GtkMessageDialog as GtkBuildable
|
||||||
*
|
*
|
||||||
* The GtkMessageDialog implementation of the GtkBuildable interface exposes
|
* The `GtkMessageDialog` implementation of the `GtkBuildable` interface exposes
|
||||||
* the message area as an internal child with the name “message_area”.
|
* the message area as an internal child with the name “message_area”.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -377,8 +378,9 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class)
|
|||||||
/**
|
/**
|
||||||
* GtkMessageDialog:text:
|
* GtkMessageDialog:text:
|
||||||
*
|
*
|
||||||
* The primary text of the message dialog. If the dialog has
|
* The primary text of the message dialog.
|
||||||
* a secondary text, this will appear as the title.
|
*
|
||||||
|
* If the dialog has a secondary text, this will appear as the title.
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_TEXT,
|
PROP_TEXT,
|
||||||
@ -391,7 +393,8 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class)
|
|||||||
* GtkMessageDialog:use-markup:
|
* GtkMessageDialog:use-markup:
|
||||||
*
|
*
|
||||||
* %TRUE if the primary text of the dialog includes Pango markup.
|
* %TRUE if the primary text of the dialog includes Pango markup.
|
||||||
* See pango_parse_markup().
|
*
|
||||||
|
* See [func@Pango.parse_markup].
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_USE_MARKUP,
|
PROP_USE_MARKUP,
|
||||||
@ -416,7 +419,8 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class)
|
|||||||
* GtkMessageDialog:secondary-use-markup:
|
* GtkMessageDialog:secondary-use-markup:
|
||||||
*
|
*
|
||||||
* %TRUE if the secondary text of the dialog includes Pango markup.
|
* %TRUE if the secondary text of the dialog includes Pango markup.
|
||||||
* See pango_parse_markup().
|
*
|
||||||
|
* See [func@Pango.parse_markup].
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_SECONDARY_USE_MARKUP,
|
PROP_SECONDARY_USE_MARKUP,
|
||||||
@ -428,9 +432,10 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class)
|
|||||||
/**
|
/**
|
||||||
* GtkMessageDialog:message-area:
|
* GtkMessageDialog:message-area:
|
||||||
*
|
*
|
||||||
* The #GtkBox that corresponds to the message area of this dialog. See
|
* The `GtkBox` that corresponds to the message area of this dialog.
|
||||||
* gtk_message_dialog_get_message_area() for a detailed description of this
|
*
|
||||||
* area.
|
* See [method@Gtk.MessageDialog.get_message_area] for a detailed
|
||||||
|
* description of this area.
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_MESSAGE_AREA,
|
PROP_MESSAGE_AREA,
|
||||||
@ -480,12 +485,14 @@ gtk_message_dialog_init (GtkMessageDialog *dialog)
|
|||||||
* @message_format: (allow-none): printf()-style format string, or %NULL
|
* @message_format: (allow-none): printf()-style format string, or %NULL
|
||||||
* @...: arguments for @message_format
|
* @...: arguments for @message_format
|
||||||
*
|
*
|
||||||
* Creates a new message dialog, which is a simple dialog with some text
|
* Creates a new message dialog.
|
||||||
* the user may want to see. When the user clicks a button a “response”
|
|
||||||
* signal is emitted with response IDs from #GtkResponseType. See
|
|
||||||
* #GtkDialog for more details.
|
|
||||||
*
|
*
|
||||||
* Returns: (transfer none): a new #GtkMessageDialog
|
* This is a simple dialog with some text the user may want to see.
|
||||||
|
* When the user clicks a button a “response” signal is emitted with
|
||||||
|
* response IDs from [enum@Gtk.ResponseType]. See [class@Gtk.Dialog]
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): a new `GtkMessageDialog`
|
||||||
*/
|
*/
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
gtk_message_dialog_new (GtkWindow *parent,
|
gtk_message_dialog_new (GtkWindow *parent,
|
||||||
@ -542,33 +549,36 @@ gtk_message_dialog_new (GtkWindow *parent,
|
|||||||
* @message_format: (allow-none): printf()-style format string, or %NULL
|
* @message_format: (allow-none): printf()-style format string, or %NULL
|
||||||
* @...: arguments for @message_format
|
* @...: arguments for @message_format
|
||||||
*
|
*
|
||||||
* Creates a new message dialog, which is a simple dialog with some text that
|
* Creates a new message dialog.
|
||||||
* is marked up with the [Pango text markup language][PangoMarkupFormat].
|
*
|
||||||
* When the user clicks a button a “response” signal is emitted with
|
* This is a simple dialog with some text that is marked up with
|
||||||
* response IDs from #GtkResponseType. See #GtkDialog for more details.
|
* Pango markup. When the user clicks a button a “response” signal
|
||||||
|
* is emitted with response IDs from [enum@Gtk.ResponseType]. See
|
||||||
|
* [class@Gtk.Dialog] for more details.
|
||||||
*
|
*
|
||||||
* Special XML characters in the printf() arguments passed to this
|
* Special XML characters in the printf() arguments passed to this
|
||||||
* function will automatically be escaped as necessary.
|
* function will automatically be escaped as necessary.
|
||||||
* (See g_markup_printf_escaped() for how this is implemented.)
|
* (See g_markup_printf_escaped() for how this is implemented.)
|
||||||
* Usually this is what you want, but if you have an existing
|
* Usually this is what you want, but if you have an existing
|
||||||
* Pango markup string that you want to use literally as the
|
* Pango markup string that you want to use literally as the
|
||||||
* label, then you need to use gtk_message_dialog_set_markup()
|
* label, then you need to use [method@Gtk.MessageDialog.set_markup]
|
||||||
* instead, since you can’t pass the markup string either
|
* instead, since you can’t pass the markup string either
|
||||||
* as the format (it might contain “%” characters) or as a string
|
* as the format (it might contain “%” characters) or as a string
|
||||||
* argument.
|
* argument.
|
||||||
* |[<!-- language="C" -->
|
|
||||||
* GtkWidget *dialog;
|
|
||||||
* GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
|
|
||||||
* dialog = gtk_message_dialog_new (parent_window,
|
|
||||||
* flags,
|
|
||||||
* GTK_MESSAGE_ERROR,
|
|
||||||
* GTK_BUTTONS_CLOSE,
|
|
||||||
* NULL);
|
|
||||||
* gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
|
|
||||||
* markup);
|
|
||||||
* ]|
|
|
||||||
*
|
*
|
||||||
* Returns: a new #GtkMessageDialog
|
* ```c
|
||||||
|
* GtkWidget *dialog;
|
||||||
|
* GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
|
||||||
|
* dialog = gtk_message_dialog_new (parent_window,
|
||||||
|
* flags,
|
||||||
|
* GTK_MESSAGE_ERROR,
|
||||||
|
* GTK_BUTTONS_CLOSE,
|
||||||
|
* NULL);
|
||||||
|
* gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
|
||||||
|
* markup);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Returns: a new `GtkMessageDialog`
|
||||||
**/
|
**/
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
gtk_message_dialog_new_with_markup (GtkWindow *parent,
|
gtk_message_dialog_new_with_markup (GtkWindow *parent,
|
||||||
@ -602,12 +612,11 @@ gtk_message_dialog_new_with_markup (GtkWindow *parent,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_message_dialog_set_markup:
|
* gtk_message_dialog_set_markup:
|
||||||
* @message_dialog: a #GtkMessageDialog
|
* @message_dialog: a `GtkMessageDialog`
|
||||||
* @str: markup string (see [Pango markup format][PangoMarkupFormat])
|
* @str: string with Pango markup
|
||||||
*
|
*
|
||||||
* Sets the text of the message dialog to be @str, which is marked
|
* Sets the text of the message dialog.
|
||||||
* up with the [Pango text markup language][PangoMarkupFormat].
|
*/
|
||||||
**/
|
|
||||||
void
|
void
|
||||||
gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog,
|
gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog,
|
||||||
const char *str)
|
const char *str)
|
||||||
@ -622,12 +631,11 @@ gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_message_dialog_format_secondary_text:
|
* gtk_message_dialog_format_secondary_text:
|
||||||
* @message_dialog: a #GtkMessageDialog
|
* @message_dialog: a `GtkMessageDialog`
|
||||||
* @message_format: (allow-none): printf()-style format string, or %NULL
|
* @message_format: (allow-none): printf()-style format string, or %NULL
|
||||||
* @...: arguments for @message_format
|
* @...: arguments for @message_format
|
||||||
*
|
*
|
||||||
* Sets the secondary text of the message dialog to be @message_format
|
* Sets the secondary text of the message dialog.
|
||||||
* (with printf()-style).
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog,
|
gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog,
|
||||||
@ -664,28 +672,27 @@ gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_message_dialog_format_secondary_markup:
|
* gtk_message_dialog_format_secondary_markup:
|
||||||
* @message_dialog: a #GtkMessageDialog
|
* @message_dialog: a `GtkMessageDialog`
|
||||||
* @message_format: printf()-style markup string (see
|
* @message_format: printf()-style string with Pango markup
|
||||||
[Pango markup format][PangoMarkupFormat]), or %NULL
|
|
||||||
* @...: arguments for @message_format
|
* @...: arguments for @message_format
|
||||||
*
|
*
|
||||||
* Sets the secondary text of the message dialog to be @message_format (with
|
* Sets the secondary text of the message dialog.
|
||||||
* printf()-style), which is marked up with the
|
|
||||||
* [Pango text markup language][PangoMarkupFormat].
|
|
||||||
*
|
*
|
||||||
* Due to an oversight, this function does not escape special XML characters
|
* The @message_format is assumed to contain Pango markup.
|
||||||
* like gtk_message_dialog_new_with_markup() does. Thus, if the arguments
|
*
|
||||||
* may contain special XML characters, you should use g_markup_printf_escaped()
|
* Due to an oversight, this function does not escape special
|
||||||
* to escape it.
|
* XML characters like [ctor@Gtk.MessageDialog.new_with_markup]
|
||||||
|
* does. Thus, if the arguments may contain special XML characters,
|
||||||
* |[<!-- language="C" -->
|
* you should use g_markup_printf_escaped() to escape it.
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
* char *msg;
|
* char *msg;
|
||||||
*
|
*
|
||||||
* msg = g_markup_printf_escaped (message_format, ...);
|
* msg = g_markup_printf_escaped (message_format, ...);
|
||||||
* gtk_message_dialog_format_secondary_markup (message_dialog,
|
* gtk_message_dialog_format_secondary_markup (message_dialog,
|
||||||
* "%s", msg);
|
* "%s", msg);
|
||||||
* g_free (msg);
|
* g_free (msg);
|
||||||
* ]|
|
* ```
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog,
|
gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog,
|
||||||
@ -722,17 +729,18 @@ gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_message_dialog_get_message_area:
|
* gtk_message_dialog_get_message_area:
|
||||||
* @message_dialog: a #GtkMessageDialog
|
* @message_dialog: a `GtkMessageDialog`
|
||||||
*
|
*
|
||||||
* Returns the message area of the dialog. This is the box where the
|
* Returns the message area of the dialog.
|
||||||
* dialog’s primary and secondary labels are packed. You can add your
|
|
||||||
* own extra content to that box and it will appear below those labels.
|
|
||||||
* See gtk_dialog_get_content_area() for the corresponding
|
|
||||||
* function in the parent #GtkDialog.
|
|
||||||
*
|
*
|
||||||
* Returns: (transfer none): A #GtkBox corresponding to the
|
* This is the box where the dialog’s primary and secondary labels
|
||||||
|
* are packed. You can add your own extra content to that box and it
|
||||||
|
* will appear below those labels. See [method@Gtk.Dialog.get_content_area]
|
||||||
|
* for the corresponding function in the parent [class@Gtk.Dialog].
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): A `GtkBox` corresponding to the
|
||||||
* “message area” in the @message_dialog.
|
* “message area” in the @message_dialog.
|
||||||
**/
|
*/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gtk_message_dialog_get_message_area (GtkMessageDialog *message_dialog)
|
gtk_message_dialog_get_message_area (GtkMessageDialog *message_dialog)
|
||||||
{
|
{
|
||||||
@ -742,4 +750,3 @@ gtk_message_dialog_get_message_area (GtkMessageDialog *message_dialog)
|
|||||||
|
|
||||||
return priv->message_area;
|
return priv->message_area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,9 +56,10 @@ struct _GtkMessageDialog
|
|||||||
* @GTK_BUTTONS_YES_NO: Yes and No buttons
|
* @GTK_BUTTONS_YES_NO: Yes and No buttons
|
||||||
* @GTK_BUTTONS_OK_CANCEL: OK and Cancel buttons
|
* @GTK_BUTTONS_OK_CANCEL: OK and Cancel buttons
|
||||||
*
|
*
|
||||||
* Prebuilt sets of buttons for the dialog. If
|
* Prebuilt sets of buttons for `GtkDialog`.
|
||||||
* none of these choices are appropriate, simply use %GTK_BUTTONS_NONE
|
*
|
||||||
* then call gtk_dialog_add_buttons().
|
* If none of these choices are appropriate, simply use
|
||||||
|
* %GTK_BUTTONS_NONE and call [method@Gtk.Dialog.add_buttons].
|
||||||
*
|
*
|
||||||
* > Please note that %GTK_BUTTONS_OK, %GTK_BUTTONS_YES_NO
|
* > Please note that %GTK_BUTTONS_OK, %GTK_BUTTONS_YES_NO
|
||||||
* > and %GTK_BUTTONS_OK_CANCEL are discouraged by the
|
* > and %GTK_BUTTONS_OK_CANCEL are discouraged by the
|
||||||
|
Loading…
Reference in New Issue
Block a user