[][src]Trait gtk::DialogExt

pub trait DialogExt: 'static {
    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 get_content_area(&self) -> Box;
fn get_header_bar(&self) -> Option<HeaderBar>;
fn get_response_for_widget<P: IsA<Widget>>(
        &self,
        widget: &P
    ) -> ResponseType;
fn get_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 get_property_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; }

Trait containing all Dialog methods.

Implementors

AboutDialog, AppChooserDialog, ColorChooserDialog, Dialog, FileChooserDialog, FontChooserDialog, MessageDialog, RecentChooserDialog

Required methods

fn add_action_widget<P: IsA<Widget>>(
    &self,
    child: &P,
    response_id: ResponseType
)

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

fn add_button(&self, button_text: &str, response_id: ResponseType) -> Widget

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

fn get_content_area(&self) -> Box

Returns the content area of self.

Returns

the content area Box.

fn get_header_bar(&self) -> Option<HeaderBar>

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

Returns

the header bar

fn get_response_for_widget<P: IsA<Widget>>(&self, widget: &P) -> ResponseType

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.

fn get_widget_for_response(&self, response_id: ResponseType) -> Option<Widget>

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.

fn response(&self, response_id: ResponseType)

Emits the 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 DialogExt::run will be monitoring the ::response signal and take appropriate action.

response_id

response ID

fn run(&self) -> ResponseType

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

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

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

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

Typical usage of this function might be:

  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 DialogExt::run call.

Returns

response ID

fn set_default_response(&self, response_id: ResponseType)

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

fn set_response_sensitive(&self, response_id: ResponseType, setting: bool)

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

fn get_property_use_header_bar(&self) -> i32

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.

fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

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

The default binding for this signal is the Escape key.

fn emit_close(&self)

fn connect_response<F: Fn(&Self, ResponseType) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

Emitted when an action widget is clicked, the dialog receives a delete event, or the application programmer calls DialogExt::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

Loading content...

Implementors

impl<O: IsA<Dialog>> DialogExt for O[src]

Loading content...