Top |
GtkWidget * | gtk_dialog_new () |
GtkWidget * | gtk_dialog_new_with_buttons () |
gint | gtk_dialog_run () |
void | gtk_dialog_response () |
GtkWidget * | gtk_dialog_add_button () |
void | gtk_dialog_add_buttons () |
void | gtk_dialog_add_action_widget () |
gboolean | gtk_dialog_get_has_separator () |
void | gtk_dialog_set_default_response () |
void | gtk_dialog_set_has_separator () |
void | gtk_dialog_set_response_sensitive () |
gint | gtk_dialog_get_response_for_widget () |
GtkWidget * | gtk_dialog_get_widget_for_response () |
GtkWidget * | gtk_dialog_get_action_area () |
GtkWidget * | gtk_dialog_get_content_area () |
gboolean | gtk_alternative_dialog_button_order () |
void | gtk_dialog_set_alternative_button_order () |
void | gtk_dialog_set_alternative_button_order_from_array () |
int | action-area-border | Read |
int | button-spacing | Read |
int | content-area-border | Read |
int | content-area-spacing | Read |
GObject ╰── GInitiallyUnowned ╰── GtkObject ╰── GtkWidget ╰── GtkContainer ╰── GtkBin ╰── GtkWindow ╰── GtkDialog ├── GtkAboutDialog ├── GtkColorSelectionDialog ├── GtkFileChooserDialog ├── GtkFileSelection ├── GtkFontSelectionDialog ├── GtkInputDialog ├── GtkMessageDialog ├── GtkPageSetupUnixDialog ├── GtkPrintUnixDialog ╰── GtkRecentChooserDialog
GtkWidget * gtk_dialog_new_with_buttons (const gchar *title
,GtkWindow *parent
,GtkDialogFlags flags
,const gchar *first_button_text
,...
);
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 either a stock ID such as
GTK_STOCK_OK, or some 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 “response” signal with the corresponding
response ID. If a GtkDialog receives the “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:
1 2 3 4 5 6 7 8 |
GtkWidget *dialog = gtk_dialog_new_with_buttons ("My dialog", main_app_window, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); |
title |
Title of the dialog, or |
[allow-none] |
parent |
Transient parent of the dialog, or |
[allow-none] |
flags |
from GtkDialogFlags |
|
first_button_text |
stock ID or text to go in first button, or |
[allow-none] |
Varargs |
response ID for first button, then additional buttons, ending with |
gint
gtk_dialog_run (GtkDialog *dialog
);
Blocks in a recursive main loop until the dialog
either emits the
“response” signal, or is destroyed. If the dialog is
destroyed during the call to gtk_dialog_run()
, gtk_dialog_run()
returns
GTK_RESPONSE_NONE. Otherwise, it returns the response ID from the
::response signal emission.
Before entering the recursive main loop, gtk_dialog_run()
calls
gtk_widget_show()
on the dialog for you. Note that you still
need to show any children of the dialog yourself.
During gtk_dialog_run()
, the default behavior of “delete-event”
is disabled; if the dialog receives ::delete_event, it will not be
destroyed as windows usually are, and gtk_dialog_run()
will return
GTK_RESPONSE_DELETE_EVENT. Also, during gtk_dialog_run()
the dialog
will be modal. You can force gtk_dialog_run()
to return at any time by
calling gtk_dialog_response()
to emit the ::response signal. Destroying
the dialog during gtk_dialog_run()
is a very bad idea, because your
post-run code won't know whether the dialog was destroyed or not.
After gtk_dialog_run()
returns, you are responsible for hiding or
destroying the dialog if you wish to do so.
Typical usage of this function might be:
1 2 3 4 5 6 7 8 9 10 11 |
gint result = gtk_dialog_run (GTK_DIALOG (dialog)); switch (result) { case GTK_RESPONSE_ACCEPT: do_application_specific_something (); break; default: do_nothing_since_dialog_was_cancelled (); break; } gtk_widget_destroy (dialog); |
Note that even though the recursive main loop gives the effect of a
modal dialog (it prevents the user from interacting with other
windows in the same window group while the dialog is run), callbacks
such as timeouts, IO channel watches, DND drops, etc, will
be triggered during a gtk_dialog_run()
call.
void gtk_dialog_response (GtkDialog *dialog
,gint response_id
);
Emits the “response” signal with the given response ID.
Used to indicate that the user has responded to the dialog in some way;
typically either you or gtk_dialog_run()
will be monitoring the
::response signal and take appropriate action.
GtkWidget * gtk_dialog_add_button (GtkDialog *dialog
,const gchar *button_text
,gint response_id
);
Adds a button with the given text (or a stock button, if button_text
is a
stock ID) and sets things up so that clicking the button will emit the
“response” signal with the given response_id
. The button is
appended to the end of the dialog's action area. The button widget is
returned, but usually you don't need it.
void gtk_dialog_add_buttons (GtkDialog *dialog
,const gchar *first_button_text
,...
);
Adds more buttons, same as calling gtk_dialog_add_button()
repeatedly. The variable argument list should be NULL
-terminated
as with gtk_dialog_new_with_buttons()
. Each button must have both
text and response ID.
void gtk_dialog_add_action_widget (GtkDialog *dialog
,GtkWidget *child
,gint response_id
);
Adds an activatable widget to the action area of a GtkDialog,
connecting a signal handler that will emit the “response”
signal on the dialog when the widget is activated. The widget is
appended to the end of the dialog's action area. If you want to add a
non-activatable widget, simply pack it into the action_area
field
of the GtkDialog struct.
gboolean
gtk_dialog_get_has_separator (GtkDialog *dialog
);
gtk_dialog_get_has_separator
has been deprecated since version 2.22 and should not be used in newly-written code.
This function will be removed in GTK+ 3
Accessor for whether the dialog has a separator.
void gtk_dialog_set_default_response (GtkDialog *dialog
,gint response_id
);
Sets the last widget in the dialog's action area with the given response_id
as the default widget for the dialog. Pressing "Enter" normally activates
the default widget.
void gtk_dialog_set_has_separator (GtkDialog *dialog
,gboolean setting
);
gtk_dialog_set_has_separator
has been deprecated since version 2.22 and should not be used in newly-written code.
This function will be removed in GTK+ 3
Sets whether the dialog has a separator above the buttons.
void gtk_dialog_set_response_sensitive (GtkDialog *dialog
,gint response_id
,gboolean setting
);
Calls gtk_widget_set_sensitive (widget,
for each widget in the dialog's action area with the given setting
)response_id
.
A convenient way to sensitize/desensitize dialog buttons.
gint gtk_dialog_get_response_for_widget (GtkDialog *dialog
,GtkWidget *widget
);
Gets the response id of a widget in the action area of a dialog.
Since: 2.8
GtkWidget * gtk_dialog_get_widget_for_response (GtkDialog *dialog
,gint response_id
);
Gets the widget button that uses the given response ID in the action area of a dialog.
Since: 2.20
GtkWidget *
gtk_dialog_get_action_area (GtkDialog *dialog
);
Returns the action area of dialog
.
Since: 2.14
GtkWidget *
gtk_dialog_get_content_area (GtkDialog *dialog
);
Returns the content area of dialog
.
Since: 2.14
gboolean
gtk_alternative_dialog_button_order (GdkScreen *screen
);
Returns TRUE
if dialogs are expected to use an alternative
button order on the screen screen
. See
gtk_dialog_set_alternative_button_order()
for more details
about alternative button order.
If you need to use this function, you should probably connect
to the ::notify:gtk-alternative-button-order signal on the
GtkSettings object associated to screen
, in order to be
notified if the button order setting changes.
Since: 2.6
void gtk_dialog_set_alternative_button_order (GtkDialog *dialog
,gint first_response_id
,...
);
Sets an alternative button order. If the
“gtk-alternative-button-order” setting is set to TRUE
,
the dialog buttons are reordered according to the order of the
response ids passed to this function.
By default, GTK+ dialogs use the button order advocated by the Gnome
Human Interface Guidelines with the affirmative button at the farright, and the cancel button left of it. But the builtin GTK+ dialogs and GtkMessageDialogs do provide an alternative button order, which is more suitable on some platforms, e.g. Windows.
Use this function after adding all the buttons to your dialog, as the following example shows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_OK); gtk_widget_grab_default (ok_button); help_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_HELP, GTK_RESPONSE_HELP); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, GTK_RESPONSE_HELP, -1); |
dialog |
||
first_response_id |
a response id used by one |
|
Varargs |
a list of more response ids of |
Since: 2.6
void gtk_dialog_set_alternative_button_order_from_array (GtkDialog *dialog
,gint n_params
,gint *new_order
);
Sets an alternative button order. If the
“gtk-alternative-button-order” setting is set to TRUE
,
the dialog buttons are reordered according to the order of the
response ids in new_order
.
See gtk_dialog_set_alternative_button_order()
for more information.
This function is for use by language bindings.
dialog |
||
n_params |
the number of response ids in |
|
new_order |
an array of response ids of
|
[array length=n_params] |
Since: 2.6
“has-separator”
property “has-separator” gboolean
When TRUE
, the dialog has a separator bar above its buttons.
GtkDialog:has-separator
has been deprecated since version 2.22 and should not be used in newly-written code.
This property will be removed in GTK+ 3.
Owner: GtkDialog
Flags: Read / Write
Default value: FALSE
“action-area-border”
style property “action-area-border” int
Width of border around the button area at the bottom of the dialog.
Owner: GtkDialog
Flags: Read
Allowed values: >= 0
Default value: 5
“button-spacing”
style property “button-spacing” int
Spacing between buttons.
Owner: GtkDialog
Flags: Read
Allowed values: >= 0
Default value: 6
“content-area-border”
style property “content-area-border” int
Width of border around the main dialog area.
Owner: GtkDialog
Flags: Read
Allowed values: >= 0
Default value: 2
“content-area-spacing”
style property “content-area-spacing” int
The default spacing used between elements of the
content area of the dialog, as returned by
gtk_dialog_get_content_area()
, unless gtk_box_set_spacing()
was called on that widget directly.
Owner: GtkDialog
Flags: Read
Allowed values: >= 0
Default value: 0
Since: 2.16
“close”
signalvoid user_function (GtkDialog *dialog, gpointer user_data)
The ::close signal is a
keybinding signalwhich gets emitted when the user uses a keybinding to close the dialog.
The default binding for this signal is the Escape key.
Flags: Action
“response”
signalvoid user_function (GtkDialog *dialog, int response_id, gpointer user_data)
Emitted when an action widget is clicked, the dialog receives a
delete event, or the application programmer calls gtk_dialog_response()
.
On a delete event, the response ID is GTK_RESPONSE_DELETE_EVENT.
Otherwise, it depends on which action widget was clicked.
dialog |
the object on which the signal is emitted |
|
response_id |
the response ID |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last