[fractal] event-actions: Implement save for media files
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] event-actions: Implement save for media files
- Date: Tue, 5 Jul 2022 10:59:50 +0000 (UTC)
commit f5b12387fecaf1218015d411286e4817416bbdcc
Author: Kirill Schmidt <kirill schmidt teckids org>
Date: Sun Jul 3 09:27:55 2022 +0300
event-actions: Implement save for media files
Part-of: <https://gitlab.gnome.org/GNOME/fractal/-/merge_requests/1115>
data/resources/ui/event-menu.ui | 20 ++++++++++++++++++++
src/session/room/event.rs | 18 ++++++++++++++++++
src/session/room/event_actions.rs | 27 +++++++++++++++++++++++++++
3 files changed, 65 insertions(+)
---
diff --git a/data/resources/ui/event-menu.ui b/data/resources/ui/event-menu.ui
index 48ebaa3d7..d6dcb24ee 100644
--- a/data/resources/ui/event-menu.ui
+++ b/data/resources/ui/event-menu.ui
@@ -47,6 +47,16 @@
<attribute name="action">event.save-image</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
+ <item>
+ <attribute name="label" translatable="yes">S_ave Video</attribute>
+ <attribute name="action">event.save-video</attribute>
+ <attribute name="hidden-when">action-missing</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">S_ave Audio</attribute>
+ <attribute name="action">event.save-audio</attribute>
+ <attribute name="hidden-when">action-missing</attribute>
+ </item>
<item>
<attribute name="label" translatable="yes">_Permalink</attribute>
<attribute name="action">event.permalink</attribute>
@@ -78,6 +88,16 @@
<attribute name="action">event.save-image</attribute>
<attribute name="hidden-when">action-missing</attribute>
</item>
+ <item>
+ <attribute name="label" translatable="yes">S_ave Video</attribute>
+ <attribute name="action">event.save-video</attribute>
+ <attribute name="hidden-when">action-missing</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">S_ave Audio</attribute>
+ <attribute name="action">event.save-audio</attribute>
+ <attribute name="hidden-when">action-missing</attribute>
+ </item>
</section>
</menu>
<menu id="state_menu_model">
diff --git a/src/session/room/event.rs b/src/session/room/event.rs
index 79919570f..1dd2057e8 100644
--- a/src/session/room/event.rs
+++ b/src/session/room/event.rs
@@ -615,6 +615,7 @@ impl Event {
/// - File message (`MessageType::File`).
/// - Image message (`MessageType::Image`).
/// - Video message (`MessageType::Video`).
+ /// - Audio message (`MessageType::Audio`).
///
/// Returns `Ok((uid, filename, binary_content))` on success, `Err` if an
/// error occurred while fetching the content. Panics on an incompatible
@@ -679,6 +680,23 @@ impl Event {
let data = handle.await.unwrap()?.unwrap();
return Ok((uid, filename, data));
}
+ MessageType::Audio(content) => {
+ let uid = media_type_uid(content.source());
+ let filename = if content.body.is_empty() {
+ filename_for_mime(
+ content
+ .info
+ .as_ref()
+ .and_then(|info| info.mimetype.as_deref()),
+ Some(mime::AUDIO),
+ )
+ } else {
+ content.body.clone()
+ };
+ let handle = spawn_tokio!(async move { client.get_file(content, true).await });
+ let data = handle.await.unwrap()?.unwrap();
+ return Ok((uid, filename, data));
+ }
_ => {}
};
};
diff --git a/src/session/room/event_actions.rs b/src/session/room/event_actions.rs
index a8c894e08..3bc7a0f42 100644
--- a/src/session/room/event_actions.rs
+++ b/src/session/room/event_actions.rs
@@ -174,6 +174,33 @@ where
})
);
}
+ MessageType::Image(_) => {
+ gtk_macros::action!(
+ &action_group,
+ "save-image",
+ clone!(@weak self as widget, @weak event => move |_, _| {
+ widget.save_event_file(event);
+ })
+ );
+ }
+ MessageType::Video(_) => {
+ gtk_macros::action!(
+ &action_group,
+ "save-video",
+ clone!(@weak self as widget, @weak event => move |_, _| {
+ widget.save_event_file(event);
+ })
+ );
+ }
+ MessageType::Audio(_) => {
+ gtk_macros::action!(
+ &action_group,
+ "save-audio",
+ clone!(@weak self as widget, @weak event => move |_, _| {
+ widget.save_event_file(event);
+ })
+ );
+ }
_ => {}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]