Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(desktop-gpui): open the audio file picker on Linux

Akshar Patel1015671988b5
diff --git a/apps/desktop-gpui/src/editor_window.rs b/apps/desktop-gpui/src/editor_window.rs
index e295f24fa..4fac77cb0 100644
--- a/apps/desktop-gpui/src/editor_window.rs
+++ b/apps/desktop-gpui/src/editor_window.rs
@@ -5585,7 +5585,16 @@ impl EditorWindow {
) {
let project_path = self.project_path.clone();
cx.spawn_in(window, async move |this, cx| {
- let imported = match crate::platform::open_audio_panel() {
+ #[cfg(target_os = "linux")]
+ let source = crate::platform::open_file_panel_async(
+ &[("Audio", AUDIO_IMPORT_EXTENSIONS)],
+ None,
+ cx,
+ )
+ .await;
+ #[cfg(not(target_os = "linux"))]
+ let source = crate::platform::open_audio_panel();
+ let imported = match source {
Some(source)
if this
.update_in(cx, |this, _, _| {
@@ -11749,6 +11758,8 @@ impl Render for EditorWindow {
}
}
+const AUDIO_IMPORT_EXTENSIONS: &[&str] = &["mp3", "wav", "m4a", "ogg", "flac", "aac"];
+
struct ImportedAudio {
path: String,
name: String,
@@ -11764,8 +11775,7 @@ fn import_audio_file(
.and_then(|ext| ext.to_str())
.map(|ext| ext.to_ascii_lowercase())
.ok_or_else(|| "Audio file has no extension".to_string())?;
- const EXTENSIONS: &[&str] = &["mp3", "wav", "m4a", "ogg", "flac", "aac"];
- if !EXTENSIONS.contains(&extension.as_str()) {
+ if !AUDIO_IMPORT_EXTENSIONS.contains(&extension.as_str()) {
return Err(format!("Unsupported audio format: .{extension}"));
}
if !source.exists() {
diff --git a/apps/desktop-gpui/src/platform.rs b/apps/desktop-gpui/src/platform.rs
index 6189355ea..7c05c4f6b 100644
--- a/apps/desktop-gpui/src/platform.rs
+++ b/apps/desktop-gpui/src/platform.rs
@@ -2765,9 +2765,6 @@ mod stub {
pub fn open_image_panel(_extensions: &[&str]) -> Option<std::path::PathBuf> {
None
}
- pub fn open_audio_panel() -> Option<std::path::PathBuf> {
- None
- }
pub fn confirm_dialog(
title: &str,
message: &str,