Yoda/src/browser/mod.rs

48 lines
979 B
Rust
Raw Normal View History

2024-09-22 17:34:22 +03:00
mod action;
2024-09-22 13:17:18 +03:00
mod db;
2024-09-20 18:02:10 +03:00
mod header;
mod main;
2024-09-22 17:34:22 +03:00
mod widget;
2024-09-18 20:33:29 +03:00
2024-09-22 17:34:22 +03:00
use gtk::prelude::ActionMapExtManual;
2024-09-18 20:33:29 +03:00
2024-09-22 02:00:54 +03:00
pub struct Browser {
2024-09-22 13:17:18 +03:00
db: db::Browser,
2024-09-22 17:34:22 +03:00
widget: widget::Browser,
2024-09-22 02:00:54 +03:00
}
2024-09-21 20:48:12 +03:00
2024-09-22 17:34:22 +03:00
impl Browser {
// Construct new browser
pub fn new(
app: &gtk::Application,
connection: std::sync::Arc<sqlite::Connection>,
2024-09-22 17:36:31 +03:00
default_width: i32,
default_height: i32,
2024-09-22 17:34:22 +03:00
) -> Browser {
// Init widget
let widget = widget::Browser::new(
app,
header::Header::new().widget().gtk(),
main::new().widget.as_ref(), // @TODO
2024-09-22 17:36:31 +03:00
default_width,
default_height,
2024-09-22 17:34:22 +03:00
);
// Connect actions
widget
.gtk()
.add_action_entries([action::debug(), action::quit()]);
// Return
Self {
db: db::Browser::new(connection),
widget,
}
}
2024-09-19 18:08:09 +03:00
2024-09-22 17:34:22 +03:00
// Getters
pub fn widget(&self) -> &widget::Browser {
&self.widget
2024-09-22 12:42:34 +03:00
}
2024-09-20 18:02:10 +03:00
}