pub struct SignalHandlerId(_);
Expand description

The id of a signal that is returned by connect.

This type does not implement Clone to prevent disconnecting the same signal handler multiple times.

use glib::SignalHandlerId;
use gtk::prelude::*;
use std::cell::RefCell;

struct Button {
    widget: gtk::Button,
    clicked_handler_id: RefCell<Option<SignalHandlerId>>,
}

impl Button {
    fn new() -> Self {
        let widget = gtk::Button::new();
        let clicked_handler_id = RefCell::new(Some(widget.connect_clicked(|_button| {
            // Do something.
        })));
        Self {
            widget,
            clicked_handler_id,
        }
    }

    fn disconnect(&self) {
        if let Some(id) = self.clicked_handler_id.take() {
            self.widget.disconnect(id)
        }
    }
}

Implementations

Returns the internal signal handler ID.

Trait Implementations

Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.