mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +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
|
|
@ -37,7 +37,7 @@ const DEFAULT_IS_LOAD: bool = false;
|
|||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Append` action of `Window` group
|
||||
pub struct Append {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Append {
|
||||
|
|
@ -46,7 +46,7 @@ impl Append {
|
|||
/// Create new `Self` with default action state preset
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&(
|
||||
|
|
@ -69,7 +69,7 @@ impl Append {
|
|||
pub fn activate_default_once(&self) {
|
||||
// Save current state in memory
|
||||
let (position, request, is_pinned, is_selected, is_attention, is_load) =
|
||||
state(&self.gobject);
|
||||
state(&self.simple_action);
|
||||
|
||||
// Set default state
|
||||
self.change_state(
|
||||
|
|
@ -82,7 +82,7 @@ impl Append {
|
|||
);
|
||||
|
||||
// Activate action
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
|
||||
// Return previous state
|
||||
self.change_state(
|
||||
|
|
@ -108,7 +108,7 @@ impl Append {
|
|||
) {
|
||||
// Save current state in memory
|
||||
let (_position, _request, _is_pinned, _is_selected, _is_attention, _is_load) =
|
||||
state(&self.gobject);
|
||||
state(&self.simple_action);
|
||||
|
||||
// Apply requested state
|
||||
self.change_state(
|
||||
|
|
@ -121,7 +121,7 @@ impl Append {
|
|||
);
|
||||
|
||||
// Activate action
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
|
||||
// Return previous state
|
||||
self.change_state(
|
||||
|
|
@ -144,7 +144,7 @@ impl Append {
|
|||
is_attention: bool,
|
||||
is_load: bool,
|
||||
) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&(
|
||||
// Convert Option to C-based variant value
|
||||
position,
|
||||
|
|
@ -171,7 +171,7 @@ impl Append {
|
|||
&self,
|
||||
callback: impl Fn(Position, Option<String>, bool, bool, bool, bool) + 'static,
|
||||
) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let (position, request, is_pinned, is_selected, is_attention, is_load) = state(this);
|
||||
callback(
|
||||
position,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
|||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Home` action of `Window` group
|
||||
pub struct Bookmark {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Bookmark {
|
||||
|
|
@ -20,7 +20,7 @@ impl Bookmark {
|
|||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
|
|
@ -32,13 +32,13 @@ impl Bookmark {
|
|||
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn activate(&self) {
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
}
|
||||
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
|
|
@ -52,7 +52,7 @@ impl Bookmark {
|
|||
/// 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) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
|||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Close` action of `Window` group
|
||||
pub struct Close {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Close {
|
||||
|
|
@ -20,7 +20,7 @@ impl Close {
|
|||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
|
|
@ -33,7 +33,7 @@ impl Close {
|
|||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
|
|
@ -47,7 +47,7 @@ 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) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
|||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `CloseAll` action of `Window` group
|
||||
pub struct CloseAll {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl CloseAll {
|
||||
|
|
@ -20,7 +20,7 @@ impl CloseAll {
|
|||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
|
|
@ -33,7 +33,7 @@ impl CloseAll {
|
|||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
|
|
@ -47,7 +47,7 @@ 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) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
|||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `HistoryBack` action of `Window` group
|
||||
pub struct HistoryBack {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl HistoryBack {
|
||||
|
|
@ -20,7 +20,7 @@ impl HistoryBack {
|
|||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
|
|
@ -32,13 +32,13 @@ impl HistoryBack {
|
|||
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn activate(&self) {
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
}
|
||||
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
|
|
@ -52,7 +52,7 @@ 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) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
|||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `HistoryForward` action of `Window` group
|
||||
pub struct HistoryForward {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl HistoryForward {
|
||||
|
|
@ -20,7 +20,7 @@ impl HistoryForward {
|
|||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
|
|
@ -32,13 +32,13 @@ impl HistoryForward {
|
|||
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn activate(&self) {
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
}
|
||||
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
|
|
@ -52,7 +52,7 @@ 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) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
|||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Home` action of `Window` group
|
||||
pub struct Home {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Home {
|
||||
|
|
@ -20,7 +20,7 @@ impl Home {
|
|||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
|
|
@ -32,13 +32,13 @@ impl Home {
|
|||
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn activate(&self) {
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
}
|
||||
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
|
|
@ -52,7 +52,7 @@ 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) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
|||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Pin` action of `Window` group
|
||||
pub struct Pin {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Pin {
|
||||
|
|
@ -20,7 +20,7 @@ impl Pin {
|
|||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
|
|
@ -33,7 +33,7 @@ impl Pin {
|
|||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
|
|
@ -47,7 +47,7 @@ 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) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
|||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Reload` action of `Window` group
|
||||
pub struct Reload {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Reload {
|
||||
|
|
@ -20,7 +20,7 @@ impl Reload {
|
|||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
|
|
@ -32,13 +32,13 @@ impl Reload {
|
|||
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn activate(&self) {
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
}
|
||||
|
||||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
|
|
@ -52,7 +52,7 @@ 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) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
|||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Save As` action of `Window` group
|
||||
pub struct SaveAs {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl SaveAs {
|
||||
|
|
@ -20,7 +20,7 @@ impl SaveAs {
|
|||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
|
|
@ -33,7 +33,7 @@ impl SaveAs {
|
|||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
|
|
@ -47,7 +47,7 @@ impl SaveAs {
|
|||
/// 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) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1;
|
|||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Source` action of `Window` group
|
||||
pub struct Source {
|
||||
pub gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Source {
|
||||
|
|
@ -20,7 +20,7 @@ impl Source {
|
|||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new_stateful(
|
||||
simple_action: SimpleAction::new_stateful(
|
||||
&uuid_string_random(),
|
||||
None,
|
||||
&DEFAULT_STATE.to_variant(),
|
||||
|
|
@ -33,7 +33,7 @@ impl Source {
|
|||
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
|
||||
/// * set `DEFAULT_STATE` on `None`
|
||||
pub fn change_state(&self, state: Option<i32>) {
|
||||
self.gobject.change_state(
|
||||
self.simple_action.change_state(
|
||||
&match state {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_STATE,
|
||||
|
|
@ -47,7 +47,7 @@ impl Source {
|
|||
/// 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) {
|
||||
self.gobject.connect_activate(move |this, _| {
|
||||
self.simple_action.connect_activate(move |this, _| {
|
||||
let state = this
|
||||
.state()
|
||||
.expect("State value required")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue