give name to gobject variables

This commit is contained in:
yggverse 2024-12-14 06:50:30 +02:00
parent 702269f1f1
commit a1617b2b1b
35 changed files with 213 additions and 209 deletions

View File

@ -16,14 +16,14 @@ const APPLICATION_ID: &str = "io.github.yggverse.Yoda";
pub struct App { pub struct App {
profile: Rc<Profile>, profile: Rc<Profile>,
gobject: Application, application: Application,
} }
impl App { impl App {
// Construct // Construct
pub fn new(profile: Rc<Profile>) -> Self { pub fn new(profile: Rc<Profile>) -> Self {
// Init GTK // Init GTK
let gobject = Application::builder() let application = Application::builder()
.application_id(APPLICATION_ID) .application_id(APPLICATION_ID)
.build(); .build();
@ -31,12 +31,12 @@ impl App {
let browser = Rc::new(Browser::new(profile.clone())); let browser = Rc::new(Browser::new(profile.clone()));
// Init events // Init events
gobject.connect_activate({ application.connect_activate({
let browser = browser.clone(); let browser = browser.clone();
move |_| browser.update() move |_| browser.update()
}); });
gobject.connect_startup({ application.connect_startup({
let browser = browser.clone(); let browser = browser.clone();
let profile = profile.clone(); let profile = profile.clone();
move |this| { move |this| {
@ -72,7 +72,7 @@ impl App {
} }
}); });
gobject.connect_shutdown({ application.connect_shutdown({
let browser = browser.clone(); let browser = browser.clone();
let profile = profile.clone(); let profile = profile.clone();
move |_| { move |_| {
@ -136,7 +136,7 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.action.id, browser.action.id,
browser.action.close.gobject.name() browser.action.close.simple_action.name()
), ),
&["<Primary>Escape"], &["<Primary>Escape"],
), ),
@ -144,7 +144,7 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.action.id, browser.action.id,
browser.action.debug.gobject.name() browser.action.debug.simple_action.name()
), ),
&["<Primary>i"], &["<Primary>i"],
), ),
@ -152,7 +152,7 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.action.id, browser.action.id,
browser.action.update.gobject.name() browser.action.update.simple_action.name()
), ),
&["<Primary>u"], &["<Primary>u"],
), ),
@ -160,7 +160,7 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.action.id, browser.action.id,
browser.action.focus.gobject.name() browser.action.focus.simple_action.name()
), ),
&["Escape"], &["Escape"],
), ),
@ -169,7 +169,7 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.window.action.id, browser.window.action.id,
browser.window.action.append.gobject.name() browser.window.action.append.simple_action.name()
), ),
&["<Primary>t"], &["<Primary>t"],
), ),
@ -177,7 +177,7 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.window.action.id, browser.window.action.id,
browser.window.action.bookmark.gobject.name() browser.window.action.bookmark.simple_action.name()
), ),
&["<Primary>b"], &["<Primary>b"],
), ),
@ -185,7 +185,7 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.window.action.id, browser.window.action.id,
browser.window.action.pin.gobject.name() browser.window.action.pin.simple_action.name()
), ),
&["<Primary>p"], &["<Primary>p"],
), ),
@ -193,7 +193,7 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.window.action.id, browser.window.action.id,
browser.window.action.reload.gobject.name() browser.window.action.reload.simple_action.name()
), ),
&["<Primary>r"], &["<Primary>r"],
), ),
@ -201,7 +201,7 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.window.action.id, browser.window.action.id,
browser.window.action.save_as.gobject.name() browser.window.action.save_as.simple_action.name()
), ),
&["<Primary>s"], &["<Primary>s"],
), ),
@ -209,7 +209,7 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.window.action.id, browser.window.action.id,
browser.window.action.source.gobject.name() browser.window.action.source.simple_action.name()
), ),
&["<Primary>u"], &["<Primary>u"],
), ),
@ -217,7 +217,7 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.window.action.id, browser.window.action.id,
browser.window.action.home.gobject.name() browser.window.action.home.simple_action.name()
), ),
&["<Primary>h"], &["<Primary>h"],
), ),
@ -225,7 +225,7 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.window.action.id, browser.window.action.id,
browser.window.action.history_back.gobject.name() browser.window.action.history_back.simple_action.name()
), ),
&["<Primary>Left"], &["<Primary>Left"],
), ),
@ -233,7 +233,7 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.window.action.id, browser.window.action.id,
browser.window.action.history_forward.gobject.name() browser.window.action.history_forward.simple_action.name()
), ),
&["<Primary>Right"], &["<Primary>Right"],
), ),
@ -241,16 +241,19 @@ impl App {
format!( format!(
"{}.{}", "{}.{}",
browser.window.action.id, browser.window.action.id,
browser.window.action.close.gobject.name() browser.window.action.close.simple_action.name()
), ),
&["<Primary>q"], &["<Primary>q"],
), ),
] { ] {
gobject.set_accels_for_action(detailed_action_name, &accels); application.set_accels_for_action(detailed_action_name, &accels);
} }
// Return activated App struct // Return activated App struct
Self { profile, gobject } Self {
profile,
application,
}
} }
// Actions // Actions
@ -283,7 +286,7 @@ impl App {
} // unlock database } // unlock database
// Start application // Start application
self.gobject.run() self.application.run()
} }
} }

View File

@ -39,12 +39,12 @@ impl Browser {
( (
// Browser // Browser
&action.id, &action.id,
action.gobject.clone(), action.simple_action_group.clone(),
), ),
( (
// Window // Window
&window.action.id, &window.action.id,
window.action.gobject.clone(), window.action.simple_action_group.clone(),
), ),
], ],
)); ));

View File

