mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20: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({
|
action.close.connect_activate({
|
||||||
let widget = widget.clone();
|
let widget = widget.clone();
|
||||||
move || widget.gobject().close()
|
move || widget.application_window.close()
|
||||||
});
|
});
|
||||||
|
|
||||||
action.debug.connect_activate({
|
action.debug.connect_activate({
|
||||||
let widget = widget.clone();
|
let widget = widget.clone();
|
||||||
move || {
|
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 {
|
pub fn init(&self, application: Option<&impl IsA<Application>>) -> &Self {
|
||||||
// Assign browser window to this application
|
// Assign browser window to this application
|
||||||
self.widget.gobject().set_application(application); // @TODO
|
self.widget.application_window.set_application(application); // @TODO
|
||||||
|
|
||||||
// Init main window
|
// Init main window
|
||||||
self.window.init();
|
self.window.init();
|
||||||
@ -168,7 +168,7 @@ impl Browser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn present(&self) -> &Self {
|
pub fn present(&self) -> &Self {
|
||||||
self.widget.gobject().present();
|
self.widget.application_window.present();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ const DEFAULT_WIDTH: i32 = 640;
|
|||||||
const MAXIMIZED: bool = false;
|
const MAXIMIZED: bool = false;
|
||||||
|
|
||||||
pub struct Widget {
|
pub struct Widget {
|
||||||
gobject: ApplicationWindow,
|
pub application_window: ApplicationWindow,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
@ -24,7 +24,7 @@ impl Widget {
|
|||||||
action_groups: &[(&GString, SimpleActionGroup)],
|
action_groups: &[(&GString, SimpleActionGroup)],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Init GTK
|
// Init GTK
|
||||||
let gobject = ApplicationWindow::builder()
|
let application_window = ApplicationWindow::builder()
|
||||||
.content(content)
|
.content(content)
|
||||||
.default_height(DEFAULT_HEIGHT)
|
.default_height(DEFAULT_HEIGHT)
|
||||||
.default_width(DEFAULT_WIDTH)
|
.default_width(DEFAULT_WIDTH)
|
||||||
@ -33,11 +33,11 @@ impl Widget {
|
|||||||
|
|
||||||
// Register actions
|
// Register actions
|
||||||
for (name, group) in action_groups {
|
for (name, group) in action_groups {
|
||||||
gobject.insert_action_group(name, Some(group));
|
application_window.insert_action_group(name, Some(group));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return new struct
|
// Return new struct
|
||||||
Self { gobject }
|
Self { application_window }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
@ -65,8 +65,8 @@ impl Widget {
|
|||||||
Ok(records) => {
|
Ok(records) => {
|
||||||
for record in records {
|
for record in records {
|
||||||
// Restore widget
|
// Restore widget
|
||||||
self.gobject.set_maximized(record.is_maximized);
|
self.application_window.set_maximized(record.is_maximized);
|
||||||
self.gobject
|
self.application_window
|
||||||
.set_default_size(record.default_width, record.default_height);
|
.set_default_size(record.default_width, record.default_height);
|
||||||
|
|
||||||
// Delegate restore action to childs
|
// Delegate restore action to childs
|
||||||
@ -83,9 +83,9 @@ impl Widget {
|
|||||||
match database::insert(
|
match database::insert(
|
||||||
transaction,
|
transaction,
|
||||||
app_browser_id,
|
app_browser_id,
|
||||||
&self.gobject.default_width(),
|
&self.application_window.default_width(),
|
||||||
&self.gobject.default_height(),
|
&self.application_window.default_height(),
|
||||||
&self.gobject.is_maximized(),
|
&self.application_window.is_maximized(),
|
||||||
) {
|
) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// Delegate save action to childs
|
// Delegate save action to childs
|
||||||
@ -97,11 +97,6 @@ impl Widget {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
|
||||||
pub fn gobject(&self) -> &ApplicationWindow {
|
|
||||||
&self.gobject
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
|
@ -32,7 +32,7 @@ impl Bar {
|
|||||||
widget: Rc::new(Widget::new(
|
widget: Rc::new(Widget::new(
|
||||||
&control.widget.gobject,
|
&control.widget.gobject,
|
||||||
&menu.widget.gobject,
|
&menu.widget.gobject,
|
||||||
&tab.widget.gobject,
|
&tab.widget.tab_bar,
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,14 @@ use adw::{TabBar, TabView};
|
|||||||
use gtk::prelude::IsA;
|
use gtk::prelude::IsA;
|
||||||
|
|
||||||
pub struct Widget {
|
pub struct Widget {
|
||||||
pub gobject: TabBar,
|
pub tab_bar: TabBar,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(view: &TabView, start_action_widget: &impl IsA<gtk::Widget>) -> Self {
|
pub fn new(view: &TabView, start_action_widget: &impl IsA<gtk::Widget>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
gobject: TabBar::builder()
|
tab_bar: TabBar::builder()
|
||||||
.autohide(false)
|
.autohide(false)
|
||||||
.expand_tabs(false)
|
.expand_tabs(false)
|
||||||
.end_action_widget(start_action_widget) // @TODO find solution to append after tabs
|
.end_action_widget(start_action_widget) // @TODO find solution to append after tabs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user