remove extra widget mod

This commit is contained in:
yggverse 2025-01-27 16:09:23 +02:00
parent ff824846e5
commit 1c98178f67
3 changed files with 20 additions and 55 deletions

View file

@ -58,7 +58,7 @@ impl Page {
let input = Rc::new(Input::new()); let input = Rc::new(Input::new());
let widget = Rc::new(Widget::build( let widget = Rc::new(Widget::build(
&navigation.widget.g_box, &navigation.g_box,
&content.g_box, &content.g_box,
&search.g_box, &search.g_box,
&input.clamp, &input.clamp,

View file

@ -4,18 +4,19 @@ mod history;
mod home; mod home;
mod reload; mod reload;
mod request; mod request;
mod widget;
use super::{ItemAction, Profile, TabAction, WindowAction}; use super::{ItemAction, Profile, TabAction, WindowAction};
use bookmark::Bookmark; use bookmark::Bookmark;
use gtk::{Box, Button}; use gtk::{prelude::BoxExt, Box, Button, Orientation};
use history::History; use history::History;
use home::Home; use home::Home;
use reload::Reload; use reload::Reload;
use request::Request; use request::Request;
use sqlite::Transaction; use sqlite::Transaction;
use std::rc::Rc; use std::rc::Rc;
use widget::Widget;
const MARGIN: i32 = 6;
const SPACING: i32 = 6;
pub struct Navigation { pub struct Navigation {
pub profile: Rc<Profile>, pub profile: Rc<Profile>,
@ -23,7 +24,7 @@ pub struct Navigation {
pub reload: Button, pub reload: Button,
pub bookmark: Button, pub bookmark: Button,
pub request: Rc<Request>, pub request: Rc<Request>,
pub widget: Rc<Widget>, pub g_box: Box,
} }
impl Navigation { impl Navigation {
@ -43,23 +44,27 @@ impl Navigation {
let home = Button::home((window_action, tab_action, item_action), &request); let home = Button::home((window_action, tab_action, item_action), &request);
let bookmark = Button::bookmark(window_action, profile, &request); let bookmark = Button::bookmark(window_action, profile, &request);
// init main widget let g_box = Box::builder()
let widget = Rc::new(Widget::build( .orientation(Orientation::Horizontal)
&home, .spacing(SPACING)
&history, .margin_start(MARGIN)
&reload, .margin_end(MARGIN)
&request.entry, // @TODO .margin_bottom(MARGIN)
&bookmark, .build();
));
g_box.append(&home);
g_box.append(&history);
g_box.append(&reload);
g_box.append(&request.entry); // @TODO
g_box.append(&bookmark);
// done
Self { Self {
profile: profile.clone(), profile: profile.clone(),
home, home,
request, request,
reload, reload,
bookmark, bookmark,
widget, g_box,
} }
} }

View file

@ -1,40 +0,0 @@
use gtk::{
prelude::{BoxExt, IsA},
Box, Orientation,
};
const MARGIN: i32 = 6;
const SPACING: i32 = 6;
pub struct Widget {
pub g_box: Box,
}
impl Widget {
// Constructors
/// Build new `Self`
pub fn build(
base: &impl IsA<gtk::Widget>,
history: &impl IsA<gtk::Widget>,
reload: &impl IsA<gtk::Widget>,
request: &impl IsA<gtk::Widget>,
bookmark: &impl IsA<gtk::Widget>,
) -> Self {
let g_box = Box::builder()
.orientation(Orientation::Horizontal)
.spacing(SPACING)
.margin_start(MARGIN)
.margin_end(MARGIN)
.margin_bottom(MARGIN)
.build();
g_box.append(base);
g_box.append(history);
g_box.append(reload);
g_box.append(request);
g_box.append(bookmark);
Self { g_box }
}
}