@ -30,7 +30,7 @@ pub struct Action {
pub update: Rc<Update>, pub update: Rc<Update>,
// Group // Group
pub id: GString, pub id: GString,
pub gobject: SimpleActionGroup, pub simple_action_group: SimpleActionGroup,
} }
impl Action { impl Action {
@ -50,15 +50,15 @@ impl Action {
let id = uuid_string_random(); let id = uuid_string_random();
// Init group // Init group
let gobject = SimpleActionGroup::new(); let simple_action_group = SimpleActionGroup::new();
// Add action to given group // Add action to given group
gobject.add_action(&about.gobject); simple_action_group.add_action(&about.simple_action);
gobject.add_action(&close.gobject); simple_action_group.add_action(&close.simple_action);
gobject.add_action(&debug.gobject); simple_action_group.add_action(&debug.simple_action);
gobject.add_action(&focus.gobject); simple_action_group.add_action(&focus.simple_action);
gobject.add_action(&profile.gobject); simple_action_group.add_action(&profile.simple_action);
gobject.add_action(&update.gobject); simple_action_group.add_action(&update.simple_action);
// Done // Done
Self { Self {
@ -69,7 +69,7 @@ impl Action {
profile, profile,
update, update,
id, id,
gobject, simple_action_group,
} }
} }
} }

View File

@ -2,7 +2,7 @@ use gtk::{gio::SimpleAction, glib::uuid_string_random};
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `About` action of `Browser` group /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `About` action of `Browser` group
pub struct About { pub struct About {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl About { impl About {
@ -11,7 +11,7 @@ impl About {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new(&uuid_string_random(), None), simple_action: SimpleAction::new(&uuid_string_random(), None),
} }
} }
@ -20,6 +20,6 @@ impl About {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn() + 'static) { pub fn connect_activate(&self, callback: impl Fn() + 'static) {
self.gobject.connect_activate(move |_, _| callback()); self.simple_action.connect_activate(move |_, _| callback());
} }
} }

View File

@ -2,7 +2,7 @@ use gtk::{gio::SimpleAction, glib::uuid_string_random};
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Close` action of `Browser` group /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Close` action of `Browser` group
pub struct Close { pub struct Close {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl Close { impl Close {
@ -11,7 +11,7 @@ impl Close {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new(&uuid_string_random(), None), simple_action: SimpleAction::new(&uuid_string_random(), None),
} }
} }
@ -20,6 +20,6 @@ impl Close {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn() + 'static) { pub fn connect_activate(&self, callback: impl Fn() + 'static) {
self.gobject.connect_activate(move |_, _| callback()); self.simple_action.connect_activate(move |_, _| callback());
} }
} }

View File

@ -2,7 +2,7 @@ use gtk::{gio::SimpleAction, glib::uuid_string_random};
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Debug` action of `Browser` group /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Debug` action of `Browser` group
pub struct Debug { pub struct Debug {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl Debug { impl Debug {
@ -11,7 +11,7 @@ impl Debug {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new(&uuid_string_random(), None), simple_action: SimpleAction::new(&uuid_string_random(), None),
} }
} }
@ -20,6 +20,6 @@ impl Debug {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn() + 'static) { pub fn connect_activate(&self, callback: impl Fn() + 'static) {
self.gobject.connect_activate(move |_, _| callback()); self.simple_action.connect_activate(move |_, _| callback());
} }
} }

View File

@ -2,7 +2,7 @@ use gtk::{gio::SimpleAction, glib::uuid_string_random, prelude::ActionExt};
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Focus` action of `Browser` group /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Focus` action of `Browser` group
pub struct Focus { pub struct Focus {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl Focus { impl Focus {
@ -11,7 +11,7 @@ impl Focus {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new(&uuid_string_random(), None), simple_action: SimpleAction::new(&uuid_string_random(), None),
} }
} }
@ -20,7 +20,7 @@ impl Focus {
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// 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 /// with formatted for this action [Variant](https://docs.gtk.org/glib/struct.Variant.html) value
pub fn activate(&self) { pub fn activate(&self) {
self.gobject.activate(None); // @TODO custom value self.simple_action.activate(None); // @TODO custom value
} }
// Events // Events
@ -28,6 +28,6 @@ impl Focus {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn() + 'static) { pub fn connect_activate(&self, callback: impl Fn() + 'static) {
self.gobject.connect_activate(move |_, _| callback()); self.simple_action.connect_activate(move |_, _| callback());
} }
} }

View File

@ -2,7 +2,7 @@ use gtk::{gio::SimpleAction, glib::uuid_string_random};
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Profile` action of `Browser` group /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Profile` action of `Browser` group
pub struct Profile { pub struct Profile {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl Profile { impl Profile {
@ -11,7 +11,7 @@ impl Profile {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new(&uuid_string_random(), None), simple_action: SimpleAction::new(&uuid_string_random(), None),
} }
} }
@ -20,6 +20,6 @@ impl Profile {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn() + 'static) { pub fn connect_activate(&self, callback: impl Fn() + 'static) {
self.gobject.connect_activate(move |_, _| callback()); self.simple_action.connect_activate(move |_, _| callback());
} }
} }

View File

@ -6,7 +6,7 @@ use gtk::{
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Update` action of `Browser` group /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Update` action of `Browser` group
pub struct Update { pub struct Update {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl Update { impl Update {
@ -15,7 +15,10 @@ impl Update {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
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 /// 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 /// with formatted for this action [Variant](https://docs.gtk.org/glib/struct.Variant.html) value
pub fn activate(&self, tab_item_id: Option<&str>) { pub fn activate(&self, tab_item_id: Option<&str>) {
self.gobject.activate(Some( self.simple_action.activate(Some(
&match tab_item_id { &match tab_item_id {
Some(value) => String::from(value), Some(value) => String::from(value),
None => String::new(), None => String::new(),
@ -38,7 +41,7 @@ impl Update {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn(Option<GString>) + 'static) { 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 let tab_item_id = variant
.expect("Variant required to call this action") .expect("Variant required to call this action")
.get::<String>() .get::<String>()

View File

@ -29,8 +29,8 @@ impl Window {
// Init components // Init components
let tab = Rc::new(Tab::new(profile, (browser_action.clone(), action.clone()))); let tab = Rc::new(Tab::new(profile, (browser_action.clone(), action.clone())));
let header = Header::new(browser_action, action.clone(), &tab.widget.gobject); let header = Header::new(browser_action, action.clone(), &tab.widget.tab_view);
let widget = Rc::new(Widget::new(&header.widget.gobject, &tab.widget.gobject)); let widget = Rc::new(Widget::new(&header.widget.gobject, &tab.widget.tab_view));
// Init events // Init events
action.append.connect_activate({ action.append.connect_activate({

View File

@ -47,7 +47,7 @@ pub struct Action {
pub source: Rc<Source>, pub source: Rc<Source>,
// Group // Group
pub id: GString, pub id: GString,
pub gobject: SimpleActionGroup, pub simple_action_group: SimpleActionGroup,
} }
impl Action { impl Action {
@ -72,20 +72,20 @@ impl Action {
let id = uuid_string_random(); let id = uuid_string_random();
// Init group // Init group
let gobject = SimpleActionGroup::new(); let simple_action_group = SimpleActionGroup::new();
// Add action to given group // Add action to given group
gobject.add_action(&append.gobject); simple_action_group.add_action(&append.simple_action);
gobject.add_action(&bookmark.gobject); simple_action_group.add_action(&bookmark.simple_action);
gobject.add_action(&close_all.gobject); simple_action_group.add_action(&close_all.simple_action);
gobject.add_action(&close.gobject); simple_action_group.add_action(&close.simple_action);
gobject.add_action(&history_back.gobject); simple_action_group.add_action(&history_back.simple_action);
gobject.add_action(&history_forward.gobject); simple_action_group.add_action(&history_forward.simple_action);
gobject.add_action(&home.gobject); simple_action_group.add_action(&home.simple_action);
gobject.add_action(&pin.gobject); simple_action_group.add_action(&pin.simple_action);
gobject.add_action(&reload.gobject); simple_action_group.add_action(&reload.simple_action);
gobject.add_action(&save_as.gobject); simple_action_group.add_action(&save_as.simple_action);
gobject.add_action(&source.gobject); simple_action_group.add_action(&source.simple_action);
// Done // Done
Self { Self {
@ -101,7 +101,7 @@ impl Action {
save_as, save_as,
source, source,
id, id,
gobject, simple_action_group,
} }
} }
} }

View File

@ -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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Append` action of `Window` group
pub struct Append { pub struct Append {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl Append { impl Append {
@ -46,7 +46,7 @@ impl Append {
/// Create new `Self` with default action state preset /// Create new `Self` with default action state preset
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new_stateful( simple_action: SimpleAction::new_stateful(
&uuid_string_random(), &uuid_string_random(),
None, None,
&( &(
@ -69,7 +69,7 @@ impl Append {
pub fn activate_default_once(&self) { pub fn activate_default_once(&self) {
// Save current state in memory // Save current state in memory
let (position, request, is_pinned, is_selected, is_attention, is_load) = let (position, request, is_pinned, is_selected, is_attention, is_load) =
state(&self.gobject); state(&self.simple_action);
// Set default state // Set default state
self.change_state( self.change_state(
@ -82,7 +82,7 @@ impl Append {
); );
// Activate action // Activate action
self.gobject.activate(None); self.simple_action.activate(None);
// Return previous state // Return previous state
self.change_state( self.change_state(
@ -108,7 +108,7 @@ impl Append {
) { ) {
// Save current state in memory // Save current state in memory
let (_position, _request, _is_pinned, _is_selected, _is_attention, _is_load) = let (_position, _request, _is_pinned, _is_selected, _is_attention, _is_load) =
state(&self.gobject); state(&self.simple_action);
// Apply requested state // Apply requested state
self.change_state( self.change_state(
@ -121,7 +121,7 @@ impl Append {
); );
// Activate action // Activate action
self.gobject.activate(None); self.simple_action.activate(None);
// Return previous state // Return previous state
self.change_state( self.change_state(
@ -144,7 +144,7 @@ impl Append {
is_attention: bool, is_attention: bool,
is_load: bool, is_load: bool,
) { ) {
self.gobject.change_state( self.simple_action.change_state(
&( &(
// Convert Option to C-based variant value // Convert Option to C-based variant value
position, position,
@ -171,7 +171,7 @@ impl Append {
&self, &self,
callback: impl Fn(Position, Option<String>, bool, bool, bool, bool) + 'static, 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); let (position, request, is_pinned, is_selected, is_attention, is_load) = state(this);
callback( callback(
position, position,

View File

@ -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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Home` action of `Window` group
pub struct Bookmark { pub struct Bookmark {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl Bookmark { impl Bookmark {
@ -20,7 +20,7 @@ impl Bookmark {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new_stateful( simple_action: SimpleAction::new_stateful(
&uuid_string_random(), &uuid_string_random(),
None, None,
&DEFAULT_STATE.to_variant(), &DEFAULT_STATE.to_variant(),
@ -32,13 +32,13 @@ impl Bookmark {
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn activate(&self) { 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) /// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
/// * set `DEFAULT_STATE` on `None` /// * set `DEFAULT_STATE` on `None`
pub fn change_state(&self, state: Option<i32>) { pub fn change_state(&self, state: Option<i32>) {
self.gobject.change_state( self.simple_action.change_state(
&match state { &match state {
Some(value) => value, Some(value) => value,
None => DEFAULT_STATE, None => DEFAULT_STATE,
@ -52,7 +52,7 @@ impl Bookmark {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) { 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 let state = this
.state() .state()
.expect("State value required") .expect("State value required")

View File

@ -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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Close` action of `Window` group
pub struct Close { pub struct Close {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl Close { impl Close {
@ -20,7 +20,7 @@ impl Close {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new_stateful( simple_action: SimpleAction::new_stateful(
&uuid_string_random(), &uuid_string_random(),
None, None,
&DEFAULT_STATE.to_variant(), &DEFAULT_STATE.to_variant(),
@ -33,7 +33,7 @@ impl Close {
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html) /// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
/// * set `DEFAULT_STATE` on `None` /// * set `DEFAULT_STATE` on `None`
pub fn change_state(&self, state: Option<i32>) { pub fn change_state(&self, state: Option<i32>) {
self.gobject.change_state( self.simple_action.change_state(
&match state { &match state {
Some(value) => value, Some(value) => value,
None => DEFAULT_STATE, None => DEFAULT_STATE,
@ -47,7 +47,7 @@ impl Close {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) { 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 let state = this
.state() .state()
.expect("State value required") .expect("State value required")

View File

@ -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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `CloseAll` action of `Window` group
pub struct CloseAll { pub struct CloseAll {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl CloseAll { impl CloseAll {
@ -20,7 +20,7 @@ impl CloseAll {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new_stateful( simple_action: SimpleAction::new_stateful(
&uuid_string_random(), &uuid_string_random(),
None, None,
&DEFAULT_STATE.to_variant(), &DEFAULT_STATE.to_variant(),
@ -33,7 +33,7 @@ impl CloseAll {
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html) /// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
/// * set `DEFAULT_STATE` on `None` /// * set `DEFAULT_STATE` on `None`
pub fn change_state(&self, state: Option<i32>) { pub fn change_state(&self, state: Option<i32>) {
self.gobject.change_state( self.simple_action.change_state(
&match state { &match state {
Some(value) => value, Some(value) => value,
None => DEFAULT_STATE, None => DEFAULT_STATE,
@ -47,7 +47,7 @@ impl CloseAll {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) { 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 let state = this
.state() .state()
.expect("State value required") .expect("State value required")

View File

@ -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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `HistoryBack` action of `Window` group
pub struct HistoryBack { pub struct HistoryBack {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl HistoryBack { impl HistoryBack {
@ -20,7 +20,7 @@ impl HistoryBack {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new_stateful( simple_action: SimpleAction::new_stateful(
&uuid_string_random(), &uuid_string_random(),
None, None,
&DEFAULT_STATE.to_variant(), &DEFAULT_STATE.to_variant(),
@ -32,13 +32,13 @@ impl HistoryBack {
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn activate(&self) { 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) /// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
/// * set `DEFAULT_STATE` on `None` /// * set `DEFAULT_STATE` on `None`
pub fn change_state(&self, state: Option<i32>) { pub fn change_state(&self, state: Option<i32>) {
self.gobject.change_state( self.simple_action.change_state(
&match state { &match state {
Some(value) => value, Some(value) => value,
None => DEFAULT_STATE, None => DEFAULT_STATE,
@ -52,7 +52,7 @@ impl HistoryBack {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) { 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 let state = this
.state() .state()
.expect("State value required") .expect("State value required")

View File

@ -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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `HistoryForward` action of `Window` group
pub struct HistoryForward { pub struct HistoryForward {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl HistoryForward { impl HistoryForward {
@ -20,7 +20,7 @@ impl HistoryForward {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new_stateful( simple_action: SimpleAction::new_stateful(
&uuid_string_random(), &uuid_string_random(),
None, None,
&DEFAULT_STATE.to_variant(), &DEFAULT_STATE.to_variant(),
@ -32,13 +32,13 @@ impl HistoryForward {
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn activate(&self) { 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) /// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
/// * set `DEFAULT_STATE` on `None` /// * set `DEFAULT_STATE` on `None`
pub fn change_state(&self, state: Option<i32>) { pub fn change_state(&self, state: Option<i32>) {
self.gobject.change_state( self.simple_action.change_state(
&match state { &match state {
Some(value) => value, Some(value) => value,
None => DEFAULT_STATE, None => DEFAULT_STATE,
@ -52,7 +52,7 @@ impl HistoryForward {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) { 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 let state = this
.state() .state()
.expect("State value required") .expect("State value required")

View File

@ -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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Home` action of `Window` group
pub struct Home { pub struct Home {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl Home { impl Home {
@ -20,7 +20,7 @@ impl Home {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new_stateful( simple_action: SimpleAction::new_stateful(
&uuid_string_random(), &uuid_string_random(),
None, None,
&DEFAULT_STATE.to_variant(), &DEFAULT_STATE.to_variant(),
@ -32,13 +32,13 @@ impl Home {
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn activate(&self) { 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) /// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
/// * set `DEFAULT_STATE` on `None` /// * set `DEFAULT_STATE` on `None`
pub fn change_state(&self, state: Option<i32>) { pub fn change_state(&self, state: Option<i32>) {
self.gobject.change_state( self.simple_action.change_state(
&match state { &match state {
Some(value) => value, Some(value) => value,
None => DEFAULT_STATE, None => DEFAULT_STATE,
@ -52,7 +52,7 @@ impl Home {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) { 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 let state = this
.state() .state()
.expect("State value required") .expect("State value required")

View File

@ -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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Pin` action of `Window` group
pub struct Pin { pub struct Pin {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl Pin { impl Pin {
@ -20,7 +20,7 @@ impl Pin {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new_stateful( simple_action: SimpleAction::new_stateful(
&uuid_string_random(), &uuid_string_random(),
None, None,
&DEFAULT_STATE.to_variant(), &DEFAULT_STATE.to_variant(),
@ -33,7 +33,7 @@ impl Pin {
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html) /// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
/// * set `DEFAULT_STATE` on `None` /// * set `DEFAULT_STATE` on `None`
pub fn change_state(&self, state: Option<i32>) { pub fn change_state(&self, state: Option<i32>) {
self.gobject.change_state( self.simple_action.change_state(
&match state { &match state {
Some(value) => value, Some(value) => value,
None => DEFAULT_STATE, None => DEFAULT_STATE,
@ -47,7 +47,7 @@ impl Pin {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) { 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 let state = this
.state() .state()
.expect("State value required") .expect("State value required")

View File

@ -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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Reload` action of `Window` group
pub struct Reload { pub struct Reload {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl Reload { impl Reload {
@ -20,7 +20,7 @@ impl Reload {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new_stateful( simple_action: SimpleAction::new_stateful(
&uuid_string_random(), &uuid_string_random(),
None, None,
&DEFAULT_STATE.to_variant(), &DEFAULT_STATE.to_variant(),
@ -32,13 +32,13 @@ impl Reload {
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn activate(&self) { 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) /// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
/// * set `DEFAULT_STATE` on `None` /// * set `DEFAULT_STATE` on `None`
pub fn change_state(&self, state: Option<i32>) { pub fn change_state(&self, state: Option<i32>) {
self.gobject.change_state( self.simple_action.change_state(
&match state { &match state {
Some(value) => value, Some(value) => value,
None => DEFAULT_STATE, None => DEFAULT_STATE,
@ -52,7 +52,7 @@ impl Reload {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) { 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 let state = this
.state() .state()
.expect("State value required") .expect("State value required")

View File

@ -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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Save As` action of `Window` group
pub struct SaveAs { pub struct SaveAs {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl SaveAs { impl SaveAs {
@ -20,7 +20,7 @@ impl SaveAs {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new_stateful( simple_action: SimpleAction::new_stateful(
&uuid_string_random(), &uuid_string_random(),
None, None,
&DEFAULT_STATE.to_variant(), &DEFAULT_STATE.to_variant(),
@ -33,7 +33,7 @@ impl SaveAs {
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html) /// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
/// * set `DEFAULT_STATE` on `None` /// * set `DEFAULT_STATE` on `None`
pub fn change_state(&self, state: Option<i32>) { pub fn change_state(&self, state: Option<i32>) {
self.gobject.change_state( self.simple_action.change_state(
&match state { &match state {
Some(value) => value, Some(value) => value,
None => DEFAULT_STATE, None => DEFAULT_STATE,
@ -47,7 +47,7 @@ impl SaveAs {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) { 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 let state = this
.state() .state()
.expect("State value required") .expect("State value required")

View File

@ -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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Source` action of `Window` group
pub struct Source { pub struct Source {
pub gobject: SimpleAction, pub simple_action: SimpleAction,
} }
impl Source { impl Source {
@ -20,7 +20,7 @@ impl Source {
/// Create new `Self` /// Create new `Self`
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
gobject: SimpleAction::new_stateful( simple_action: SimpleAction::new_stateful(
&uuid_string_random(), &uuid_string_random(),
None, None,
&DEFAULT_STATE.to_variant(), &DEFAULT_STATE.to_variant(),
@ -33,7 +33,7 @@ impl Source {
/// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html) /// Change action [state](https://docs.gtk.org/gio/method.SimpleAction.set_state.html)
/// * set `DEFAULT_STATE` on `None` /// * set `DEFAULT_STATE` on `None`
pub fn change_state(&self, state: Option<i32>) { pub fn change_state(&self, state: Option<i32>) {
self.gobject.change_state( self.simple_action.change_state(
&match state { &match state {
Some(value) => value, Some(value) => value,
None => DEFAULT_STATE, None => DEFAULT_STATE,
@ -47,7 +47,7 @@ impl Source {
/// Define callback function for /// Define callback function for
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
pub fn connect_activate(&self, callback: impl Fn(Option<i32>) + 'static) { 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 let state = this
.state() .state()
.expect("State value required") .expect("State value required")

View File

@ -27,7 +27,7 @@ impl Header {
// Return new struct // Return new struct
Self { Self {
widget: Rc::new(Widget::new(&bar.widget.gobject)), widget: Rc::new(Widget::new(&bar.widget.g_box)),
} }
} }
} }

View File

@ -27,19 +27,19 @@ impl Menu {
main_page.append(Some("New"), Some(&format!( main_page.append(Some("New"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.append.gobject.name() window_action.append.simple_action.name()
))); )));
main_page.append(Some("Reload"), Some(&format!( main_page.append(Some("Reload"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.reload.gobject.name() window_action.reload.simple_action.name()
))); )));
main_page.append(Some("Save as.."), Some(&format!( main_page.append(Some("Save as.."), Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.save_as.gobject.name() window_action.save_as.simple_action.name()
))); )));
// Main > Page > Mark // Main > Page > Mark
@ -48,13 +48,13 @@ impl Menu {
main_page_mark.append(Some("Bookmark"), Some(&format!( main_page_mark.append(Some("Bookmark"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.bookmark.gobject.name() window_action.bookmark.simple_action.name()
))); )));
main_page_mark.append(Some("Pin"), Some(&format!( main_page_mark.append(Some("Pin"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.pin.gobject.name() window_action.pin.simple_action.name()
))); )));
main_page.append_section(None, &main_page_mark); main_page.append_section(None, &main_page_mark);
@ -65,7 +65,7 @@ impl Menu {
main_page_tools.append(Some("Source"), Some(&format!( main_page_tools.append(Some("Source"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.source.gobject.name() window_action.source.simple_action.name()
))); )));
main_page.append_section(None, &main_page_tools); main_page.append_section(None, &main_page_tools);
@ -76,7 +76,7 @@ impl Menu {
main_page_navigation.append(Some("Home"), Some(&format!( main_page_navigation.append(Some("Home"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.home.gobject.name() window_action.home.simple_action.name()
))); )));
// Main > Page > Navigation > History // Main > Page > Navigation > History
@ -85,13 +85,13 @@ impl Menu {
main_page_navigation_history.append(Some("Back"), Some(&format!( main_page_navigation_history.append(Some("Back"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.history_back.gobject.name() window_action.history_back.simple_action.name()
))); )));
main_page_navigation_history.append(Some("Forward"), Some(&format!( main_page_navigation_history.append(Some("Forward"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.history_forward.gobject.name() window_action.history_forward.simple_action.name()
))); )));
main_page_navigation.append_submenu(Some("History"), &main_page_navigation_history); main_page_navigation.append_submenu(Some("History"), &main_page_navigation_history);
@ -104,13 +104,13 @@ impl Menu {
main_page_close.append(Some("Current"), Some(&format!( main_page_close.append(Some("Current"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.close.gobject.name() window_action.close.simple_action.name()
))); )));
main_page_close.append(Some("All"), Some(&format!( main_page_close.append(Some("All"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.close_all.gobject.name() window_action.close_all.simple_action.name()
))); )));
main_page.append_submenu(Some("Close"), &main_page_close); main_page.append_submenu(Some("Close"), &main_page_close);
@ -124,19 +124,19 @@ impl Menu {
main_tool.append(Some("Debug"), Some(&format!( main_tool.append(Some("Debug"), Some(&format!(
"{}.{}", "{}.{}",
browser_action.id, browser_action.id,
browser_action.debug.gobject.name() browser_action.debug.simple_action.name()
))); )));
main_tool.append(Some("Profile"), Some(&format!( main_tool.append(Some("Profile"), Some(&format!(
"{}.{}", "{}.{}",
browser_action.id, browser_action.id,
browser_action.profile.gobject.name() browser_action.profile.simple_action.name()
))); )));
main_tool.append(Some("About"), Some(&format!( main_tool.append(Some("About"), Some(&format!(
"{}.{}", "{}.{}",
browser_action.id, browser_action.id,
browser_action.about.gobject.name() browser_action.about.simple_action.name()
))); )));
main.append_submenu(Some("Tool"), &main_tool); main.append_submenu(Some("Tool"), &main_tool);
@ -144,7 +144,7 @@ impl Menu {
main.append(Some("Quit"), Some(&format!( main.append(Some("Quit"), Some(&format!(
"{}.{}", "{}.{}",
browser_action.id, browser_action.id,
browser_action.close.gobject.name() browser_action.close.simple_action.name()
))); )));
// Result // Result

View File

@ -2,21 +2,21 @@ use adw::TabBar;
use gtk::{prelude::BoxExt, Box, MenuButton, Orientation, WindowControls}; use gtk::{prelude::BoxExt, Box, MenuButton, Orientation, WindowControls};
pub struct Widget { pub struct Widget {
pub gobject: Box, pub g_box: Box,
} }
impl Widget { impl Widget {
// Construct // Construct
pub fn new(control: &WindowControls, menu: &MenuButton, tab: &TabBar) -> Self { pub fn new(control: &WindowControls, menu: &MenuButton, tab: &TabBar) -> Self {
let gobject = Box::builder() let g_box = Box::builder()
.orientation(Orientation::Horizontal) .orientation(Orientation::Horizontal)
.spacing(8) .spacing(8)
.build(); .build();
gobject.append(tab); g_box.append(tab);
gobject.append(menu); g_box.append(menu);
gobject.append(control); g_box.append(control);
Self { gobject } Self { g_box }
} }
} }

View File

@ -40,11 +40,11 @@ impl Tab {
let menu = Menu::new(action.1.clone()); let menu = Menu::new(action.1.clone());
// Init widget // Init widget
let widget = Rc::new(Widget::new(&menu.gobject)); let widget = Rc::new(Widget::new(&menu.main));
// Init events // Init events
widget.gobject.connect_setup_menu({ widget.tab_view.connect_setup_menu({
let action = action.1.clone(); let action = action.1.clone();
move |tab_view, tab_page| { move |tab_view, tab_page| {
// Set new state for page selected on menu open // Set new state for page selected on menu open
@ -65,7 +65,7 @@ impl Tab {
} }
}); });
widget.gobject.connect_close_page({ widget.tab_view.connect_close_page({
let index = index.clone(); let index = index.clone();
move |_, item| { move |_, item| {
// Get index ID by keyword saved // Get index ID by keyword saved
@ -84,7 +84,7 @@ impl Tab {
} }
}); });
widget.gobject.connect_selected_page_notify({ widget.tab_view.connect_selected_page_notify({
let index = index.clone(); let index = index.clone();
move |this| { move |this| {
if let Some(page) = this.selected_page() { if let Some(page) = this.selected_page() {
@ -120,7 +120,7 @@ impl Tab {
) -> Rc<Item> { ) -> Rc<Item> {
// Init new tab item // Init new tab item
let item = Rc::new(Item::new( let item = Rc::new(Item::new(
&self.widget.gobject, &self.widget.tab_view,
self.profile.clone(), self.profile.clone(),
// Actions // Actions
(self.actions.0.clone(), self.actions.1.clone()), (self.actions.0.clone(), self.actions.1.clone()),
@ -227,7 +227,7 @@ impl Tab {
// Update tab title on loading indicator inactive // Update tab title on loading indicator inactive
if !item.page.is_loading() { if !item.page.is_loading() {
item.widget item.widget
.gobject .tab_page
.set_title(&item.page.meta.title.borrow()) .set_title(&item.page.meta.title.borrow())
} }
} }
@ -240,7 +240,7 @@ impl Tab {
// Update tab title on loading indicator inactive // Update tab title on loading indicator inactive
if !item.page.is_loading() { if !item.page.is_loading() {
item.widget item.widget
.gobject .tab_page
.set_title(&item.page.meta.title.borrow()) .set_title(&item.page.meta.title.borrow())
} }
} }
@ -282,7 +282,7 @@ impl Tab {
Ok(records) => { Ok(records) => {
for record in records { for record in records {
match Item::restore( match Item::restore(
&self.widget.gobject, &self.widget.tab_view,
transaction, transaction,
&record.id, &record.id,
self.profile.clone(), self.profile.clone(),
@ -321,10 +321,10 @@ impl Tab {
item.save( item.save(
transaction, transaction,
&id, &id,
&self.widget.gobject.page_position(&item.widget.gobject), &self.widget.tab_view.page_position(&item.widget.tab_page),
&item.widget.gobject.is_pinned(), &item.widget.tab_page.is_pinned(),
&item.widget.gobject.is_selected(), &item.widget.tab_page.is_selected(),
&item.widget.gobject.needs_attention(), &item.widget.tab_page.needs_attention(),
)?; )?;
} }
} }

View File

@ -57,7 +57,7 @@ impl Item {
let widget = Rc::new(Widget::new( let widget = Rc::new(Widget::new(
id.as_str(), id.as_str(),
tab_view, tab_view,
page.widget.gobject(), &page.widget.g_box,
None, None,
position, position,
(is_pinned, is_selected, is_attention), (is_pinned, is_selected, is_attention),
@ -118,7 +118,7 @@ impl Item {
self.page.update(); self.page.update();
// Update tab loading indicator // Update tab loading indicator
self.widget.gobject.set_loading(self.page.is_loading()); self.widget.tab_page.set_loading(self.page.is_loading());
} }
pub fn clean( pub fn clean(

View File

@ -24,7 +24,7 @@ impl Back {
pub fn update(&self, status: bool) { pub fn update(&self, status: bool) {
// Update actions // Update actions
self.action.history_back.gobject.set_enabled(status); self.action.history_back.simple_action.set_enabled(status);
// Update child components // Update child components
self.widget.update(status); self.widget.update(status);

View File

@ -22,7 +22,10 @@ impl Forward {
// Actions // Actions
pub fn update(&self, status: bool) { pub fn update(&self, status: bool) {
// Update actions // Update actions
self.action.history_forward.gobject.set_enabled(status); self.action
.history_forward
.simple_action
.set_enabled(status);
// Update child components // Update child components
self.widget.update(status); self.widget.update(status);

View File

@ -34,7 +34,7 @@ impl Home {
false false
} }
}; };
self.action.home.gobject.set_enabled(has_home); self.action.home.simple_action.set_enabled(has_home);
self.widget.update(has_home); self.widget.update(has_home);
} }

View File

@ -23,7 +23,7 @@ impl Reload {
pub fn update(&self, is_enabled: bool) { pub fn update(&self, is_enabled: bool) {
// Update actions // Update actions
self.action.reload.gobject.set_enabled(is_enabled); self.action.reload.simple_action.set_enabled(is_enabled);
// Update child components // Update child components
self.widget.update(is_enabled); self.widget.update(is_enabled);

View File

@ -4,7 +4,7 @@ use gtk::{
}; };
pub struct Widget { pub struct Widget {
gobject: Box, pub g_box: Box,
} }
impl Widget { impl Widget {
@ -17,20 +17,15 @@ impl Widget {
input: &impl IsA<gtk::Widget>, input: &impl IsA<gtk::Widget>,
) -> Self { ) -> Self {
// Init self // Init self
let gobject = Box::builder() let g_box = Box::builder()
.orientation(Orientation::Vertical) .orientation(Orientation::Vertical)
.name(name) .name(name)
.build(); .build();
gobject.append(navigation); g_box.append(navigation);
gobject.append(content); g_box.append(content);
gobject.append(input); g_box.append(input);
Self { gobject } Self { g_box }
}
// Getters
pub fn gobject(&self) -> &Box {
&self.gobject
} }
} }

View File

@ -8,7 +8,7 @@ use sqlite::Transaction;
const DEFAULT_TITLE: &str = "New page"; const DEFAULT_TITLE: &str = "New page";
pub struct Widget { pub struct Widget {
pub gobject: TabPage, pub tab_page: TabPage,
} }
impl Widget { impl Widget {
@ -25,8 +25,8 @@ impl Widget {
// Define state variables // Define state variables
let (is_pinned, is_selected, is_attention) = state; let (is_pinned, is_selected, is_attention) = state;
// Create new `TabPage` GObject in given `TabView` // Create new `TabPage` for given `TabView`
let gobject = match position { let tab_page = match position {
Position::After => match tab_view.selected_page() { Position::After => match tab_view.selected_page() {
Some(page) => add(tab_view, child, tab_view.page_position(&page) + 1), Some(page) => add(tab_view, child, tab_view.page_position(&page) + 1),
None => tab_view.append(child), None => tab_view.append(child),
@ -35,22 +35,22 @@ impl Widget {
Position::Number(value) => add(tab_view, child, value), Position::Number(value) => add(tab_view, child, value),
}; };
// Setup `GObject` // Setup
gobject.set_needs_attention(is_attention); tab_page.set_needs_attention(is_attention);
gobject.set_keyword(keyword); tab_page.set_keyword(keyword);
gobject.set_title(match title { tab_page.set_title(match title {
Some(value) => value, Some(value) => value,
None => DEFAULT_TITLE, None => DEFAULT_TITLE,
}); });
tab_view.set_page_pinned(&gobject, is_pinned); tab_view.set_page_pinned(&tab_page, is_pinned);
if is_selected { if is_selected {
tab_view.set_selected_page(&gobject); tab_view.set_selected_page(&tab_page);
} }
// Done // Done
Self { gobject } Self { tab_page }
} }
// Actions // Actions
@ -88,7 +88,7 @@ impl Widget {
for record in records { for record in records {
// Record value can be stored as NULL // Record value can be stored as NULL
if let Some(title) = record.title { if let Some(title) = record.title {
self.gobject.set_title(title.as_str()); self.tab_page.set_title(title.as_str());
} }
// Delegate restore action to the item childs // Delegate restore action to the item childs
@ -107,7 +107,7 @@ impl Widget {
app_browser_window_tab_item_id: &i64, app_browser_window_tab_item_id: &i64,
) -> Result<(), String> { ) -> Result<(), String> {
// Keep value in memory until operation complete // Keep value in memory until operation complete
let title = self.gobject.title(); let title = self.tab_page.title();
match database::insert( match database::insert(
transaction, transaction,

View File

@ -6,7 +6,7 @@ use std::rc::Rc;
/// ///
/// https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/method.TabView.get_menu_model.html /// https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/method.TabView.get_menu_model.html
pub struct Menu { pub struct Menu {
pub gobject: gtk::gio::Menu, pub main: gtk::gio::Menu,
} }
impl Menu { impl Menu {
@ -21,7 +21,7 @@ impl Menu {
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.reload.gobject.name() window_action.reload.simple_action.name()
)), )),
); );
@ -30,7 +30,7 @@ impl Menu {
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.save_as.gobject.name() window_action.save_as.simple_action.name()
)), )),
); );
@ -41,7 +41,7 @@ impl Menu {
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.bookmark.gobject.name() window_action.bookmark.simple_action.name()
)), )),
); );
@ -50,7 +50,7 @@ impl Menu {
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.pin.gobject.name() window_action.pin.simple_action.name()
)), )),
); );
@ -63,7 +63,7 @@ impl Menu {
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.source.gobject.name() window_action.source.simple_action.name()
)), )),
); );
@ -76,7 +76,7 @@ impl Menu {
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.home.gobject.name() window_action.home.simple_action.name()
)), )),
); );
@ -89,7 +89,7 @@ impl Menu {
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.history_back.gobject.name() window_action.history_back.simple_action.name()
)), )),
); );
@ -98,7 +98,7 @@ impl Menu {
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.history_forward.gobject.name() window_action.history_forward.simple_action.name()
)), )),
); );
@ -111,7 +111,7 @@ impl Menu {
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.close.gobject.name() window_action.close.simple_action.name()
)), )),
); );
@ -120,12 +120,12 @@ impl Menu {
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id, window_action.id,
window_action.close_all.gobject.name() window_action.close_all.simple_action.name()
)), )),
); );
main.append_submenu(Some("Close"), &close); main.append_submenu(Some("Close"), &close);
Self { gobject: main } Self { main }
} }
} }

View File

@ -9,7 +9,7 @@ const DEFAULT_TAB_ICON: &str = "view-pin-symbolic";
/// Wrapper for [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) GObject /// Wrapper for [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) GObject
pub struct Widget { pub struct Widget {
pub gobject: TabView, pub tab_view: TabView,
} }
impl Widget { impl Widget {
@ -18,17 +18,17 @@ impl Widget {
/// Create new `Self` /// Create new `Self`
pub fn new(menu_model: &impl IsA<MenuModel>) -> Self { pub fn new(menu_model: &impl IsA<MenuModel>) -> Self {
// Init gobject // Init gobject
let gobject = TabView::builder().menu_model(menu_model).build(); let tab_view = TabView::builder().menu_model(menu_model).build();
// Change default icon (if available in the system icon set) // Change default icon (if available in the system icon set)
// * visible for pinned tabs only // * visible for pinned tabs only
// * @TODO not default GTK behavior, make this feature optional // * @TODO not default GTK behavior, make this feature optional
if let Ok(default_icon) = Icon::for_string(DEFAULT_TAB_ICON) { if let Ok(default_icon) = Icon::for_string(DEFAULT_TAB_ICON) {
gobject.set_default_icon(&default_icon); tab_view.set_default_icon(&default_icon);
} }
// Done // Done
Self { gobject } Self { tab_view }
} }
// Actions // Actions
@ -39,8 +39,8 @@ impl Widget {
/// * use native [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) API with `GObject` reference getter /// * use native [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) API with `GObject` reference getter
pub fn close(&self, position: Option<i32>) { pub fn close(&self, position: Option<i32>) {
if let Some(page) = self.page(position) { if let Some(page) = self.page(position) {
self.gobject.set_page_pinned(&page, false); self.tab_view.set_page_pinned(&page, false);
self.gobject.close_page(&page); self.tab_view.close_page(&page);
} }
} }
@ -49,16 +49,16 @@ impl Widget {
/// * deactivate [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) outside if selected page should not be closed /// * deactivate [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) outside if selected page should not be closed
/// * use native [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) API with `GObject` reference getter /// * use native [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) API with `GObject` reference getter
pub fn close_all(&self) { pub fn close_all(&self) {
while let Some(page) = self.gobject.selected_page() { while let Some(page) = self.tab_view.selected_page() {
self.gobject.set_page_pinned(&page, false); self.tab_view.set_page_pinned(&page, false);
self.gobject.close_page(&page); self.tab_view.close_page(&page);
} }
} }
/// Toggle pin for page at given `position`, `None` to pin selected page (if available) /// Toggle pin for page at given `position`, `None` to pin selected page (if available)
pub fn pin(&self, position: Option<i32>) { pub fn pin(&self, position: Option<i32>) {
if let Some(page) = self.page(position) { if let Some(page) = self.page(position) {
self.gobject.set_page_pinned(&page, !page.is_pinned()); // toggle self.tab_view.set_page_pinned(&page, !page.is_pinned()); // toggle
} }
} }
@ -68,8 +68,8 @@ impl Widget {
/// * return `None` if requested or selected page not found /// * return `None` if requested or selected page not found
pub fn page(&self, position: Option<i32>) -> Option<TabPage> { pub fn page(&self, position: Option<i32>) -> Option<TabPage> {
match position { match position {
Some(value) => Some(self.gobject.nth_page(value)), Some(value) => Some(self.tab_view.nth_page(value)),
None => self.gobject.selected_page(), None => self.tab_view.selected_page(),
} }
} }
} }