mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
move identity feature to request area
This commit is contained in:
parent
78957ff85b
commit
2dc6154d54
32 changed files with 59 additions and 84 deletions
|
|
@ -1,39 +0,0 @@
|
|||
use gtk::{gio::SimpleAction, glib::uuid_string_random, prelude::ActionExt};
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Ident` action of `Item` group
|
||||
pub struct Ident {
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Default for Ident {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Ident {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
simple_action: SimpleAction::new(&uuid_string_random(), None),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
||||
/// 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) {
|
||||
self.simple_action.activate(None);
|
||||
}
|
||||
|
||||
// Events
|
||||
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn() + 'static) {
|
||||
self.simple_action.connect_activate(move |_, _| callback());
|
||||
}
|
||||
}
|
||||
13
src/app/browser/window/tab/item/action/identity.rs
Normal file
13
src/app/browser/window/tab/item/action/identity.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
use gtk::{gio::SimpleAction, glib::uuid_string_random};
|
||||
|
||||
pub trait Identity {
|
||||
fn identity() -> Self;
|
||||
}
|
||||
|
||||
impl Identity for SimpleAction {
|
||||
fn identity() -> Self {
|
||||
let identity = SimpleAction::new(&uuid_string_random(), None);
|
||||
identity.set_enabled(false);
|
||||
identity
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue