From a5c0a4bdd08a11eea94c5b4e45179cfa30a1e90a Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 3 Dec 2024 19:29:14 +0200 Subject: [PATCH] update ggemtext api version --- src/app/browser/window/tab/item/page.rs | 8 ++++---- src/app/browser/window/tab/item/page/content/text.rs | 7 ++----- .../tab/item/page/content/text/gemini/reader.rs | 12 ++++++------ 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs index 2fb829f2..499023a0 100644 --- a/src/app/browser/window/tab/item/page.rs +++ b/src/app/browser/window/tab/item/page.rs @@ -866,12 +866,12 @@ pub fn migrate(tx: &Transaction) -> Result<(), String> { /// Useful as common placeholder when page title could not be detected /// /// * this feature may be improved and moved outside @TODO -fn uri_to_title(uri: &Uri) -> GString { - let title = GString::from(uri.path().split('/').last().unwrap_or_default()); +fn uri_to_title(uri: &Uri) -> String { + let title = uri.path().split('/').last().unwrap_or_default().to_string(); if title.is_empty() { match uri.host() { - Some(host) => gformat!("{host}"), - None => gformat!("Untitled"), + Some(host) => host.to_string(), + None => "Untitled".to_string(), } } else { title diff --git a/src/app/browser/window/tab/item/page/content/text.rs b/src/app/browser/window/tab/item/page/content/text.rs index 3d149575..7de7ca24 100644 --- a/src/app/browser/window/tab/item/page/content/text.rs +++ b/src/app/browser/window/tab/item/page/content/text.rs @@ -3,14 +3,11 @@ mod gemini; use gemini::Gemini; use crate::app::browser::window::{tab::item::Action as TabAction, Action as WindowAction}; -use gtk::{ - glib::{GString, Uri}, - ScrolledWindow, -}; +use gtk::{glib::Uri, ScrolledWindow}; use std::rc::Rc; pub struct Meta { - pub title: Option, + pub title: Option, } // @TODO move to separated mod pub struct Text { 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 32a5f9e1..fc267997 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 @@ -13,7 +13,7 @@ use crate::app::browser::window::{ }; use adw::StyleManager; use gemtext::line::{ - code::Code, + code::{Inline, Multiline}, header::{Header, Level}, link::Link, list::List, @@ -22,7 +22,7 @@ use gemtext::line::{ use gtk::{ gdk::{BUTTON_MIDDLE, BUTTON_PRIMARY}, gio::Cancellable, - glib::{GString, TimeZone, Uri}, + glib::{TimeZone, Uri}, prelude::{TextBufferExt, TextBufferExtManual, TextViewExt, WidgetExt}, EventControllerMotion, GestureClick, TextBuffer, TextTag, TextWindowType, UriLauncher, Window, WrapMode, @@ -35,7 +35,7 @@ pub const LIST_ITEM: &str = "•"; pub const NEW_LINE: &str = "\n"; pub struct Reader { - pub title: Option, + pub title: Option, pub widget: Rc, } @@ -67,7 +67,7 @@ impl Reader { // Parse gemtext lines for line in gemtext.lines() { // Is inline code - if let Some(code) = Code::inline_from(line) { + if let Some(code) = Inline::from(line) { // Append value to buffer match syntax.highlight(&code.value, &tag.code.text_tag, None) { Ok(highlight) => { @@ -104,7 +104,7 @@ impl Reader { match multiline { None => { // Open tag found - if let Some(code) = Code::multiline_begin_from(line) { + if let Some(code) = Multiline::begin_from(line) { // Begin next lines collection into the code buffer multiline = Some(code); @@ -113,7 +113,7 @@ impl Reader { } } Some(ref mut this) => { - match Code::multiline_continue_from(this, line) { + match Multiline::continue_from(this, line) { Ok(()) => { // Close tag found: if this.completed {