mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
init header components
This commit is contained in:
parent
0759f14843
commit
0c8684491b
7 changed files with 210 additions and 1 deletions
|
|
@ -1,6 +1,22 @@
|
||||||
|
#[path = "header/subject.rs"] mod subject;
|
||||||
|
#[path = "header/tray.rs"] mod tray;
|
||||||
|
|
||||||
use gtk::HeaderBar;
|
use gtk::HeaderBar;
|
||||||
|
|
||||||
pub fn new() -> HeaderBar
|
pub fn new() -> HeaderBar
|
||||||
{
|
{
|
||||||
return HeaderBar::builder().build();
|
let header = HeaderBar::builder().build();
|
||||||
|
|
||||||
|
// Compose childs
|
||||||
|
header.pack_start(
|
||||||
|
&tray::new()
|
||||||
|
);
|
||||||
|
|
||||||
|
header.set_title_widget(
|
||||||
|
Some(
|
||||||
|
&subject::new()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return header;
|
||||||
}
|
}
|
||||||
32
src/app/browser/header/subject.rs
Normal file
32
src/app/browser/header/subject.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#[path = "subject/title.rs"] mod title;
|
||||||
|
#[path = "subject/description.rs"] mod description;
|
||||||
|
|
||||||
|
use gtk::Box;
|
||||||
|
use gtk::prelude::BoxExt;
|
||||||
|
|
||||||
|
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()
|
||||||
|
);
|
||||||
|
|
||||||
|
return subject;
|
||||||
|
}
|
||||||
49
src/app/browser/header/subject/description.rs
Normal file
49
src/app/browser/header/subject/description.rs
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
use gtk::Label;
|
||||||
|
use gtk::prelude::WidgetExt;
|
||||||
|
|
||||||
|
pub fn new() -> Label
|
||||||
|
{
|
||||||
|
let description = Label::builder()
|
||||||
|
|
||||||
|
.css_classes(
|
||||||
|
[
|
||||||
|
"subtitle"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
.single_line_mode(
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
|
.ellipsize(
|
||||||
|
gtk::pango::EllipsizeMode::End
|
||||||
|
)
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
|
update(
|
||||||
|
&description,
|
||||||
|
"" // @TODO
|
||||||
|
);
|
||||||
|
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update(
|
||||||
|
description: &Label,
|
||||||
|
text: &str
|
||||||
|
) {
|
||||||
|
description.set_text(
|
||||||
|
text
|
||||||
|
);
|
||||||
|
|
||||||
|
if text.is_empty()
|
||||||
|
{
|
||||||
|
description.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
description.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
50
src/app/browser/header/subject/title.rs
Normal file
50
src/app/browser/header/subject/title.rs
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
30
src/app/browser/header/tray.rs
Normal file
30
src/app/browser/header/tray.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#[path = "tray/menu.rs"] mod menu;
|
||||||
|
#[path = "tray/tab.rs"] mod tab;
|
||||||
|
|
||||||
|
use gtk::Box;
|
||||||
|
use gtk::prelude::BoxExt;
|
||||||
|
|
||||||
|
pub fn new() -> Box
|
||||||
|
{
|
||||||
|
let tray = Box::builder()
|
||||||
|
|
||||||
|
// Tuneup
|
||||||
|
.orientation(
|
||||||
|
gtk::Orientation::Horizontal
|
||||||
|
)
|
||||||
|
|
||||||
|
.spacing(8)
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Compose childs
|
||||||
|
tray.append(
|
||||||
|
&menu::new()
|
||||||
|
);
|
||||||
|
|
||||||
|
tray.append(
|
||||||
|
&tab::new()
|
||||||
|
);
|
||||||
|
|
||||||
|
return tray;
|
||||||
|
}
|
||||||
14
src/app/browser/header/tray/menu.rs
Normal file
14
src/app/browser/header/tray/menu.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
use gtk::MenuButton;
|
||||||
|
|
||||||
|
pub fn new() -> MenuButton
|
||||||
|
{
|
||||||
|
let menu = MenuButton::builder()
|
||||||
|
|
||||||
|
.tooltip_text(
|
||||||
|
"Menu"
|
||||||
|
)
|
||||||
|
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
18
src/app/browser/header/tray/tab.rs
Normal file
18
src/app/browser/header/tray/tab.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
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