1
0
mirror of https://github.com/YGGverse/Yoda.git synced 2025-03-13 06:01:21 +00:00

just page request features

This commit is contained in:
yggverse 2024-10-16 08:10:31 +03:00
parent 2da322a47e
commit e865221598
10 changed files with 226 additions and 0 deletions
src/app/browser/window/tab/item

@ -2,11 +2,13 @@ mod content;
mod database;
mod meta;
mod navigation;
mod request;
mod widget;
use content::Content;
use database::Database;
use navigation::Navigation;
use request::Request;
use widget::Widget;
use meta::{Meta, Mime, Status};
@ -72,11 +74,14 @@ impl Page {
action_update.clone(),
);
let request = Request::new_arc();
let widget = Widget::new_arc(
&id,
action_page_open.clone(),
navigation.gobject(),
content.gobject(),
request.gobject(),
);
// Init async mutable Meta object

@ -0,0 +1,30 @@
mod content;
mod widget;
use content::Content;
use widget::Widget;
use adw::ToolbarView;
use std::sync::Arc;
pub struct Request {
widget: Arc<Widget>,
}
impl Request {
pub fn new_arc() -> Arc<Self> {
// Init components
let content = Content::new_arc();
// Init widget
let widget = Widget::new_arc(content.gobject());
// Result
Arc::new(Self { widget })
}
// Getters
pub fn gobject(&self) -> &ToolbarView {
&self.widget.gobject()
}
}

@ -0,0 +1,38 @@
mod response;
mod send;
mod widget;
use response::Response;
use send::Send;
use widget::Widget;
use gtk::Box;
use std::sync::Arc;
pub struct Content {
widget: Arc<Widget>,
}
impl Content {
pub fn new_arc() -> Arc<Self> {
// Init components
let response = Response::new_arc();
let send = Send::new_arc();
// Init widget
let widget = Widget::new_arc(response.gobject(), send.gobject());
// Init events
/* @TODO
response.gobject().connect_activate(|_| {});
send.gobject().connect_clicked(|_| {}); */
// Return activated struct
Arc::new(Self { widget })
}
// Getters
pub fn gobject(&self) -> &Box {
&self.widget.gobject()
}
}

@ -0,0 +1,25 @@
mod widget;
use widget::Widget;
use gtk::Entry;
use std::sync::Arc;
pub struct Response {
widget: Arc<Widget>,
}
impl Response {
pub fn new_arc() -> Arc<Self> {
// Init widget
let widget = Widget::new_arc();
// Result
Arc::new(Self { widget })
}
// Getters
pub fn gobject(&self) -> &Entry {
&self.widget.gobject()
}
}

@ -0,0 +1,20 @@
use gtk::Entry;
use std::sync::Arc;
pub struct Widget {
gobject: Entry,
}
impl Widget {
// Construct
pub fn new_arc() -> Arc<Self> {
let gobject = Entry::builder().hexpand(true).build();
Arc::new(Self { gobject })
}
// Getters
pub fn gobject(&self) -> &Entry {
&self.gobject
}
}

@ -0,0 +1,25 @@
mod widget;
use widget::Widget;
use gtk::Button;
use std::sync::Arc;
pub struct Send {
widget: Arc<Widget>,
}
impl Send {
pub fn new_arc() -> Arc<Self> {
// Init widget
let widget = Widget::new_arc();
// Result
Arc::new(Self { widget })
}
// Getters
pub fn gobject(&self) -> &Button {
&self.widget.gobject()
}
}

@ -0,0 +1,23 @@
use gtk::Button;
use std::sync::Arc;
pub struct Widget {
gobject: Button,
}
impl Widget {
// Construct
pub fn new_arc() -> Arc<Self> {
let gobject = Button::builder()
.css_classes(["accent"])
.label("Send")
.build();
Arc::new(Self { gobject })
}
// Getters
pub fn gobject(&self) -> &Button {
&self.gobject
}
}

@ -0,0 +1,33 @@
use gtk::{prelude::BoxExt, Box, Button, Entry, Orientation};
use std::sync::Arc;
const MARGIN: i32 = 6;
const SPACING: i32 = 8;
pub struct Widget {
gobject: Box,
}
impl Widget {
// Construct
pub fn new_arc(response: &Entry, send: &Button) -> Arc<Self> {
let gobject = Box::builder()
.margin_bottom(MARGIN)
.margin_end(MARGIN)
.margin_start(MARGIN)
.margin_top(MARGIN)
.spacing(SPACING)
.orientation(Orientation::Horizontal)
.build();
gobject.append(response);
gobject.append(send);
Arc::new(Self { gobject })
}
// Getters
pub fn gobject(&self) -> &Box {
&self.gobject
}
}

@ -0,0 +1,24 @@
use adw::ToolbarView;
use gtk::Box;
use std::sync::Arc;
pub struct Widget {
gobject: ToolbarView,
}
impl Widget {
// Construct
pub fn new_arc(content: &Box) -> Arc<Self> {
let gobject = ToolbarView::builder()
.content(content)
.visible(false)
.build();
Arc::new(Self { gobject })
}
// Getters
pub fn gobject(&self) -> &ToolbarView {
&self.gobject
}
}

@ -1,3 +1,4 @@
use adw::ToolbarView;
use gtk::{
gio::{SimpleAction, SimpleActionGroup},
glib::uuid_string_random,
@ -19,6 +20,7 @@ impl Widget {
// Components
navigation: &Box,
content: &Box,
request: &ToolbarView,
) -> Arc<Self> {
// Init additional action group
let action_group = SimpleActionGroup::new();
@ -32,6 +34,7 @@ impl Widget {
gobject.append(navigation);
gobject.append(content);
gobject.append(request);
gobject.insert_action_group(&uuid_string_random(), Some(&action_group));