mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
implement about dialog
This commit is contained in:
parent
39ee50c4ba
commit
eca93df1eb
@ -41,6 +41,7 @@ impl App {
|
||||
profile_path: PathBuf,
|
||||
) -> Self {
|
||||
// Init actions
|
||||
let action_about = Action::new("win", true, None);
|
||||
let action_debug = Action::new("win", true, None);
|
||||
let action_profile = Action::new("win", true, None);
|
||||
let action_quit = Action::new("win", true, None);
|
||||
@ -80,6 +81,7 @@ impl App {
|
||||
// Init components
|
||||
let browser = Arc::new(Browser::new(
|
||||
profile_path,
|
||||
action_about.simple(),
|
||||
action_debug.simple(),
|
||||
action_profile.simple(),
|
||||
action_quit.simple(),
|
||||
|
@ -1,7 +1,9 @@
|
||||
mod about;
|
||||
mod database;
|
||||
mod widget;
|
||||
mod window;
|
||||
|
||||
use about::About;
|
||||
use database::Database;
|
||||
use widget::Widget;
|
||||
use window::Window;
|
||||
@ -28,6 +30,7 @@ impl Browser {
|
||||
// Extras
|
||||
profile_path: PathBuf,
|
||||
// Actions
|
||||
action_about: SimpleAction,
|
||||
action_debug: SimpleAction,
|
||||
action_profile: SimpleAction,
|
||||
action_quit: SimpleAction,
|
||||
@ -43,6 +46,7 @@ impl Browser {
|
||||
) -> Browser {
|
||||
// Init components
|
||||
let window = Arc::new(Window::new(
|
||||
action_about.clone(),
|
||||
action_debug.clone(),
|
||||
action_profile.clone(),
|
||||
action_quit.clone(),
|
||||
@ -61,6 +65,7 @@ impl Browser {
|
||||
let widget = Arc::new(Widget::new(
|
||||
window.gobject(),
|
||||
&[
|
||||
action_about.clone(),
|
||||
action_debug.clone(),
|
||||
action_profile.clone(),
|
||||
action_quit.clone(),
|
||||
@ -77,6 +82,13 @@ impl Browser {
|
||||
));
|
||||
|
||||
// Init events
|
||||
action_about.connect_activate({
|
||||
let window = window.clone();
|
||||
move |_, _| {
|
||||
About::new().present(Some(window.gobject()));
|
||||
}
|
||||
});
|
||||
|
||||
action_debug.connect_activate({
|
||||
let widget = widget.clone();
|
||||
move |_, _| {
|
||||
|
41
src/app/browser/about.rs
Normal file
41
src/app/browser/about.rs
Normal file
@ -0,0 +1,41 @@
|
||||
use adw::{prelude::AdwDialogExt, AboutDialog};
|
||||
use gtk::{prelude::IsA, License};
|
||||
|
||||
pub struct About {
|
||||
gobject: AboutDialog,
|
||||
}
|
||||
|
||||
impl About {
|
||||
// Construct
|
||||
pub fn new() -> Self {
|
||||
// Collect debug info
|
||||
let debug = &[
|
||||
format!(
|
||||
"GTK {}.{}.{}",
|
||||
gtk::major_version(),
|
||||
gtk::minor_version(),
|
||||
gtk::micro_version()
|
||||
),
|
||||
format!("SQLite {}", sqlite::version()),
|
||||
// @TODO
|
||||
];
|
||||
|
||||
// Init gobject
|
||||
let gobject = AboutDialog::builder()
|
||||
.application_name(env!("CARGO_PKG_NAME"))
|
||||
.debug_info(debug.join("\n"))
|
||||
.developer_name(env!("CARGO_PKG_DESCRIPTION"))
|
||||
.issue_url(env!("CARGO_PKG_REPOSITORY"))
|
||||
.license_type(License::MitX11)
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.build();
|
||||
|
||||
// Return new struct
|
||||
Self { gobject }
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn present(&self, parent: Option<&impl IsA<gtk::Widget>>) {
|
||||
self.gobject.present(parent);
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ impl Window {
|
||||
// Construct
|
||||
pub fn new(
|
||||
// Actions
|
||||
action_about: SimpleAction,
|
||||
action_debug: SimpleAction,
|
||||
action_profile: SimpleAction,
|
||||
action_quit: SimpleAction,
|
||||
@ -47,17 +48,18 @@ impl Window {
|
||||
|
||||
let header = Header::new_arc(
|
||||
// Actions
|
||||
action_debug.clone(),
|
||||
action_profile.clone(),
|
||||
action_quit.clone(),
|
||||
action_page_new.clone(),
|
||||
action_page_close.clone(),
|
||||
action_page_close_all.clone(),
|
||||
action_page_home.clone(),
|
||||
action_page_history_back.clone(),
|
||||
action_page_history_forward.clone(),
|
||||
action_page_reload.clone(),
|
||||
action_page_pin.clone(),
|
||||
action_about,
|
||||
action_debug,
|
||||
action_profile,
|
||||
action_quit,
|
||||
action_page_new,
|
||||
action_page_close,
|
||||
action_page_close_all,
|
||||
action_page_home,
|
||||
action_page_history_back,
|
||||
action_page_history_forward,
|
||||
action_page_reload,
|
||||
action_page_pin,
|
||||
// Widgets
|
||||
tab.gobject(),
|
||||
);
|
||||
|
@ -16,6 +16,7 @@ impl Header {
|
||||
// Construct
|
||||
pub fn new_arc(
|
||||
// Actions
|
||||
action_about: SimpleAction,
|
||||
action_debug: SimpleAction,
|
||||
action_profile: SimpleAction,
|
||||
action_quit: SimpleAction,
|
||||
@ -32,6 +33,7 @@ impl Header {
|
||||
) -> Arc<Self> {
|
||||
// Init components
|
||||
let bar = Bar::new_arc(
|
||||
action_about,
|
||||
action_debug,
|
||||
action_profile,
|
||||
action_quit,
|
||||
|
@ -19,6 +19,7 @@ pub struct Bar {
|
||||
impl Bar {
|
||||
// Construct
|
||||
pub fn new_arc(
|
||||
action_about: SimpleAction,
|
||||
action_debug: SimpleAction,
|
||||
action_profile: SimpleAction,
|
||||
action_quit: SimpleAction,
|
||||
@ -36,6 +37,7 @@ impl Bar {
|
||||
let control = Control::new_arc();
|
||||
let tab = Tab::new_arc(action_page_new.clone(), view);
|
||||
let menu = Menu::new_arc(
|
||||
action_about,
|
||||
action_debug,
|
||||
action_profile,
|
||||
action_quit,
|
||||
|
@ -17,6 +17,7 @@ pub struct Menu {
|
||||
#[rustfmt::skip] // @TODO template builder?
|
||||
impl Menu {
|
||||
pub fn new_arc(
|
||||
action_about: SimpleAction,
|
||||
action_debug: SimpleAction,
|
||||
action_profile: SimpleAction,
|
||||
action_quit: SimpleAction,
|
||||
@ -64,6 +65,7 @@ impl Menu {
|
||||
let main_tool = gio::Menu::new();
|
||||
main_tool.append(Some("Debug"), Some(&detailed_action_name(action_debug)));
|
||||
main_tool.append(Some("Profile"), Some(&detailed_action_name(action_profile)));
|
||||
main_tool.append(Some("About"), Some(&detailed_action_name(action_about)));
|
||||
|
||||
main.append_submenu(Some("Tool"), &main_tool);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user