mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +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,8 +1,19 @@
|
|||
use gtk::Box;
|
||||
// use gtk::prelude::BoxExt; @TODO append
|
||||
mod widget;
|
||||
|
||||
pub fn new() -> Box {
|
||||
Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.build()
|
||||
pub struct Content {
|
||||
widget: widget::Content,
|
||||
}
|
||||
|
||||
impl Content {
|
||||
// Construct
|
||||
pub fn new() -> Content {
|
||||
Self {
|
||||
widget: widget::Content::new(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Content {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
19
src/browser/main/tab/page/content/widget.rs
Normal file
19
src/browser/main/tab/page/content/widget.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
pub struct Content {
|
||||
gtk: gtk::Box,
|
||||
}
|
||||
|
||||
impl Content {
|
||||
// Construct new object
|
||||
pub fn new() -> Content {
|
||||
Self {
|
||||
gtk: gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Box {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,23 @@
|
|||
mod content;
|
||||
mod navigation;
|
||||
mod widget;
|
||||
|
||||
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
|
||||
pub struct Page {
|
||||
widget: widget::Page,
|
||||
}
|
||||
|
||||
impl Page {
|
||||
pub fn new() -> Page {
|
||||
Self {
|
||||
widget: widget::Page::new(
|
||||
navigation::Navigation::new().widget().gtk(),
|
||||
content::Content::new().widget().gtk(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Page {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,19 @@
|
|||
use gtk::Button;
|
||||
mod widget;
|
||||
|
||||
pub fn new() -> Button {
|
||||
Button::builder()
|
||||
.icon_name("go-home-symbolic")
|
||||
.tooltip_text("Base")
|
||||
.sensitive(false)
|
||||
.build()
|
||||
pub struct Base {
|
||||
widget: widget::Base,
|
||||
}
|
||||
|
||||
impl Base {
|
||||
// Construct
|
||||
pub fn new() -> Base {
|
||||
Self {
|
||||
widget: widget::Base::new(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Base {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
21
src/browser/main/tab/page/navigation/base/widget.rs
Normal file
21
src/browser/main/tab/page/navigation/base/widget.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
pub struct Base {
|
||||
gtk: gtk::Button,
|
||||
}
|
||||
|
||||
impl Base {
|
||||
// Construct
|
||||
pub fn new() -> Base {
|
||||
Self {
|
||||
gtk: gtk::Button::builder()
|
||||
.icon_name("go-home-symbolic")
|
||||
.tooltip_text("Base")
|
||||
.sensitive(false)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Button {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,19 @@
|
|||
use gtk::Button;
|
||||
mod widget;
|
||||
|
||||
pub fn new() -> Button {
|
||||
Button::builder()
|
||||
.icon_name("starred-symbolic")
|
||||
.tooltip_text("Toggle bookmark")
|
||||
.sensitive(false)
|
||||
.build()
|
||||
pub struct Bookmark {
|
||||
widget: widget::Bookmark,
|
||||
}
|
||||
|
||||
impl Bookmark {
|
||||
// Construct
|
||||
pub fn new() -> Bookmark {
|
||||
Self {
|
||||
widget: widget::Bookmark::new(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Bookmark {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
21
src/browser/main/tab/page/navigation/bookmark/widget.rs
Normal file
21
src/browser/main/tab/page/navigation/bookmark/widget.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
pub struct Bookmark {
|
||||
gtk: gtk::Button,
|
||||
}
|
||||
|
||||
impl Bookmark {
|
||||
// Construct
|
||||
pub fn new() -> Bookmark {
|
||||
Self {
|
||||
gtk: gtk::Button::builder()
|
||||
.icon_name("starred-symbolic")
|
||||
.tooltip_text("Toggle bookmark")
|
||||
.sensitive(false)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Button {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,19 @@
|
|||
use gtk::Button;
|
||||
mod widget;
|
||||
|
||||
pub fn new() -> Button {
|
||||
Button::builder()
|
||||
.icon_name("go-previous-symbolic")
|
||||
.tooltip_text("Back")
|
||||
.sensitive(false)
|
||||
.build()
|
||||
pub struct Back {
|
||||
widget: widget::Back,
|
||||
}
|
||||
|
||||
impl Back {
|
||||
// Construct
|
||||
pub fn new() -> Back {
|
||||
Self {
|
||||
widget: widget::Back::new(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Back {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
21
src/browser/main/tab/page/navigation/history/back/widget.rs
Normal file
21
src/browser/main/tab/page/navigation/history/back/widget.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
pub struct Back {
|
||||
gtk: gtk::Button,
|
||||
}
|
||||
|
||||
impl Back {
|
||||
// Construct
|
||||
pub fn new() -> Back {
|
||||
Self {
|
||||
gtk: gtk::Button::builder()
|
||||
.icon_name("go-previous-symbolic")
|
||||
.tooltip_text("Back")
|
||||
.sensitive(false)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Button {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,19 @@
|
|||
use gtk::Button;
|
||||
mod widget;
|
||||
|
||||
pub fn new() -> Button {
|
||||
Button::builder()
|
||||
.icon_name("go-next-symbolic")
|
||||
.tooltip_text("Forward")
|
||||
.sensitive(false)
|
||||
.build()
|
||||
pub struct Forward {
|
||||
widget: widget::Forward,
|
||||
}
|
||||
|
||||
impl Forward {
|
||||
// Construct
|
||||
pub fn new() -> Forward {
|
||||
Self {
|
||||
widget: widget::Forward::new(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Forward {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
pub struct Forward {
|
||||
gtk: gtk::Button,
|
||||
}
|
||||
|
||||
impl Forward {
|
||||
// Construct
|
||||
pub fn new() -> Forward {
|
||||
Self {
|
||||
gtk: gtk::Button::builder()
|
||||
.icon_name("go-next-symbolic")
|
||||
.tooltip_text("Forward")
|
||||
.sensitive(false)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Button {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,24 @@
|
|||
mod back;
|
||||
mod forward;
|
||||
mod widget;
|
||||
|
||||
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
|
||||
pub struct History {
|
||||
widget: widget::History,
|
||||
}
|
||||
|
||||
impl History {
|
||||
// Construct
|
||||
pub fn new() -> History {
|
||||
Self {
|
||||
widget: widget::History::new(
|
||||
back::Back::new().widget().gtk(),
|
||||
forward::Forward::new().widget().gtk(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::History {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
src/browser/main/tab/page/navigation/history/widget.rs
Normal file
27
src/browser/main/tab/page/navigation/history/widget.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
use gtk::prelude::BoxExt;
|
||||
|
||||
pub struct History {
|
||||
gtk: gtk::Box,
|
||||
}
|
||||
|
||||
impl History {
|
||||
// Construct
|
||||
pub fn new(back: >k::Button, forward: >k::Button) -> History {
|
||||
let gtk = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.css_classes([
|
||||
"linked", // merge childs
|
||||
])
|
||||
.build();
|
||||
|
||||
gtk.append(back);
|
||||
gtk.append(forward);
|
||||
|
||||
Self { gtk }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Box {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
|
|
@ -4,26 +4,27 @@ mod history;
|
|||
mod reload;
|
||||
mod request;
|
||||
|
||||
use gtk::prelude::BoxExt;
|
||||
use gtk::Box;
|
||||
mod widget;
|
||||
|
||||
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
|
||||
pub struct Navigation {
|
||||
widget: widget::Navigation,
|
||||
}
|
||||
|
||||
impl Navigation {
|
||||
pub fn new() -> Navigation {
|
||||
Self {
|
||||
widget: widget::Navigation::new(
|
||||
base::Base::new().widget().gtk(),
|
||||
history::History::new().widget().gtk(),
|
||||
reload::Reload::new().widget().gtk(),
|
||||
request::Request::new().widget().gtk(),
|
||||
bookmark::Bookmark::new().widget().gtk(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Navigation {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,19 @@
|
|||
use gtk::Button;
|
||||
mod widget;
|
||||
|
||||
pub fn new() -> Button {
|
||||
return Button::builder()
|
||||
.icon_name("view-refresh-symbolic")
|
||||
.tooltip_text("Reload")
|
||||
.sensitive(false)
|
||||
.build();
|
||||
pub struct Reload {
|
||||
widget: widget::Reload,
|
||||
}
|
||||
|
||||
impl Reload {
|
||||
// Construct
|
||||
pub fn new() -> Reload {
|
||||
Self {
|
||||
widget: widget::Reload::new(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Reload {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
21
src/browser/main/tab/page/navigation/reload/widget.rs
Normal file
21
src/browser/main/tab/page/navigation/reload/widget.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
pub struct Reload {
|
||||
gtk: gtk::Button,
|
||||
}
|
||||
|
||||
impl Reload {
|
||||
// Construct
|
||||
pub fn new() -> Reload {
|
||||
Self {
|
||||
gtk: gtk::Button::builder()
|
||||
.icon_name("view-refresh-symbolic")
|
||||
.tooltip_text("Reload")
|
||||
.sensitive(false)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Button {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,19 @@
|
|||
use gtk::Entry;
|
||||
mod widget;
|
||||
|
||||
pub fn new() -> Entry {
|
||||
Entry::builder()
|
||||
.placeholder_text("URL or search term...")
|
||||
.hexpand(true)
|
||||
.progress_pulse_step(0.1)
|
||||
.build()
|
||||
pub struct Request {
|
||||
widget: widget::Request,
|
||||
}
|
||||
|
||||
impl Request {
|
||||
// Construct
|
||||
pub fn new() -> Request {
|
||||
Self {
|
||||
widget: widget::Request::new(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Request {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
21
src/browser/main/tab/page/navigation/request/widget.rs
Normal file
21
src/browser/main/tab/page/navigation/request/widget.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
pub struct Request {
|
||||
gtk: gtk::Entry,
|
||||
}
|
||||
|
||||
impl Request {
|
||||
// Construct
|
||||
pub fn new() -> Request {
|
||||
Self {
|
||||
gtk: gtk::Entry::builder()
|
||||
.placeholder_text("URL or search term...")
|
||||
.hexpand(true)
|
||||
.progress_pulse_step(0.1)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Entry {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
38
src/browser/main/tab/page/navigation/widget.rs
Normal file
38
src/browser/main/tab/page/navigation/widget.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
use gtk::prelude::BoxExt;
|
||||
|
||||
pub struct Navigation {
|
||||
gtk: gtk::Box,
|
||||
}
|
||||
|
||||
impl Navigation {
|
||||
// Construct
|
||||
pub fn new(
|
||||
base: >k::Button,
|
||||
history: >k::Box,
|
||||
reload: >k::Button,
|
||||
request: >k::Entry,
|
||||
bookmark: >k::Button,
|
||||
) -> Navigation {
|
||||
let gtk = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.spacing(8)
|
||||
.margin_top(8)
|
||||
.margin_start(8)
|
||||
.margin_end(8)
|
||||
.margin_bottom(8)
|
||||
.build();
|
||||
|
||||
gtk.append(base);
|
||||
gtk.append(history);
|
||||
gtk.append(reload);
|
||||
gtk.append(request);
|
||||
gtk.append(bookmark);
|
||||
|
||||
Self { gtk }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Box {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
24
src/browser/main/tab/page/widget.rs
Normal file
24
src/browser/main/tab/page/widget.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
use gtk::prelude::BoxExt;
|
||||
|
||||
pub struct Page {
|
||||
gtk: gtk::Box,
|
||||
}
|
||||
|
||||
impl Page {
|
||||
// Construct
|
||||
pub fn new(navigation: >k::Box, content: >k::Box) -> Page {
|
||||
let gtk = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
gtk.append(navigation);
|
||||
gtk.append(content);
|
||||
|
||||
Self { gtk }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Box {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue