Constructor

GtkDialognew_with_buttons

Declaration [src]

GtkWidget*
gtk_dialog_new_with_buttons (
  const gchar* title,
  GtkWindow* parent,
  GtkDialogFlags flags,
  const gchar* first_button_text,
  ...
)

Description [src]

Creates a new GtkDialog with title title (or NULL for the default title; see gtk_window_set_title()) and transient parent parent (or NULL for none; see gtk_window_set_transient_for()). The flags argument can be used to make the dialog modal (#GTK_DIALOG_MODAL) and/or to have it destroyed along with its transient parent (#GTK_DIALOG_DESTROY_WITH_PARENT). After flags, button text/response ID pairs should be listed, with a NULL pointer ending the list. Button text can be arbitrary text. A response ID can be any positive number, or one of the values in the GtkResponseType enumeration. If the user clicks one of these dialog buttons, GtkDialog will emit the GtkDialog::response signal with the corresponding response ID. If a GtkDialog receives the GtkWidget::delete-event signal, it will emit ::response with a response ID of #GTK_RESPONSE_DELETE_EVENT. However, destroying a dialog does not emit the ::response signal; so be careful relying on ::response when using the

GTK_DIALOG_DESTROY_WITH_PARENT flag. Buttons are from left to right,

so the first button in the list will be the leftmost button in the dialog.

Here’s a simple example:

 GtkWidget *main_app_window; // Window the dialog should show up on
 GtkWidget *dialog;
 GtkDialogFlags flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
 dialog = gtk_dialog_new_with_buttons ("My dialog",
                                       main_app_window,
                                       flags,
                                       _("_OK"),
                                       GTK_RESPONSE_ACCEPT,
                                       _("_Cancel"),
                                       GTK_RESPONSE_REJECT,
                                       NULL);

This method is not directly available to language bindings.

Parameters

title

Type: const gchar*

Title of the dialog, or NULL.

The argument can be NULL.
The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.
parent

Type: GtkWindow

Transient parent of the dialog, or NULL.

The argument can be NULL.
The data is owned by the caller of the function.
flags

Type: GtkDialogFlags

From GtkDialogFlags.

first_button_text

Type: const gchar*

Text to go in first button, or NULL.

The argument can be NULL.
The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.
...

Type: 

Response ID for first button, then additional buttons, ending with NULL.

Return value

Type: GtkWidget

A new GtkDialog.

The data is owned by the called function.