mirror of
https://github.com/xlmnxp/blue-recorder.git
synced 2025-04-02 07:44:54 +03:00
update gui
This commit is contained in:
parent
95aac002ae
commit
1476d20e20
@ -9,6 +9,38 @@ pub enum RecordMode {
|
|||||||
Window,
|
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")]
|
#[cfg(feature = "gtk")]
|
||||||
// Disable GtkWidget
|
// Disable GtkWidget
|
||||||
pub fn disable_input_widgets(input_widgets: Vec<adw::gtk::Widget>) {
|
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")
|
.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")]
|
#[cfg(feature = "gtk")]
|
||||||
// Play recorded file
|
// Play recorded file
|
||||||
pub fn play_record(file_name: &str) -> Result<()> {
|
pub fn play_record(file_name: &str) -> Result<()> {
|
||||||
|
@ -8,10 +8,10 @@ use anyhow::Result;
|
|||||||
use blue_recorder_core::ffmpeg_linux::Ffmpeg;
|
use blue_recorder_core::ffmpeg_linux::Ffmpeg;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
use blue_recorder_core::ffmpeg_windows::Ffmpeg;
|
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};
|
is_overwrite, is_wayland, play_record, RecordMode};
|
||||||
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
#[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")]
|
#[cfg(target_os = "windows")]
|
||||||
use cpal::traits::{DeviceTrait, HostTrait};
|
use cpal::traits::{DeviceTrait, HostTrait};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
@ -202,12 +202,17 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
|
|||||||
} else {
|
} else {
|
||||||
String::new()
|
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"))]
|
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
||||||
let sources_descriptions: Vec<String> = sources_descriptions_list().unwrap_or_else(|_| Vec::new());
|
let sources_descriptions: Vec<String> = sources_descriptions_list().unwrap_or_else(|_| Vec::new());
|
||||||
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
|
||||||
let audio_output_source: String = audio_output_source().unwrap_or_else(|_| String::new());
|
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));
|
audio_source_combobox.append(Some("default"), &get_bundle("audio-input", None));
|
||||||
for (id, audio_source) in sources_descriptions.iter().enumerate() {
|
for (id, audio_source) in sources_descriptions.iter().enumerate() {
|
||||||
audio_source_combobox.append(Some(id.to_string().as_str()), audio_source);
|
audio_source_combobox.append(Some(id.to_string().as_str()), audio_source);
|
||||||
|
Loading…
Reference in New Issue
Block a user