mirror of
https://github.com/xlmnxp/blue-recorder.git
synced 2025-03-31 23:04:55 +03:00
update gui
This commit is contained in:
parent
95aac002ae
commit
1476d20e20
@ -9,6 +9,38 @@ pub enum RecordMode {
|
||||
Window,
|
||||
}
|
||||
|
||||
// Get audio output source
|
||||
#[cfg(feature = "gtk")]
|
||||
pub fn audio_output_source() -> Result<String> {
|
||||
// Get the default sink
|
||||
let default_sink_output = Command::new("pactl")
|
||||
.arg("get-default-sink")
|
||||
.output()?;
|
||||
|
||||
let default_sink = String::from_utf8_lossy(&default_sink_output.stdout)
|
||||
.trim()
|
||||
.to_string();
|
||||
|
||||
// List sinks and filter for the monitor of the default sink
|
||||
let sinks_output = Command::new("pactl")
|
||||
.arg("list")
|
||||
.arg("sinks")
|
||||
.output()?;
|
||||
|
||||
let sinks = String::from_utf8_lossy(&sinks_output.stdout);
|
||||
let monitor_line = sinks
|
||||
.lines()
|
||||
.find(|line| line.contains(&format!("{}.monitor", default_sink)))
|
||||
.unwrap_or("");
|
||||
|
||||
// Extract the part after the colon
|
||||
let output_source = monitor_line.split(':')
|
||||
.nth(1)
|
||||
.unwrap_or("")
|
||||
.trim().to_string();
|
||||
Ok(output_source)
|
||||
}
|
||||
|
||||
#[cfg(feature = "gtk")]
|
||||
// Disable GtkWidget
|
||||
pub fn disable_input_widgets(input_widgets: Vec<adw::gtk::Widget>) {
|
||||
@ -105,38 +137,6 @@ pub fn is_wayland() -> bool {
|
||||
.eq_ignore_ascii_case("wayland")
|
||||
}
|
||||
|
||||
// Get audio output source
|
||||
#[cfg(feature = "gtk")]
|
||||
pub fn audio_output_source() -> Result<String> {
|
||||
// Get the default sink
|
||||
let default_sink_output = Command::new("pactl")
|
||||
.arg("get-default-sink")
|
||||
.output()?;
|
||||
|
||||
let default_sink = String::from_utf8_lossy(&default_sink_output.stdout)
|
||||
.trim()
|
||||
.to_string();
|
||||
|
||||
// List sinks and filter for the monitor of the default sink
|
||||
let sinks_output = Command::new("pactl")
|
||||
.arg("list")
|
||||
.arg("sinks")
|
||||
.output()?;
|
||||
|
||||
let sinks = String::from_utf8_lossy(&sinks_output.stdout);
|
||||
let monitor_line = sinks
|
||||
.lines()
|
||||
.find(|line| line.contains(&format!("{}.monitor", default_sink)))
|
||||
.unwrap_or("");
|
||||
|
||||
// Extract the part after the colon
|
||||
let output_source = monitor_line.split(':')
|
||||
.nth(1)
|
||||
.unwrap_or("")
|
||||
.trim().to_string();
|
||||
Ok(output_source)
|
||||
}
|
||||
|
||||
#[cfg(feature = "gtk")]
|
||||
// Play recorded file
|
||||
pub fn play_record(file_name: &str) -> Result<()> {
|
||||
|
@ -8,10 +8,10 @@ use anyhow::Result;
|
||||
use blue_recorder_core::ffmpeg_linux::Ffmpeg;
|
||||
#[cfg(target_os = "windows")]
|
||||
use blue_recorder_core::ffmpeg_windows::Ffmpeg;
|
||||
use blue_recorder_core::utils::{audio_output_source, disable_input_widgets, enable_input_widgets,
|
||||
use blue_recorder_core::utils::{disable_input_widgets, enable_input_widgets,
|
||||
is_overwrite, is_wayland, play_record, RecordMode};
|
||||
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
||||
use blue_recorder_core::utils::sources_descriptions_list;
|
||||
use blue_recorder_core::utils::{audio_output_source, sources_descriptions_list};
|
||||
#[cfg(target_os = "windows")]
|
||||
use cpal::traits::{DeviceTrait, HostTrait};
|
||||
use std::cell::RefCell;
|
||||
@ -202,12 +202,17 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
audio_source_combobox.append(Some("default"), &get_bundle("audio-input", None));
|
||||
for (id, audio_source) in sources_descriptions.iter().enumerate() {
|
||||
audio_source_combobox.append(Some(id.to_string().as_str()), audio_source);
|
||||
}
|
||||
}
|
||||
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
||||
let sources_descriptions: Vec<String> = sources_descriptions_list().unwrap_or_else(|_| Vec::new());
|
||||
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
||||
let audio_output_source: String = audio_output_source().unwrap_or_else(|_| String::new());
|
||||
|
||||
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
||||
audio_source_combobox.append(Some("default"), &get_bundle("audio-input", None));
|
||||
for (id, audio_source) in sources_descriptions.iter().enumerate() {
|
||||
audio_source_combobox.append(Some(id.to_string().as_str()), audio_source);
|
||||
|
Loading…
Reference in New Issue
Block a user