diff --git a/resources/ui/image_dialog_search_page.ui b/resources/ui/image_dialog_search_page.ui
index 9a23cda1..e8266cdb 100644
--- a/resources/ui/image_dialog_search_page.ui
+++ b/resources/ui/image_dialog_search_page.ui
@@ -38,7 +38,10 @@
diff --git a/src/client/emby_client.rs b/src/client/emby_client.rs
index 420ce7de..88b300b8 100644
--- a/src/client/emby_client.rs
+++ b/src/client/emby_client.rs
@@ -1348,6 +1348,19 @@ impl EmbyClient {
self.post("Items/Delete", ¶ms, json!({})).await
}
+ pub async fn download_remote_images(
+ &self, id: &str, type_: &str, provider_name: &str, image_url: &str,
+ ) -> Result<()> {
+ let path = format!("Items/{}/RemoteImages/Download", id);
+ let params = [
+ ("Type", type_),
+ ("ProviderName", provider_name),
+ ("ImageUrl", image_url),
+ ];
+ self.post(&path, ¶ms, json!({})).await?;
+ Ok(())
+ }
+
pub async fn get_show_missing(
&self, id: &str, include_specials: bool, upcoming: bool,
) -> Result {
diff --git a/src/ui/widgets/identify/search_page.rs b/src/ui/widgets/identify/search_page.rs
index b131b24e..0b606d61 100644
--- a/src/ui/widgets/identify/search_page.rs
+++ b/src/ui/widgets/identify/search_page.rs
@@ -139,12 +139,14 @@ impl IdentifyDialogSearchPage {
#[weak]
check_button,
move |_, _| {
- let id = id.clone();
- let value = value.clone();
let replace = check_button.is_active();
spawn(glib::clone!(
#[weak]
obj,
+ #[strong]
+ id,
+ #[strong]
+ value,
async move {
match spawn_tokio(async move {
EMBY_CLIENT.apply_remote_search(&id, value, replace).await
diff --git a/src/ui/widgets/image_dialog/search_page.rs b/src/ui/widgets/image_dialog/search_page.rs
index 6206ef99..d188f48f 100644
--- a/src/ui/widgets/image_dialog/search_page.rs
+++ b/src/ui/widgets/image_dialog/search_page.rs
@@ -1,4 +1,5 @@
use adw::subclass::prelude::*;
+use gettextrs::gettext;
use gtk::{
gio,
glib,
@@ -6,10 +7,8 @@ use gtk::{
StringObject,
};
-use gtk::{
- prelude::*,
- template_callbacks,
-};
+use adw::prelude::*;
+use gtk::template_callbacks;
use crate::{
client::{
@@ -17,7 +16,10 @@ use crate::{
error::UserFacingError,
},
toast,
- ui::widgets::eu_item,
+ ui::widgets::eu_item::{
+ self,
+ EuObject,
+ },
utils::{
spawn,
spawn_tokio,
@@ -117,6 +119,78 @@ impl ImageDialogSearchPage {
.build()
}
+ #[template_callback]
+ async fn item_activated_cb(&self, pos: u32, gridview: >k::GridView) {
+ let Some(item) = gridview.model().and_then(|m| {
+ m.item(pos)
+ .and_downcast::()
+ .and_then(|o| o.item())
+ }) else {
+ return;
+ };
+
+ let Some(provider_name) = item.line1() else {
+ return;
+ };
+
+ let Some(url) = item.image_original_url() else {
+ return;
+ };
+
+ let id = self.id();
+ let image_type = self.image_type();
+
+ let alert_dialog = adw::AlertDialog::builder()
+ .heading(gettext("Replace Image"))
+ .title("Replace Image")
+ .body(gettext("Are you sure you wish to continue?"))
+ .build();
+
+ alert_dialog.add_response("close", &gettext("Cancel"));
+ alert_dialog.add_response("ok", &gettext("Ok"));
+ alert_dialog.set_response_appearance("ok", adw::ResponseAppearance::Suggested);
+
+ alert_dialog.connect_response(
+ Some("ok"),
+ glib::clone!(
+ #[weak(rename_to = obj)]
+ self,
+ move |_, _| {
+ spawn(glib::clone!(
+ #[weak]
+ obj,
+ #[strong]
+ id,
+ #[strong]
+ image_type,
+ #[strong]
+ provider_name,
+ #[strong]
+ url,
+ async move {
+ match spawn_tokio(async move {
+ EMBY_CLIENT
+ .download_remote_images(&id, &image_type, &provider_name, &url)
+ .await
+ })
+ .await
+ {
+ Ok(_) => {
+ toast!(obj, gettext("Success"));
+ }
+ Err(e) => {
+ toast!(obj, e.to_user_facing());
+ }
+ }
+ }
+ ))
+ }
+ ),
+ );
+
+ alert_dialog.present(Some(self));
+ }
+
pub async fn init(&self) {
let id = self.id();
let type_ = self.image_type();
diff --git a/src/ui/widgets/metadata_dialog.rs b/src/ui/widgets/metadata_dialog.rs
index f93dc717..d9ab68d5 100644
--- a/src/ui/widgets/metadata_dialog.rs
+++ b/src/ui/widgets/metadata_dialog.rs
@@ -130,9 +130,7 @@ mod imp {
impl MetadataDialog {
fn init(&self) {
if IS_ADMIN.load(std::sync::atomic::Ordering::Relaxed) {
- self.page.set_title("View Metadata");
- self.hint
- .set_subtitle("This page is READ-ONLY, because it is not finished yet.");
+ self.hint.set_visible(false);
}
spawn(glib::clone!(