Struct glib::signal::SignalHandlerId
source · pub struct SignalHandlerId(NonZeroU64);
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)
}
}
}
Tuple Fields§
§0: NonZeroU64
Implementations§
Trait Implementations§
source§impl Debug for SignalHandlerId
impl Debug for SignalHandlerId
source§impl PartialEq for SignalHandlerId
impl PartialEq for SignalHandlerId
impl Eq for SignalHandlerId
impl StructuralPartialEq for SignalHandlerId
Auto Trait Implementations§
impl Freeze for SignalHandlerId
impl RefUnwindSafe for SignalHandlerId
impl Send for SignalHandlerId
impl Sync for SignalHandlerId
impl Unpin for SignalHandlerId
impl UnwindSafe for SignalHandlerId
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more