Browse Source

move debug menu item to the tool submenu, draft open profile dir action

master
yggverse 2 months ago
parent
commit
82219c01b9
  1. 22
      src/app.rs
  2. 17
      src/app/browser.rs
  3. 6
      src/app/browser/header.rs
  4. 6
      src/app/browser/header/tray.rs
  5. 11
      src/app/browser/header/tray/menu.rs

22
src/app.rs

@ -34,11 +34,12 @@ impl App { @@ -34,11 +34,12 @@ impl App {
// Init database model
let database = match Database::init(profile_database_connection) {
Ok(database) => Arc::new(database),
Err(e) => panic!("{e}"), // @TODO
Err(error) => panic!("{error}"), // @TODO
};
// Init actions
let action_debug = Action::new("win", true);
let action_tool_debug = Action::new("win", true);
let action_tool_profile_directory = Action::new("win", true);
let action_quit = Action::new("win", true);
let action_update = Action::new("win", true);
let action_tab_append = Action::new("win", true);
@ -56,7 +57,7 @@ impl App { @@ -56,7 +57,7 @@ impl App {
.build();
// Init accels
app.set_accels_for_action(&action_debug.detailed_name(), &["<Primary>i"]);
app.set_accels_for_action(&action_tool_debug.detailed_name(), &["<Primary>i"]);
app.set_accels_for_action(&action_update.detailed_name(), &["<Primary>u"]);
app.set_accels_for_action(&action_quit.detailed_name(), &["<Primary>Escape"]);
app.set_accels_for_action(&action_tab_append.detailed_name(), &["<Primary>t"]);
@ -82,7 +83,8 @@ impl App { @@ -82,7 +83,8 @@ impl App {
// Init components
let browser = Arc::new(Browser::new(
/*db.clone(),*/
action_debug.simple(),
action_tool_debug.simple(),
action_tool_profile_directory.simple(),
action_quit.simple(),
action_update.simple(),
action_tab_append.simple(),
@ -97,9 +99,9 @@ impl App { @@ -97,9 +99,9 @@ impl App {
// Init events
app.connect_activate({
// let database = database.clone();
let action_update = action_update.simple();
let browser = browser.clone();
let database = database.clone();
move |this| {
// @TODO restore previous session from DB
match database.records() {
@ -108,7 +110,7 @@ impl App { @@ -108,7 +110,7 @@ impl App {
println!("{:?}", record.id) // @TODO
}
}
Err(e) => panic!("{e}"),
Err(error) => panic!("{error}"), // @TODO
}
// Activate events
@ -123,14 +125,12 @@ impl App { @@ -123,14 +125,12 @@ impl App {
});
// Save current session to DB
// app.connect_window_added()
/*
app.connect_window_removed({
let database = database.clone();
move |_, _| {
// Cleanup previous record
match database.records() {
Ok(_) => {
Ok(records) => {
// Delegate clean action to children components
// self.browser.clean(app_id) @TODO
// ..
@ -138,7 +138,7 @@ impl App { @@ -138,7 +138,7 @@ impl App {
// Create new record
match database.add() {
Ok(_) => {
// let app_id = self.database.last_insert_id();
// let app_id = database.last_insert_id();
// Delegate save action to children components
// self.browser.save(app_id) @TODO
@ -150,7 +150,7 @@ impl App { @@ -150,7 +150,7 @@ impl App {
Err(error) => panic!("{error}"), // @TODO
}
}
});*/
});
// Return activated App struct
Self {

17
src/app/browser.rs

@ -29,7 +29,8 @@ impl Browser { @@ -29,7 +29,8 @@ impl Browser {
// Extras
// connection: Arc<sqlite::Connection>,
// Actions
action_debug: Arc<SimpleAction>,
action_tool_debug: Arc<SimpleAction>,
action_tool_profile_directory: Arc<SimpleAction>,
action_quit: Arc<SimpleAction>,
action_update: Arc<SimpleAction>,
action_tab_append: Arc<SimpleAction>,
@ -46,7 +47,8 @@ impl Browser { @@ -46,7 +47,8 @@ impl Browser {
// Init components
let header = Arc::new(Header::new(
action_debug.clone(),
action_tool_debug.clone(),
action_tool_profile_directory.clone(),
action_quit.clone(),
action_tab_append.clone(),
action_tab_close.clone(),
@ -75,7 +77,8 @@ impl Browser { @@ -75,7 +77,8 @@ impl Browser {
.build();
// Assign actions
widget.add_action(action_debug.as_ref());
widget.add_action(action_tool_debug.as_ref());
widget.add_action(action_tool_profile_directory.as_ref());
widget.add_action(action_quit.as_ref());
widget.add_action(action_update.as_ref());
widget.add_action(action_tab_append.as_ref());
@ -88,13 +91,19 @@ impl Browser { @@ -88,13 +91,19 @@ impl Browser {
widget.add_action(action_tab_pin.as_ref());
// Init events
action_debug.connect_activate({
action_tool_debug.connect_activate({
let widget = widget.clone();
move |_, _| {
widget.emit_enable_debugging(true);
}
});
action_tool_profile_directory.connect_activate({
move |_, _| {
// @TODO
}
});
action_quit.connect_activate({
let widget = widget.clone();
move |_, _| {

6
src/app/browser/header.rs

@ -16,7 +16,8 @@ pub struct Header { @@ -16,7 +16,8 @@ pub struct Header {
impl Header {
// Construct
pub fn new(
action_debug: Arc<SimpleAction>,
action_tool_debug: Arc<SimpleAction>,
action_tool_profile_directory: Arc<SimpleAction>,
action_quit: Arc<SimpleAction>,
action_tab_append: Arc<SimpleAction>,
action_tab_close: Arc<SimpleAction>,
@ -29,7 +30,8 @@ impl Header { @@ -29,7 +30,8 @@ impl Header {
) -> Self {
// Init components
let tray = Tray::new(
action_debug,
action_tool_debug,
action_tool_profile_directory,
action_quit,
action_tab_append,
action_tab_close,

6
src/app/browser/header/tray.rs

@ -18,7 +18,8 @@ pub struct Tray { @@ -18,7 +18,8 @@ pub struct Tray {
impl Tray {
pub fn new(
action_debug: Arc<SimpleAction>,
action_tool_debug: Arc<SimpleAction>,
action_tool_profile_directory: Arc<SimpleAction>,
action_quit: Arc<SimpleAction>,
action_tab_append: Arc<SimpleAction>,
action_tab_close: Arc<SimpleAction>,
@ -33,7 +34,8 @@ impl Tray { @@ -33,7 +34,8 @@ impl Tray {
let tab = Tab::new(action_tab_append.clone());
let menu = Menu::new(
action_debug,
action_tool_debug,
action_tool_profile_directory,
action_quit,
action_tab_append,
action_tab_close,

11
src/app/browser/header/tray/menu.rs

@ -13,7 +13,8 @@ pub struct Menu { @@ -13,7 +13,8 @@ pub struct Menu {
#[rustfmt::skip] // @TODO template builder?
impl Menu {
pub fn new(
action_debug: Arc<SimpleAction>,
action_tool_debug: Arc<SimpleAction>,
action_tool_profile_directory: Arc<SimpleAction>,
action_quit: Arc<SimpleAction>,
action_tab_append: Arc<SimpleAction>,
action_tab_close: Arc<SimpleAction>,
@ -55,7 +56,13 @@ impl Menu { @@ -55,7 +56,13 @@ impl Menu {
model_tab.append_submenu(Some("Close"), &model_tab_close);
model.append_submenu(Some("Tab"), &model_tab);
model.append(Some("Debug"), Some(&detailed_action_name(action_debug)));
let model_tool = gio::Menu::new();
model_tool.append(Some("Debug"), Some(&detailed_action_name(action_tool_debug)));
model_tool.append(Some("Profile directory"), Some(&detailed_action_name(action_tool_profile_directory)));
model.append_submenu(Some("Tool"), &model_tool);
model.append(Some("Quit"), Some(&detailed_action_name(action_quit)));
// Init widget

Loading…
Cancel
Save