mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
apply rustfmt
This commit is contained in:
parent
e6e81e846a
commit
f8d938a8af
24 changed files with 253 additions and 611 deletions
|
|
@ -1,82 +1,38 @@
|
||||||
#[path = "browser/header.rs"] mod header;
|
#[path = "browser/header.rs"]
|
||||||
#[path = "browser/main.rs"] mod main;
|
mod header;
|
||||||
|
#[path = "browser/main.rs"]
|
||||||
|
mod main;
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
Application,
|
|
||||||
ApplicationWindow,
|
|
||||||
gio::ActionEntry,
|
gio::ActionEntry,
|
||||||
prelude::{
|
prelude::{ActionMapExtManual, GtkWindowExt},
|
||||||
ActionMapExtManual,
|
Application, ApplicationWindow,
|
||||||
GtkWindowExt
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(app: &Application, width: i32, height: i32) -> ApplicationWindow {
|
||||||
app: &Application,
|
|
||||||
width: i32,
|
|
||||||
height: i32
|
|
||||||
) -> ApplicationWindow
|
|
||||||
{
|
|
||||||
// Init browser window
|
// Init browser window
|
||||||
let browser = ApplicationWindow::builder()
|
let browser = ApplicationWindow::builder()
|
||||||
|
.default_width(width)
|
||||||
// Tuneup
|
.default_height(height)
|
||||||
.default_width(
|
.application(app)
|
||||||
width
|
.titlebar(&header::new())
|
||||||
)
|
.child(&main::new())
|
||||||
|
|
||||||
.default_height(
|
|
||||||
height
|
|
||||||
)
|
|
||||||
|
|
||||||
// Relate
|
|
||||||
.application(
|
|
||||||
app
|
|
||||||
)
|
|
||||||
|
|
||||||
// Init components
|
|
||||||
.titlebar(
|
|
||||||
&header::new()
|
|
||||||
)
|
|
||||||
|
|
||||||
.child(
|
|
||||||
&main::new()
|
|
||||||
)
|
|
||||||
|
|
||||||
// Make
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Init actions
|
// Init actions
|
||||||
let action_debug = ActionEntry::builder("debug")
|
let action_debug = ActionEntry::builder("debug")
|
||||||
|
.activate(|browser: &ApplicationWindow, _, _| {
|
||||||
.activate(
|
browser.emit_enable_debugging(true);
|
||||||
|browser: &ApplicationWindow, _, _|
|
})
|
||||||
{
|
|
||||||
browser.emit_enable_debugging(
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let action_quit = ActionEntry::builder("quit")
|
let action_quit = ActionEntry::builder("quit")
|
||||||
|
.activate(|browser: &ApplicationWindow, _, _| {
|
||||||
.activate(
|
|
||||||
|browser: &ApplicationWindow, _, _|
|
|
||||||
{
|
|
||||||
browser.close();
|
browser.close();
|
||||||
}
|
})
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
browser.add_action_entries(
|
browser.add_action_entries([action_debug, action_quit]);
|
||||||
[
|
|
||||||
action_debug,
|
|
||||||
action_quit
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
browser
|
browser
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,14 @@
|
||||||
#[path = "header/subject.rs"] mod subject;
|
#[path = "header/subject.rs"]
|
||||||
#[path = "header/tray.rs"] mod tray;
|
mod subject;
|
||||||
|
#[path = "header/tray.rs"]
|
||||||
|
mod tray;
|
||||||
|
|
||||||
use gtk::HeaderBar;
|
use gtk::HeaderBar;
|
||||||
|
|
||||||
pub fn new() -> HeaderBar
|
pub fn new() -> HeaderBar {
|
||||||
{
|
|
||||||
let header = HeaderBar::builder().build();
|
let header = HeaderBar::builder().build();
|
||||||
|
|
||||||
header.pack_start(
|
header.pack_start(&tray::new());
|
||||||
&tray::new()
|
header.set_title_widget(Some(&subject::new()));
|
||||||
);
|
|
||||||
|
|
||||||
header.set_title_widget(
|
|
||||||
Some(
|
|
||||||
&subject::new()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
header
|
header
|
||||||
}
|
}
|
||||||
|
|
@ -1,32 +1,21 @@
|
||||||
#[path = "subject/title.rs"] mod title;
|
#[path = "subject/description.rs"]
|
||||||
#[path = "subject/description.rs"] mod description;
|
mod description;
|
||||||
|
#[path = "subject/title.rs"]
|
||||||
|
mod title;
|
||||||
|
|
||||||
use gtk::Box;
|
|
||||||
use gtk::prelude::BoxExt;
|
use gtk::prelude::BoxExt;
|
||||||
|
use gtk::Box;
|
||||||
|
|
||||||
pub fn new() -> Box
|
pub fn new() -> Box {
|
||||||
{
|
|
||||||
let subject = Box::builder()
|
let subject = Box::builder()
|
||||||
|
|
||||||
// Tuneup
|
// Tuneup
|
||||||
.orientation(
|
.orientation(gtk::Orientation::Vertical)
|
||||||
gtk::Orientation::Vertical
|
.valign(gtk::Align::Center)
|
||||||
)
|
|
||||||
|
|
||||||
.valign(
|
|
||||||
gtk::Align::Center
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Compose childs
|
// Compose childs
|
||||||
subject.append(
|
subject.append(&title::new());
|
||||||
&title::new()
|
subject.append(&description::new());
|
||||||
);
|
|
||||||
|
|
||||||
subject.append(
|
|
||||||
&description::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
subject
|
subject
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,27 @@
|
||||||
use gtk::Label;
|
|
||||||
use gtk::prelude::WidgetExt;
|
use gtk::prelude::WidgetExt;
|
||||||
|
use gtk::Label;
|
||||||
|
|
||||||
pub fn new() -> Label
|
pub fn new() -> Label {
|
||||||
{
|
|
||||||
let description = Label::builder()
|
let description = Label::builder()
|
||||||
|
.css_classes(["subtitle"])
|
||||||
.css_classes(
|
.single_line_mode(true)
|
||||||
[
|
.ellipsize(gtk::pango::EllipsizeMode::End)
|
||||||
"subtitle"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
.single_line_mode(
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
.ellipsize(
|
|
||||||
gtk::pango::EllipsizeMode::End
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
update(
|
update(
|
||||||
&description,
|
&description,
|
||||||
"" // @TODO
|
"", // @TODO
|
||||||
);
|
);
|
||||||
|
|
||||||
return description;
|
description
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(
|
pub fn update(description: &Label, text: &str) {
|
||||||
description: &Label,
|
description.set_text(text);
|
||||||
text: &str
|
|
||||||
) {
|
|
||||||
description.set_text(
|
|
||||||
text
|
|
||||||
);
|
|
||||||
|
|
||||||
if text.is_empty()
|
if text.is_empty() {
|
||||||
{
|
|
||||||
description.hide();
|
description.hide();
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
description.show();
|
description.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,50 +1,23 @@
|
||||||
use gtk::Label;
|
use gtk::Label;
|
||||||
|
|
||||||
pub fn new() -> Label
|
pub fn new() -> Label {
|
||||||
{
|
|
||||||
let title = Label::builder()
|
let title = Label::builder()
|
||||||
|
.css_classes(["title"])
|
||||||
.css_classes(
|
.single_line_mode(true)
|
||||||
[
|
.ellipsize(gtk::pango::EllipsizeMode::End)
|
||||||
"title"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
.single_line_mode(
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
.ellipsize(
|
|
||||||
gtk::pango::EllipsizeMode::End
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
update(
|
update(&title, "Welcome");
|
||||||
&title,
|
|
||||||
"Welcome"
|
|
||||||
);
|
|
||||||
|
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(
|
pub fn update(title: &Label, text: &str) {
|
||||||
title: &Label,
|
|
||||||
text: &str
|
|
||||||
) {
|
|
||||||
let default_text = "Yoda"; // @TODO
|
let default_text = "Yoda"; // @TODO
|
||||||
|
|
||||||
if text.is_empty()
|
if text.is_empty() {
|
||||||
{
|
title.set_text(default_text);
|
||||||
title.set_text(
|
} else {
|
||||||
default_text
|
title.set_text(&format!("{} - {}", text, default_text));
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
title.set_text(
|
|
||||||
&format!("{} - {}", text, default_text)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,31 +1,20 @@
|
||||||
#[path = "tray/menu.rs"] mod menu;
|
#[path = "tray/menu.rs"]
|
||||||
#[path = "tray/tab.rs"] mod tab;
|
mod menu;
|
||||||
|
#[path = "tray/tab.rs"]
|
||||||
|
mod tab;
|
||||||
|
|
||||||
use gtk::Box;
|
|
||||||
use gtk::prelude::BoxExt;
|
use gtk::prelude::BoxExt;
|
||||||
|
use gtk::Box;
|
||||||
|
|
||||||
pub fn new() -> Box
|
pub fn new() -> Box {
|
||||||
{
|
|
||||||
let tray = Box::builder()
|
let tray = Box::builder()
|
||||||
|
.orientation(gtk::Orientation::Horizontal)
|
||||||
// Tuneup
|
|
||||||
.orientation(
|
|
||||||
gtk::Orientation::Horizontal
|
|
||||||
)
|
|
||||||
|
|
||||||
.spacing(8)
|
.spacing(8)
|
||||||
|
|
||||||
// Make
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Compose childs
|
// Compose childs
|
||||||
tray.append(
|
tray.append(&menu::new());
|
||||||
&menu::new()
|
tray.append(&tab::new());
|
||||||
);
|
|
||||||
|
|
||||||
tray.append(
|
|
||||||
&tab::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
tray
|
tray
|
||||||
}
|
}
|
||||||
|
|
@ -1,45 +1,17 @@
|
||||||
use gtk::{
|
use gtk::{gio, MenuButton};
|
||||||
gio,
|
|
||||||
MenuButton
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn new() -> MenuButton
|
pub fn new() -> MenuButton {
|
||||||
{
|
let menu = MenuButton::builder().tooltip_text("Menu").build();
|
||||||
let menu = MenuButton::builder()
|
|
||||||
|
|
||||||
.tooltip_text(
|
|
||||||
"Menu"
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let model = gio::Menu::new();
|
let model = gio::Menu::new();
|
||||||
|
|
||||||
let model_tab = gio::Menu::new();
|
let model_tab = gio::Menu::new();
|
||||||
|
|
||||||
model_tab.append(
|
model_tab.append(Some("Append"), Some("win.tab_append"));
|
||||||
Some("Append"),
|
model.append_submenu(Some("Tab"), &model_tab);
|
||||||
Some("win.tab_append")
|
model.append(Some("Debug"), Some("win.debug"));
|
||||||
);
|
model.append(Some("Quit"), Some("win.quit"));
|
||||||
|
|
||||||
model.append_submenu(
|
menu.set_menu_model(Some(&model));
|
||||||
Some("Tab"),
|
|
||||||
&model_tab
|
|
||||||
);
|
|
||||||
|
|
||||||
model.append(
|
|
||||||
Some("Debug"),
|
|
||||||
Some("win.debug")
|
|
||||||
);
|
|
||||||
|
|
||||||
model.append(
|
|
||||||
Some("Quit"),
|
|
||||||
Some("win.quit")
|
|
||||||
);
|
|
||||||
|
|
||||||
menu.set_menu_model(
|
|
||||||
Some(&model)
|
|
||||||
);
|
|
||||||
|
|
||||||
menu
|
menu
|
||||||
}
|
}
|
||||||
|
|
@ -1,17 +1,9 @@
|
||||||
use gtk::Button;
|
use gtk::Button;
|
||||||
|
|
||||||
pub fn new() -> Button
|
pub fn new() -> Button {
|
||||||
{
|
|
||||||
let tab = Button::builder()
|
let tab = Button::builder()
|
||||||
|
.icon_name("tab-new-symbolic")
|
||||||
.icon_name(
|
.tooltip_text("New tab")
|
||||||
"tab-new-symbolic"
|
|
||||||
)
|
|
||||||
|
|
||||||
.tooltip_text(
|
|
||||||
"New tab"
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return tab;
|
return tab;
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,15 @@
|
||||||
#[path = "main/tab.rs"] mod tab;
|
#[path = "main/tab.rs"]
|
||||||
|
mod tab;
|
||||||
|
|
||||||
use gtk::Box;
|
|
||||||
use gtk::prelude::BoxExt;
|
use gtk::prelude::BoxExt;
|
||||||
|
use gtk::Box;
|
||||||
|
|
||||||
pub fn new() -> Box
|
pub fn new() -> Box {
|
||||||
{
|
let main = Box::builder()
|
||||||
let main = Box::builder().orientation(
|
.orientation(gtk::Orientation::Vertical)
|
||||||
gtk::Orientation::Vertical
|
.build();
|
||||||
).build();
|
|
||||||
|
|
||||||
main.append(
|
main.append(&tab::new());
|
||||||
&tab::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
return main;
|
main
|
||||||
}
|
}
|
||||||
|
|
@ -1,54 +1,29 @@
|
||||||
#[path = "tab/label.rs"] mod label;
|
#[path = "tab/label.rs"]
|
||||||
#[path = "tab/page.rs"] mod page;
|
mod label;
|
||||||
|
#[path = "tab/page.rs"]
|
||||||
|
mod page;
|
||||||
|
|
||||||
use gtk::Notebook;
|
use gtk::Notebook;
|
||||||
|
|
||||||
pub fn new() -> Notebook
|
pub fn new() -> Notebook {
|
||||||
{
|
let tab = Notebook::builder().scrollable(true).build();
|
||||||
let tab = Notebook::builder()
|
|
||||||
|
|
||||||
.scrollable(
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Add test tab @TODO restore from session
|
// Add test tab @TODO restore from session
|
||||||
append(
|
append(&tab, true);
|
||||||
&tab,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
return tab;
|
tab
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn append(
|
pub fn append(tab: &Notebook, current: bool) -> u32 {
|
||||||
tab: &Notebook,
|
|
||||||
current: bool
|
|
||||||
) -> u32
|
|
||||||
{
|
|
||||||
let page = page::new();
|
let page = page::new();
|
||||||
|
|
||||||
let page_number = tab.append_page(
|
let page_number = tab.append_page(&page, Some(&label::new()));
|
||||||
&page,
|
|
||||||
Some(
|
|
||||||
&label::new()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
tab.set_tab_reorderable(
|
tab.set_tab_reorderable(&page, true);
|
||||||
&page,
|
|
||||||
true
|
if current {
|
||||||
);
|
tab.set_current_page(Some(page_number));
|
||||||
|
}
|
||||||
|
|
||||||
if current
|
|
||||||
{
|
|
||||||
tab.set_current_page(
|
|
||||||
Some(
|
|
||||||
page_number
|
page_number
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return page_number;
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,30 +1,18 @@
|
||||||
#[path = "label/pin.rs"] mod pin;
|
#[path = "label/pin.rs"]
|
||||||
#[path = "label/title.rs"] mod title;
|
mod pin;
|
||||||
|
#[path = "label/title.rs"]
|
||||||
|
mod title;
|
||||||
|
|
||||||
use gtk::Box;
|
|
||||||
use gtk::prelude::BoxExt;
|
use gtk::prelude::BoxExt;
|
||||||
|
use gtk::Box;
|
||||||
|
|
||||||
pub fn new() -> Box
|
pub fn new() -> Box {
|
||||||
{
|
|
||||||
let label = Box::builder()
|
let label = Box::builder()
|
||||||
|
.orientation(gtk::Orientation::Horizontal)
|
||||||
// Tuneup
|
|
||||||
.orientation(
|
|
||||||
gtk::Orientation::Horizontal
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Components
|
label.append(&pin::new(false));
|
||||||
label.append(
|
label.append(&title::new());
|
||||||
&pin::new(
|
|
||||||
false
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
label.append(
|
label
|
||||||
&title::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
return label;
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,8 @@
|
||||||
use gtk::Image;
|
use gtk::Image;
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(visible: bool) -> Image {
|
||||||
visible : bool
|
Image::builder()
|
||||||
) -> Image
|
.icon_name("view-pin-symbolic")
|
||||||
{
|
.visible(visible)
|
||||||
return Image::builder()
|
.build()
|
||||||
|
|
||||||
.icon_name(
|
|
||||||
"view-pin-symbolic"
|
|
||||||
)
|
|
||||||
|
|
||||||
.visible(
|
|
||||||
visible
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,24 +1,10 @@
|
||||||
use gtk::Label;
|
use gtk::Label;
|
||||||
|
|
||||||
pub fn new() -> Label
|
pub fn new() -> Label {
|
||||||
{
|
Label::builder()
|
||||||
return Label::builder()
|
.label("New page")
|
||||||
|
.ellipsize(gtk::pango::EllipsizeMode::End)
|
||||||
.label(
|
.width_chars(16)
|
||||||
"New page"
|
.single_line_mode(true)
|
||||||
)
|
.build()
|
||||||
|
|
||||||
.ellipsize(
|
|
||||||
gtk::pango::EllipsizeMode::End
|
|
||||||
)
|
|
||||||
|
|
||||||
.width_chars(
|
|
||||||
16
|
|
||||||
)
|
|
||||||
|
|
||||||
.single_line_mode(
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +1,18 @@
|
||||||
#[path = "page/navigation.rs"] mod navigation;
|
#[path = "page/content.rs"]
|
||||||
#[path = "page/content.rs"] mod content;
|
mod content;
|
||||||
|
#[path = "page/navigation.rs"]
|
||||||
|
mod navigation;
|
||||||
|
|
||||||
use gtk::Box;
|
|
||||||
use gtk::prelude::BoxExt;
|
use gtk::prelude::BoxExt;
|
||||||
|
use gtk::Box;
|
||||||
|
|
||||||
pub fn new() -> Box
|
pub fn new() -> Box {
|
||||||
{
|
let page = Box::builder()
|
||||||
let page = Box::builder().orientation(
|
.orientation(gtk::Orientation::Vertical)
|
||||||
gtk::Orientation::Vertical
|
.build();
|
||||||
).build();
|
|
||||||
|
|
||||||
page.append(
|
page.append(&navigation::new());
|
||||||
&navigation::new()
|
page.append(&content::new());
|
||||||
);
|
|
||||||
|
|
||||||
page.append(
|
page
|
||||||
&content::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
return page;
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
use gtk::Box;
|
use gtk::Box;
|
||||||
// use gtk::prelude::BoxExt; @TODO append
|
// use gtk::prelude::BoxExt; @TODO append
|
||||||
|
|
||||||
pub fn new() -> Box
|
pub fn new() -> Box {
|
||||||
{
|
Box::builder()
|
||||||
return Box::builder().orientation(
|
.orientation(gtk::Orientation::Vertical)
|
||||||
gtk::Orientation::Vertical
|
.build()
|
||||||
).build();
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,50 +1,34 @@
|
||||||
#[path = "navigation/base.rs"] mod base;
|
#[path = "navigation/base.rs"]
|
||||||
#[path = "navigation/history.rs"] mod history;
|
mod base;
|
||||||
#[path = "navigation/reload.rs"] mod reload;
|
#[path = "navigation/bookmark.rs"]
|
||||||
#[path = "navigation/request.rs"] mod request;
|
mod bookmark;
|
||||||
#[path = "navigation/bookmark.rs"] mod bookmark;
|
#[path = "navigation/history.rs"]
|
||||||
|
mod history;
|
||||||
|
#[path = "navigation/reload.rs"]
|
||||||
|
mod reload;
|
||||||
|
#[path = "navigation/request.rs"]
|
||||||
|
mod request;
|
||||||
|
|
||||||
use gtk::Box;
|
|
||||||
use gtk::prelude::BoxExt;
|
use gtk::prelude::BoxExt;
|
||||||
|
use gtk::Box;
|
||||||
|
|
||||||
pub fn new() -> Box
|
pub fn new() -> Box {
|
||||||
{
|
|
||||||
let navigation = Box::builder()
|
let navigation = Box::builder()
|
||||||
|
|
||||||
// Tuneup
|
// Tuneup
|
||||||
.orientation(
|
.orientation(gtk::Orientation::Horizontal)
|
||||||
gtk::Orientation::Horizontal
|
|
||||||
)
|
|
||||||
|
|
||||||
.spacing(8)
|
.spacing(8)
|
||||||
|
|
||||||
.margin_top(8)
|
.margin_top(8)
|
||||||
.margin_start(8)
|
.margin_start(8)
|
||||||
.margin_end(8)
|
.margin_end(8)
|
||||||
.margin_bottom(8)
|
.margin_bottom(8)
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Compose childs
|
// Compose childs
|
||||||
navigation.append(
|
navigation.append(&base::new());
|
||||||
&base::new()
|
navigation.append(&history::new());
|
||||||
);
|
navigation.append(&reload::new());
|
||||||
|
navigation.append(&request::new());
|
||||||
|
navigation.append(&bookmark::new());
|
||||||
|
|
||||||
navigation.append(
|
navigation
|
||||||
&history::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
navigation.append(
|
|
||||||
&reload::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
navigation.append(
|
|
||||||
&request::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
navigation.append(
|
|
||||||
&bookmark::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
return navigation;
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +1,9 @@
|
||||||
use gtk::Button;
|
use gtk::Button;
|
||||||
|
|
||||||
pub fn new() -> Button
|
pub fn new() -> Button {
|
||||||
{
|
Button::builder()
|
||||||
let button = Button::builder()
|
.icon_name("go-home-symbolic")
|
||||||
|
.tooltip_text("Base")
|
||||||
.icon_name(
|
.sensitive(false)
|
||||||
"go-home-symbolic"
|
.build()
|
||||||
)
|
|
||||||
|
|
||||||
.tooltip_text(
|
|
||||||
"Base"
|
|
||||||
)
|
|
||||||
|
|
||||||
.sensitive(
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
|
||||||
|
|
||||||
return button;
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +1,9 @@
|
||||||
use gtk::Button;
|
use gtk::Button;
|
||||||
|
|
||||||
pub fn new() -> Button
|
pub fn new() -> Button {
|
||||||
{
|
Button::builder()
|
||||||
let button = Button::builder()
|
.icon_name("starred-symbolic")
|
||||||
|
.tooltip_text("Toggle bookmark")
|
||||||
.icon_name(
|
.sensitive(false)
|
||||||
"starred-symbolic"
|
.build()
|
||||||
)
|
|
||||||
|
|
||||||
.tooltip_text(
|
|
||||||
"Toggle bookmark"
|
|
||||||
)
|
|
||||||
|
|
||||||
.sensitive(
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
|
||||||
|
|
||||||
return button;
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,34 +1,22 @@
|
||||||
#[path = "history/back.rs"] mod back;
|
#[path = "history/back.rs"]
|
||||||
#[path = "history/forward.rs"] mod forward;
|
mod back;
|
||||||
|
#[path = "history/forward.rs"]
|
||||||
|
mod forward;
|
||||||
|
|
||||||
use gtk::Box;
|
|
||||||
use gtk::prelude::BoxExt;
|
use gtk::prelude::BoxExt;
|
||||||
|
use gtk::Box;
|
||||||
|
|
||||||
pub fn new() -> Box
|
pub fn new() -> Box {
|
||||||
{
|
|
||||||
let history = Box::builder()
|
let history = Box::builder()
|
||||||
|
.orientation(gtk::Orientation::Horizontal)
|
||||||
// Tuneup
|
.css_classes([
|
||||||
.orientation(
|
"linked", // merge childs
|
||||||
gtk::Orientation::Horizontal
|
])
|
||||||
)
|
|
||||||
|
|
||||||
.css_classes(
|
|
||||||
[
|
|
||||||
"linked" // merge childs
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Compose childs
|
// Compose childs
|
||||||
history.append(
|
history.append(&back::new());
|
||||||
&back::new()
|
history.append(&forward::new());
|
||||||
);
|
|
||||||
|
|
||||||
history.append(
|
history
|
||||||
&forward::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
return history;
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +1,9 @@
|
||||||
use gtk::Button;
|
use gtk::Button;
|
||||||
|
|
||||||
pub fn new() -> Button
|
pub fn new() -> Button {
|
||||||
{
|
Button::builder()
|
||||||
let button = Button::builder()
|
.icon_name("go-previous-symbolic")
|
||||||
|
.tooltip_text("Back")
|
||||||
.icon_name(
|
.sensitive(false)
|
||||||
"go-previous-symbolic"
|
.build()
|
||||||
)
|
|
||||||
|
|
||||||
.tooltip_text(
|
|
||||||
"Back"
|
|
||||||
)
|
|
||||||
|
|
||||||
.sensitive(
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
|
||||||
|
|
||||||
return button;
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +1,9 @@
|
||||||
use gtk::Button;
|
use gtk::Button;
|
||||||
|
|
||||||
pub fn new() -> Button
|
pub fn new() -> Button {
|
||||||
{
|
Button::builder()
|
||||||
let button = Button::builder()
|
.icon_name("go-next-symbolic")
|
||||||
|
.tooltip_text("Forward")
|
||||||
.icon_name(
|
.sensitive(false)
|
||||||
"go-next-symbolic"
|
.build()
|
||||||
)
|
|
||||||
|
|
||||||
.tooltip_text(
|
|
||||||
"Forward"
|
|
||||||
)
|
|
||||||
|
|
||||||
.sensitive(
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
|
||||||
|
|
||||||
return button;
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +1,9 @@
|
||||||
use gtk::Button;
|
use gtk::Button;
|
||||||
|
|
||||||
pub fn new() -> Button
|
pub fn new() -> Button {
|
||||||
{
|
return Button::builder()
|
||||||
let button = Button::builder()
|
.icon_name("view-refresh-symbolic")
|
||||||
|
.tooltip_text("Reload")
|
||||||
.icon_name(
|
.sensitive(false)
|
||||||
"view-refresh-symbolic"
|
|
||||||
)
|
|
||||||
|
|
||||||
.tooltip_text(
|
|
||||||
"Reload"
|
|
||||||
)
|
|
||||||
|
|
||||||
.sensitive(
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return button;
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +1,9 @@
|
||||||
use gtk::Entry;
|
use gtk::Entry;
|
||||||
|
|
||||||
pub fn new() -> Entry
|
pub fn new() -> Entry {
|
||||||
{
|
Entry::builder()
|
||||||
let entry = Entry::builder()
|
.placeholder_text("URL or search term...")
|
||||||
|
.hexpand(true)
|
||||||
.placeholder_text(
|
.progress_pulse_step(0.1)
|
||||||
"URL or search term..."
|
.build()
|
||||||
)
|
|
||||||
|
|
||||||
.hexpand(
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
.progress_pulse_step(
|
|
||||||
0.1
|
|
||||||
)
|
|
||||||
|
|
||||||
.build();
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
}
|
}
|
||||||
56
src/main.rs
56
src/main.rs
|
|
@ -1,52 +1,26 @@
|
||||||
#[path = "app/browser.rs"] mod browser;
|
#[path = "app/browser.rs"]
|
||||||
|
mod browser;
|
||||||
|
|
||||||
use gtk::prelude::{
|
use gtk::prelude::{ApplicationExt, ApplicationExtManual, GtkApplicationExt, GtkWindowExt};
|
||||||
ApplicationExt,
|
|
||||||
ApplicationExtManual,
|
|
||||||
GtkApplicationExt,
|
|
||||||
GtkWindowExt
|
|
||||||
};
|
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{glib, Application};
|
||||||
Application,
|
|
||||||
glib
|
|
||||||
};
|
|
||||||
|
|
||||||
fn main() -> glib::ExitCode
|
fn main() -> glib::ExitCode {
|
||||||
{
|
|
||||||
// Init app
|
// Init app
|
||||||
let app = Application::builder().application_id(
|
let app = Application::builder()
|
||||||
"io.github.yggverse.Yoda.app"
|
.application_id("io.github.yggverse.Yoda.app")
|
||||||
).build();
|
.build();
|
||||||
|
|
||||||
// Init accels
|
// Init accels
|
||||||
app.set_accels_for_action(
|
app.set_accels_for_action("win.tab_append", &["<Ctrl>t"]);
|
||||||
"win.tab_append", &["<Ctrl>t"]
|
app.set_accels_for_action("win.tab_close", &["<Ctrl>q"]);
|
||||||
);
|
app.set_accels_for_action("win.debug", &["<Ctrl>i"]);
|
||||||
|
app.set_accels_for_action("win.quit", &["<Ctrl>Escape"]);
|
||||||
app.set_accels_for_action(
|
|
||||||
"win.tab_close", &["<Ctrl>q"]
|
|
||||||
);
|
|
||||||
|
|
||||||
app.set_accels_for_action(
|
|
||||||
"win.debug", &["<Ctrl>i"]
|
|
||||||
);
|
|
||||||
|
|
||||||
app.set_accels_for_action(
|
|
||||||
"win.quit", &["<Ctrl>Escape"]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Create new window
|
// Create new window
|
||||||
app.connect_activate(
|
app.connect_activate(|app| {
|
||||||
|app|
|
browser::new(app, 640, 480).present();
|
||||||
{
|
});
|
||||||
browser::new(
|
|
||||||
app,
|
|
||||||
640,
|
|
||||||
480
|
|
||||||
).present();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Start
|
// Start
|
||||||
app.run()
|
app.run()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue