From 582bef28b057b57a287d19a23b45f753d3b9f42c Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 12 Dec 2024 14:35:53 +0200 Subject: [PATCH] remove extra getters, give name to gobjects --- src/app/browser.rs | 8 +++---- src/app/browser/widget.rs | 23 ++++++++----------- src/app/browser/window/header/bar.rs | 2 +- .../browser/window/header/bar/tab/widget.rs | 4 ++-- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/app/browser.rs b/src/app/browser.rs index c86d935d..0a111da0 100644 --- a/src/app/browser.rs +++ b/src/app/browser.rs @@ -59,13 +59,13 @@ impl Browser { action.close.connect_activate({ let widget = widget.clone(); - move || widget.gobject().close() + move || widget.application_window.close() }); action.debug.connect_activate({ let widget = widget.clone(); move || { - widget.gobject().emit_enable_debugging(true); + widget.application_window.emit_enable_debugging(true); } }); @@ -160,7 +160,7 @@ impl Browser { pub fn init(&self, application: Option<&impl IsA>) -> &Self { // Assign browser window to this application - self.widget.gobject().set_application(application); // @TODO + self.widget.application_window.set_application(application); // @TODO // Init main window self.window.init(); @@ -168,7 +168,7 @@ impl Browser { } pub fn present(&self) -> &Self { - self.widget.gobject().present(); + self.widget.application_window.present(); self } diff --git a/src/app/browser/widget.rs b/src/app/browser/widget.rs index 64f2b92e..2157bbf0 100644 --- a/src/app/browser/widget.rs +++ b/src/app/browser/widget.rs @@ -14,7 +14,7 @@ const DEFAULT_WIDTH: i32 = 640; const MAXIMIZED: bool = false; pub struct Widget { - gobject: ApplicationWindow, + pub application_window: ApplicationWindow, } impl Widget { @@ -24,7 +24,7 @@ impl Widget { action_groups: &[(&GString, SimpleActionGroup)], ) -> Self { // Init GTK - let gobject = ApplicationWindow::builder() + let application_window = ApplicationWindow::builder() .content(content) .default_height(DEFAULT_HEIGHT) .default_width(DEFAULT_WIDTH) @@ -33,11 +33,11 @@ impl Widget { // Register actions for (name, group) in action_groups { - gobject.insert_action_group(name, Some(group)); + application_window.insert_action_group(name, Some(group)); } // Return new struct - Self { gobject } + Self { application_window } } // Actions @@ -65,8 +65,8 @@ impl Widget { Ok(records) => { for record in records { // Restore widget - self.gobject.set_maximized(record.is_maximized); - self.gobject + self.application_window.set_maximized(record.is_maximized); + self.application_window .set_default_size(record.default_width, record.default_height); // Delegate restore action to childs @@ -83,9 +83,9 @@ impl Widget { match database::insert( transaction, app_browser_id, - &self.gobject.default_width(), - &self.gobject.default_height(), - &self.gobject.is_maximized(), + &self.application_window.default_width(), + &self.application_window.default_height(), + &self.application_window.is_maximized(), ) { Ok(_) => { // Delegate save action to childs @@ -97,11 +97,6 @@ impl Widget { Ok(()) } - - // Getters - pub fn gobject(&self) -> &ApplicationWindow { - &self.gobject - } } // Tools diff --git a/src/app/browser/window/header/bar.rs b/src/app/browser/window/header/bar.rs index 0be125fc..cd4cc92e 100644 --- a/src/app/browser/window/header/bar.rs +++ b/src/app/browser/window/header/bar.rs @@ -32,7 +32,7 @@ impl Bar { widget: Rc::new(Widget::new( &control.widget.gobject, &menu.widget.gobject, - &tab.widget.gobject, + &tab.widget.tab_bar, )), } } diff --git a/src/app/browser/window/header/bar/tab/widget.rs b/src/app/browser/window/header/bar/tab/widget.rs index 9ccc3aa0..e972772b 100644 --- a/src/app/browser/window/header/bar/tab/widget.rs +++ b/src/app/browser/window/header/bar/tab/widget.rs @@ -2,14 +2,14 @@ use adw::{TabBar, TabView}; use gtk::prelude::IsA; pub struct Widget { - pub gobject: TabBar, + pub tab_bar: TabBar, } impl Widget { // Construct pub fn new(view: &TabView, start_action_widget: &impl IsA) -> Self { Self { - gobject: TabBar::builder() + tab_bar: TabBar::builder() .autohide(false) .expand_tabs(false) .end_action_widget(start_action_widget) // @TODO find solution to append after tabs