use canonical module subfolder tree

This commit is contained in:
yggverse 2024-09-21 00:31:37 +03:00
parent 80783d2ae4
commit 8969899a2f
24 changed files with 0 additions and 23 deletions

12
src/browser/header/mod.rs Normal file
View file

@ -0,0 +1,12 @@
mod subject;
mod tray;
use gtk::HeaderBar;
pub fn new() -> HeaderBar {
let header = HeaderBar::builder().build();
header.pack_start(&tray::new());
header.set_title_widget(Some(&subject::new()));
header
}

View file

@ -0,0 +1,27 @@
use gtk::prelude::WidgetExt;
use gtk::Label;
pub fn new() -> Label {
let description = Label::builder()
.css_classes(["subtitle"])
.single_line_mode(true)
.ellipsize(gtk::pango::EllipsizeMode::End)
.build();
update(
&description,
"", // @TODO
);
description
}
pub fn update(description: &Label, text: &str) {
description.set_text(text);
if text.is_empty() {
description.hide();
} else {
description.show();
}
}

View file

@ -0,0 +1,20 @@
mod description;
mod title;
use gtk::prelude::BoxExt;
use gtk::Box;
pub fn new() -> Box {
let subject = Box::builder()
// Tuneup
.orientation(gtk::Orientation::Vertical)
.valign(gtk::Align::Center)
.build();
// Compose childs
subject.append(&title::new());
subject.append(&description::new());
// Done
subject
}

View file

@ -0,0 +1,23 @@
use gtk::Label;
pub fn new() -> Label {
let title = Label::builder()
.css_classes(["title"])
.single_line_mode(true)
.ellipsize(gtk::pango::EllipsizeMode::End)
.build();
update(&title, "Welcome");
return title;
}
pub fn update(title: &Label, text: &str) {
let default_text = "Yoda"; // @TODO
if text.is_empty() {
title.set_text(default_text);
} else {
title.set_text(&format!("{} - {}", text, default_text));
}
}

View file

