mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
init browser actions, add menu items
This commit is contained in:
parent
930cb663ba
commit
1c1907741d
5 changed files with 99 additions and 35 deletions
|
|
@ -1,7 +1,15 @@
|
||||||
#[path = "browser/header.rs"] mod header;
|
#[path = "browser/header.rs"] mod header;
|
||||||
#[path = "browser/main.rs"] mod main;
|
#[path = "browser/main.rs"] mod main;
|
||||||
|
|
||||||
use gtk::{Application, ApplicationWindow};
|
use gtk::{
|
||||||
|
Application,
|
||||||
|
ApplicationWindow,
|
||||||
|
gio::ActionEntry,
|
||||||
|
prelude::{
|
||||||
|
ActionMapExtManual,
|
||||||
|
GtkWindowExt
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
app: &Application,
|
app: &Application,
|
||||||
|
|
@ -9,12 +17,8 @@ pub fn new(
|
||||||
height: i32
|
height: i32
|
||||||
) -> ApplicationWindow
|
) -> ApplicationWindow
|
||||||
{
|
{
|
||||||
return ApplicationWindow::builder()
|
// Init browser window
|
||||||
|
let browser = ApplicationWindow::builder()
|
||||||
// Relate
|
|
||||||
.application(
|
|
||||||
app
|
|
||||||
)
|
|
||||||
|
|
||||||
// Tuneup
|
// Tuneup
|
||||||
.default_width(
|
.default_width(
|
||||||
|
|
@ -25,6 +29,11 @@ pub fn new(
|
||||||
height
|
height
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Relate
|
||||||
|
.application(
|
||||||
|
app
|
||||||
|
)
|
||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
.titlebar(
|
.titlebar(
|
||||||
&header::new()
|
&header::new()
|
||||||
|
|
@ -36,4 +45,39 @@ pub fn new(
|
||||||
|
|
||||||
// Make
|
// Make
|
||||||
.build();
|
.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
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,6 @@ pub fn new() -> HeaderBar
|
||||||
{
|
{
|
||||||
let header = HeaderBar::builder().build();
|
let header = HeaderBar::builder().build();
|
||||||
|
|
||||||
// Compose childs
|
|
||||||
header.pack_start(
|
header.pack_start(
|
||||||
&tray::new()
|
&tray::new()
|
||||||
);
|
);
|
||||||
|
|
@ -18,5 +17,5 @@ pub fn new() -> HeaderBar
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return header;
|
header
|
||||||
}
|
}
|
||||||
|
|
@ -28,5 +28,6 @@ pub fn new() -> Box
|
||||||
&description::new()
|
&description::new()
|
||||||
);
|
);
|
||||||
|
|
||||||
return subject;
|
// Done
|
||||||
|
subject
|
||||||
}
|
}
|
||||||
|
|
@ -15,6 +15,7 @@ pub fn new() -> Box
|
||||||
|
|
||||||
.spacing(8)
|
.spacing(8)
|
||||||
|
|
||||||
|
// Make
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Compose childs
|
// Compose childs
|
||||||
|
|
@ -26,5 +27,5 @@ pub fn new() -> Box
|
||||||
&tab::new()
|
&tab::new()
|
||||||
);
|
);
|
||||||
|
|
||||||
return tray;
|
tray
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
use gtk::MenuButton;
|
use gtk::{
|
||||||
|
gio,
|
||||||
|
MenuButton
|
||||||
|
};
|
||||||
|
|
||||||
pub fn new() -> MenuButton
|
pub fn new() -> MenuButton
|
||||||
{
|
{
|
||||||
|
|
@ -10,5 +13,21 @@ pub fn new() -> MenuButton
|
||||||
|
|
||||||
.build();
|
.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
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue