mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
move global actions to the app level
This commit is contained in:
parent
2a985a6fa1
commit
3959872201
2 changed files with 52 additions and 27 deletions
43
src/main.rs
43
src/main.rs
|
|
@ -3,12 +3,13 @@ mod browser;
|
|||
use browser::Browser;
|
||||
|
||||
use gtk::{
|
||||
gio::SimpleAction,
|
||||
glib::{user_config_dir, ExitCode},
|
||||
prelude::{ApplicationExt, ApplicationExtManual, GtkApplicationExt, GtkWindowExt},
|
||||
prelude::{ActionExt, ApplicationExt, ApplicationExtManual, GtkApplicationExt, GtkWindowExt},
|
||||
Application,
|
||||
};
|
||||
|
||||
use std::fs::create_dir_all;
|
||||
use std::{fs::create_dir_all, sync::Arc};
|
||||
|
||||
const APP_ID: &str = "io.github.yggverse.Yoda";
|
||||
|
||||
|
|
@ -16,7 +17,22 @@ fn main() -> ExitCode {
|
|||
// Init app
|
||||
let app = Application::builder().application_id(APP_ID).build();
|
||||
|
||||
// Init actions
|
||||
let action_debug = Arc::new(SimpleAction::new("debug", None));
|
||||
let action_quit = Arc::new(SimpleAction::new("quit", None));
|
||||
let action_update = Arc::new(SimpleAction::new("update", None));
|
||||
|
||||
let action_tab_append = Arc::new(SimpleAction::new("tab_append", None));
|
||||
let action_tab_close = Arc::new(SimpleAction::new("tab_close", None));
|
||||
let action_tab_close_all = Arc::new(SimpleAction::new("tab_close_all", None));
|
||||
let action_tab_page_reload = Arc::new(SimpleAction::new("tab_page_reload", None));
|
||||
let action_tab_pin = Arc::new(SimpleAction::new("tab_pin", None));
|
||||
|
||||
// Init accels
|
||||
app.set_accels_for_action("win.debug", &["<Primary>i"]);
|
||||
app.set_accels_for_action("win.update", &["<Primary>u"]);
|
||||
app.set_accels_for_action("win.quit", &["<Primary>Escape"]);
|
||||
|
||||
app.set_accels_for_action("win.tab_append", &["<Primary>t"]);
|
||||
app.set_accels_for_action("win.tab_pin", &["<Primary>p"]);
|
||||
app.set_accels_for_action("win.tab_close", &["<Primary>q"]);
|
||||
|
|
@ -25,9 +41,6 @@ fn main() -> ExitCode {
|
|||
app.set_accels_for_action("win.tab_page_history_forward", &["<Primary>Right"]);
|
||||
app.set_accels_for_action("win.tab_page_reload", &["<Primary>r"]);
|
||||
app.set_accels_for_action("win.tab_page_bookmark", &["<Primary>b"]);
|
||||
app.set_accels_for_action("win.debug", &["<Primary>i"]);
|
||||
app.set_accels_for_action("win.update", &["<Primary>u"]);
|
||||
app.set_accels_for_action("win.quit", &["<Primary>Escape"]);
|
||||
|
||||
// Create new window
|
||||
app.connect_activate({
|
||||
|
|
@ -52,9 +65,23 @@ fn main() -> ExitCode {
|
|||
};*/
|
||||
|
||||
move |this: &Application| {
|
||||
Browser::new(this, /*db.clone(),*/ 640, 480)
|
||||
.widget()
|
||||
.present();
|
||||
Browser::new(
|
||||
this,
|
||||
/*db.clone(),*/
|
||||
action_debug.clone(),
|
||||
action_quit.clone(),
|
||||
action_update.clone(),
|
||||
action_tab_append.clone(),
|
||||
action_tab_close.clone(),
|
||||
action_tab_close_all.clone(),
|
||||
action_tab_page_reload.clone(),
|
||||
action_tab_pin.clone(),
|
||||
)
|
||||
.widget()
|
||||
.present();
|
||||
|
||||
// Make initial update
|
||||
action_update.activate(None);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue