mirror of
https://github.com/xlmnxp/blue-recorder.git
synced 2024-11-23 17:13:11 +03:00
update translation
This commit is contained in:
parent
0c31d21d95
commit
8e039c3df5
@ -81,6 +81,9 @@ delay-window-stop = إيقاف
|
|||||||
# About message
|
# About message
|
||||||
dialog-comment = مسجّل شاشة لسطح مكتب لينكس، يدعم إكس ووايلاند.
|
dialog-comment = مسجّل شاشة لسطح مكتب لينكس، يدعم إكس ووايلاند.
|
||||||
|
|
||||||
|
# Details button
|
||||||
|
details-button = Details
|
||||||
|
|
||||||
# Run command input
|
# Run command input
|
||||||
enter-command = اكتب الأمر هنا..
|
enter-command = اكتب الأمر هنا..
|
||||||
|
|
||||||
@ -106,9 +109,8 @@ license =
|
|||||||
|
|
||||||
لمزيد تفاصيل راجع رخصة جنو العمومية. إن لم تكن حصلت على نسخة من رخصة جنو العمومية مع المسجل الأزرق فانظر { license-website }.
|
لمزيد تفاصيل راجع رخصة جنو العمومية. إن لم تكن حصلت على نسخة من رخصة جنو العمومية مع المسجل الأزرق فانظر { license-website }.
|
||||||
|
|
||||||
# Video bitrate label
|
# Play error
|
||||||
video-bitrate = B/Video:
|
play-error = Cannot play the video file
|
||||||
|
|
||||||
|
|
||||||
# Recording button
|
# Recording button
|
||||||
record = سجل
|
record = سجل
|
||||||
@ -136,6 +138,9 @@ stop-recording = إيقاف التسجيل
|
|||||||
# Show mouse label
|
# Show mouse label
|
||||||
show-mouse = إظهار مؤشر الفأرة
|
show-mouse = إظهار مؤشر الفأرة
|
||||||
|
|
||||||
|
# Video bitrate label
|
||||||
|
video-bitrate = B/Video:
|
||||||
|
|
||||||
# Website link
|
# Website link
|
||||||
website = الموقع
|
website = الموقع
|
||||||
|
|
||||||
|
@ -81,6 +81,9 @@ delay-window-stop = إيقاف
|
|||||||
# About message
|
# About message
|
||||||
dialog-comment = مسجّل شاشة لسطح مكتب لينكس، يدعم إكس ووايلاند.
|
dialog-comment = مسجّل شاشة لسطح مكتب لينكس، يدعم إكس ووايلاند.
|
||||||
|
|
||||||
|
# Details button
|
||||||
|
details-button = Details
|
||||||
|
|
||||||
# Run command input
|
# Run command input
|
||||||
enter-command = اكتب الأمر هنا..
|
enter-command = اكتب الأمر هنا..
|
||||||
|
|
||||||
@ -106,9 +109,8 @@ license =
|
|||||||
|
|
||||||
لمزيد تفاصيل راجع رخصة جنو العمومية. إن لم تكن حصلت على نسخة من رخصة جنو العمومية مع المسجل الأزرق فانظر { license-website }.
|
لمزيد تفاصيل راجع رخصة جنو العمومية. إن لم تكن حصلت على نسخة من رخصة جنو العمومية مع المسجل الأزرق فانظر { license-website }.
|
||||||
|
|
||||||
# Video bitrate label
|
# Play error
|
||||||
video-bitrate = B/Video:
|
play-error = Cannot play the video file
|
||||||
|
|
||||||
|
|
||||||
# Recording button
|
# Recording button
|
||||||
record = سجل
|
record = سجل
|
||||||
@ -136,6 +138,9 @@ stop-recording = إيقاف التسجيل
|
|||||||
# Show mouse label
|
# Show mouse label
|
||||||
show-mouse = إظهار مؤشر الفأرة
|
show-mouse = إظهار مؤشر الفأرة
|
||||||
|
|
||||||
|
# Video bitrate label
|
||||||
|
video-bitrate = B/Video:
|
||||||
|
|
||||||
# Website link
|
# Website link
|
||||||
website = الموقع
|
website = الموقع
|
||||||
|
|
||||||
|
@ -81,6 +81,9 @@ delay-window-stop = Stop
|
|||||||
# About message
|
# About message
|
||||||
dialog-comment = A simple screen recorder for Linux desktop. Supports Wayland & Xorg.
|
dialog-comment = A simple screen recorder for Linux desktop. Supports Wayland & Xorg.
|
||||||
|
|
||||||
|
# Details button
|
||||||
|
details-button = Details
|
||||||
|
|
||||||
# Run command input
|
# Run command input
|
||||||
enter-command = Enter your command here..
|
enter-command = Enter your command here..
|
||||||
|
|
||||||
@ -103,8 +106,8 @@ license =
|
|||||||
Blue Recorder is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
Blue Recorder is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Blue Recorder. If not, see { license-website }.
|
See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Blue Recorder. If not, see { license-website }.
|
||||||
|
|
||||||
# Video bitrate label
|
# Play error
|
||||||
video-bitrate = B/Video:
|
play-error = Cannot play the video file
|
||||||
|
|
||||||
# Recording button
|
# Recording button
|
||||||
record = Record
|
record = Record
|
||||||
@ -126,12 +129,21 @@ select-area = Select an Area
|
|||||||
select-screen = Select a Screen
|
select-screen = Select a Screen
|
||||||
select-window = Select a Window
|
select-window = Select a Window
|
||||||
|
|
||||||
|
# Start error
|
||||||
|
start-error = Blue Recorder unable to start recording
|
||||||
|
|
||||||
|
# Stop error
|
||||||
|
stop-error = Unfortunately, the recording process was not successful
|
||||||
|
|
||||||
# Stop recording button
|
# Stop recording button
|
||||||
stop-recording = Stop recording
|
stop-recording = Stop recording
|
||||||
|
|
||||||
# Show mouse label
|
# Show mouse label
|
||||||
show-mouse = Show Mouse
|
show-mouse = Show Mouse
|
||||||
|
|
||||||
|
# Video bitrate label
|
||||||
|
video-bitrate = B/Video:
|
||||||
|
|
||||||
# Website link
|
# Website link
|
||||||
website = Website
|
website = Website
|
||||||
|
|
||||||
|
@ -81,6 +81,9 @@ delay-window-stop = Stop
|
|||||||
# About message
|
# About message
|
||||||
dialog-comment = A simple screen recorder for Linux desktop. Supports Wayland & Xorg.
|
dialog-comment = A simple screen recorder for Linux desktop. Supports Wayland & Xorg.
|
||||||
|
|
||||||
|
# Details button
|
||||||
|
details-button = Details
|
||||||
|
|
||||||
# Run command input
|
# Run command input
|
||||||
enter-command = Enter your command here..
|
enter-command = Enter your command here..
|
||||||
|
|
||||||
@ -103,8 +106,8 @@ license =
|
|||||||
Blue Recorder is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
Blue Recorder is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Blue Recorder. If not, see { license-website }.
|
See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Blue Recorder. If not, see { license-website }.
|
||||||
|
|
||||||
# Video bitrate label
|
# Play error
|
||||||
video-bitrate = B/Video:
|
play-error = Cannot play the video file
|
||||||
|
|
||||||
# Recording button
|
# Recording button
|
||||||
record = Record
|
record = Record
|
||||||
@ -126,12 +129,21 @@ select-area = Select an Area
|
|||||||
select-screen = Select a Screen
|
select-screen = Select a Screen
|
||||||
select-window = Select a Window
|
select-window = Select a Window
|
||||||
|
|
||||||
|
# Start error
|
||||||
|
start-error = Blue Recorder unable to start recording
|
||||||
|
|
||||||
|
# Stop error
|
||||||
|
stop-error = Unfortunately, the recording process was not successful
|
||||||
|
|
||||||
# Stop recording button
|
# Stop recording button
|
||||||
stop-recording = Stop recording
|
stop-recording = Stop recording
|
||||||
|
|
||||||
# Show mouse label
|
# Show mouse label
|
||||||
show-mouse = Show Mouse
|
show-mouse = Show Mouse
|
||||||
|
|
||||||
|
# Video bitrate label
|
||||||
|
video-bitrate = B/Video:
|
||||||
|
|
||||||
# Website link
|
# Website link
|
||||||
website = Website
|
website = Website
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ impl Ffmpeg {
|
|||||||
let is_audio_record = std::path::Path::new(audio_filename.as_str()).exists();
|
let is_audio_record = std::path::Path::new(audio_filename.as_str()).exists();
|
||||||
|
|
||||||
if is_video_record {
|
if is_video_record {
|
||||||
if is_wayland() {
|
if is_wayland() && self.filename.2.active_id().unwrap().as_str() != "gif" {
|
||||||
// convert webm to specified format
|
// convert webm to specified format
|
||||||
let mut ffmpeg_command = FfmpegCommand::new();
|
let mut ffmpeg_command = FfmpegCommand::new();
|
||||||
ffmpeg_command.input(self.temp_video_filename.as_str());
|
ffmpeg_command.input(self.temp_video_filename.as_str());
|
||||||
@ -329,7 +329,31 @@ impl Ffmpeg {
|
|||||||
]).overwrite()
|
]).overwrite()
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap().wait().unwrap();
|
.unwrap().wait().unwrap();
|
||||||
|
} else if is_wayland() && self.filename.2.active_id().unwrap().as_str() == "gif" {
|
||||||
|
let fps = 100/self.record_frames.value_as_int();
|
||||||
|
let scale = self.height.unwrap();
|
||||||
|
let mut ffmpeg_command = FfmpegCommand::new();
|
||||||
|
ffmpeg_command.input(self.temp_video_filename.as_str())
|
||||||
|
.filter_complex(
|
||||||
|
format!("fps={},scale={}:-1:flags=lanczos,[0]split[s0][s1]; [s0]palettegen[p]; [s1][p]paletteuse",
|
||||||
|
fps,scale));
|
||||||
|
if self.video_record_bitrate.value() > 0.0 {
|
||||||
|
ffmpeg_command.args([
|
||||||
|
"-b:v",
|
||||||
|
&format!("{}K", self.video_record_bitrate.value()),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
ffmpeg_command.args(["-loop", "0"])
|
||||||
|
.args([
|
||||||
|
self.filename.2.active_id().unwrap().as_str(),
|
||||||
|
self.saved_filename.as_ref().unwrap(),
|
||||||
|
])
|
||||||
|
.overwrite().spawn().unwrap().wait().expect("failed to convert video to gif");
|
||||||
|
if is_audio_record {
|
||||||
|
std::fs::remove_file(audio_filename.clone()).unwrap();
|
||||||
|
}
|
||||||
} else if !is_wayland() && self.filename.2.active_id().unwrap().as_str() == "gif" {
|
} else if !is_wayland() && self.filename.2.active_id().unwrap().as_str() == "gif" {
|
||||||
|
// convert mp4 to gif
|
||||||
let fps = 100/self.record_frames.value_as_int();
|
let fps = 100/self.record_frames.value_as_int();
|
||||||
let scale = self.height.unwrap();
|
let scale = self.height.unwrap();
|
||||||
let mut ffmpeg_command = FfmpegCommand::new();
|
let mut ffmpeg_command = FfmpegCommand::new();
|
||||||
|
285
src/main.rs
285
src/main.rs
@ -9,8 +9,6 @@ mod wayland_record;
|
|||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
use ffmpeg_interface::Ffmpeg;
|
use ffmpeg_interface::Ffmpeg;
|
||||||
use fluent_bundle::bundle::FluentBundle;
|
|
||||||
use fluent_bundle::FluentResource;
|
|
||||||
use gtk::glib;
|
use gtk::glib;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
@ -18,7 +16,7 @@ use gtk::{
|
|||||||
FileChooserAction, FileChooserNative, Image, Label, SpinButton,
|
FileChooserAction, FileChooserNative, Image, Label, SpinButton,
|
||||||
ToggleButton, Window,
|
ToggleButton, Window,
|
||||||
};
|
};
|
||||||
use utils::is_wayland;
|
use utils::{get_bundle, is_wayland};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@ -46,37 +44,6 @@ pub fn build_ui(application: &Application) {
|
|||||||
// Init audio source
|
// Init audio source
|
||||||
let host_audio_device = cpal::default_host();
|
let host_audio_device = cpal::default_host();
|
||||||
|
|
||||||
// Translate
|
|
||||||
let mut ftl_path = {
|
|
||||||
let mut current_exec_dir = std::env::current_exe().unwrap();
|
|
||||||
current_exec_dir.pop();
|
|
||||||
current_exec_dir
|
|
||||||
}.join(Path::new("locales"));
|
|
||||||
if !ftl_path.exists() {
|
|
||||||
ftl_path = std::fs::canonicalize(Path::new(
|
|
||||||
&std::env::var("LC_DIR").unwrap_or_else(|_| String::from("locales")),
|
|
||||||
)).unwrap();
|
|
||||||
}
|
|
||||||
let supported_lang: Vec<String> = std::fs::read_dir(&ftl_path)
|
|
||||||
.unwrap()
|
|
||||||
.map(|entry| {
|
|
||||||
let path = entry.unwrap().path();
|
|
||||||
path.file_stem().unwrap().to_string_lossy().to_string()
|
|
||||||
}).collect();
|
|
||||||
let mut locale = std::env::var("LANG").unwrap_or("en_US".to_string());
|
|
||||||
if !supported_lang.contains(&locale) {
|
|
||||||
locale = locale.split('_').next().unwrap().to_string();
|
|
||||||
if !supported_lang.contains(&locale) {
|
|
||||||
locale = String::from("en_US");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let ftl_file = std::fs::read_to_string(
|
|
||||||
format!("{}/{}.ftl", ftl_path.to_str().unwrap(),locale.split('.').next().unwrap())
|
|
||||||
).unwrap();
|
|
||||||
let res = FluentResource::try_new(ftl_file).unwrap();
|
|
||||||
let mut bundle = FluentBundle::default();
|
|
||||||
bundle.add_resource(res).expect("Failed to add localization resources to the bundle.");
|
|
||||||
|
|
||||||
// Config initialize
|
// Config initialize
|
||||||
config_management::initialize();
|
config_management::initialize();
|
||||||
|
|
||||||
@ -132,11 +99,9 @@ pub fn build_ui(application: &Application) {
|
|||||||
|
|
||||||
// --- default properties
|
// --- default properties
|
||||||
// Windows
|
// Windows
|
||||||
main_window.set_title(Some(&bundle.format_pattern(bundle.get_message("blue-recorder").unwrap()
|
main_window.set_title(Some(&get_bundle("blue-recorder", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
main_window.set_application(Some(application));
|
main_window.set_application(Some(application));
|
||||||
area_chooser_window.set_title(Some(&bundle.format_pattern(bundle.get_message("area-chooser").unwrap()
|
area_chooser_window.set_title(Some(&get_bundle("area-chooser", None))); // Title is hidden
|
||||||
.value().unwrap(), None, &mut vec![]).to_string())); // Title is hidden
|
|
||||||
|
|
||||||
// Hide stop & play buttons
|
// Hide stop & play buttons
|
||||||
stop_button.hide();
|
stop_button.hide();
|
||||||
@ -147,13 +112,9 @@ pub fn build_ui(application: &Application) {
|
|||||||
screen_grab_button.set_active(true);
|
screen_grab_button.set_active(true);
|
||||||
|
|
||||||
// Comboboxs tooltip
|
// Comboboxs tooltip
|
||||||
audio_source_combobox.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("audio-source-tooltip").unwrap()
|
audio_source_combobox.set_tooltip_text(Some(&get_bundle("audio-source-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
format_chooser_combobox.set_tooltip_text(Some(&get_bundle("format-tooltip", None)));
|
||||||
format_chooser_combobox.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("format-tooltip").unwrap()
|
area_grab_button.set_tooltip_text(Some(&get_bundle("area-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
|
|
||||||
area_grab_button.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("area-tooltip").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
// Temporary solution
|
// Temporary solution
|
||||||
if is_wayland() {
|
if is_wayland() {
|
||||||
// Disabled for the tooltip
|
// Disabled for the tooltip
|
||||||
@ -162,36 +123,26 @@ pub fn build_ui(application: &Application) {
|
|||||||
//area_grab_button.add_css_class("disabled");
|
//area_grab_button.add_css_class("disabled");
|
||||||
area_grab_button.set_sensitive(false);
|
area_grab_button.set_sensitive(false);
|
||||||
// Hide window grab button in Wayland
|
// Hide window grab button in Wayland
|
||||||
area_grab_button.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("wayland-tooltip").unwrap()
|
area_grab_button.set_tooltip_text(Some(&get_bundle("wayland-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entries
|
// Entries
|
||||||
filename_entry.set_placeholder_text(Some(&bundle.format_pattern(bundle.get_message("file-name").unwrap()
|
filename_entry.set_placeholder_text(Some(&get_bundle("file-name", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
command_entry.set_placeholder_text(Some(&get_bundle("default-command", None)));
|
||||||
command_entry.set_placeholder_text(Some(&bundle.format_pattern(bundle.get_message("default-command").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
filename_entry.set_text(&config_management::get("default", "filename"));
|
filename_entry.set_text(&config_management::get("default", "filename"));
|
||||||
command_entry.set_text(&config_management::get("default", "command"));
|
command_entry.set_text(&config_management::get("default", "command"));
|
||||||
|
|
||||||
// Format combobox
|
// Format combobox
|
||||||
format_chooser_combobox.append(Some("mp4"), &bundle.format_pattern(bundle.get_message("mp4-format").unwrap()
|
format_chooser_combobox.append(Some("mp4"), &get_bundle("mp4-format", None));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
format_chooser_combobox.append(
|
format_chooser_combobox.append(
|
||||||
Some("mkv"),
|
Some("mkv"),
|
||||||
&bundle.format_pattern(bundle.get_message("mkv-format").unwrap()
|
&get_bundle("mkv-format", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
);
|
);
|
||||||
format_chooser_combobox.append(Some("webm"), &bundle.format_pattern(bundle.get_message("webm-format").unwrap()
|
format_chooser_combobox.append(Some("webm"), &get_bundle("webm-format", None));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
format_chooser_combobox.append(Some("gif"), &get_bundle("gif-format", None));
|
||||||
format_chooser_combobox.append(Some("gif"), &bundle.format_pattern(bundle.get_message("gif-format").unwrap()
|
format_chooser_combobox.append(Some("avi"), &get_bundle("avi-format", None));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
format_chooser_combobox.append(Some("wmv"), &get_bundle("wmv-format", None));
|
||||||
format_chooser_combobox.append(Some("avi"), &bundle.format_pattern(bundle.get_message("avi-format").unwrap()
|
format_chooser_combobox.append(Some("nut"), &get_bundle("nut-format", None));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
format_chooser_combobox.append(Some("wmv"), &bundle.format_pattern(bundle.get_message("wmv-format").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
format_chooser_combobox.append(Some("nut"), &bundle.format_pattern(bundle.get_message("nut-format").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
format_chooser_combobox.set_active(Some(config_management::get("default", "format").parse::<u32>().unwrap()));
|
format_chooser_combobox.set_active(Some(config_management::get("default", "format").parse::<u32>().unwrap()));
|
||||||
|
|
||||||
// Get audio sources
|
// Get audio sources
|
||||||
@ -200,38 +151,25 @@ pub fn build_ui(application: &Application) {
|
|||||||
.filter_map(|device| device.name().ok())
|
.filter_map(|device| device.name().ok())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
audio_source_combobox.append(Some("default"), &bundle.format_pattern(bundle.get_message("audio-input").unwrap()
|
audio_source_combobox.append(Some("default"), &get_bundle("audio-input", None));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
audio_source_combobox.set_active(Some(0));
|
audio_source_combobox.set_active(Some(0));
|
||||||
|
|
||||||
// Switchs
|
// Switchs
|
||||||
video_switch.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("video-tooltip").unwrap()
|
video_switch.set_tooltip_text(Some(&get_bundle("video-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
video_switch.set_label(Some(&get_bundle("record-video", None)));
|
||||||
video_switch.set_label(Some(&bundle.format_pattern(bundle.get_message("record-video").unwrap()
|
audio_switch.set_tooltip_text(Some(&get_bundle("audio-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
audio_switch.set_label(Some(&get_bundle("record-audio", None)));
|
||||||
audio_switch.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("audio-tooltip").unwrap()
|
mouse_switch.set_tooltip_text(Some(&get_bundle("mouse-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
mouse_switch.set_label(Some(&get_bundle("show-mouse", None)));
|
||||||
audio_switch.set_label(Some(&bundle.format_pattern(bundle.get_message("record-audio").unwrap()
|
follow_mouse_switch.set_tooltip_text(Some(&get_bundle("follow-mouse-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
follow_mouse_switch.set_label(Some(&get_bundle("follow-mouse", None)));
|
||||||
mouse_switch.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("mouse-tooltip").unwrap()
|
hide_switch.set_tooltip_text(Some(&get_bundle("hide-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
hide_switch.set_label(Some(&get_bundle("auto-hide", None)));
|
||||||
mouse_switch.set_label(Some(&bundle.format_pattern(bundle.get_message("show-mouse").unwrap()
|
speaker_switch.set_tooltip_text(Some(&get_bundle("speaker-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
speaker_switch.set_label(Some(&get_bundle("record-speaker", None)));
|
||||||
follow_mouse_switch.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("follow-mouse-tooltip").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
follow_mouse_switch.set_label(Some(&bundle.format_pattern(bundle.get_message("follow-mouse").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
hide_switch.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("hide-tooltip").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
hide_switch.set_label(Some(&bundle.format_pattern(bundle.get_message("auto-hide").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
speaker_switch.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("speaker-tooltip").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
speaker_switch.set_label(Some(&bundle.format_pattern(bundle.get_message("record-speaker").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
video_switch.set_active(config_management::get_bool("default", "videocheck"));
|
video_switch.set_active(config_management::get_bool("default", "videocheck"));
|
||||||
audio_switch.set_active(config_management::get_bool("default", "audiocheck"));
|
audio_switch.set_active(config_management::get_bool("default", "audiocheck"));
|
||||||
mouse_switch.set_active(config_management::get_bool("default", "mousecheck"));
|
mouse_switch.set_active(config_management::get_bool("default", "mousecheck"));
|
||||||
@ -393,14 +331,10 @@ pub fn build_ui(application: &Application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Spin
|
// Spin
|
||||||
frames_spin.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("frames-tooltip").unwrap()
|
frames_spin.set_tooltip_text(Some(&get_bundle("frames-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
delay_spin.set_tooltip_text(Some(&get_bundle("delay-tooltip", None)));
|
||||||
delay_spin.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("delay-tooltip").unwrap()
|
video_bitrate_spin.set_tooltip_text(Some(&get_bundle("video-bitrate-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
audio_bitrate_spin.set_tooltip_text(Some(&get_bundle("audio-bitrate-tooltip", None)));
|
||||||
video_bitrate_spin.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("video-bitrate-tooltip").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
audio_bitrate_spin.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("audio-bitrate-tooltip").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
frames_spin.set_value(
|
frames_spin.set_value(
|
||||||
config_management::get("default",
|
config_management::get("default",
|
||||||
&format!
|
&format!
|
||||||
@ -490,18 +424,12 @@ pub fn build_ui(application: &Application) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Labels
|
// Labels
|
||||||
command_label.set_label(&bundle.format_pattern(bundle.get_message("run-command").unwrap()
|
command_label.set_label(&get_bundle("run-command", None));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
frames_label.set_label(&get_bundle("frames", None));
|
||||||
frames_label.set_label(&bundle.format_pattern(bundle.get_message("frames").unwrap()
|
delay_label.set_label(&get_bundle("delay", None));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
video_bitrate_label.set_label(&get_bundle("video-bitrate", None));
|
||||||
delay_label.set_label(&bundle.format_pattern(bundle.get_message("delay").unwrap()
|
audio_bitrate_label.set_label(&get_bundle("audio-bitrate", None));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
audio_source_label.set_label(&get_bundle("audio-source", None));
|
||||||
video_bitrate_label.set_label(&bundle.format_pattern(bundle.get_message("video-bitrate").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
audio_bitrate_label.set_label(&bundle.format_pattern(bundle.get_message("audio-bitrate").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
audio_source_label.set_label(&bundle.format_pattern(bundle.get_message("audio-source").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
|
|
||||||
// FileChooser
|
// FileChooser
|
||||||
let folder_chooser_native = FileChooserNative::new(
|
let folder_chooser_native = FileChooserNative::new(
|
||||||
@ -526,8 +454,7 @@ pub fn build_ui(application: &Application) {
|
|||||||
folder_chooser_label.set_label(&folder_chooser_name.to_string_lossy());
|
folder_chooser_label.set_label(&folder_chooser_name.to_string_lossy());
|
||||||
let folder_chooser_icon = config_management::folder_icon(folder_chooser_name.to_str());
|
let folder_chooser_icon = config_management::folder_icon(folder_chooser_name.to_str());
|
||||||
folder_chooser_image.set_icon_name(Some(folder_chooser_icon));
|
folder_chooser_image.set_icon_name(Some(folder_chooser_icon));
|
||||||
folder_chooser_button.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("folder-tooltip").unwrap()
|
folder_chooser_button.set_tooltip_text(Some(&get_bundle("folder-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
// Show file chooser dialog
|
// Show file chooser dialog
|
||||||
folder_chooser_button.connect_clicked(glib::clone!(@strong folder_chooser_native => move |_| {
|
folder_chooser_button.connect_clicked(glib::clone!(@strong folder_chooser_native => move |_| {
|
||||||
folder_chooser_native.connect_response(glib::clone!(@strong folder_chooser_native, @strong folder_chooser_label, @strong folder_chooser_image => move |_, response| {
|
folder_chooser_native.connect_response(glib::clone!(@strong folder_chooser_native, @strong folder_chooser_label, @strong folder_chooser_image => move |_, response| {
|
||||||
@ -547,10 +474,8 @@ pub fn build_ui(application: &Application) {
|
|||||||
// --- connections
|
// --- connections
|
||||||
// Show dialog window when about button clicked then hide it after close
|
// Show dialog window when about button clicked then hide it after close
|
||||||
let _about_dialog: AboutDialog = about_dialog.to_owned();
|
let _about_dialog: AboutDialog = about_dialog.to_owned();
|
||||||
about_button.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("about-tooltip").unwrap()
|
about_button.set_tooltip_text(Some(&get_bundle("about-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
about_button.set_label(&get_bundle("about", None));
|
||||||
about_button.set_label(&bundle.format_pattern(bundle.get_message("about").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
about_button.connect_clicked(move |_| {
|
about_button.connect_clicked(move |_| {
|
||||||
_about_dialog.show();
|
_about_dialog.show();
|
||||||
_about_dialog.set_hide_on_close(true);
|
_about_dialog.set_hide_on_close(true);
|
||||||
@ -562,8 +487,7 @@ pub fn build_ui(application: &Application) {
|
|||||||
|
|
||||||
let _area_chooser_window = area_chooser_window.clone();
|
let _area_chooser_window = area_chooser_window.clone();
|
||||||
let mut _area_capture = area_capture.clone();
|
let mut _area_capture = area_capture.clone();
|
||||||
area_grab_label.set_label(&bundle.format_pattern(bundle.get_message("select-area").unwrap()
|
area_grab_label.set_label(&get_bundle("select-area", None));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
area_grab_button.connect_clicked(move |_| {
|
area_grab_button.connect_clicked(move |_| {
|
||||||
config_management::set("default", "mode", "area");
|
config_management::set("default", "mode", "area");
|
||||||
_area_chooser_window.show();
|
_area_chooser_window.show();
|
||||||
@ -571,8 +495,7 @@ pub fn build_ui(application: &Application) {
|
|||||||
|
|
||||||
let _area_chooser_window = area_chooser_window.clone();
|
let _area_chooser_window = area_chooser_window.clone();
|
||||||
let mut _area_capture = area_capture.clone();
|
let mut _area_capture = area_capture.clone();
|
||||||
area_apply_label.set_label(&bundle.format_pattern(bundle.get_message("apply").unwrap()
|
area_apply_label.set_label(&get_bundle("apply", None));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
area_set_button.connect_clicked(move |_| {
|
area_set_button.connect_clicked(move |_| {
|
||||||
_area_capture
|
_area_capture
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
@ -585,10 +508,8 @@ pub fn build_ui(application: &Application) {
|
|||||||
let record_window: Rc<RefCell<bool>> = Rc::new(RefCell::new(false));
|
let record_window: Rc<RefCell<bool>> = Rc::new(RefCell::new(false));
|
||||||
let window_grab_button_record_window: Rc<RefCell<bool>> = record_window.clone();
|
let window_grab_button_record_window: Rc<RefCell<bool>> = record_window.clone();
|
||||||
let screen_grab_button_record_window: Rc<RefCell<bool>> = record_window.clone();
|
let screen_grab_button_record_window: Rc<RefCell<bool>> = record_window.clone();
|
||||||
screen_grab_button.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("screen-tooltip").unwrap()
|
screen_grab_button.set_tooltip_text(Some(&get_bundle("screen-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
screen_grab_label.set_label(&get_bundle("select-screen", None));
|
||||||
screen_grab_label.set_label(&bundle.format_pattern(bundle.get_message("select-screen").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
screen_grab_button.connect_clicked(move |_| {
|
screen_grab_button.connect_clicked(move |_| {
|
||||||
config_management::set("default", "mode", "screen");
|
config_management::set("default", "mode", "screen");
|
||||||
screen_grab_button_record_window.replace(false);
|
screen_grab_button_record_window.replace(false);
|
||||||
@ -598,10 +519,8 @@ pub fn build_ui(application: &Application) {
|
|||||||
|
|
||||||
let _area_chooser_window: Window = area_chooser_window.clone();
|
let _area_chooser_window: Window = area_chooser_window.clone();
|
||||||
let mut _area_capture: Rc<RefCell<area_capture::AreaCapture>> = area_capture.clone();
|
let mut _area_capture: Rc<RefCell<area_capture::AreaCapture>> = area_capture.clone();
|
||||||
window_grab_button.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("window-tooltip").unwrap()
|
window_grab_button.set_tooltip_text(Some(&get_bundle("window-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
window_grab_label.set_label(&get_bundle("select-window", None));
|
||||||
window_grab_label.set_label(&bundle.format_pattern(bundle.get_message("select-window").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
window_grab_button.connect_clicked(move |_| {
|
window_grab_button.connect_clicked(move |_| {
|
||||||
config_management::set("default", "mode", "window");
|
config_management::set("default", "mode", "window");
|
||||||
_area_chooser_window.hide();
|
_area_chooser_window.hide();
|
||||||
@ -616,8 +535,7 @@ pub fn build_ui(application: &Application) {
|
|||||||
|
|
||||||
let main_context = glib::MainContext::default();
|
let main_context = glib::MainContext::default();
|
||||||
let wayland_record = main_context.block_on(WaylandRecorder::new());
|
let wayland_record = main_context.block_on(WaylandRecorder::new());
|
||||||
let bundle_msg = bundle.format_pattern(bundle.get_message("already-exist").unwrap()
|
let bundle_msg = get_bundle("already-exist", None);
|
||||||
.value().unwrap(), None, &mut vec![]).to_string();
|
|
||||||
// Init record struct
|
// Init record struct
|
||||||
let ffmpeg_record_interface: Rc<RefCell<Ffmpeg>> = Rc::new(RefCell::new(Ffmpeg {
|
let ffmpeg_record_interface: Rc<RefCell<Ffmpeg>> = Rc::new(RefCell::new(Ffmpeg {
|
||||||
filename: (
|
filename: (
|
||||||
@ -657,14 +575,10 @@ pub fn build_ui(application: &Application) {
|
|||||||
let _record_button = record_button.clone();
|
let _record_button = record_button.clone();
|
||||||
let _record_time_label = record_time_label.clone();
|
let _record_time_label = record_time_label.clone();
|
||||||
let _stop_button = stop_button.clone();
|
let _stop_button = stop_button.clone();
|
||||||
record_button.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("record-tooltip").unwrap()
|
record_button.set_tooltip_text(Some(&get_bundle("record-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
record_label.set_label(&get_bundle("record", None));
|
||||||
record_label.set_label(&bundle.format_pattern(bundle.get_message("record").unwrap()
|
delay_window_title.set_label(&get_bundle("delay-title", None));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
delay_window_button.set_label(&get_bundle("delay-window-stop", None));
|
||||||
delay_window_title.set_label(&bundle.format_pattern(bundle.get_message("delay-title").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
delay_window_button.set_label(&bundle.format_pattern(bundle.get_message("delay-window-stop").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
record_button.connect_clicked(move |_| {
|
record_button.connect_clicked(move |_| {
|
||||||
_delay_window_button.set_active(false);
|
_delay_window_button.set_active(false);
|
||||||
if _delay_spin.value() as u64 > 0 {
|
if _delay_spin.value() as u64 > 0 {
|
||||||
@ -705,10 +619,8 @@ pub fn build_ui(application: &Application) {
|
|||||||
let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone();
|
let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone();
|
||||||
let _play_button = play_button.clone();
|
let _play_button = play_button.clone();
|
||||||
let _stop_button = stop_button.clone();
|
let _stop_button = stop_button.clone();
|
||||||
stop_button.set_tooltip_text(Some(&bundle.format_pattern(bundle.get_message("stop-tooltip").unwrap()
|
stop_button.set_tooltip_text(Some(&get_bundle("stop-tooltip", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
stop_label.set_label(&get_bundle("stop-recording", None));
|
||||||
stop_label.set_label(&bundle.format_pattern(bundle.get_message("stop-recording").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
stop_button.connect_clicked(move |_| {
|
stop_button.connect_clicked(move |_| {
|
||||||
_record_time_label.set_visible(false);
|
_record_time_label.set_visible(false);
|
||||||
stop_timer(_record_time_label.clone());
|
stop_timer(_record_time_label.clone());
|
||||||
@ -747,83 +659,54 @@ pub fn build_ui(application: &Application) {
|
|||||||
|
|
||||||
let logo = Image::from_file(&about_icon_path.to_str().unwrap());
|
let logo = Image::from_file(&about_icon_path.to_str().unwrap());
|
||||||
about_dialog.set_transient_for(Some(&main_window));
|
about_dialog.set_transient_for(Some(&main_window));
|
||||||
about_dialog.set_program_name(Some(&bundle.format_pattern(bundle.get_message("blue-recorder").unwrap()
|
about_dialog.set_program_name(Some(&get_bundle("blue-recorder", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
about_dialog.set_version(Some("0.3.0"));
|
about_dialog.set_version(Some("0.3.0"));
|
||||||
about_dialog.set_copyright(Some(&bundle.format_pattern(bundle.get_message("copy-right").unwrap()
|
about_dialog.set_copyright(Some(&get_bundle("copy-right", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
about_dialog.set_wrap_license(true);
|
about_dialog.set_wrap_license(true);
|
||||||
about_dialog.set_license(Some(&bundle.format_pattern(bundle.get_message("license").unwrap()
|
about_dialog.set_license(Some(&get_bundle("license", None)));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
about_dialog.set_comments(Some(&get_bundle("dialog-comment", None)));
|
||||||
about_dialog.set_comments(Some(&bundle.format_pattern(bundle.get_message("dialog-comment").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string()));
|
|
||||||
// Authors
|
// Authors
|
||||||
about_dialog.add_credit_section(
|
about_dialog.add_credit_section(
|
||||||
&bundle.format_pattern(bundle.get_message("authors").unwrap()
|
&get_bundle("authors", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
&[&get_bundle("address-abdullah-al-baroty", None),
|
||||||
&[&bundle.format_pattern(bundle.get_message("address-abdullah-al-baroty").unwrap()
|
&get_bundle("address-alessandro-toia", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
&get_bundle("address-chibani", None),
|
||||||
&bundle.format_pattern(bundle.get_message("address-alessandro-toia").unwrap()
|
&get_bundle("address-hamir-mahal", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
&get_bundle("address-hanny-sabbagh", None),
|
||||||
&bundle.format_pattern(bundle.get_message("address-chibani").unwrap()
|
&get_bundle("address-salem-yaslem", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
&get_bundle("address-suliman-altassan", None),
|
||||||
&bundle.format_pattern(bundle.get_message("address-hamir-mahal").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
&bundle.format_pattern(bundle.get_message("address-hanny-sabbagh").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
&bundle.format_pattern(bundle.get_message("address-salem-yaslem").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
&bundle.format_pattern(bundle.get_message("address-suliman-altassan").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// Patreon suppoters
|
// Patreon suppoters
|
||||||
about_dialog.add_credit_section(
|
about_dialog.add_credit_section(
|
||||||
&bundle.format_pattern(bundle.get_message("patreon").unwrap()
|
&get_bundle("patreon", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
&[&get_bundle("address-ahmad-gharib", None),
|
||||||
&[&bundle.format_pattern(bundle.get_message("address-ahmad-gharib").unwrap()
|
&get_bundle("address-medium", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
&get_bundle("address-william-grunow", None),
|
||||||
&bundle.format_pattern(bundle.get_message("address-medium").unwrap()
|
&get_bundle("address-alex-benishek", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
&bundle.format_pattern(bundle.get_message("address-william-grunow").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
&bundle.format_pattern(bundle.get_message("address-alex-benishek").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// Designers
|
// Designers
|
||||||
about_dialog.add_credit_section(
|
about_dialog.add_credit_section(
|
||||||
&bundle.format_pattern(bundle.get_message("design").unwrap()
|
&get_bundle("design", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
&[&get_bundle("address-abdullah-al-baroty", None),
|
||||||
&[&bundle.format_pattern(bundle.get_message("address-abdullah-al-baroty").unwrap()
|
&get_bundle("address-mustapha-assabar", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
&bundle.format_pattern(bundle.get_message("address-mustapha-assabar").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// Translators
|
// Translators
|
||||||
about_dialog.add_credit_section(
|
about_dialog.add_credit_section(
|
||||||
&bundle.format_pattern(bundle.get_message("translate").unwrap()
|
&get_bundle("translate", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
&[&get_bundle("address-ake-engelbrektson", None),
|
||||||
&[&bundle.format_pattern(bundle.get_message("address-ake-engelbrektson").unwrap()
|
&get_bundle("address-amerey", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
&get_bundle("address-gmou3", None),
|
||||||
&bundle.format_pattern(bundle.get_message("address-amerey").unwrap()
|
&get_bundle("address-larry-wei", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
&get_bundle("address-mark-wagie", None),
|
||||||
&bundle.format_pattern(bundle.get_message("address-gmou3").unwrap()
|
&get_bundle("address-albanobattistella", None),
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
&get_bundle("address-mr-Narsus", None),
|
||||||
&bundle.format_pattern(bundle.get_message("address-larry-wei").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
&bundle.format_pattern(bundle.get_message("address-mark-wagie").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
&bundle.format_pattern(bundle.get_message("address-albanobattistella").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
&bundle.format_pattern(bundle.get_message("address-mr-Narsus").unwrap()
|
|
||||||
.value().unwrap(), None, &mut vec![]).to_string(),
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
about_dialog.set_website(Some("https://github.com/xlmnxp/blue-recorder/"));
|
about_dialog.set_website(Some("https://github.com/xlmnxp/blue-recorder/"));
|
||||||
about_dialog.set_website_label(&bundle.format_pattern(bundle.get_message("website").unwrap()
|
about_dialog.set_website_label(&get_bundle("website", None));
|
||||||
.value().unwrap(), None, &mut vec![]).to_string());
|
|
||||||
about_dialog.set_logo_icon_name(Some("blue-recorder"));
|
about_dialog.set_logo_icon_name(Some("blue-recorder"));
|
||||||
about_dialog.set_logo(logo.paintable().as_ref());
|
about_dialog.set_logo(logo.paintable().as_ref());
|
||||||
about_dialog.set_modal(true);
|
about_dialog.set_modal(true);
|
||||||
|
71
src/utils.rs
71
src/utils.rs
@ -1,3 +1,9 @@
|
|||||||
|
use fluent_bundle::bundle::FluentBundle;
|
||||||
|
use fluent_bundle::{FluentArgs, FluentResource};
|
||||||
|
use gtk::prelude::{ButtonExt, GtkWindowExt, WidgetExt};
|
||||||
|
use gtk::{Box, Button, ButtonsType, DialogFlags, MessageDialog, MessageType, Orientation, Window};
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
pub fn is_wayland() -> bool {
|
pub fn is_wayland() -> bool {
|
||||||
std::env::var("XDG_SESSION_TYPE")
|
std::env::var("XDG_SESSION_TYPE")
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
@ -7,3 +13,68 @@ pub fn is_wayland() -> bool {
|
|||||||
pub fn is_snap() -> bool {
|
pub fn is_snap() -> bool {
|
||||||
!std::env::var("SNAP").unwrap_or_default().is_empty()
|
!std::env::var("SNAP").unwrap_or_default().is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum BlueRecorderError {
|
||||||
|
Start,
|
||||||
|
Stop,
|
||||||
|
Play,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn error_message(error_type: BlueRecorderError) -> String {
|
||||||
|
let error_message = match error_type {
|
||||||
|
BlueRecorderError::Start => get_bundle("start-error", None),
|
||||||
|
BlueRecorderError::Stop => get_bundle("stop-error", None),
|
||||||
|
BlueRecorderError::Play => get_bundle("play-error", None),
|
||||||
|
};
|
||||||
|
error_message
|
||||||
|
}
|
||||||
|
|
||||||
|
// Translate
|
||||||
|
pub fn get_bundle(message_id: &str, arg: Option<&FluentArgs>) -> String {
|
||||||
|
let mut ftl_path = {
|
||||||
|
let mut current_exec_dir = std::env::current_exe().unwrap();
|
||||||
|
current_exec_dir.pop();
|
||||||
|
current_exec_dir
|
||||||
|
}.join(Path::new("locales"));
|
||||||
|
if !ftl_path.exists() {
|
||||||
|
ftl_path = std::fs::canonicalize(Path::new(
|
||||||
|
&std::env::var("LC_DIR").unwrap_or_else(|_| String::from("locales")),
|
||||||
|
)).unwrap();
|
||||||
|
}
|
||||||
|
let supported_lang: Vec<String> = std::fs::read_dir(&ftl_path)
|
||||||
|
.unwrap()
|
||||||
|
.map(|entry| {
|
||||||
|
let path = entry.unwrap().path();
|
||||||
|
path.file_stem().unwrap().to_string_lossy().to_string()
|
||||||
|
}).collect();
|
||||||
|
let mut locale = std::env::var("LANG").unwrap_or("en_US".to_string());
|
||||||
|
if !supported_lang.contains(&locale) {
|
||||||
|
locale = locale.split('_').next().unwrap().to_string();
|
||||||
|
if !supported_lang.contains(&locale) {
|
||||||
|
locale = String::from("en_US");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let ftl_file = std::fs::read_to_string(
|
||||||
|
format!("{}/{}.ftl", ftl_path.to_str().unwrap(),locale.split('.').next().unwrap())
|
||||||
|
).unwrap();
|
||||||
|
let res = FluentResource::try_new(ftl_file).unwrap();
|
||||||
|
let mut bundle = FluentBundle::default();
|
||||||
|
bundle.add_resource(res).expect("Failed to add localization resources to the bundle.");
|
||||||
|
bundle.format_pattern(bundle.get_message(message_id)
|
||||||
|
.unwrap().value().unwrap(), arg, &mut vec![]).to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn show_error_dialog(message: String, window: Window) {
|
||||||
|
let error_dialog = MessageDialog::new(
|
||||||
|
Some(&window),
|
||||||
|
DialogFlags::all(),
|
||||||
|
MessageType::Error,
|
||||||
|
ButtonsType::Close,
|
||||||
|
&message,
|
||||||
|
);
|
||||||
|
let dialog_box = Box::new(Orientation::Horizontal, 10);
|
||||||
|
let details_button = Button::new();
|
||||||
|
details_button.set_label(&get_bundle("details-button", None));
|
||||||
|
error_dialog.set_child(Some(&details_button));
|
||||||
|
error_dialog.show();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user