diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs index e3b417ad..85cf9df4 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs @@ -141,7 +141,7 @@ impl Reader { buffer.insert_with_tags( &mut buffer.end_iter(), alt.as_str(), - &[&tag.title.text_tag], + &[&tag.title], ); // Append new line after alt text @@ -206,9 +206,9 @@ impl Reader { &mut buffer.end_iter(), header.value.as_str(), &[match header.level { - Level::H1 => &tag.h1.text_tag, - Level::H2 => &tag.h2.text_tag, - Level::H3 => &tag.h3.text_tag, + Level::H1 => &tag.h1, + Level::H2 => &tag.h2, + Level::H3 => &tag.h3, }], ); buffer.insert(&mut buffer.end_iter(), NEW_LINE); @@ -278,7 +278,7 @@ impl Reader { buffer.insert_with_tags( &mut buffer.end_iter(), format!("{LIST_ITEM} {}", list.value).as_str(), - &[&tag.list.text_tag], + &[&tag.list], ); buffer.insert(&mut buffer.end_iter(), NEW_LINE); @@ -292,7 +292,7 @@ impl Reader { buffer.insert_with_tags( &mut buffer.end_iter(), quote.value.as_str(), - &[&tag.quote.text_tag], + &[&tag.quote], ); buffer.insert(&mut buffer.end_iter(), NEW_LINE); @@ -302,7 +302,7 @@ impl Reader { // Nothing match custom tags above, // just append plain text covered in empty tag (to handle controller events properly) - buffer.insert_with_tags(&mut buffer.end_iter(), line, &[&tag.plain.text_tag]); + buffer.insert_with_tags(&mut buffer.end_iter(), line, &[&tag.plain]); buffer.insert(&mut buffer.end_iter(), NEW_LINE); } diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag.rs index a9e31579..ccf50864 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag.rs @@ -6,50 +6,42 @@ mod plain; mod quote; mod title; -use h1::H1; -use h2::H2; -use h3::H3; -use list::List; -use plain::Plain; -use quote::Quote; -use title::Title; - -use gtk::TextTagTable; +use gtk::{TextTag, TextTagTable}; pub struct Tag { pub text_tag_table: TextTagTable, // Tags - pub h1: H1, - pub h2: H2, - pub h3: H3, - pub list: List, - pub quote: Quote, - pub title: Title, - pub plain: Plain, + pub h1: TextTag, + pub h2: TextTag, + pub h3: TextTag, + pub list: TextTag, + pub quote: TextTag, + pub title: TextTag, + pub plain: TextTag, } impl Tag { // Construct pub fn new() -> Self { // Init components - let h1 = H1::new(); - let h2 = H2::new(); - let h3 = H3::new(); - let list = List::new(); - let quote = Quote::new(); - let title = Title::new(); - let plain = Plain::new(); + let h1 = h1::new(); + let h2 = h2::new(); + let h3 = h3::new(); + let list = list::new(); + let quote = quote::new(); + let title = title::new(); + let plain = plain::new(); // Init tag table let text_tag_table = TextTagTable::new(); - text_tag_table.add(&h1.text_tag); - text_tag_table.add(&h2.text_tag); - text_tag_table.add(&h3.text_tag); - text_tag_table.add(&title.text_tag); - text_tag_table.add(&list.text_tag); - text_tag_table.add("e.text_tag); - text_tag_table.add(&plain.text_tag); + text_tag_table.add(&h1); + text_tag_table.add(&h2); + text_tag_table.add(&h3); + text_tag_table.add(&title); + text_tag_table.add(&list); + text_tag_table.add("e); + text_tag_table.add(&plain); Self { text_tag_table, diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/h1.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/h1.rs index 9cc5fc23..a11f3747 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/h1.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/h1.rs @@ -1,19 +1,10 @@ use gtk::{TextTag, WrapMode}; -pub struct H1 { - pub text_tag: TextTag, -} - -impl H1 { - // Construct - pub fn new() -> Self { - Self { - text_tag: TextTag::builder() - .scale(1.6) - .sentence(true) - .weight(500) - .wrap_mode(WrapMode::Word) - .build(), - } - } +pub fn new() -> TextTag { + TextTag::builder() + .scale(1.6) + .sentence(true) + .weight(500) + .wrap_mode(WrapMode::Word) + .build() } diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/h2.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/h2.rs index bc1b6f19..474c0286 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/h2.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/h2.rs @@ -1,19 +1,10 @@ use gtk::{TextTag, WrapMode}; -pub struct H2 { - pub text_tag: TextTag, -} - -impl H2 { - // Construct - pub fn new() -> Self { - Self { - text_tag: TextTag::builder() - .scale(1.4) - .sentence(true) - .weight(400) - .wrap_mode(WrapMode::Word) - .build(), - } - } +pub fn new() -> TextTag { + TextTag::builder() + .scale(1.4) + .sentence(true) + .weight(400) + .wrap_mode(WrapMode::Word) + .build() } diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/h3.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/h3.rs index 5a5697c0..745d5ada 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/h3.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/h3.rs @@ -1,19 +1,10 @@ use gtk::{TextTag, WrapMode}; -pub struct H3 { - pub text_tag: TextTag, -} - -impl H3 { - // Construct - pub fn new() -> Self { - Self { - text_tag: TextTag::builder() - .scale(1.2) - .sentence(true) - .weight(400) - .wrap_mode(WrapMode::Word) - .build(), - } - } +pub fn new() -> TextTag { + TextTag::builder() + .scale(1.2) + .sentence(true) + .weight(400) + .wrap_mode(WrapMode::Word) + .build() } diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/list.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/list.rs index 3b2a4253..ca1b0eb4 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/list.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/list.rs @@ -1,19 +1,10 @@ use gtk::{TextTag, WrapMode}; -pub struct List { - pub text_tag: TextTag, -} - -impl List { - // Construct - pub fn new() -> Self { - Self { - text_tag: TextTag::builder() - .left_margin(28) - .pixels_above_lines(4) - .pixels_below_lines(4) - .wrap_mode(WrapMode::Word) - .build(), - } - } +pub fn new() -> TextTag { + TextTag::builder() + .left_margin(28) + .pixels_above_lines(4) + .pixels_below_lines(4) + .wrap_mode(WrapMode::Word) + .build() } diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/plain.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/plain.rs index 01be2a8d..c42a57f8 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/plain.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/plain.rs @@ -1,14 +1,5 @@ use gtk::{TextTag, WrapMode}; -pub struct Plain { - pub text_tag: TextTag, -} - -impl Plain { - // Construct - pub fn new() -> Self { - Self { - text_tag: TextTag::builder().wrap_mode(WrapMode::Word).build(), - } - } +pub fn new() -> TextTag { + TextTag::builder().wrap_mode(WrapMode::Word).build() } diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/quote.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/quote.rs index c0df0b57..3a151443 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/quote.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/quote.rs @@ -1,17 +1,8 @@ use gtk::{pango::Style, TextTag, WrapMode}; -pub struct Quote { - pub text_tag: TextTag, -} - -impl Quote { - // Construct - pub fn new() -> Self { - Self { - text_tag: TextTag::builder() - .style(Style::Italic) - .wrap_mode(WrapMode::Word) - .build(), - } - } +pub fn new() -> TextTag { + TextTag::builder() + .style(Style::Italic) + .wrap_mode(WrapMode::Word) + .build() } diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/title.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/title.rs index 305f92cb..89fd0719 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/title.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader/tag/title.rs @@ -1,19 +1,10 @@ use gtk::{TextTag, WrapMode}; -pub struct Title { - pub text_tag: TextTag, -} - -impl Title { - // Construct - pub fn new() -> Self { - Self { - text_tag: TextTag::builder() - .pixels_above_lines(4) - .pixels_below_lines(8) - .weight(500) - .wrap_mode(WrapMode::None) - .build(), - } - } +pub fn new() -> TextTag { + TextTag::builder() + .pixels_above_lines(4) + .pixels_below_lines(8) + .weight(500) + .wrap_mode(WrapMode::None) + .build() }