@ -0,0 +1,17 @@
use gtk::{gio, MenuButton};
pub fn new() -> MenuButton {
let menu = MenuButton::builder().tooltip_text("Menu").build();
let model = gio::Menu::new();
let model_tab = gio::Menu::new();
model_tab.append(Some("Append"), Some("win.tab_append"));
model.append_submenu(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
}

View file

@ -0,0 +1,18 @@
mod menu;
mod tab;
use gtk::prelude::BoxExt;
use gtk::Box;
pub fn new() -> Box {
let tray = Box::builder()
.orientation(gtk::Orientation::Horizontal)
.spacing(8)
.build();
// Compose childs
tray.append(&menu::new());
tray.append(&tab::new());
tray
}

View file

@ -0,0 +1,10 @@
use gtk::Button;
pub fn new() -> Button {
let tab = Button::builder()
.icon_name("tab-new-symbolic")
.tooltip_text("New tab")
.build();
return tab;
}

14
src/browser/main/mod.rs Normal file
View file

@ -0,0 +1,14 @@
mod tab;
use gtk::prelude::BoxExt;
use gtk::Box;
pub fn new() -> Box {
let main = Box::builder()
.orientation(gtk::Orientation::Vertical)
.build();
main.append(&tab::new());
main
}

View file

@ -0,0 +1,16 @@
mod pin;
mod title;
use gtk::prelude::BoxExt;
use gtk::Box;
pub fn new() -> Box {
let label = Box::builder()
.orientation(gtk::Orientation::Horizontal)
.build();
label.append(&pin::new(false));
label.append(&title::new());
label
}

View file

@ -0,0 +1,8 @@
use gtk::Image;
pub fn new(visible: bool) -> Image {
Image::builder()
.icon_name("view-pin-symbolic")
.visible(visible)
.build()
}

View file

@ -0,0 +1,10 @@
use gtk::Label;
pub fn new() -> Label {
Label::builder()
.label("New page")
.ellipsize(gtk::pango::EllipsizeMode::End)
.width_chars(16)
.single_line_mode(true)
.build()
}

View file

@ -0,0 +1,27 @@
mod label;
mod page;
use gtk::Notebook;
pub fn new() -> Notebook {
let tab = Notebook::builder().scrollable(true).build();
// Add test tab @TODO restore from session
append(&tab, true);
tab
}
pub fn append(tab: &Notebook, current: bool) -> u32 {
let page = page::new();
let page_number = tab.append_page(&page, Some(&label::new()));
tab.set_tab_reorderable(&page, true);
if current {
tab.set_current_page(Some(page_number));
}
page_number
}

View file

@ -0,0 +1,8 @@
use gtk::Box;
// use gtk::prelude::BoxExt; @TODO append
pub fn new() -> Box {
Box::builder()
.orientation(gtk::Orientation::Vertical)
.build()
}

View file

@ -0,0 +1,16 @@
mod content;
mod navigation;
use gtk::prelude::BoxExt;
use gtk::Box;
pub fn new() -> Box {
let page = Box::builder()
.orientation(gtk::Orientation::Vertical)
.build();
page.append(&navigation::new());
page.append(&content::new());
page
}

View file

@ -0,0 +1,9 @@
use gtk::Button;
pub fn new() -> Button {
Button::builder()
.icon_name("go-home-symbolic")
.tooltip_text("Base")
.sensitive(false)
.build()
}

View file

@ -0,0 +1,9 @@
use gtk::Button;
pub fn new() -> Button {
Button::builder()
.icon_name("starred-symbolic")
.tooltip_text("Toggle bookmark")
.sensitive(false)
.build()
}

View file

@ -0,0 +1,9 @@
use gtk::Button;
pub fn new() -> Button {
Button::builder()
.icon_name("go-previous-symbolic")
.tooltip_text("Back")
.sensitive(false)
.build()
}

View file

@ -0,0 +1,9 @@
use gtk::Button;
pub fn new() -> Button {
Button::builder()
.icon_name("go-next-symbolic")
.tooltip_text("Forward")
.sensitive(false)
.build()
}

View file

@ -0,0 +1,20 @@
mod back;
mod forward;
use gtk::prelude::BoxExt;
use gtk::Box;
pub fn new() -> Box {
let history = Box::builder()
.orientation(gtk::Orientation::Horizontal)
.css_classes([
"linked", // merge childs
])
.build();
// Compose childs
history.append(&back::new());
history.append(&forward::new());
history
}

View file

@ -0,0 +1,29 @@
mod base;
mod bookmark;
mod history;
mod reload;
mod request;
use gtk::prelude::BoxExt;
use gtk::Box;
pub fn new() -> Box {
let navigation = Box::builder()
// Tuneup
.orientation(gtk::Orientation::Horizontal)
.spacing(8)
.margin_top(8)
.margin_start(8)
.margin_end(8)
.margin_bottom(8)
.build();
// Compose childs
navigation.append(&base::new());
navigation.append(&history::new());
navigation.append(&reload::new());
navigation.append(&request::new());
navigation.append(&bookmark::new());
navigation
}

View file

@ -0,0 +1,9 @@
use gtk::Button;
pub fn new() -> Button {
return Button::builder()
.icon_name("view-refresh-symbolic")
.tooltip_text("Reload")
.sensitive(false)
.build();
}

View file

@ -0,0 +1,9 @@
use gtk::Entry;
pub fn new() -> Entry {
Entry::builder()
.placeholder_text("URL or search term...")
.hexpand(true)
.progress_pulse_step(0.1)
.build()
}

37
src/browser/mod.rs Normal file
View file

@ -0,0 +1,37 @@
mod header;
mod main;
use gtk::{
gio::ActionEntry,
prelude::{ActionMapExtManual, GtkWindowExt},
Application, ApplicationWindow,
};
pub fn new(app: &Application, width: i32, height: i32) -> ApplicationWindow {
// Init browser window
let browser = ApplicationWindow::builder()
.default_width(width)
.default_height(height)
.application(app)
.titlebar(&header::new())
.child(&main::new())
.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
}