Compare commits

...

4 Commits

Author SHA1 Message Date
ochibani
2f11505b8b
update locales 2025-01-08 09:55:21 +02:00
ochibani
9ea3d138ea
update gui 2025-01-08 07:13:24 +00:00
ochibani
05f415e2ab
update gui 2025-01-08 08:58:59 +02:00
ochibani
406c49e7e8
update gui 2025-01-08 05:23:20 +00:00
6 changed files with 56 additions and 52 deletions

View File

@ -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<()> {

View File

@ -8,8 +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,
is_overwrite, is_wayland, play_record, RecordMode, sources_descriptions_list};
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::{audio_output_source, sources_descriptions_list};
#[cfg(target_os = "windows")]
use cpal::traits::{DeviceTrait, HostTrait};
use std::cell::RefCell;
@ -189,18 +191,20 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
// Get audio sources
#[cfg(target_os = "windows")]
{
let input_device = host_audio_device.input_devices()?;
let sources_descriptions: Vec<String> = input_device
.filter_map(|device| device.name().ok())
.collect();
let host_output_device = host_audio_device.default_output_device();
let audio_output_source = if host_output_device.is_some() {
host_output_device.unwrap().name()?
} else {
String::new()
};
}
let input_device = host_audio_device.input_devices()?;
#[cfg(target_os = "windows")]
let sources_descriptions: Vec<String> = input_device
.filter_map(|device| device.name().ok())
.collect();
#[cfg(target_os = "windows")]
let host_output_device = host_audio_device.default_output_device();
#[cfg(target_os = "windows")]
let audio_output_source = if host_output_device.is_some() {
host_output_device.unwrap().name()?
} else {
String::new()
};
#[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"))]
@ -773,8 +777,8 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
record_delay: delay_spin.clone(),
record_frames: frames_spin,
video_record_bitrate: video_bitrate_spin,
follow_mouse: follow_mouse_switch,
record_mouse: mouse_switch,
follow_mouse: follow_mouse_switch.clone(),
record_mouse: mouse_switch.clone(),
show_area: area_switch
}));
#[cfg(any(target_os = "freebsd", target_os = "linux"))]

View File

@ -184,4 +184,4 @@ video-bitrate-tooltip = Set video bitrate in KB/s
video-tooltip = يسجل الشاشة
wayland-tooltip = غير مدعوم في وايلاند
window-tooltip = يحدد نافذة ليسجلها
windows-unsupported-tooltip = Not supported on windows platform
windows-unsupported-tooltip = Not supported on Windows platform

View File

@ -184,4 +184,4 @@ video-bitrate-tooltip = Set video bitrate in KB/s
video-tooltip = يسجل الشاشة
wayland-tooltip = غير مدعوم في وايلاند
window-tooltip = يحدد نافذة ليسجلها
windows-unsupported-tooltip = Not supported on windows platform
windows-unsupported-tooltip = Not supported on Windows platform

View File

@ -184,4 +184,4 @@ video-bitrate-tooltip = Set video bitrate in KB/s
video-tooltip = Video recording
wayland-tooltip = Not supported in Wayland
window-tooltip = Select window to record
windows-unsupported-tooltip = Not supported on windows platform
windows-unsupported-tooltip = Not supported on Windows platform

View File

@ -184,4 +184,4 @@ video-bitrate-tooltip = Set video bitrate in KB/s
video-tooltip = Video recording
wayland-tooltip = Not supported in Wayland
window-tooltip = Select window to record
windows-unsupported-tooltip = Not supported on windows platform
windows-unsupported-tooltip = Not supported on Windows platform