mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
reorganize widget modules
This commit is contained in:
parent
b9b226cc54
commit
4903968309
47 changed files with 352 additions and 786 deletions
|
|
@ -1,27 +1,28 @@
|
|||
mod tab;
|
||||
mod widget;
|
||||
|
||||
use std::sync::Arc;
|
||||
use gtk::{Box, Orientation};
|
||||
use tab::Tab;
|
||||
|
||||
use gtk::prelude::BoxExt;
|
||||
|
||||
pub struct Main {
|
||||
// Components
|
||||
tab: Arc<tab::Tab>,
|
||||
|
||||
// Extras
|
||||
widget: widget::Main,
|
||||
tab: Tab,
|
||||
widget: Box,
|
||||
}
|
||||
|
||||
impl Main {
|
||||
// Construct
|
||||
pub fn new() -> Arc<Main> {
|
||||
pub fn new() -> Main {
|
||||
// Init components
|
||||
let tab = tab::Tab::new();
|
||||
let tab = Tab::new();
|
||||
|
||||
// Extras
|
||||
let widget = widget::Main::new(tab.widget().notebook());
|
||||
let widget = Box::builder().orientation(Orientation::Vertical).build();
|
||||
|
||||
widget.append(tab.widget());
|
||||
|
||||
// Init struct
|
||||
Arc::new(Self { tab, widget })
|
||||
Self { tab, widget }
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
|
@ -42,7 +43,7 @@ impl Main {
|
|||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Main {
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,46 +1,47 @@
|
|||
mod pin;
|
||||
mod title;
|
||||
mod widget;
|
||||
|
||||
use std::sync::Arc;
|
||||
use gtk::prelude::{BoxExt, WidgetExt};
|
||||
use gtk::{Box, Orientation};
|
||||
use pin::Pin;
|
||||
use title::Title;
|
||||
|
||||
pub struct Label {
|
||||
// Components
|
||||
pin: Arc<pin::Pin>,
|
||||
title: Arc<title::Title>,
|
||||
pin: Pin,
|
||||
title: Title,
|
||||
|
||||
// Extras
|
||||
is_pinned: bool,
|
||||
widget: widget::Label,
|
||||
// GTK
|
||||
widget: Box,
|
||||
}
|
||||
|
||||
impl Label {
|
||||
// Construct
|
||||
pub fn new(is_pinned: bool) -> Arc<Label> {
|
||||
pub fn new(is_pinned: bool) -> Label {
|
||||
// Components
|
||||
let pin = pin::Pin::new(is_pinned);
|
||||
let title = title::Title::new();
|
||||
let pin = Pin::new(is_pinned);
|
||||
let title = Title::new();
|
||||
|
||||
// Extras
|
||||
let widget = widget::Label::new(pin.widget().image(), title.widget().label());
|
||||
// GTK
|
||||
let widget = Box::builder().orientation(Orientation::Horizontal).build();
|
||||
|
||||
widget.append(pin.widget());
|
||||
widget.append(title.widget());
|
||||
|
||||
// Result
|
||||
Arc::new(Self {
|
||||
pin,
|
||||
title,
|
||||
is_pinned,
|
||||
widget,
|
||||
})
|
||||
Self { pin, title, widget }
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn pin(&mut self) {
|
||||
self.is_pinned = !self.is_pinned; // toggle
|
||||
// @TODO
|
||||
pub fn pin(&self) -> bool {
|
||||
self.pin
|
||||
.widget()
|
||||
.set_visible(!self.pin.widget().is_visible());
|
||||
self.pin.widget().is_visible()
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Label {
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +1,22 @@
|
|||
mod widget;
|
||||
|
||||
use gtk::prelude::WidgetExt;
|
||||
use std::sync::Arc;
|
||||
use gtk::Image;
|
||||
|
||||
pub struct Pin {
|
||||
// Extras
|
||||
is_pinned: bool,
|
||||
widget: widget::Pin,
|
||||
widget: Image,
|
||||
}
|
||||
|
||||
impl Pin {
|
||||
// Construct
|
||||
pub fn new(is_pinned: bool) -> Arc<Pin> {
|
||||
Arc::new(Self {
|
||||
is_pinned,
|
||||
widget: widget::Pin::new(is_pinned),
|
||||
})
|
||||
}
|
||||
pub fn new(visible: bool) -> Pin {
|
||||
let widget = Image::builder()
|
||||
.icon_name("view-pin-symbolic")
|
||||
.visible(visible)
|
||||
.build();
|
||||
|
||||
// Actions
|
||||
pub fn toggle(&mut self) -> bool {
|
||||
// Toggle state
|
||||
self.is_pinned = !self.widget().image().is_visible();
|
||||
|
||||
// Update widget
|
||||
self.widget().image().set_visible(self.is_pinned); // @TODO delegate?
|
||||
|
||||
// Return state
|
||||
self.is_pinned
|
||||
Self { widget }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Pin {
|
||||
pub fn widget(&self) -> &Image {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
pub struct Pin {
|
||||
image: gtk::Image,
|
||||
}
|
||||
|
||||
impl Pin {
|
||||
// Construct
|
||||
pub fn new(is_pinned: bool) -> Pin {
|
||||
let image = gtk::Image::builder()
|
||||
.icon_name("view-pin-symbolic")
|
||||
.visible(is_pinned)
|
||||
.build();
|
||||
|
||||
Self { image }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn image(&self) -> >k::Image {
|
||||
&self.image
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,24 @@
|
|||
mod widget;
|
||||
|
||||
use std::sync::Arc;
|
||||
use gtk::{pango::EllipsizeMode, Label};
|
||||
|
||||
pub struct Title {
|
||||
widget: widget::Title,
|
||||
widget: Label,
|
||||
}
|
||||
|
||||
impl Title {
|
||||
// Construct
|
||||
pub fn new() -> Arc<Title> {
|
||||
Arc::new(Self {
|
||||
widget: widget::Title::new(),
|
||||
})
|
||||
pub fn new() -> Title {
|
||||
Self {
|
||||
widget: Label::builder()
|
||||
.label("New page")
|
||||
.ellipsize(EllipsizeMode::End)
|
||||
.width_chars(16)
|
||||
.single_line_mode(true)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Title {
|
||||
pub fn widget(&self) -> &Label {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
pub struct Title {
|
||||
label: gtk::Label,
|
||||
}
|
||||
|
||||
impl Title {
|
||||
// Construct
|
||||
pub fn new() -> Title {
|
||||
let label = gtk::Label::builder()
|
||||
.label("New page")
|
||||
.ellipsize(gtk::pango::EllipsizeMode::End)
|
||||
.width_chars(16)
|
||||
.single_line_mode(true)
|
||||
.build();
|
||||
|
||||
Self { label }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn label(&self) -> >k::Label {
|
||||
&self.label
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
use gtk::prelude::BoxExt;
|
||||
|
||||
pub struct Label {
|
||||
container: gtk::Box,
|
||||
}
|
||||
|
||||
impl Label {
|
||||
// Construct new object
|
||||
pub fn new(pin: >k::Image, title: >k::Label) -> Label {
|
||||
let container = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.build();
|
||||
|
||||
container.append(pin);
|
||||
container.append(title);
|
||||
|
||||
Self { container }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn container(&self) -> >k::Box {
|
||||
&self.container
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +1,53 @@
|
|||
mod label;
|
||||
mod page;
|
||||
mod widget;
|
||||
|
||||
use std::sync::Arc;
|
||||
use gtk::Notebook;
|
||||
use label::Label;
|
||||
use page::Page;
|
||||
|
||||
pub struct Tab {
|
||||
widget: widget::Tab,
|
||||
widget: Notebook,
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
// Construct
|
||||
pub fn new() -> Arc<Tab> {
|
||||
Arc::new(Self {
|
||||
widget: widget::Tab::new(),
|
||||
})
|
||||
pub fn new() -> Tab {
|
||||
Self {
|
||||
widget: Notebook::builder().scrollable(true).build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn append(&self, is_active: bool) -> u32 {
|
||||
self.widget.append(
|
||||
label::Label::new(false).widget().container(),
|
||||
page::Page::new().widget().container(),
|
||||
is_active,
|
||||
)
|
||||
let label = Label::new(false);
|
||||
let page = Page::new();
|
||||
|
||||
let page_number = self.widget.append_page(page.widget(), Some(label.widget()));
|
||||
|
||||
self.widget.set_tab_reorderable(page.widget(), true);
|
||||
|
||||
if is_active {
|
||||
self.widget.set_current_page(Some(page_number));
|
||||
}
|
||||
|
||||
page_number
|
||||
}
|
||||
|
||||
pub fn close(&self) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/* @TODO
|
||||
pub fn close_all(&self) {
|
||||
todo!()
|
||||
}
|
||||
}*/
|
||||
|
||||
pub fn pin(&self) -> bool {
|
||||
todo!()
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Tab {
|
||||
pub fn widget(&self) -> &Notebook {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
mod widget;
|
||||
use gtk::{Box, Orientation};
|
||||
|
||||
pub struct Content {
|
||||
widget: widget::Content,
|
||||
widget: Box,
|
||||
}
|
||||
|
||||
impl Content {
|
||||
// Construct
|
||||
pub fn new() -> Content {
|
||||
Self {
|
||||
widget: widget::Content::new(),
|
||||
widget: Box::builder().orientation(Orientation::Vertical).build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Content {
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
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,23 +1,31 @@
|
|||
mod content;
|
||||
mod navigation;
|
||||
mod widget;
|
||||
|
||||
use gtk::prelude::BoxExt;
|
||||
use gtk::{Box, Orientation};
|
||||
|
||||
pub struct Page {
|
||||
widget: widget::Page,
|
||||
widget: Box,
|
||||
}
|
||||
|
||||
impl Page {
|
||||
pub fn new() -> Page {
|
||||
Self {
|
||||
widget: widget::Page::new(
|
||||
navigation::Navigation::new().widget().gtk(),
|
||||
content::Content::new().widget().gtk(),
|
||||
),
|
||||
}
|
||||
// Init components
|
||||
let navigation = navigation::Navigation::new();
|
||||
let content = content::Content::new();
|
||||
|
||||
// Init widget
|
||||
let widget = Box::builder().orientation(Orientation::Vertical).build();
|
||||
|
||||
widget.append(navigation.widget());
|
||||
widget.append(content.widget());
|
||||
|
||||
// Result
|
||||
Self { widget }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Page {
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,23 @@
|
|||
mod widget;
|
||||
use gtk::Button;
|
||||
|
||||
pub struct Base {
|
||||
widget: widget::Base,
|
||||
widget: Button,
|
||||
}
|
||||
|
||||
impl Base {
|
||||
// Construct
|
||||
pub fn new() -> Base {
|
||||
Self {
|
||||
widget: widget::Base::new(),
|
||||
widget: Button::builder()
|
||||
.icon_name("go-home-symbolic")
|
||||
.tooltip_text("Base")
|
||||
.sensitive(false)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Base {
|
||||
pub fn widget(&self) -> &Button {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
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,19 +1,23 @@
|
|||
mod widget;
|
||||
use gtk::Button;
|
||||
|
||||
pub struct Bookmark {
|
||||
widget: widget::Bookmark,
|
||||
widget: Button,
|
||||
}
|
||||
|
||||
impl Bookmark {
|
||||
// Construct
|
||||
pub fn new() -> Bookmark {
|
||||
Self {
|
||||
widget: widget::Bookmark::new(),
|
||||
widget: Button::builder()
|
||||
.icon_name("starred-symbolic")
|
||||
.tooltip_text("Toggle bookmark")
|
||||
.sensitive(false)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Bookmark {
|
||||
pub fn widget(&self) -> &Button {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
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,19 +1,23 @@
|
|||
mod widget;
|
||||
use gtk::Button;
|
||||
|
||||
pub struct Back {
|
||||
widget: widget::Back,
|
||||
widget: Button,
|
||||
}
|
||||
|
||||
impl Back {
|
||||
// Construct
|
||||
pub fn new() -> Back {
|
||||
Self {
|
||||
widget: widget::Back::new(),
|
||||
widget: Button::builder()
|
||||
.icon_name("go-previous-symbolic")
|
||||
.tooltip_text("Back")
|
||||
.sensitive(false)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Back {
|
||||
pub fn widget(&self) -> &Button {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
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,19 +1,23 @@
|
|||
mod widget;
|
||||
use gtk::Button;
|
||||
|
||||
pub struct Forward {
|
||||
widget: widget::Forward,
|
||||
widget: Button,
|
||||
}
|
||||
|
||||
impl Forward {
|
||||
// Construct
|
||||
pub fn new() -> Forward {
|
||||
Self {
|
||||
widget: widget::Forward::new(),
|
||||
widget: Button::builder()
|
||||
.icon_name("go-next-symbolic")
|
||||
.tooltip_text("Forward")
|
||||
.sensitive(false)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Forward {
|
||||
pub fn widget(&self) -> &Button {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
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,24 +1,38 @@
|
|||
mod back;
|
||||
mod forward;
|
||||
mod widget;
|
||||
|
||||
use back::Back;
|
||||
use forward::Forward;
|
||||
use gtk::prelude::BoxExt;
|
||||
use gtk::{Box, Orientation};
|
||||
|
||||
pub struct History {
|
||||
widget: widget::History,
|
||||
widget: Box,
|
||||
}
|
||||
|
||||
impl History {
|
||||
// Construct
|
||||
pub fn new() -> History {
|
||||
Self {
|
||||
widget: widget::History::new(
|
||||
back::Back::new().widget().gtk(),
|
||||
forward::Forward::new().widget().gtk(),
|
||||
),
|
||||
}
|
||||
// init components
|
||||
let back = Back::new();
|
||||
let forward = Forward::new();
|
||||
|
||||
// Init widget
|
||||
let widget = Box::builder()
|
||||
.orientation(Orientation::Horizontal)
|
||||
.css_classes([
|
||||
"linked", // merge childs
|
||||
])
|
||||
.build();
|
||||
|
||||
widget.append(back.widget());
|
||||
widget.append(forward.widget());
|
||||
|
||||
Self { widget }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::History {
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,27 +4,47 @@ mod history;
|
|||
mod reload;
|
||||
mod request;
|
||||
|
||||
mod widget;
|
||||
use gtk::prelude::BoxExt;
|
||||
use gtk::{Box, Orientation};
|
||||
|
||||
use base::Base;
|
||||
use bookmark::Bookmark;
|
||||
use history::History;
|
||||
use reload::Reload;
|
||||
use request::Request;
|
||||
|
||||
pub struct Navigation {
|
||||
widget: widget::Navigation,
|
||||
widget: Box,
|
||||
}
|
||||
|
||||
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(),
|
||||
),
|
||||
}
|
||||
let base = Base::new();
|
||||
let history = History::new();
|
||||
let reload = Reload::new();
|
||||
let request = Request::new();
|
||||
let bookmark = Bookmark::new();
|
||||
|
||||
let widget = Box::builder()
|
||||
.orientation(Orientation::Horizontal)
|
||||
.spacing(8)
|
||||
.margin_top(8)
|
||||
.margin_start(8)
|
||||
.margin_end(8)
|
||||
.margin_bottom(8)
|
||||
.build();
|
||||
|
||||
widget.append(base.widget());
|
||||
widget.append(history.widget());
|
||||
widget.append(reload.widget());
|
||||
widget.append(request.widget());
|
||||
widget.append(bookmark.widget());
|
||||
|
||||
Self { widget }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Navigation {
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,23 @@
|
|||
mod widget;
|
||||
use gtk::Button;
|
||||
|
||||
pub struct Reload {
|
||||
widget: widget::Reload,
|
||||
widget: Button,
|
||||
}
|
||||
|
||||
impl Reload {
|
||||
// Construct
|
||||
pub fn new() -> Reload {
|
||||
Self {
|
||||
widget: widget::Reload::new(),
|
||||
widget: Button::builder()
|
||||
.icon_name("view-refresh-symbolic")
|
||||
.tooltip_text("Reload")
|
||||
.sensitive(false)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Reload {
|
||||
pub fn widget(&self) -> &Button {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
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,19 +1,23 @@
|
|||
mod widget;
|
||||
use gtk::Entry;
|
||||
|
||||
pub struct Request {
|
||||
widget: widget::Request,
|
||||
widget: Entry,
|
||||
}
|
||||
|
||||
impl Request {
|
||||
// Construct
|
||||
pub fn new() -> Request {
|
||||
Self {
|
||||
widget: widget::Request::new(),
|
||||
widget: Entry::builder()
|
||||
.placeholder_text("URL or search term...")
|
||||
.hexpand(true)
|
||||
.progress_pulse_step(0.1)
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Request {
|
||||
pub fn widget(&self) -> &Entry {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
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
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
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
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
use gtk::prelude::BoxExt;
|
||||
|
||||
pub struct Page {
|
||||
container: gtk::Box,
|
||||
}
|
||||
|
||||
impl Page {
|
||||
// Construct
|
||||
pub fn new(navigation: >k::Box, content: >k::Box) -> Page {
|
||||
let container = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
container.append(navigation);
|
||||
container.append(content);
|
||||
|
||||
Self { container }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn container(&self) -> >k::Box {
|
||||
&self.container
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
pub struct Tab {
|
||||
notebook: gtk::Notebook,
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
// Construct new object
|
||||
pub fn new() -> Tab {
|
||||
Self {
|
||||
notebook: gtk::Notebook::builder().scrollable(true).build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn append(&self, label: >k::Box, page: >k::Box, current: bool) -> u32 {
|
||||
let page_number = self.notebook.append_page(page, Some(label));
|
||||
|
||||
self.notebook.set_tab_reorderable(page, true);
|
||||
|
||||
if current {
|
||||
self.notebook.set_current_page(Some(page_number));
|
||||
}
|
||||
|
||||
page_number
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn notebook(&self) -> >k::Notebook {
|
||||
&self.notebook
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
use gtk::prelude::BoxExt;
|
||||
|
||||
pub struct Main {
|
||||
gtk: gtk::Box,
|
||||
}
|
||||
|
||||
impl Main {
|
||||
// Construct new object
|
||||
pub fn new(tab: >k::Notebook) -> Main {
|
||||
let gtk = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
gtk.append(tab);
|
||||
|
||||
Self { gtk }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gtk(&self) -> >k::Box {
|
||||
&self.gtk
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue