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.borrow_mut().take() {
self.widget.disconnect(id)
}
}
}
Implementations
Trait Implementations
sourceimpl Debug for SignalHandlerId
impl Debug for SignalHandlerId
sourceimpl PartialEq<SignalHandlerId> for SignalHandlerId
impl PartialEq<SignalHandlerId> for SignalHandlerId
sourcefn 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 ==
. Read more
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more