mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 09:10:08 +00:00
use box container for text content
This commit is contained in:
parent
6150386856
commit
2a3e4048ff
@ -127,14 +127,14 @@ impl Content {
|
|||||||
base,
|
base,
|
||||||
(self.window_action.clone(), self.tab_action.clone()),
|
(self.window_action.clone(), self.tab_action.clone()),
|
||||||
);
|
);
|
||||||
self.g_box.append(&text.scrolled_window);
|
self.g_box.append(&text.g_box);
|
||||||
text
|
text
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_text_source(&self, data: &str) -> Text {
|
pub fn to_text_source(&self, data: &str) -> Text {
|
||||||
self.clean();
|
self.clean();
|
||||||
let text = Text::new_source(data);
|
let text = Text::new_source(data);
|
||||||
self.g_box.append(&text.scrolled_window);
|
self.g_box.append(&text.g_box);
|
||||||
text
|
text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use gemini::Gemini;
|
|||||||
use source::Source;
|
use source::Source;
|
||||||
|
|
||||||
use crate::app::browser::window::{tab::item::Action as TabAction, Action as WindowAction};
|
use crate::app::browser::window::{tab::item::Action as TabAction, Action as WindowAction};
|
||||||
use gtk::{glib::Uri, ScrolledWindow};
|
use gtk::{glib::Uri, prelude::BoxExt, Box, Orientation, ScrolledWindow};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Meta {
|
pub struct Meta {
|
||||||
@ -14,7 +14,7 @@ pub struct Meta {
|
|||||||
|
|
||||||
pub struct Text {
|
pub struct Text {
|
||||||
pub meta: Meta,
|
pub meta: Meta,
|
||||||
pub scrolled_window: ScrolledWindow,
|
pub g_box: Box,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Text {
|
impl Text {
|
||||||
@ -25,32 +25,37 @@ impl Text {
|
|||||||
base: &Uri,
|
base: &Uri,
|
||||||
actions: (Rc<WindowAction>, Rc<TabAction>),
|
actions: (Rc<WindowAction>, Rc<TabAction>),
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Init widget driver
|
// Init components
|
||||||
let gemini = Gemini::new(gemtext, base, actions);
|
let gemini = Gemini::new(gemtext, base, actions);
|
||||||
|
|
||||||
// Init scrolled container
|
// Init main widget
|
||||||
let scrolled_window = ScrolledWindow::builder().build();
|
let g_box = Box::builder().orientation(Orientation::Vertical).build();
|
||||||
|
g_box.append(
|
||||||
|
&ScrolledWindow::builder()
|
||||||
|
.child(&gemini.widget.clamp_scrollable)
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
|
||||||
scrolled_window.set_child(Some(&gemini.widget.clamp_scrollable));
|
|
||||||
|
|
||||||
// Result
|
|
||||||
Self {
|
Self {
|
||||||
meta: Meta {
|
meta: Meta {
|
||||||
title: gemini.reader.title.clone(),
|
title: gemini.reader.title.clone(),
|
||||||
},
|
},
|
||||||
scrolled_window,
|
g_box,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_source(data: &str) -> Self {
|
pub fn new_source(data: &str) -> Self {
|
||||||
// Init scrolled container
|
let g_box = Box::builder().orientation(Orientation::Vertical).build();
|
||||||
let scrolled_window = ScrolledWindow::builder().build();
|
|
||||||
scrolled_window.set_child(Some(&Source::new(data).text_view));
|
g_box.append(
|
||||||
|
&ScrolledWindow::builder()
|
||||||
|
.child(&Source::new(data).text_view)
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
|
||||||
// Result
|
|
||||||
Self {
|
Self {
|
||||||
meta: Meta { title: None },
|
meta: Meta { title: None },
|
||||||
scrolled_window,
|
g_box,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user