Struct glib::signal::SignalHandlerId
source · pub struct SignalHandlerId(/* private fields */);
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 for SignalHandlerId
impl PartialEq 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 ==
.impl Eq for SignalHandlerId
impl StructuralEq for SignalHandlerId
impl StructuralPartialEq for SignalHandlerId
Auto Trait Implementations§
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