mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
complete widget submodule refactory
This commit is contained in:
parent
e45b7f0a4a
commit
1e42a75f2e
29 changed files with 585 additions and 145 deletions
|
|
@ -1,16 +1,24 @@
|
|||
mod pin;
|
||||
mod title;
|
||||
mod widget;
|
||||
|
||||
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
|
||||
pub struct Label {
|
||||
widget: widget::Label,
|
||||
}
|
||||
|
||||
impl Label {
|
||||
// Construct
|
||||
pub fn new() -> Label {
|
||||
Self {
|
||||
widget: widget::Label::new(
|
||||
pin::Pin::new().widget().gtk(),
|
||||
title::Title::new().widget().gtk(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Label {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,19 @@
|
|||
use gtk::Image;
|
||||
mod widget;
|
||||
|
||||
pub fn new(visible: bool) -> Image {
|
||||
Image::builder()
|
||||
.icon_name("view-pin-symbolic")
|
||||
.visible(visible)
|
||||
.build()
|
||||
pub struct Pin {
|
||||
widget: widget::Pin,
|
||||
}
|
||||
|
||||
impl Pin {
|
||||
// Construct
|
||||
pub fn new() -> Pin {
|
||||
Self {
|
||||
widget: widget::Pin::new(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Pin {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
src/browser/main/tab/label/pin/widget.rs
Normal file
20
src/browser/main/tab/label/pin/widget.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
pub struct Pin {
|
||||
gtk: gtk::Image,
|
||||
}
|
||||
|
||||
impl Pin {
|
||||
// Construct
|
||||
pub fn new() -> Pin {
|
||||
let gtk = gtk::Image::builder()
|
||||
.icon_name("view-pin-symbolic")
|
||||
.visible(false) //@TODO
|
||||
.build();
|
||||
|
||||
Self { gtk }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Image {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,19 @@
|
|||
use gtk::Label;
|
||||
mod widget;
|
||||
|
||||
pub fn new() -> Label {
|
||||
Label::builder()
|
||||
.label("New page")
|
||||
.ellipsize(gtk::pango::EllipsizeMode::End)
|
||||
.width_chars(16)
|
||||
.single_line_mode(true)
|
||||
.build()
|
||||
pub struct Title {
|
||||
widget: widget::Title,
|
||||
}
|
||||
|
||||
impl Title {
|
||||
// Construct
|
||||
pub fn new() -> Title {
|
||||
Self {
|
||||
widget: widget::Title::new(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Title {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
22
src/browser/main/tab/label/title/widget.rs
Normal file
22
src/browser/main/tab/label/title/widget.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
pub struct Title {
|
||||
gtk: gtk::Label,
|
||||
}
|
||||
|
||||
impl Title {
|
||||
// Construct
|
||||
pub fn new() -> Title {
|
||||
let gtk = gtk::Label::builder()
|
||||
.label("New page")
|
||||
.ellipsize(gtk::pango::EllipsizeMode::End)
|
||||
.width_chars(16)
|
||||
.single_line_mode(true)
|
||||
.build();
|
||||
|
||||
Self { gtk }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Label {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
24
src/browser/main/tab/label/widget.rs
Normal file
24
src/browser/main/tab/label/widget.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
use gtk::prelude::BoxExt;
|
||||
|
||||
pub struct Label {
|
||||
gtk: gtk::Box,
|
||||
}
|
||||
|
||||
impl Label {
|
||||
// Construct new object
|
||||
pub fn new(pin: >k::Image, title: >k::Label) -> Label {
|
||||
let gtk = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.build();
|
||||
|
||||
gtk.append(pin);
|
||||
gtk.append(title);
|
||||
|
||||
Self { gtk }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Box {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue