update indication icon on page handle

This commit is contained in:
yggverse 2025-03-23 04:26:28 +02:00
parent abb9de617d
commit 556a1eba89
2 changed files with 46 additions and 54 deletions

View file

@ -180,10 +180,13 @@ fn handle(
/// * includes commit action! /// * includes commit action!
fn update_page_info(page: &Page, event_name: &str) { fn update_page_info(page: &Page, event_name: &str) {
let mut i = page.navigation.request.info.borrow_mut(); let mut i = page.navigation.request.info.borrow_mut();
i.add_event(event_name.to_string()) i
.add_event(event_name.to_string())
.unset_mime() .unset_mime()
.unset_size() .unset_size()
.commit() .commit();
page.navigation.request.update_secondary_icon(&i)
} }
// Update socket info at the point, where the connection is active yet // Update socket info at the point, where the connection is active yet
// * also, actualize `request` as same everywhere below // * also, actualize `request` as same everywhere below
@ -349,6 +352,7 @@ fn handle(
i i
.add_event(EVENT_COMPLETED.to_string()) .add_event(EVENT_COMPLETED.to_string())
.commit(); .commit();
page.navigation.request.update_secondary_icon(&i)
}, },
Err(e) => { Err(e) => {
let s = page.content.to_status_failure(); let s = page.content.to_status_failure();
@ -420,27 +424,19 @@ fn handle(
Ok(buffer) => { Ok(buffer) => {
page.set_title(&crate::tool::uri_to_title(&uri)); page.set_title(&crate::tool::uri_to_title(&uri));
page.content.to_image(&Texture::for_pixbuf(&buffer)); page.content.to_image(&Texture::for_pixbuf(&buffer));
{
let mut i = page.navigation.request.info.borrow_mut(); let mut i = page.navigation.request.info.borrow_mut();
i i
.add_event(EVENT_COMPLETED.to_string()) .add_event(EVENT_COMPLETED.to_string())
.set_mime(Some(success.mime().to_string())) .set_mime(Some(success.mime().to_string()))
.set_size(None, Some(buffer.byte_length())) .set_size(None, Some(buffer.byte_length()))
.commit(); .commit();
} page.navigation.request.update_secondary_icon(&i)
} }
Err(e) => { Err(e) => {
let s = page.content.to_status_failure(); let s = page.content.to_status_failure();
s.set_description(Some(e.message())); s.set_description(Some(e.message()));
page.set_title(&s.title()); page.set_title(&s.title());
{ update_page_info(&page, EVENT_COMPLETED);
let mut i = page.navigation.request.info.borrow_mut();
i
.add_event(EVENT_COMPLETED.to_string())
.set_mime(Some(success.mime().to_string()))
.unset_size()
.commit();
}
} }
} }
page.set_progress(0.0); page.set_progress(0.0);
@ -460,14 +456,7 @@ fn handle(
page.snap_history(); page.snap_history();
} }
redirects.replace(0); // reset redirects.replace(0); // reset
{ update_page_info(&page, EVENT_COMPLETED);
let mut i = page.navigation.request.info.borrow_mut();
i
.add_event(EVENT_COMPLETED.to_string())
.set_mime(Some(success.mime().to_string()))
.unset_size()
.commit();
}
} }
} }
} }
@ -485,14 +474,13 @@ fn handle(
page.snap_history(); page.snap_history();
} }
redirects.replace(0); // reset redirects.replace(0); // reset
{
let mut i = page.navigation.request.info.borrow_mut(); let mut i = page.navigation.request.info.borrow_mut();
i i
.add_event(EVENT_COMPLETED.to_string()) .add_event(EVENT_COMPLETED.to_string())
.set_mime(Some(mime.to_string())) .set_mime(Some(mime.to_string()))
.unset_size() .unset_size()
.commit(); .commit();
} page.navigation.request.update_secondary_icon(&i)
}, },
} }
}, },
@ -635,14 +623,13 @@ fn handle(
page.snap_history(); page.snap_history();
} }
redirects.replace(0); // reset redirects.replace(0); // reset
{
let mut i = page.navigation.request.info.borrow_mut(); let mut i = page.navigation.request.info.borrow_mut();
i.add_event(EVENT_COMPLETED.to_string()) i.add_event(EVENT_COMPLETED.to_string())
.set_request(Some(uri.to_string())) .set_request(Some(uri.to_string()))
.unset_mime() .unset_mime()
.unset_size() .unset_size()
.commit() .commit();
} page.navigation.request.update_secondary_icon(&i)
} }
} }
}, },

View file

@ -188,22 +188,11 @@ impl Request {
} }
// Actions // Actions
pub fn escape(&self) { pub fn escape(&self) {
self.suggestion.hide() self.suggestion.hide()
} }
/// Try build home [Uri](https://docs.gtk.org/glib/struct.Uri.html) for `Self`
/// * return `None` if current request already match home or Uri not parsable
pub fn home(&self) -> Option<Uri> {
home(&self.entry)
}
/// Try get current request value as [Uri](https://docs.gtk.org/glib/struct.Uri.html)
/// * `strip_prefix` on parse
pub fn uri(&self) -> Option<Uri> {
uri(&self.entry)
}
pub fn show_identity_dialog(&self) { pub fn show_identity_dialog(&self) {
show_identity_dialog(&self.entry, &self.profile) show_identity_dialog(&self.entry, &self.profile)
} }
@ -258,6 +247,10 @@ impl Request {
Ok(()) Ok(())
} }
pub fn update_secondary_icon(&self, info: &Info) {
update_secondary_icon(&self.entry, info);
}
// Setters // Setters
pub fn to_download(&self) { pub fn to_download(&self) {
@ -270,6 +263,18 @@ impl Request {
// Getters // Getters
/// Try build home [Uri](https://docs.gtk.org/glib/struct.Uri.html) for `Self`
/// * return `None` if current request already match home or Uri not parsable
pub fn home(&self) -> Option<Uri> {
home(&self.entry)
}
/// Try get current request value as [Uri](https://docs.gtk.org/glib/struct.Uri.html)
/// * `strip_prefix` on parse
pub fn uri(&self) -> Option<Uri> {
uri(&self.entry)
}
pub fn is_file(&self) -> bool { pub fn is_file(&self) -> bool {
self.entry.text().starts_with("file://") self.entry.text().starts_with("file://")
} }