mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 09:10:08 +00:00
remove extra getters, give name to gobjects
This commit is contained in:
parent
58f9ed537d
commit
582bef28b0
@ -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<Application>>) -> &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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -32,7 +32,7 @@ impl Bar {
|
||||
widget: Rc::new(Widget::new(
|
||||
&control.widget.gobject,
|
||||
&menu.widget.gobject,
|
||||
&tab.widget.gobject,
|
||||
&tab.widget.tab_bar,
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
@ -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<gtk::Widget>) -> 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user