mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-11 02:44:15 +00:00
reorganize widget modules
This commit is contained in:
parent
b9b226cc54
commit
4903968309
@ -1,26 +1,29 @@
|
|||||||
mod subject;
|
mod subject;
|
||||||
mod tray;
|
mod tray;
|
||||||
mod widget;
|
|
||||||
|
|
||||||
use std::sync::Arc;
|
use gtk::HeaderBar;
|
||||||
|
use subject::Subject;
|
||||||
|
use tray::Tray;
|
||||||
|
|
||||||
pub struct Header {
|
pub struct Header {
|
||||||
widget: widget::Header,
|
widget: HeaderBar,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Header {
|
impl Header {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Arc<Header> {
|
pub fn new() -> Header {
|
||||||
Arc::new(Self {
|
let tray = Tray::new();
|
||||||
widget: widget::Header::new(
|
let subject = Subject::new();
|
||||||
tray::Tray::new().widget().gtk(),
|
|
||||||
subject::Subject::new().widget().gtk(),
|
let widget = HeaderBar::builder().build();
|
||||||
),
|
widget.pack_start(tray.widget());
|
||||||
})
|
widget.set_title_widget(Some(subject.widget()));
|
||||||
|
|
||||||
|
Self { widget }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Header {
|
pub fn widget(&self) -> &HeaderBar {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,30 @@
|
|||||||
mod widget;
|
use gtk::prelude::WidgetExt;
|
||||||
|
use gtk::{pango::EllipsizeMode, Label};
|
||||||
|
|
||||||
pub struct Description {
|
pub struct Description {
|
||||||
widget: widget::Description,
|
widget: Label,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Description {
|
impl Description {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Description {
|
pub fn new() -> Description {
|
||||||
Self {
|
let widget = Label::builder()
|
||||||
widget: widget::Description::new(),
|
.css_classes(["subtitle"])
|
||||||
}
|
.single_line_mode(true)
|
||||||
|
.ellipsize(EllipsizeMode::End)
|
||||||
|
.visible(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Self { widget }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn set_text(&self, text: &str) {
|
|
||||||
self.widget.gtk().set_text(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn update(&self) {
|
pub fn update(&self) {
|
||||||
self.widget.update();
|
self.widget.set_visible(self.widget.text().is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Description {
|
pub fn widget(&self) -> &Label {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
use gtk::prelude::WidgetExt;
|
|
||||||
|
|
||||||
pub struct Description {
|
|
||||||
gtk: gtk::Label,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Description {
|
|
||||||
// Construct
|
|
||||||
pub fn new() -> Description {
|
|
||||||
let gtk = gtk::Label::builder()
|
|
||||||
.css_classes(["subtitle"])
|
|
||||||
.single_line_mode(true)
|
|
||||||
.ellipsize(gtk::pango::EllipsizeMode::End)
|
|
||||||
.visible(false)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Self { gtk }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actions
|
|
||||||
pub fn update(&self) {
|
|
||||||
self.gtk.set_visible(self.gtk.text().is_empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters
|
|
||||||
pub fn gtk(&self) -> >k::Label {
|
|
||||||
&self.gtk
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +1,34 @@
|
|||||||
mod description;
|
mod description;
|
||||||
mod title;
|
mod title;
|
||||||
mod widget;
|
|
||||||
|
use description::Description;
|
||||||
|
use gtk::prelude::BoxExt;
|
||||||
|
use gtk::{Align, Box, Orientation};
|
||||||
|
use title::Title;
|
||||||
|
|
||||||
pub struct Subject {
|
pub struct Subject {
|
||||||
widget: widget::Subject,
|
widget: Box,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Subject {
|
impl Subject {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Subject {
|
pub fn new() -> Subject {
|
||||||
Self {
|
let title = Title::new();
|
||||||
widget: widget::Subject::new(
|
let description = Description::new();
|
||||||
title::Title::new().widget().gtk(),
|
|
||||||
description::Description::new().widget().gtk(),
|
let widget = Box::builder()
|
||||||
),
|
.orientation(Orientation::Vertical)
|
||||||
}
|
.valign(Align::Center)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
widget.append(title.widget());
|
||||||
|
widget.append(description.widget());
|
||||||
|
|
||||||
|
Self { widget }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Subject {
|
pub fn widget(&self) -> &Box {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,36 @@
|
|||||||
mod widget;
|
use gtk::{pango::EllipsizeMode, Label};
|
||||||
|
|
||||||
|
const DEFAULT_TEXT: &str = "Yoda"; // @TODO
|
||||||
|
|
||||||
pub struct Title {
|
pub struct Title {
|
||||||
widget: widget::Title,
|
widget: Label,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Title {
|
impl Title {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Title {
|
pub fn new() -> Title {
|
||||||
Self {
|
let widget = gtk::Label::builder()
|
||||||
widget: widget::Title::new(),
|
.css_classes(["title"])
|
||||||
}
|
.single_line_mode(true)
|
||||||
|
.ellipsize(EllipsizeMode::End)
|
||||||
|
.label(DEFAULT_TEXT)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Self { widget }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn update(&self, text: &str) {
|
pub fn update(&self, text: &str) {
|
||||||
self.widget.update(text);
|
if text.is_empty() {
|
||||||
|
self.widget.set_text(DEFAULT_TEXT);
|
||||||
|
} else {
|
||||||
|
self.widget
|
||||||
|
.set_text(&format!("{} - {}", text, DEFAULT_TEXT));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Title {
|
pub fn widget(&self) -> &Label {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
const DEFAULT_TEXT: &str = "Yoda";
|
|
||||||
|
|
||||||
pub struct Title {
|
|
||||||
gtk: gtk::Label,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Title {
|
|
||||||
// Construct
|
|
||||||
pub fn new() -> Title {
|
|
||||||
let gtk = gtk::Label::builder()
|
|
||||||
.css_classes(["title"])
|
|
||||||
.single_line_mode(true)
|
|
||||||
.ellipsize(gtk::pango::EllipsizeMode::End)
|
|
||||||
.label(DEFAULT_TEXT)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Self { gtk }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actions
|
|
||||||
pub fn update(&self, text: &str) {
|
|
||||||
if text.is_empty() {
|
|
||||||
self.gtk.set_text(DEFAULT_TEXT);
|
|
||||||
} else {
|
|
||||||
self.gtk.set_text(&format!("{} - {}", text, DEFAULT_TEXT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters
|
|
||||||
pub fn gtk(&self) -> >k::Label {
|
|
||||||
&self.gtk
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
use gtk::prelude::BoxExt;
|
|
||||||
|
|
||||||
pub struct Subject {
|
|
||||||
gtk: gtk::Box,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Subject {
|
|
||||||
pub fn new(title: >k::Label, description: >k::Label) -> Subject {
|
|
||||||
let gtk = gtk::Box::builder()
|
|
||||||
.orientation(gtk::Orientation::Vertical)
|
|
||||||
.valign(gtk::Align::Center)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
gtk.append(title);
|
|
||||||
gtk.append(description);
|
|
||||||
|
|
||||||
Self { gtk }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn gtk(&self) -> >k::Box {
|
|
||||||
&self.gtk
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +1,36 @@
|
|||||||
mod model;
|
use gtk::{gio, MenuButton};
|
||||||
mod widget;
|
|
||||||
|
|
||||||
pub struct Menu {
|
pub struct Menu {
|
||||||
widget: widget::Menu,
|
widget: MenuButton,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Menu {
|
impl Menu {
|
||||||
pub fn new() -> Menu {
|
pub fn new() -> Menu {
|
||||||
Self {
|
// Init model
|
||||||
widget: widget::Menu::new(model::Menu::new().model()),
|
let model_tab = gio::Menu::new();
|
||||||
}
|
model_tab.append(Some("New"), Some("win.tab_append"));
|
||||||
|
model_tab.append(Some("Pin"), Some("win.tab_pin"));
|
||||||
|
|
||||||
|
let model_tab_close = gio::Menu::new();
|
||||||
|
model_tab_close.append(Some("Current"), Some("win.tab_close"));
|
||||||
|
model_tab_close.append(Some("All"), Some("win.tab_close_all"));
|
||||||
|
model_tab.append_submenu(Some("Close"), &model_tab_close);
|
||||||
|
|
||||||
|
let model = gio::Menu::new();
|
||||||
|
model.append_submenu(Some("Tab"), &model_tab);
|
||||||
|
model.append(Some("Debug"), Some("win.debug"));
|
||||||
|
model.append(Some("Quit"), Some("win.quit"));
|
||||||
|
|
||||||
|
// Init widget
|
||||||
|
let widget = MenuButton::builder().tooltip_text("Menu").build();
|
||||||
|
widget.set_menu_model(Some(&model));
|
||||||
|
|
||||||
|
// Result
|
||||||
|
Self { widget }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Menu {
|
pub fn widget(&self) -> &MenuButton {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
use gtk::gio;
|
|
||||||
|
|
||||||
pub struct Menu {
|
|
||||||
model: gio::Menu,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Menu {
|
|
||||||
// Construct
|
|
||||||
pub fn new() -> Menu {
|
|
||||||
let model_tab = gio::Menu::new();
|
|
||||||
model_tab.append(Some("New"), Some("win.tab_append"));
|
|
||||||
model_tab.append(Some("Pin"), Some("win.tab_pin"));
|
|
||||||
|
|
||||||
let model_tab_close = gio::Menu::new();
|
|
||||||
model_tab_close.append(Some("Current"), Some("win.tab_close"));
|
|
||||||
model_tab_close.append(Some("All"), Some("win.tab_close_all"));
|
|
||||||
model_tab.append_submenu(Some("Close"), &model_tab_close);
|
|
||||||
|
|
||||||
let model = gio::Menu::new();
|
|
||||||
model.append_submenu(Some("Tab"), &model_tab);
|
|
||||||
model.append(Some("Debug"), Some("win.debug"));
|
|
||||||
model.append(Some("Quit"), Some("win.quit"));
|
|
||||||
|
|
||||||
Self { model }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters
|
|
||||||
pub fn model(&self) -> &gio::Menu {
|
|
||||||
&self.model
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
use gtk::gio;
|
|
||||||
|
|
||||||
pub struct Menu {
|
|
||||||
gtk: gtk::MenuButton,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Menu {
|
|
||||||
// Construct
|
|
||||||
pub fn new(model: &gio::Menu) -> Menu {
|
|
||||||
let gtk = gtk::MenuButton::builder().tooltip_text("Menu").build();
|
|
||||||
|
|
||||||
gtk.set_menu_model(Some(model));
|
|
||||||
|
|
||||||
Self { gtk }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters
|
|
||||||
pub fn gtk(&self) -> >k::MenuButton {
|
|
||||||
&self.gtk
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +1,33 @@
|
|||||||
mod menu;
|
mod menu;
|
||||||
mod tab;
|
mod tab;
|
||||||
mod widget;
|
|
||||||
|
use gtk::prelude::BoxExt;
|
||||||
|
use gtk::{Box, Orientation};
|
||||||
|
use menu::Menu;
|
||||||
|
use tab::Tab;
|
||||||
|
|
||||||
pub struct Tray {
|
pub struct Tray {
|
||||||
widget: widget::Tray,
|
widget: Box,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tray {
|
impl Tray {
|
||||||
pub fn new() -> Tray {
|
pub fn new() -> Tray {
|
||||||
Self {
|
let menu = Menu::new();
|
||||||
widget: widget::Tray::new(
|
let tab = Tab::new();
|
||||||
menu::Menu::new().widget().gtk(),
|
|
||||||
tab::Tab::new().widget().gtk(),
|
let widget = Box::builder()
|
||||||
),
|
.orientation(Orientation::Horizontal)
|
||||||
}
|
.spacing(8)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
widget.append(menu.widget());
|
||||||
|
widget.append(tab.widget());
|
||||||
|
|
||||||
|
Self { widget }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Tray {
|
pub fn widget(&self) -> &Box {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
mod widget;
|
use gtk::Button;
|
||||||
|
|
||||||
pub struct Tab {
|
pub struct Tab {
|
||||||
pub widget: widget::Tab,
|
pub widget: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Tab {
|
pub fn new() -> Tab {
|
||||||
Self {
|
Self {
|
||||||
widget: widget::Tab::new(),
|
widget: Button::builder()
|
||||||
|
.action_name("win.tab_append")
|
||||||
|
.icon_name("tab-new-symbolic")
|
||||||
|
.tooltip_text("New tab")
|
||||||
|
.build(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Tab {
|
pub fn widget(&self) -> &Button {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
pub struct Tab {
|
|
||||||
gtk: gtk::Button,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Tab {
|
|
||||||
// Construct
|
|
||||||
pub fn new() -> Tab {
|
|
||||||
Self {
|
|
||||||
gtk: gtk::Button::builder()
|
|
||||||
.action_name("win.tab_append")
|
|
||||||
.icon_name("tab-new-symbolic")
|
|
||||||
.tooltip_text("New tab")
|
|
||||||
.build(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters
|
|
||||||
pub fn gtk(&self) -> >k::Button {
|
|
||||||
&self.gtk
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
use gtk::prelude::BoxExt;
|
|
||||||
|
|
||||||
pub struct Tray {
|
|
||||||
gtk: gtk::Box,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Tray {
|
|
||||||
// Construct
|
|
||||||
pub fn new(menu: >k::MenuButton, tab: >k::Button) -> Tray {
|
|
||||||
let gtk = gtk::Box::builder()
|
|
||||||
.orientation(gtk::Orientation::Horizontal)
|
|
||||||
.spacing(8)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
gtk.append(menu);
|
|
||||||
gtk.append(tab);
|
|
||||||
|
|
||||||
Self { gtk }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters
|
|
||||||
pub fn gtk(&self) -> >k::Box {
|
|
||||||
&self.gtk
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
pub struct Header {
|
|
||||||
gtk: gtk::HeaderBar,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Header {
|
|
||||||
pub fn new(tray: >k::Box, subject: >k::Box) -> Header {
|
|
||||||
let gtk = gtk::HeaderBar::builder().build();
|
|
||||||
|
|
||||||
gtk.pack_start(tray);
|
|
||||||
gtk.set_title_widget(Some(subject));
|
|
||||||
|
|
||||||
Self { gtk }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn gtk(&self) -> >k::HeaderBar {
|
|
||||||
&self.gtk
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +1,28 @@
|
|||||||
mod tab;
|
mod tab;
|
||||||
mod widget;
|
|
||||||
|
|
||||||
use std::sync::Arc;
|
use gtk::{Box, Orientation};
|
||||||
|
use tab::Tab;
|
||||||
|
|
||||||
|
use gtk::prelude::BoxExt;
|
||||||
|
|
||||||
pub struct Main {
|
pub struct Main {
|
||||||
// Components
|
tab: Tab,
|
||||||
tab: Arc<tab::Tab>,
|
widget: Box,
|
||||||
|
|
||||||
// Extras
|
|
||||||
widget: widget::Main,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Main {
|
impl Main {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Arc<Main> {
|
pub fn new() -> Main {
|
||||||
// Init components
|
// Init components
|
||||||
let tab = tab::Tab::new();
|
let tab = Tab::new();
|
||||||
|
|
||||||
// Extras
|
// Extras
|
||||||
let widget = widget::Main::new(tab.widget().notebook());
|
let widget = Box::builder().orientation(Orientation::Vertical).build();
|
||||||
|
|
||||||
|
widget.append(tab.widget());
|
||||||
|
|
||||||
// Init struct
|
// Init struct
|
||||||
Arc::new(Self { tab, widget })
|
Self { tab, widget }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
@ -42,7 +43,7 @@ impl Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Main {
|
pub fn widget(&self) -> &Box {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,46 +1,47 @@
|
|||||||
mod pin;
|
mod pin;
|
||||||
mod title;
|
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 {
|
pub struct Label {
|
||||||
// Components
|
// Components
|
||||||
pin: Arc<pin::Pin>,
|
pin: Pin,
|
||||||
title: Arc<title::Title>,
|
title: Title,
|
||||||
|
|
||||||
// Extras
|
// GTK
|
||||||
is_pinned: bool,
|
widget: Box,
|
||||||
widget: widget::Label,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Label {
|
impl Label {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(is_pinned: bool) -> Arc<Label> {
|
pub fn new(is_pinned: bool) -> Label {
|
||||||
// Components
|
// Components
|
||||||
let pin = pin::Pin::new(is_pinned);
|
let pin = Pin::new(is_pinned);
|
||||||
let title = title::Title::new();
|
let title = Title::new();
|
||||||
|
|
||||||
// Extras
|
// GTK
|
||||||
let widget = widget::Label::new(pin.widget().image(), title.widget().label());
|
let widget = Box::builder().orientation(Orientation::Horizontal).build();
|
||||||
|
|
||||||
|
widget.append(pin.widget());
|
||||||
|
widget.append(title.widget());
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
Arc::new(Self {
|
Self { pin, title, widget }
|
||||||
pin,
|
|
||||||
title,
|
|
||||||
is_pinned,
|
|
||||||
widget,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn pin(&mut self) {
|
pub fn pin(&self) -> bool {
|
||||||
self.is_pinned = !self.is_pinned; // toggle
|
self.pin
|
||||||
// @TODO
|
.widget()
|
||||||
|
.set_visible(!self.pin.widget().is_visible());
|
||||||
|
self.pin.widget().is_visible()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Label {
|
pub fn widget(&self) -> &Box {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,22 @@
|
|||||||
mod widget;
|
use gtk::Image;
|
||||||
|
|
||||||
use gtk::prelude::WidgetExt;
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub struct Pin {
|
pub struct Pin {
|
||||||
// Extras
|
widget: Image,
|
||||||
is_pinned: bool,
|
|
||||||
widget: widget::Pin,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Pin {
|
impl Pin {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(is_pinned: bool) -> Arc<Pin> {
|
pub fn new(visible: bool) -> Pin {
|
||||||
Arc::new(Self {
|
let widget = Image::builder()
|
||||||
is_pinned,
|
.icon_name("view-pin-symbolic")
|
||||||
widget: widget::Pin::new(is_pinned),
|
.visible(visible)
|
||||||
})
|
.build();
|
||||||
}
|
|
||||||
|
|
||||||
// Actions
|
Self { widget }
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Pin {
|
pub fn widget(&self) -> &Image {
|
||||||
&self.widget
|
&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 gtk::{pango::EllipsizeMode, Label};
|
||||||
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub struct Title {
|
pub struct Title {
|
||||||
widget: widget::Title,
|
widget: Label,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Title {
|
impl Title {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Arc<Title> {
|
pub fn new() -> Title {
|
||||||
Arc::new(Self {
|
Self {
|
||||||
widget: widget::Title::new(),
|
widget: Label::builder()
|
||||||
})
|
.label("New page")
|
||||||
|
.ellipsize(EllipsizeMode::End)
|
||||||
|
.width_chars(16)
|
||||||
|
.single_line_mode(true)
|
||||||
|
.build(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Title {
|
pub fn widget(&self) -> &Label {
|
||||||
&self.widget
|
&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 label;
|
||||||
mod page;
|
mod page;
|
||||||
mod widget;
|
|
||||||
|
|
||||||
use std::sync::Arc;
|
use gtk::Notebook;
|
||||||
|
use label::Label;
|
||||||
|
use page::Page;
|
||||||
|
|
||||||
pub struct Tab {
|
pub struct Tab {
|
||||||
widget: widget::Tab,
|
widget: Notebook,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Arc<Tab> {
|
pub fn new() -> Tab {
|
||||||
Arc::new(Self {
|
Self {
|
||||||
widget: widget::Tab::new(),
|
widget: Notebook::builder().scrollable(true).build(),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn append(&self, is_active: bool) -> u32 {
|
pub fn append(&self, is_active: bool) -> u32 {
|
||||||
self.widget.append(
|
let label = Label::new(false);
|
||||||
label::Label::new(false).widget().container(),
|
let page = Page::new();
|
||||||
page::Page::new().widget().container(),
|
|
||||||
is_active,
|
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) {
|
pub fn close(&self) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* @TODO
|
||||||
pub fn close_all(&self) {
|
pub fn close_all(&self) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}*/
|
||||||
|
|
||||||
pub fn pin(&self) -> bool {
|
pub fn pin(&self) -> bool {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Tab {
|
pub fn widget(&self) -> &Notebook {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
mod widget;
|
use gtk::{Box, Orientation};
|
||||||
|
|
||||||
pub struct Content {
|
pub struct Content {
|
||||||
widget: widget::Content,
|
widget: Box,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Content {
|
impl Content {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Content {
|
pub fn new() -> Content {
|
||||||
Self {
|
Self {
|
||||||
widget: widget::Content::new(),
|
widget: Box::builder().orientation(Orientation::Vertical).build(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Content {
|
pub fn widget(&self) -> &Box {
|
||||||
&self.widget
|
&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 content;
|
||||||
mod navigation;
|
mod navigation;
|
||||||
mod widget;
|
|
||||||
|
use gtk::prelude::BoxExt;
|
||||||
|
use gtk::{Box, Orientation};
|
||||||
|
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
widget: widget::Page,
|
widget: Box,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
pub fn new() -> Page {
|
pub fn new() -> Page {
|
||||||
Self {
|
// Init components
|
||||||
widget: widget::Page::new(
|
let navigation = navigation::Navigation::new();
|
||||||
navigation::Navigation::new().widget().gtk(),
|
let content = content::Content::new();
|
||||||
content::Content::new().widget().gtk(),
|
|
||||||
),
|
// Init widget
|
||||||
}
|
let widget = Box::builder().orientation(Orientation::Vertical).build();
|
||||||
|
|
||||||
|
widget.append(navigation.widget());
|
||||||
|
widget.append(content.widget());
|
||||||
|
|
||||||
|
// Result
|
||||||
|
Self { widget }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Page {
|
pub fn widget(&self) -> &Box {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
mod widget;
|
use gtk::Button;
|
||||||
|
|
||||||
pub struct Base {
|
pub struct Base {
|
||||||
widget: widget::Base,
|
widget: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Base {
|
impl Base {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Base {
|
pub fn new() -> Base {
|
||||||
Self {
|
Self {
|
||||||
widget: widget::Base::new(),
|
widget: Button::builder()
|
||||||
|
.icon_name("go-home-symbolic")
|
||||||
|
.tooltip_text("Base")
|
||||||
|
.sensitive(false)
|
||||||
|
.build(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Base {
|
pub fn widget(&self) -> &Button {
|
||||||
&self.widget
|
&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 {
|
pub struct Bookmark {
|
||||||
widget: widget::Bookmark,
|
widget: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bookmark {
|
impl Bookmark {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Bookmark {
|
pub fn new() -> Bookmark {
|
||||||
Self {
|
Self {
|
||||||
widget: widget::Bookmark::new(),
|
widget: Button::builder()
|
||||||
|
.icon_name("starred-symbolic")
|
||||||
|
.tooltip_text("Toggle bookmark")
|
||||||
|
.sensitive(false)
|
||||||
|
.build(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Bookmark {
|
pub fn widget(&self) -> &Button {
|
||||||
&self.widget
|
&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 {
|
pub struct Back {
|
||||||
widget: widget::Back,
|
widget: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Back {
|
impl Back {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Back {
|
pub fn new() -> Back {
|
||||||
Self {
|
Self {
|
||||||
widget: widget::Back::new(),
|
widget: Button::builder()
|
||||||
|
.icon_name("go-previous-symbolic")
|
||||||
|
.tooltip_text("Back")
|
||||||
|
.sensitive(false)
|
||||||
|
.build(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Back {
|
pub fn widget(&self) -> &Button {
|
||||||
&self.widget
|
&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 {
|
pub struct Forward {
|
||||||
widget: widget::Forward,
|
widget: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Forward {
|
impl Forward {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Forward {
|
pub fn new() -> Forward {
|
||||||
Self {
|
Self {
|
||||||
widget: widget::Forward::new(),
|
widget: Button::builder()
|
||||||
|
.icon_name("go-next-symbolic")
|
||||||
|
.tooltip_text("Forward")
|
||||||
|
.sensitive(false)
|
||||||
|
.build(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Forward {
|
pub fn widget(&self) -> &Button {
|
||||||
&self.widget
|
&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 back;
|
||||||
mod forward;
|
mod forward;
|
||||||
mod widget;
|
|
||||||
|
use back::Back;
|
||||||
|
use forward::Forward;
|
||||||
|
use gtk::prelude::BoxExt;
|
||||||
|
use gtk::{Box, Orientation};
|
||||||
|
|
||||||
pub struct History {
|
pub struct History {
|
||||||
widget: widget::History,
|
widget: Box,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl History {
|
impl History {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> History {
|
pub fn new() -> History {
|
||||||
Self {
|
// init components
|
||||||
widget: widget::History::new(
|
let back = Back::new();
|
||||||
back::Back::new().widget().gtk(),
|
let forward = Forward::new();
|
||||||
forward::Forward::new().widget().gtk(),
|
|
||||||
),
|
// 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
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::History {
|
pub fn widget(&self) -> &Box {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,27 +4,47 @@ mod history;
|
|||||||
mod reload;
|
mod reload;
|
||||||
mod request;
|
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 {
|
pub struct Navigation {
|
||||||
widget: widget::Navigation,
|
widget: Box,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Navigation {
|
impl Navigation {
|
||||||
pub fn new() -> Navigation {
|
pub fn new() -> Navigation {
|
||||||
Self {
|
let base = Base::new();
|
||||||
widget: widget::Navigation::new(
|
let history = History::new();
|
||||||
base::Base::new().widget().gtk(),
|
let reload = Reload::new();
|
||||||
history::History::new().widget().gtk(),
|
let request = Request::new();
|
||||||
reload::Reload::new().widget().gtk(),
|
let bookmark = Bookmark::new();
|
||||||
request::Request::new().widget().gtk(),
|
|
||||||
bookmark::Bookmark::new().widget().gtk(),
|
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
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Navigation {
|
pub fn widget(&self) -> &Box {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
mod widget;
|
use gtk::Button;
|
||||||
|
|
||||||
pub struct Reload {
|
pub struct Reload {
|
||||||
widget: widget::Reload,
|
widget: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reload {
|
impl Reload {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Reload {
|
pub fn new() -> Reload {
|
||||||
Self {
|
Self {
|
||||||
widget: widget::Reload::new(),
|
widget: Button::builder()
|
||||||
|
.icon_name("view-refresh-symbolic")
|
||||||
|
.tooltip_text("Reload")
|
||||||
|
.sensitive(false)
|
||||||
|
.build(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Reload {
|
pub fn widget(&self) -> &Button {
|
||||||
&self.widget
|
&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 {
|
pub struct Request {
|
||||||
widget: widget::Request,
|
widget: Entry,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Request {
|
pub fn new() -> Request {
|
||||||
Self {
|
Self {
|
||||||
widget: widget::Request::new(),
|
widget: Entry::builder()
|
||||||
|
.placeholder_text("URL or search term...")
|
||||||
|
.hexpand(true)
|
||||||
|
.progress_pulse_step(0.1)
|
||||||
|
.build(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Request {
|
pub fn widget(&self) -> &Entry {
|
||||||
&self.widget
|
&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
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +1,46 @@
|
|||||||
mod db;
|
mod db;
|
||||||
mod header;
|
mod header;
|
||||||
mod main;
|
mod main;
|
||||||
mod widget;
|
|
||||||
|
|
||||||
use gtk::gio::ActionEntry;
|
use gtk::gio::ActionEntry;
|
||||||
|
use gtk::prelude::{ActionMapExtManual, GtkWindowExt};
|
||||||
use gtk::{Application, ApplicationWindow};
|
use gtk::{Application, ApplicationWindow};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use gtk::prelude::{ActionMapExtManual, GtkWindowExt};
|
|
||||||
|
|
||||||
pub struct Browser {
|
pub struct Browser {
|
||||||
// Extras
|
// Extras
|
||||||
db: db::Browser,
|
// db: db::Browser,
|
||||||
widget: widget::Browser,
|
widget: ApplicationWindow,
|
||||||
// Components
|
// Components
|
||||||
header: Arc<header::Header>,
|
// header: Arc<header::Header>,
|
||||||
main: Arc<main::Main>,
|
// main: main::Main,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Browser {
|
impl Browser {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(
|
pub fn new(
|
||||||
app: &Application,
|
app: &Application,
|
||||||
connection: Arc<sqlite::Connection>,
|
// connection: Arc<sqlite::Connection>,
|
||||||
default_width: i32,
|
default_width: i32,
|
||||||
default_height: i32,
|
default_height: i32,
|
||||||
) -> Arc<Browser> {
|
) -> Browser {
|
||||||
// Init components
|
// Init components
|
||||||
let db = db::Browser::new(connection);
|
// let db = db::Browser::new(connection);
|
||||||
let header = header::Header::new();
|
let header = header::Header::new();
|
||||||
let main = main::Main::new();
|
let main = main::Main::new();
|
||||||
|
|
||||||
let widget = widget::Browser::new(
|
let widget = ApplicationWindow::builder()
|
||||||
app,
|
.application(app)
|
||||||
header.widget().gtk(),
|
.default_width(default_width)
|
||||||
main.widget().gtk(),
|
.default_height(default_height)
|
||||||
default_width,
|
.titlebar(header.widget())
|
||||||
default_height,
|
.child(main.widget())
|
||||||
);
|
.build();
|
||||||
|
|
||||||
// Init actions @TODO separated module
|
// Init actions
|
||||||
widget.window().add_action_entries([
|
let main_ref = Arc::new(main); // @TODO
|
||||||
|
|
||||||
|
widget.add_action_entries([
|
||||||
ActionEntry::builder("debug")
|
ActionEntry::builder("debug")
|
||||||
.activate(|this: &ApplicationWindow, _, _| {
|
.activate(|this: &ApplicationWindow, _, _| {
|
||||||
this.emit_enable_debugging(true);
|
this.emit_enable_debugging(true);
|
||||||
@ -53,7 +53,7 @@ impl Browser {
|
|||||||
.build(),
|
.build(),
|
||||||
ActionEntry::builder("tab_append")
|
ActionEntry::builder("tab_append")
|
||||||
.activate({
|
.activate({
|
||||||
let main = main.clone();
|
let main = main_ref.clone();
|
||||||
move |_, _, _| {
|
move |_, _, _| {
|
||||||
main.tab_append();
|
main.tab_append();
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ impl Browser {
|
|||||||
.build(),
|
.build(),
|
||||||
ActionEntry::builder("tab_close")
|
ActionEntry::builder("tab_close")
|
||||||
.activate({
|
.activate({
|
||||||
let main = main.clone();
|
let main = main_ref.clone();
|
||||||
move |_, _, _| {
|
move |_, _, _| {
|
||||||
main.tab_close();
|
main.tab_close();
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ impl Browser {
|
|||||||
.build(),
|
.build(),
|
||||||
ActionEntry::builder("tab_close_all")
|
ActionEntry::builder("tab_close_all")
|
||||||
.activate({
|
.activate({
|
||||||
let main = main.clone();
|
let main = main_ref.clone();
|
||||||
move |_, _, _| {
|
move |_, _, _| {
|
||||||
main.tab_close_all();
|
main.tab_close_all();
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ impl Browser {
|
|||||||
.build(),
|
.build(),
|
||||||
ActionEntry::builder("tab_pin")
|
ActionEntry::builder("tab_pin")
|
||||||
.activate({
|
.activate({
|
||||||
let main = main.clone();
|
let main = main_ref.clone();
|
||||||
move |_, _, _| {
|
move |_, _, _| {
|
||||||
main.tab_pin();
|
main.tab_pin();
|
||||||
}
|
}
|
||||||
@ -86,16 +86,16 @@ impl Browser {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
Arc::new(Self {
|
Self {
|
||||||
db,
|
// db,
|
||||||
widget,
|
widget,
|
||||||
header,
|
// header,
|
||||||
main,
|
// main,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &widget::Browser {
|
pub fn widget(&self) -> &ApplicationWindow {
|
||||||
&self.widget
|
&self.widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
use gtk::{Application, ApplicationWindow, Box, HeaderBar};
|
|
||||||
|
|
||||||
pub struct Browser {
|
|
||||||
window: ApplicationWindow,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Browser {
|
|
||||||
pub fn new(
|
|
||||||
application: &Application,
|
|
||||||
titlebar: &HeaderBar,
|
|
||||||
child: &Box,
|
|
||||||
default_width: i32,
|
|
||||||
default_height: i32,
|
|
||||||
) -> Browser {
|
|
||||||
Self {
|
|
||||||
window: ApplicationWindow::builder()
|
|
||||||
.application(application)
|
|
||||||
.default_width(default_width)
|
|
||||||
.default_height(default_height)
|
|
||||||
.titlebar(titlebar)
|
|
||||||
.child(child)
|
|
||||||
.build(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn window(&self) -> &ApplicationWindow {
|
|
||||||
&self.window
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
mod browser;
|
mod browser;
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use gtk::prelude::{ApplicationExt, ApplicationExtManual, GtkApplicationExt, GtkWindowExt};
|
use gtk::prelude::{ApplicationExt, ApplicationExtManual, GtkApplicationExt, GtkWindowExt};
|
||||||
|
|
||||||
@ -32,6 +31,7 @@ fn main() -> glib::ExitCode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init profile database
|
// Init profile database
|
||||||
|
/* @TODO
|
||||||
let mut db = fs.clone();
|
let mut db = fs.clone();
|
||||||
|
|
||||||
db.push("database.sqlite3");
|
db.push("database.sqlite3");
|
||||||
@ -39,12 +39,11 @@ fn main() -> glib::ExitCode {
|
|||||||
let db = match sqlite::open(db) {
|
let db = match sqlite::open(db) {
|
||||||
Ok(db) => Arc::new(db),
|
Ok(db) => Arc::new(db),
|
||||||
Err(e) => panic!("Failed to connect profile database: {e}"),
|
Err(e) => panic!("Failed to connect profile database: {e}"),
|
||||||
};
|
};*/
|
||||||
|
|
||||||
move |this: &Application| {
|
move |this: &Application| {
|
||||||
browser::Browser::new(this, db.clone(), 640, 480)
|
browser::Browser::new(this, /*db.clone(),*/ 640, 480)
|
||||||
.widget()
|
.widget()
|
||||||
.window()
|
|
||||||
.present();
|
.present();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user