rename actions

This commit is contained in:
yggverse 2024-11-01 00:17:36 +02:00
parent b2237879be
commit 7da4d617da
2 changed files with 18 additions and 18 deletions

View File

@ -189,7 +189,7 @@ impl Page {
let description = gformat!("Protocol `{scheme}` not supported"); let description = gformat!("Protocol `{scheme}` not supported");
// Update widget // Update widget
self.content.set_status_failure( self.content.to_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(description.as_str()), Some(description.as_str()),
None, None,
@ -495,7 +495,7 @@ impl Page {
match result { match result {
Ok(buffer) => { Ok(buffer) => {
// Set children component // Set children component
let text_gemini = content.set_text_gemini( let text_gemini = content.to_text_gemini(
&uri, &uri,
&buffer.data() &buffer.data()
); );
@ -524,7 +524,7 @@ impl Page {
}; };
// Update widget // Update widget
content.set_status_failure( content.to_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(description.as_str()), Some(description.as_str()),
None None
@ -550,7 +550,7 @@ impl Page {
gemini::client::response::meta::Mime::ImageWebp gemini::client::response::meta::Mime::ImageWebp
=> { => {
// Final image size unknown, show loading widget // Final image size unknown, show loading widget
let status = content.set_status_loading( let status = content.to_status_loading(
Some(&"Loading.."), Some(&"Loading.."),
None, None,
Some(Duration::from_secs(1)) // show if download time > 1 second Some(Duration::from_secs(1)) // show if download time > 1 second
@ -583,7 +583,7 @@ impl Page {
meta.borrow_mut().title = Some(uri_to_title(&uri)); meta.borrow_mut().title = Some(uri_to_title(&uri));
// Update page content // Update page content
content.set_image(&buffer); content.to_image(&buffer);
// Update window components // Update window components
action_update.activate(Some(&id)); action_update.activate(Some(&id));
@ -594,7 +594,7 @@ impl Page {
let title = gformat!("Oops"); let title = gformat!("Oops");
// Update widget // Update widget
content.set_status_failure( content.to_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(reason.message()), Some(reason.message()),
None None
@ -623,7 +623,7 @@ impl Page {
}; };
// Update widget // Update widget
content.set_status_failure( content.to_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(description.as_str()), Some(description.as_str()),
None None
@ -648,7 +648,7 @@ impl Page {
meta.borrow_mut().title = Some(gformat!("Stream")); meta.borrow_mut().title = Some(gformat!("Stream"));
// Update page content // Update page content
// content.set_stream(); // content.to_stream();
// Update window components // Update window components
action_update.activate(Some(&id)); action_update.activate(Some(&id));
@ -660,7 +660,7 @@ impl Page {
let description = gformat!("Content type not supported"); let description = gformat!("Content type not supported");
// Update widget // Update widget
content.set_status_failure( content.to_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(description.as_str()), Some(description.as_str()),
None None
@ -690,13 +690,13 @@ impl Page {
// Build gemtext message for manual redirection @TODO use template? // Build gemtext message for manual redirection @TODO use template?
match response.data().value() { match response.data().value() {
Some(url) => { Some(url) => {
content.set_text_gemini( content.to_text_gemini(
&uri, &uri,
&gformat!("# Redirect\n\nAuto-follow not implemented, click on link below to continue\n\n=> {url}") &gformat!("# Redirect\n\nAuto-follow not implemented, click on link below to continue\n\n=> {url}")
); );
}, },
None => { None => {
content.set_status_failure( content.to_status_failure(
Some(&"Oops"), Some(&"Oops"),
Some(&"Could not parse redirect meta"), Some(&"Could not parse redirect meta"),
None None
@ -760,7 +760,7 @@ impl Page {
}; };
// Update widget // Update widget
content.set_status_failure( content.to_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(description.as_str()), Some(description.as_str()),
None None
@ -785,7 +785,7 @@ impl Page {
let title = gformat!("Oops"); let title = gformat!("Oops");
// Update widget // Update widget
content.set_status_failure( content.to_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(reason.message()), Some(reason.message()),
None None
@ -809,7 +809,7 @@ impl Page {
let title = gformat!("Oops"); let title = gformat!("Oops");
// Update widget // Update widget
content.set_status_failure( content.to_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(reason.message()), Some(reason.message()),
None None

View File

@ -40,7 +40,7 @@ impl Content {
/// Set new `content::Image` component for `Self` /// Set new `content::Image` component for `Self`
/// ///
/// * action removes previous children component from `Self` /// * action removes previous children component from `Self`
pub fn set_image(&self, buffer: &Pixbuf) -> Image { pub fn to_image(&self, buffer: &Pixbuf) -> Image {
self.clean(); self.clean();
let image = Image::new_from_pixbuf(buffer); let image = Image::new_from_pixbuf(buffer);
self.gobject.append(image.gobject()); self.gobject.append(image.gobject());
@ -50,7 +50,7 @@ impl Content {
/// Set new `content::Status` component for `Self` with new `status::Failure` preset /// Set new `content::Status` component for `Self` with new `status::Failure` preset
/// ///
/// * action removes previous children component from `Self` /// * action removes previous children component from `Self`
pub fn set_status_failure( pub fn to_status_failure(
&self, &self,
title: Option<&str>, title: Option<&str>,
description: Option<&str>, description: Option<&str>,
@ -65,7 +65,7 @@ impl Content {
/// Set new `content::Status` component for `Self` with new `status::Loading` preset /// Set new `content::Status` component for `Self` with new `status::Loading` preset
/// ///
/// * action removes previous children component from `Self` /// * action removes previous children component from `Self`
pub fn set_status_loading( pub fn to_status_loading(
&self, &self,
title: Option<&str>, title: Option<&str>,
description: Option<&str>, description: Option<&str>,
@ -92,7 +92,7 @@ impl Content {
/// ///
/// `Text` component with it public API /// `Text` component with it public API
/// * could be useful to extract document title parsed from Gemtext /// * could be useful to extract document title parsed from Gemtext
pub fn set_text_gemini(&self, base: &Uri, data: &str) -> Text { pub fn to_text_gemini(&self, base: &Uri, data: &str) -> Text {
self.clean(); self.clean();
let text = Text::gemini( let text = Text::gemini(
data, data,