![]() |
![]() |
Dialog boxes are a convenient way to prompt the user for a small amount of input, eg. to display a message, ask a question, or anything else that does not require extensive effort on the user's part.
gtkmm treats a dialog as a window split vertically. The top section is a Gtk::VBox, and is where widgets such as a Gtk::Label or a Gtk::Entry should be packed. The bottom area is known as the action_area. This is generally used for packing buttons into the dialog which may perform functions such as cancel, ok, or apply. The two areas are separated by a Gtk::HSeparator.
The dialog can be 'modal' (that is, one which freezes the rest of the application from user input) - this can be specified in the Gtk::Dialog constructor.
When adding buttons using add_button(), clicking the button will emit signal_response() with a "response id" you specified. You are encouraged to use the Gtk::ResponseType enum. If a dialog receives a delete event, the "response" signal will be emitted with a response id of Gtk::RESPONSE_NONE.
If you want to block waiting for a dialog to return before returning control flow to your code, you can call run(). This function enters a recursive main loop and waits for the user to respond to the dialog, returning the response ID corresponding to the button the user clicked.
Public Member Functions | |
virtual | ~Dialog () |
GtkDialog* | gobj () |
Provides access to the underlying C GtkObject. | |
const GtkDialog* | gobj () const |
Provides access to the underlying C GtkObject. | |
Dialog () | |
Dialog (const Glib::ustring& title, bool modal=false, bool use_separator=false) | |
Dialog (const Glib::ustring& title, Gtk::Window& parent, bool modal=false, bool use_separator=false) | |
void | add_action_widget (Widget& child, int response_id) |
Adds an activatable widget to the action area of a Gtk::Dialog, connecting a signal handler that will emit the "response" signal on the dialog when the widget is activated. | |
Button* | add_button (const Glib::ustring& button_text, int 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 . | |
Button* | add_button (const Gtk::StockID& stock_id, int 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 . | |
void | set_response_sensitive (int response_id, bool setting=true) |
Calls gtk_widget_set_sensitive (widget, setting ) for each widget in the dialog's action area with the given response_id . | |
void | set_default_response (int response_id) |
Sets the last widget in the dialog's action area with the given response_id as the default widget for the dialog. | |
void | set_has_separator (bool setting=true) |
Sets whether the dialog has a separator above the buttons. | |
bool | get_has_separator () const |
Accessor for whether the dialog has a separator. | |
void | response (int response_id) |
Emits the "response" signal with the given response ID. | |
int | run () |
Blocks in a recursive main loop until the dialog emits the response signal. | |
VBox* | get_vbox () |
const VBox* | get_vbox () const |
HButtonBox* | get_action_area () |
const HButtonBox* | get_action_area () const |
Glib::PropertyProxy<bool> | property_has_separator () |
You rarely need to use properties because there are get_ and set_ methods for almost all of them. | |
Glib::SignalProxy1< void, int > | signal_response () |
Glib::SignalProxy0<void> | signal_close () |
Protected Member Functions | |
virtual void | on_response (int response_id) |
virtual void | on_close () |
void | construct_ (bool modal, bool use_separator) |
Related Functions | |
(Note that these are not member functions.) | |
Gtk::Dialog* | wrap (GtkDialog* object, bool take_copy=false) |
|
|
|
|
|
|
|
|
|
Adds an activatable widget to the action area of a Gtk::Dialog, 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
|
|
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.
|
|
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.
|
|
|
|
Reimplemented in Gtk::FileSelection. |
|
Reimplemented in Gtk::FileSelection. |
|
Accessor for whether the dialog has a separator.
|
|
|
|
|
|
Provides access to the underlying C GtkObject.
Reimplemented from Gtk::Window. Reimplemented in Gtk::ColorSelectionDialog, Gtk::FileSelection, Gtk::FontSelectionDialog, Gtk::InputDialog, and Gtk::MessageDialog. |
|
Provides access to the underlying C GtkObject.
Reimplemented from Gtk::Window. Reimplemented in Gtk::ColorSelectionDialog, Gtk::FileSelection, Gtk::FontSelectionDialog, Gtk::InputDialog, and Gtk::MessageDialog. |
|
|
|
|
|
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
|
|
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 run() will be monitoring the "response" signal and take appropriate action.
|
|
Blocks in a recursive main loop until the dialog emits the response signal. It returns the response ID from the "response" signal emission. Before entering the recursive main loop, run() calls Gtk::Widget::show() on the dialog for you. Note that you still need to show any children of the dialog yourself. If the dialog receives "delete_event", 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. 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: <tt>int</tt> result = dialog.run(); switch (result) { case GTK_RESPONSE_ACCEPT: do_application_specific_something (<!-- -->); break; default: do_nothing_since_dialog_was_cancelled (<!-- -->); break; }
|
|
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.
|
|
Sets whether the dialog has a separator above the buttons.
|
|
Calls A convenient way to sensitize/desensitize dialog buttons.
|
|
|
|
|
|
|