![]() |
![]() |
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 | |
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 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 . | |
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 . | |
Dialog (const Glib::ustring& title, Gtk::Window& parent, bool modal=false, bool use_separator=false) | |
Dialog (const Glib::ustring& title, bool modal=false, bool use_separator=false) | |
Dialog () | |
const HButtonBox* | get_action_area () const |
HButtonBox* | get_action_area () |
bool | get_has_separator () const |
Accessor for whether the dialog has a separator. | |
int | get_response_for_widget (const Gtk::Widget& widget) const |
Gets the response id of a widget in the action area of a dialog. | |
const VBox* | get_vbox () const |
VBox* | get_vbox () |
const GtkDialog* | gobj () const |
Provides access to the underlying C GtkObject. | |
GtkDialog* | gobj () |
Provides access to the underlying C GtkObject. | |
Glib::PropertyProxy_ReadOnly< bool > | property_has_separator () const |
The dialog has a separator bar above its buttons. | |
Glib::PropertyProxy<bool> | property_has_separator () |
The dialog has a separator bar above its buttons. | |
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. | |
void | set_alternative_button_order_from_array (const Glib::ArrayHandle<int>& new_order) |
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. | |
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 . | |
Glib::SignalProxy1< void, int > | signal_response () |
virtual | ~Dialog () |
Static Public Member Functions | |
static bool | alternative_button_order (const Glib::RefPtr<const Gdk::Screen>& screen) |
Returns true if dialogs are expected to use an alternative button order on the screen screen . | |
Protected Member Functions | |
void | construct_ (bool modal, bool use_separator) |
virtual void | on_response (int response_id) |
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.
|
|
Returns 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 Gtk::Settings object associated to screen , in order to be notified if the button order setting changes.
|
|
|
|
Reimplemented in Gtk::FileSelection. |
|
Reimplemented in Gtk::FileSelection. |
|
Accessor for whether the dialog has a separator.
|
|
Gets the response id of a widget in the action area of a dialog.
|
|
|
|
|
|
Provides access to the underlying C GtkObject.
Reimplemented from Gtk::Window. Reimplemented in Gtk::AboutDialog, Gtk::ColorSelectionDialog, Gtk::FileChooserDialog, Gtk::FileSelection, Gtk::FontSelectionDialog, Gtk::InputDialog, and Gtk::MessageDialog. |
|
Provides access to the underlying C GtkObject.
Reimplemented from Gtk::Window. Reimplemented in Gtk::AboutDialog, Gtk::ColorSelectionDialog, Gtk::FileChooserDialog, Gtk::FileSelection, Gtk::FontSelectionDialog, Gtk::InputDialog, and Gtk::MessageDialog. |
|
|
|
The dialog has a separator bar above its buttons. You rarely need to use properties because there are get_ and set_ methods for almost all of them.
|
|
The dialog has a separator bar above its buttons. 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.
|
|
|
|
|