mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-10 10:24:13 +00:00
reorganize widget modules
This commit is contained in:
parent
b9b226cc54
commit
4903968309
@ -1,26 +1,29 @@
|
||||
mod subject;
|
||||
mod tray;
|
||||
mod widget;
|
||||
|
||||
use std::sync::Arc;
|
||||
use gtk::HeaderBar;
|
||||
use subject::Subject;
|
||||
use tray::Tray;
|
||||
|
||||
pub struct Header {
|
||||
widget: widget::Header,
|
||||
widget: HeaderBar,
|
||||
}
|
||||
|
||||
impl Header {
|
||||
// Construct
|
||||
pub fn new() -> Arc<Header> {
|
||||
Arc::new(Self {
|
||||
widget: widget::Header::new(
|
||||
tray::Tray::new().widget().gtk(),
|
||||
subject::Subject::new().widget().gtk(),
|
||||
),
|
||||
})
|
||||
pub fn new() -> Header {
|
||||
let tray = Tray::new();
|
||||
let subject = Subject::new();
|
||||
|
||||
let widget = HeaderBar::builder().build();
|
||||
widget.pack_start(tray.widget());
|
||||
widget.set_title_widget(Some(subject.widget()));
|
||||
|
||||
Self { widget }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Header {
|
||||
pub fn widget(&self) -> &HeaderBar {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,30 @@
|
||||
mod widget;
|
||||
use gtk::prelude::WidgetExt;
|
||||
use gtk::{pango::EllipsizeMode, Label};
|
||||
|
||||
pub struct Description {
|
||||
widget: widget::Description,
|
||||
widget: Label,
|
||||
}
|
||||
|
||||
impl Description {
|
||||
// Construct
|
||||
pub fn new() -> Description {
|
||||
Self {
|
||||
widget: widget::Description::new(),
|
||||
}
|
||||
let widget = Label::builder()
|
||||
.css_classes(["subtitle"])
|
||||
.single_line_mode(true)
|
||||
.ellipsize(EllipsizeMode::End)
|
||||
.visible(false)
|
||||
.build();
|
||||
|
||||
Self { widget }
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn set_text(&self, text: &str) {
|
||||
self.widget.gtk().set_text(text);
|
||||
}
|
||||
|
||||
pub fn update(&self) {
|
||||
self.widget.update();
|
||||
self.widget.set_visible(self.widget.text().is_empty());
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Description {
|
||||
pub fn widget(&self) -> &Label {
|
||||
&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 title;
|
||||
mod widget;
|
||||
|
||||
use description::Description;
|
||||
use gtk::prelude::BoxExt;
|
||||
use gtk::{Align, Box, Orientation};
|
||||
use title::Title;
|
||||
|
||||
pub struct Subject {
|
||||
widget: widget::Subject,
|
||||
widget: Box,
|
||||
}
|
||||
|
||||
impl Subject {
|
||||
// Construct
|
||||
pub fn new() -> Subject {
|
||||
Self {
|
||||
widget: widget::Subject::new(
|
||||
title::Title::new().widget().gtk(),
|
||||
description::Description::new().widget().gtk(),
|
||||
),
|
||||
}
|
||||
let title = Title::new();
|
||||
let description = Description::new();
|
||||
|
||||
let widget = Box::builder()
|
||||
.orientation(Orientation::Vertical)
|
||||
.valign(Align::Center)
|
||||
.build();
|
||||
|
||||
widget.append(title.widget());
|
||||
widget.append(description.widget());
|
||||
|
||||
Self { widget }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Subject {
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,36 @@
|
||||
mod widget;
|
||||
use gtk::{pango::EllipsizeMode, Label};
|
||||
|
||||
const DEFAULT_TEXT: &str = "Yoda"; // @TODO
|
||||
|
||||
pub struct Title {
|
||||
widget: widget::Title,
|
||||
widget: Label,
|
||||
}
|
||||
|
||||
impl Title {
|
||||
// Construct
|
||||
pub fn new() -> Title {
|
||||
Self {
|
||||
widget: widget::Title::new(),
|
||||
}
|
||||
let widget = gtk::Label::builder()
|
||||
.css_classes(["title"])
|
||||
.single_line_mode(true)
|
||||
.ellipsize(EllipsizeMode::End)
|
||||
.label(DEFAULT_TEXT)
|
||||
.build();
|
||||
|
||||
Self { widget }
|
||||
}
|
||||
|
||||
// Actions
|
||||
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
|
||||
pub fn widget(&self) -> &widget::Title {
|
||||
pub fn widget(&self) -> &Label {
|
||||
&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;
|
||||
mod widget;
|
||||
use gtk::{gio, MenuButton};
|
||||
|
||||
pub struct Menu {
|
||||
widget: widget::Menu,
|
||||
widget: MenuButton,
|
||||
}
|
||||
|
||||
impl Menu {
|
||||
pub fn new() -> Menu {
|
||||
Self {
|
||||
widget: widget::Menu::new(model::Menu::new().model()),
|
||||
}
|
||||
// Init 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
|
||||
pub fn widget(&self) -> &widget::Menu {
|
||||
pub fn widget(&self) -> &MenuButton {
|
||||
&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 tab;
|
||||
mod widget;
|
||||
|
||||
use gtk::prelude::BoxExt;
|
||||
use gtk::{Box, Orientation};
|
||||
use menu::Menu;
|
||||
use tab::Tab;
|
||||
|
||||
pub struct Tray {
|
||||
widget: widget::Tray,
|
||||
widget: Box,
|
||||
}
|
||||
|
||||
impl Tray {
|
||||
pub fn new() -> Tray {
|
||||
Self {
|
||||
widget: widget::Tray::new(
|
||||
menu::Menu::new().widget().gtk(),
|
||||
tab::Tab::new().widget().gtk(),
|
||||
),
|
||||
}
|
||||
let menu = Menu::new();
|
||||
let tab = Tab::new();
|
||||
|
||||
let widget = Box::builder()
|
||||
.orientation(Orientation::Horizontal)
|
||||
.spacing(8)
|
||||
.build();
|
||||
|
||||
widget.append(menu.widget());
|
||||
widget.append(tab.widget());
|
||||
|
||||
Self { widget }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Tray {
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,23 @@
|
||||
mod widget;
|
||||
use gtk::Button;
|
||||
|
||||
pub struct Tab {
|
||||
pub widget: widget::Tab,
|
||||
pub widget: Button,
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
// Construct
|
||||
pub fn new() -> Tab {
|
||||
Self {
|
||||
widget: widget::Tab::new(),
|
||||
widget: Button::builder()
|
||||
.action_name("win.tab_append")
|
||||
.icon_name("tab-new-symbolic")
|
||||
.tooltip_text("New tab")
|
||||
.build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Tab {
|
||||
pub fn widget(&self) -> &Button {
|
||||
&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 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
|
||||
}
|
||||
}
|
@ -1,46 +1,46 @@
|
||||
mod db;
|
||||
mod header;
|
||||
mod main;
|
||||
mod widget;
|
||||
|
||||
use gtk::gio::ActionEntry;
|
||||
use gtk::prelude::{ActionMapExtManual, GtkWindowExt};
|
||||
use gtk::{Application, ApplicationWindow};
|
||||
use std::sync::Arc;
|
||||
|
||||
use gtk::prelude::{ActionMapExtManual, GtkWindowExt};
|
||||
|
||||
pub struct Browser {
|
||||
// Extras
|
||||
db: db::Browser,
|
||||
widget: widget::Browser,
|
||||
// db: db::Browser,
|
||||
widget: ApplicationWindow,
|
||||
// Components
|
||||
header: Arc<header::Header>,
|
||||
main: Arc<main::Main>,
|
||||
// header: Arc<header::Header>,
|
||||
// main: main::Main,
|
||||
}
|
||||
|
||||
impl Browser {
|
||||
// Construct
|
||||
pub fn new(
|
||||
app: &Application,
|
||||
connection: Arc<sqlite::Connection>,
|
||||
// connection: Arc<sqlite::Connection>,
|
||||
default_width: i32,
|
||||
default_height: i32,
|
||||
) -> Arc<Browser> {
|
||||
) -> Browser {
|
||||
// Init components
|
||||
let db = db::Browser::new(connection);
|
||||
// let db = db::Browser::new(connection);
|
||||
let header = header::Header::new();
|
||||
let main = main::Main::new();
|
||||
|
||||
let widget = widget::Browser::new(
|
||||
app,
|
||||
header.widget().gtk(),
|
||||
main.widget().gtk(),
|
||||
default_width,
|
||||
default_height,
|
||||
);
|
||||
let widget = ApplicationWindow::builder()
|
||||
.application(app)
|
||||
.default_width(default_width)
|
||||
.default_height(default_height)
|
||||
.titlebar(header.widget())
|
||||
.child(main.widget())
|
||||
.build();
|
||||
|
||||
// Init actions @TODO separated module
|
||||
widget.window().add_action_entries([
|
||||
// Init actions
|
||||
let main_ref = Arc::new(main); // @TODO
|
||||
|
||||
widget.add_action_entries([
|
||||
ActionEntry::builder("debug")
|
||||
.activate(|this: &ApplicationWindow, _, _| {
|
||||
this.emit_enable_debugging(true);
|
||||
@ -53,7 +53,7 @@ impl Browser {
|
||||
.build(),
|
||||
ActionEntry::builder("tab_append")
|
||||
.activate({
|
||||
let main = main.clone();
|
||||
let main = main_ref.clone();
|
||||
move |_, _, _| {
|
||||
main.tab_append();
|
||||
}
|
||||
@ -61,7 +61,7 @@ impl Browser {
|
||||
.build(),
|
||||
ActionEntry::builder("tab_close")
|
||||
.activate({
|
||||
let main = main.clone();
|
||||
let main = main_ref.clone();
|
||||
move |_, _, _| {
|
||||
main.tab_close();
|
||||
}
|
||||
@ -69,7 +69,7 @@ impl Browser {
|
||||
.build(),
|
||||
ActionEntry::builder("tab_close_all")
|
||||
.activate({
|
||||
let main = main.clone();
|
||||
let main = main_ref.clone();
|
||||
move |_, _, _| {
|
||||
main.tab_close_all();
|
||||
}
|
||||
@ -77,7 +77,7 @@ impl Browser {
|
||||
.build(),
|
||||
ActionEntry::builder("tab_pin")
|
||||
.activate({
|
||||
let main = main.clone();
|
||||
let main = main_ref.clone();
|
||||
move |_, _, _| {
|
||||
main.tab_pin();
|
||||
}
|
||||
@ -86,16 +86,16 @@ impl Browser {
|
||||
]);
|
||||
|
||||
// Return
|
||||
Arc::new(Self {
|
||||
db,
|
||||
Self {
|
||||
// db,
|
||||
widget,
|
||||
header,
|
||||
main,
|
||||
})
|
||||
// header,
|
||||
// main,
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Browser {
|
||||
pub fn widget(&self) -> &ApplicationWindow {
|
||||
&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;
|
||||
|
||||
use std::fs;
|
||||
use std::sync::Arc;
|
||||
|
||||
use gtk::prelude::{ApplicationExt, ApplicationExtManual, GtkApplicationExt, GtkWindowExt};
|
||||
|
||||
@ -32,6 +31,7 @@ fn main() -> glib::ExitCode {
|
||||
}
|
||||
|
||||
// Init profile database
|
||||
/* @TODO
|
||||
let mut db = fs.clone();
|
||||
|
||||
db.push("database.sqlite3");
|
||||
@ -39,12 +39,11 @@ fn main() -> glib::ExitCode {
|
||||
let db = match sqlite::open(db) {
|
||||
Ok(db) => Arc::new(db),
|
||||
Err(e) => panic!("Failed to connect profile database: {e}"),
|
||||
};
|
||||
};*/
|
||||
|
||||
move |this: &Application| {
|
||||
browser::Browser::new(this, db.clone(), 640, 480)
|
||||
browser::Browser::new(this, /*db.clone(),*/ 640, 480)
|
||||
.widget()
|
||||
.window()
|
||||
.present();
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user