diff --git a/src/app/browser.rs b/src/app/browser.rs index b1b6f359..6c3274d5 100644 --- a/src/app/browser.rs +++ b/src/app/browser.rs @@ -1,7 +1,15 @@ #[path = "browser/header.rs"] mod header; #[path = "browser/main.rs"] mod main; -use gtk::{Application, ApplicationWindow}; +use gtk::{ + Application, + ApplicationWindow, + gio::ActionEntry, + prelude::{ + ActionMapExtManual, + GtkWindowExt + } +}; pub fn new( app: &Application, @@ -9,12 +17,8 @@ pub fn new( height: i32 ) -> ApplicationWindow { - return ApplicationWindow::builder() - - // Relate - .application( - app - ) + // Init browser window + let browser = ApplicationWindow::builder() // Tuneup .default_width( @@ -25,6 +29,11 @@ pub fn new( height ) + // Relate + .application( + app + ) + // Init components .titlebar( &header::new() @@ -36,4 +45,39 @@ pub fn new( // Make .build(); + + // Init actions + let action_debug = ActionEntry::builder("debug") + + .activate( + |browser: &ApplicationWindow, _, _| + { + browser.emit_enable_debugging( + true + ); + } + ) + + .build(); + + let action_quit = ActionEntry::builder("quit") + + .activate( + |browser: &ApplicationWindow, _, _| + { + browser.close(); + } + ) + + .build(); + + browser.add_action_entries( + [ + action_debug, + action_quit + ] + ); + + // Done + browser } \ No newline at end of file diff --git a/src/app/browser/header.rs b/src/app/browser/header.rs index f51bf2c3..4c388a92 100644 --- a/src/app/browser/header.rs +++ b/src/app/browser/header.rs @@ -7,16 +7,15 @@ pub fn new() -> HeaderBar { let header = HeaderBar::builder().build(); - // Compose childs - header.pack_start( - &tray::new() - ); + header.pack_start( + &tray::new() + ); - header.set_title_widget( - Some( - &subject::new() - ) - ); + header.set_title_widget( + Some( + &subject::new() + ) + ); - return header; + header } \ No newline at end of file diff --git a/src/app/browser/header/subject.rs b/src/app/browser/header/subject.rs index 40a7aaab..e4b6ac3f 100644 --- a/src/app/browser/header/subject.rs +++ b/src/app/browser/header/subject.rs @@ -19,14 +19,15 @@ pub fn new() -> Box .build(); - // Compose childs - subject.append( - &title::new() - ); + // Compose childs + subject.append( + &title::new() + ); - subject.append( - &description::new() - ); + subject.append( + &description::new() + ); - return subject; + // Done + subject } \ No newline at end of file diff --git a/src/app/browser/header/tray.rs b/src/app/browser/header/tray.rs index f1942dd7..8a1e0faa 100644 --- a/src/app/browser/header/tray.rs +++ b/src/app/browser/header/tray.rs @@ -15,16 +15,17 @@ pub fn new() -> Box .spacing(8) + // Make .build(); - // Compose childs - tray.append( - &menu::new() - ); + // Compose childs + tray.append( + &menu::new() + ); - tray.append( - &tab::new() - ); + tray.append( + &tab::new() + ); - return tray; + tray } \ No newline at end of file diff --git a/src/app/browser/header/tray/menu.rs b/src/app/browser/header/tray/menu.rs index 29a763de..923abced 100644 --- a/src/app/browser/header/tray/menu.rs +++ b/src/app/browser/header/tray/menu.rs @@ -1,4 +1,7 @@ -use gtk::MenuButton; +use gtk::{ + gio, + MenuButton +}; pub fn new() -> MenuButton { @@ -10,5 +13,21 @@ pub fn new() -> MenuButton .build(); - return menu; + let model = gio::Menu::new(); + + model.append( + Some("Debug"), + Some("win.debug") + ); + + model.append( + Some("Quit"), + Some("win.quit") + ); + + menu.set_menu_model( + Some(&model) + ); + + menu } \ No newline at end of file