mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-13 06:01:21 +00:00
relocate actions
This commit is contained in:
parent
48541da91d
commit
b5b4b359fa
@ -1,31 +0,0 @@
|
|||||||
use gtk::gio::ActionEntry;
|
|
||||||
use gtk::prelude::GtkWindowExt;
|
|
||||||
use gtk::ApplicationWindow;
|
|
||||||
|
|
||||||
pub fn debug() -> ActionEntry<ApplicationWindow> {
|
|
||||||
ActionEntry::builder("debug")
|
|
||||||
.activate(|this: &ApplicationWindow, _, _| {
|
|
||||||
this.emit_enable_debugging(true);
|
|
||||||
})
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn quit() -> ActionEntry<ApplicationWindow> {
|
|
||||||
ActionEntry::builder("quit")
|
|
||||||
.activate(|this: &ApplicationWindow, _, _| {
|
|
||||||
this.close();
|
|
||||||
})
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
|
|
||||||
/* @TODO
|
|
||||||
pub fn tab_append(main) -> ActionEntry<ApplicationWindow> {
|
|
||||||
let action_tab_append = ActionEntry::builder("tab_append")
|
|
||||||
.activate({
|
|
||||||
let main = main.clone();
|
|
||||||
move |_, _, _| {
|
|
||||||
main.tab_append();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.build();
|
|
||||||
}*/
|
|
@ -1,6 +1,8 @@
|
|||||||
mod tab;
|
mod tab;
|
||||||
mod widget;
|
mod widget;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct Main {
|
pub struct Main {
|
||||||
widget: widget::Main,
|
widget: widget::Main,
|
||||||
tab: tab::Tab,
|
tab: tab::Tab,
|
||||||
@ -8,15 +10,15 @@ pub struct Main {
|
|||||||
|
|
||||||
impl Main {
|
impl Main {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Main {
|
pub fn new() -> Arc<Main> {
|
||||||
// Init components
|
// Init components
|
||||||
let tab = tab::Tab::new();
|
let tab = tab::Tab::new();
|
||||||
|
|
||||||
// Init struct
|
// Init struct
|
||||||
Self {
|
Arc::new(Self {
|
||||||
widget: widget::Main::new(tab.widget().gtk()), // @TODO
|
widget: widget::Main::new(tab.widget().gtk()), // @TODO
|
||||||
tab,
|
tab,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
mod action;
|
|
||||||
mod db;
|
mod db;
|
||||||
mod header;
|
mod header;
|
||||||
mod main;
|
mod main;
|
||||||
mod widget;
|
mod widget;
|
||||||
|
|
||||||
use gtk::prelude::ActionMapExtManual;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use gtk::prelude::{ActionMapExtManual, GtkWindowExt};
|
||||||
|
|
||||||
pub struct Browser {
|
pub struct Browser {
|
||||||
db: db::Browser,
|
db: db::Browser,
|
||||||
|
header: header::Header,
|
||||||
|
main: Arc<main::Main>,
|
||||||
widget: widget::Browser,
|
widget: widget::Browser,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,27 +18,50 @@ impl Browser {
|
|||||||
// Construct new browser
|
// Construct new browser
|
||||||
pub fn new(
|
pub fn new(
|
||||||
app: >k::Application,
|
app: >k::Application,
|
||||||
connection: std::sync::Arc<sqlite::Connection>,
|
connection: std::sync::Arc<sqlite::Connection>, // @TODO glib clone macro?
|
||||||
default_width: i32,
|
default_width: i32,
|
||||||
default_height: i32,
|
default_height: i32,
|
||||||
) -> Browser {
|
) -> Browser {
|
||||||
// Init widget
|
// Init components
|
||||||
|
let db = db::Browser::new(connection);
|
||||||
|
let header = header::Header::new();
|
||||||
|
let main = main::Main::new();
|
||||||
|
|
||||||
let widget = widget::Browser::new(
|
let widget = widget::Browser::new(
|
||||||
app,
|
app,
|
||||||
header::Header::new().widget().gtk(),
|
header.widget().gtk(),
|
||||||
main::Main::new().widget().gtk(),
|
main.widget().gtk(),
|
||||||
default_width,
|
default_width,
|
||||||
default_height,
|
default_height,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Connect actions
|
// Init actions @TODO separated module
|
||||||
widget
|
widget.gtk().add_action_entries([
|
||||||
.gtk()
|
gtk::gio::ActionEntry::builder("debug")
|
||||||
.add_action_entries([action::debug(), action::quit()]);
|
.activate(|this: >k::ApplicationWindow, _, _| {
|
||||||
|
this.emit_enable_debugging(true);
|
||||||
|
})
|
||||||
|
.build(),
|
||||||
|
gtk::gio::ActionEntry::builder("quit")
|
||||||
|
.activate(|this: >k::ApplicationWindow, _, _| {
|
||||||
|
this.close();
|
||||||
|
})
|
||||||
|
.build(),
|
||||||
|
gtk::gio::ActionEntry::builder("tab_append")
|
||||||
|
.activate({
|
||||||
|
let main = main.clone();
|
||||||
|
move |_, _, _| {
|
||||||
|
main.tab_append();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build(),
|
||||||
|
]);
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
Self {
|
Self {
|
||||||
db: db::Browser::new(connection),
|
db,
|
||||||
|
header,
|
||||||
|
main,
|
||||||
widget,
|
widget,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user