mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
give name to gobject variables
This commit is contained in:
parent
702269f1f1
commit
a1617b2b1b
35 changed files with 213 additions and 209 deletions
|
|
@ -6,7 +6,7 @@ use gtk::{
|
|||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Update` action of `Browser` group
|
||||
pub struct Update {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Update {
|
||||
|
|
@ -15,7 +15,10 @@ impl Update {
|
|||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new(&uuid_string_random(), Some(&String::static_variant_type())),
|
||||
simple_action: SimpleAction::new(
|
||||
&uuid_string_random(),
|
||||
Some(&String::static_variant_type()),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -24,7 +27,7 @@ impl Update {
|
|||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
/// with formatted for this action [Variant](https://docs.gtk.org/glib/struct.Variant.html) value
|
||||
pub fn activate(&self, tab_item_id: Option<&str>) {
|
||||
self.gobject.activate(Some(
|
||||
self.simple_action.activate(Some(
|
||||
&match tab_item_id {
|
||||
Some(value) => String::from(value),
|
||||
None => String::new(),
|
||||
|
|
@ -38,7 +41,7 @@ impl Update {
|
|||
/// 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<GString>) + 'static) {
|
||||
self.gobject.connect_activate(move |_, variant| {
|
||||
self.simple_action.connect_activate(move |_, variant| {
|
||||
let tab_item_id = variant
|
||||
.expect("Variant required to call this action")
|
||||
.get::<String>()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue