Struct glib::signal::SignalHandlerId
source · 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§
Trait Implementations§
source§impl Debug for SignalHandlerId
impl Debug for SignalHandlerId
source§impl PartialEq<SignalHandlerId> for SignalHandlerId
impl PartialEq<SignalHandlerId> for SignalHandlerId
source§fn eq(&self, other: &SignalHandlerId) -> bool
fn eq(&self, other: &SignalHandlerId) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.