mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
use canonical module subfolder tree
This commit is contained in:
parent
80783d2ae4
commit
8969899a2f
24 changed files with 0 additions and 23 deletions
12
src/browser/header/mod.rs
Normal file
12
src/browser/header/mod.rs
Normal 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
|
||||
}
|
||||
27
src/browser/header/subject/description/mod.rs
Normal file
27
src/browser/header/subject/description/mod.rs
Normal 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();
|
||||
}
|
||||
}
|
||||
20
src/browser/header/subject/mod.rs
Normal file
20
src/browser/header/subject/mod.rs
Normal 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
|
||||
}
|
||||
23
src/browser/header/subject/title/mod.rs
Normal file
23
src/browser/header/subject/title/mod.rs
Normal 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));
|
||||
}
|
||||
}
|
||||
17
src/browser/header/tray/menu/mod.rs
Normal file
17
src/browser/header/tray/menu/mod.rs
Normal 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
|
||||
}
|
||||
18
src/browser/header/tray/mod.rs
Normal file
18
src/browser/header/tray/mod.rs
Normal 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
|
||||
}
|
||||
10
src/browser/header/tray/tab/mod.rs
Normal file
10
src/browser/header/tray/tab/mod.rs
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue