mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
fix current state detection
This commit is contained in:
parent
ddead4e870
commit
43abe41b31
@ -53,26 +53,22 @@ impl Close {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
let state = self.state();
|
||||
self.gobject.connect_activate(move |_, _| callback(state));
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn state(&self) -> Option<i32> {
|
||||
let state = self
|
||||
.gobject
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
.get::<i32>()
|
||||
.expect("Parameter type does not match `i32`");
|
||||
|
||||
if state != DEFAULT_STATE {
|
||||
Some(state)
|
||||
} else {
|
||||
callback(if state == DEFAULT_STATE {
|
||||
None
|
||||
} else {
|
||||
Some(state)
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
/// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject
|
||||
pub fn gobject(&self) -> &SimpleAction {
|
||||
|
@ -53,26 +53,22 @@ impl CloseAll {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
let state = self.state();
|
||||
self.gobject.connect_activate(move |_, _| callback(state));
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn state(&self) -> Option<i32> {
|
||||
let state = self
|
||||
.gobject
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
.get::<i32>()
|
||||
.expect("Parameter type does not match `i32`");
|
||||
|
||||
if state != DEFAULT_STATE {
|
||||
Some(state)
|
||||
} else {
|
||||
callback(if state == DEFAULT_STATE {
|
||||
None
|
||||
} else {
|
||||
Some(state)
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
/// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject
|
||||
pub fn gobject(&self) -> &SimpleAction {
|
||||
|
@ -52,26 +52,22 @@ impl HistoryBack {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
let state = self.state();
|
||||
self.gobject.connect_activate(move |_, _| callback(state));
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn state(&self) -> Option<i32> {
|
||||
let state = self
|
||||
.gobject
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
.get::<i32>()
|
||||
.expect("Parameter type does not match `i32`");
|
||||
|
||||
if state != DEFAULT_STATE {
|
||||
Some(state)
|
||||
} else {
|
||||
callback(if state == DEFAULT_STATE {
|
||||
None
|
||||
} else {
|
||||
Some(state)
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
/// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject
|
||||
pub fn gobject(&self) -> &SimpleAction {
|
||||
|
@ -52,26 +52,22 @@ impl HistoryForward {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
let state = self.state();
|
||||
self.gobject.connect_activate(move |_, _| callback(state));
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn state(&self) -> Option<i32> {
|
||||
let state = self
|
||||
.gobject
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
.get::<i32>()
|
||||
.expect("Parameter type does not match `i32`");
|
||||
|
||||
if state != DEFAULT_STATE {
|
||||
Some(state)
|
||||
} else {
|
||||
callback(if state == DEFAULT_STATE {
|
||||
None
|
||||
} else {
|
||||
Some(state)
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
/// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject
|
||||
pub fn gobject(&self) -> &SimpleAction {
|
||||
|
@ -52,26 +52,22 @@ impl Home {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
let state = self.state();
|
||||
self.gobject.connect_activate(move |_, _| callback(state));
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn state(&self) -> Option<i32> {
|
||||
let state = self
|
||||
.gobject
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
.get::<i32>()
|
||||
.expect("Parameter type does not match `i32`");
|
||||
|
||||
if state != DEFAULT_STATE {
|
||||
Some(state)
|
||||
} else {
|
||||
callback(if state == DEFAULT_STATE {
|
||||
None
|
||||
} else {
|
||||
Some(state)
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
/// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject
|
||||
pub fn gobject(&self) -> &SimpleAction {
|
||||
|
@ -47,26 +47,22 @@ impl Pin {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
let state = self.state();
|
||||
self.gobject.connect_activate(move |_, _| callback(state));
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn state(&self) -> Option<i32> {
|
||||
let state = self
|
||||
.gobject
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
.get::<i32>()
|
||||
.expect("Parameter type does not match `i32`");
|
||||
|
||||
if state != DEFAULT_STATE {
|
||||
Some(state)
|
||||
} else {
|
||||
callback(if state == DEFAULT_STATE {
|
||||
None
|
||||
} else {
|
||||
Some(state)
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
/// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject
|
||||
pub fn gobject(&self) -> &SimpleAction {
|
||||
|
@ -52,26 +52,22 @@ impl Reload {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) {
|
||||
let state = self.state();
|
||||
self.gobject.connect_activate(move |_, _| callback(state));
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn state(&self) -> Option<i32> {
|
||||
let state = self
|
||||
.gobject
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
.get::<i32>()
|
||||
.expect("Parameter type does not match `i32`");
|
||||
|
||||
if state != DEFAULT_STATE {
|
||||
Some(state)
|
||||
} else {
|
||||
callback(if state == DEFAULT_STATE {
|
||||
None
|
||||
} else {
|
||||
Some(state)
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
/// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject
|
||||
pub fn gobject(&self) -> &SimpleAction {
|
||||
|
Loading…
x
Reference in New Issue
Block a user