Trait gtk::prelude::DialogExt[][src]

pub trait DialogExt: 'static {
Show methods fn add_action_widget<P: IsA<Widget>>(
        &self,
        child: &P,
        response_id: ResponseType
    );
fn add_button(&self, button_text: &str, response_id: ResponseType) -> Widget;
fn content_area(&self) -> Box;
fn header_bar(&self) -> Option<HeaderBar>;
fn response_for_widget<P: IsA<Widget>>(&self, widget: &P) -> ResponseType;
fn widget_for_response(&self, response_id: ResponseType) -> Option<Widget>;
fn response(&self, response_id: ResponseType);
fn run(&self) -> ResponseType;
fn set_default_response(&self, response_id: ResponseType);
fn set_response_sensitive(&self, response_id: ResponseType, setting: bool);
fn use_header_bar(&self) -> i32;
fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn emit_close(&self);
fn connect_response<F: Fn(&Self, ResponseType) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
}
Expand description

Required methods

Adds an activatable widget to the action area of a Dialog, connecting a signal handler that will emit the signal::Dialog::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 Dialog struct.

child

an activatable widget

response_id

response ID for child

Adds a button with the given text and sets things up so that clicking the button will emit the signal::Dialog::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.

button_text

text of button

response_id

response ID for the button

Returns

the Button widget that was added

Returns the content area of self.

Returns

the content area Box.

Returns the header bar of self. Note that the headerbar is only used by the dialog if the property::Dialog::use-header-bar property is true.

Returns

the header bar

Gets the response id of a widget in the action area of a dialog.

widget

a widget in the action area of self

Returns

the response id of widget, or ResponseType::None if widget doesn’t have a response id set.

Gets the widget button that uses the given response ID in the action area of a dialog.

response_id

the response ID used by the self widget

Returns

the widget button that uses the given response_id, or None.

Emits the signal::Dialog::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.

response_id

response ID

Blocks in a recursive main loop until the self either emits the signal::Dialog::response signal, or is destroyed. If the dialog is destroyed during the call to run(), run() returns ResponseType::None. Otherwise, it returns the response ID from the ::response signal emission.

Before entering the recursive main loop, run() calls WidgetExt::show() on the dialog for you. Note that you still need to show any children of the dialog yourself.

During run(), the default behavior of signal::Widget::delete-event is disabled; if the dialog receives ::delete_event, it will not be destroyed as windows usually are, and run() will return ResponseType::DeleteEvent. Also, during run() the dialog will be modal. You can force run() to return at any time by calling response() to emit the ::response signal. Destroying the dialog during run() is a very bad idea, because your post-run code won’t know whether the dialog was destroyed or not.

After run() returns, you are responsible for hiding or destroying the dialog if you wish to do so.

Typical usage of this function might be:

⚠️ The following code is in C ⚠️

  GtkWidget *dialog = gtk_dialog_new ();
  // Set up dialog...

  int 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 run() call.

Returns

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.

response_id

a response ID

Calls gtk_widget_set_sensitive (widget, setting) for each widget in the dialog’s action area with the given response_id. A convenient way to sensitize/desensitize dialog buttons.

response_id

a response ID

setting

true for sensitive

true if the dialog uses a HeaderBar for action buttons instead of the action-area.

For technical reasons, this property is declared as an integer property, but you should only set it to true or false.

The ::close signal is a [keybinding signal][GtkBindingSignal] which gets emitted when the user uses a keybinding to close the dialog.

The default binding for this signal is the Escape key.

Emitted when an action widget is clicked, the dialog receives a delete event, or the application programmer calls response(). On a delete event, the response ID is ResponseType::DeleteEvent. Otherwise, it depends on which action widget was clicked.

response_id

the response ID

Implementors