mirror of
https://github.com/xlmnxp/blue-recorder.git
synced 2024-11-23 17:13:11 +03:00
add start recording error dialog
This commit is contained in:
parent
965b303832
commit
c601747c79
@ -63,6 +63,9 @@ blue-recorder = Blue Recorder
|
|||||||
# Copy right
|
# Copy right
|
||||||
copy-right = © 2021 Salem Yaslem
|
copy-right = © 2021 Salem Yaslem
|
||||||
|
|
||||||
|
# Close error dialog
|
||||||
|
close-error-dialog = Close
|
||||||
|
|
||||||
# Run command label
|
# Run command label
|
||||||
default-command = Default command:
|
default-command = Default command:
|
||||||
|
|
||||||
@ -78,15 +81,18 @@ delay-title = Start Recording in…
|
|||||||
# Stop delay timer
|
# Stop delay timer
|
||||||
delay-window-stop = Stop
|
delay-window-stop = Stop
|
||||||
|
|
||||||
# About message
|
|
||||||
dialog-comment = A simple screen recorder for Linux desktop. Supports Wayland & Xorg.
|
|
||||||
|
|
||||||
# Details button
|
# Details button
|
||||||
details-button = Details
|
details-button = Details
|
||||||
|
|
||||||
|
# About message
|
||||||
|
dialog-comment = A simple screen recorder for Linux desktop. Supports Wayland & Xorg.
|
||||||
|
|
||||||
# Run command input
|
# Run command input
|
||||||
enter-command = Enter your command here..
|
enter-command = Enter your command here..
|
||||||
|
|
||||||
|
# Error dialog
|
||||||
|
error-dialog = Error
|
||||||
|
|
||||||
# Frames label
|
# Frames label
|
||||||
file-name = Default filename:
|
file-name = Default filename:
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ use std::thread::sleep;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use subprocess::Exec;
|
use subprocess::Exec;
|
||||||
use filename::Filename;
|
use filename::Filename;
|
||||||
|
use std::io::{Error, ErrorKind};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Ffmpeg {
|
pub struct Ffmpeg {
|
||||||
@ -45,7 +46,7 @@ pub struct Ffmpeg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Ffmpeg {
|
impl Ffmpeg {
|
||||||
pub fn start_record(&mut self, x: u16, y: u16, width: u16, height: u16) -> Option<()> {
|
pub fn start_record(&mut self, x: u16, y: u16, width: u16, height: u16) -> Result<(), Error> {
|
||||||
self.saved_filename = Some(
|
self.saved_filename = Some(
|
||||||
self.filename
|
self.filename
|
||||||
.0
|
.0
|
||||||
@ -83,7 +84,7 @@ impl Ffmpeg {
|
|||||||
message_dialog.close();
|
message_dialog.close();
|
||||||
|
|
||||||
if answer != ResponseType::Yes {
|
if answer != ResponseType::Yes {
|
||||||
return None;
|
return Err(Error::new(ErrorKind::Interrupted, "failed to overwrite file"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,8 +248,7 @@ impl Ffmpeg {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
)) {
|
)) {
|
||||||
println!("failed to start recording");
|
return Err(Error::new(ErrorKind::Interrupted,"failed to start recording"));
|
||||||
return None;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ impl Ffmpeg {
|
|||||||
self.audio_process = Some(Rc::new(RefCell::new(ffmpeg_command.spawn().unwrap())));
|
self.audio_process = Some(Rc::new(RefCell::new(ffmpeg_command.spawn().unwrap())));
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stop_record(&mut self) {
|
pub fn stop_record(&mut self) {
|
||||||
|
23
src/main.rs
23
src/main.rs
@ -11,6 +11,7 @@ mod utils;
|
|||||||
use ffmpeg_interface::Ffmpeg;
|
use ffmpeg_interface::Ffmpeg;
|
||||||
use gtk::glib;
|
use gtk::glib;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
use gtk::TextBuffer;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
AboutDialog, Application, Builder, Button, CheckButton, ComboBoxText, CssProvider, Entry,
|
AboutDialog, Application, Builder, Button, CheckButton, ComboBoxText, CssProvider, Entry,
|
||||||
FileChooserAction, FileChooserNative, Image, Label, MessageDialog, SpinButton,
|
FileChooserAction, FileChooserNative, Image, Label, MessageDialog, SpinButton,
|
||||||
@ -18,6 +19,7 @@ use gtk::{
|
|||||||
};
|
};
|
||||||
use utils::{get_bundle, is_wayland};
|
use utils::{get_bundle, is_wayland};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
use std::io::ErrorKind;
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
@ -597,14 +599,22 @@ pub fn build_ui(application: &Application) {
|
|||||||
);
|
);
|
||||||
} else if _delay_spin.value() as u64 == 0 {
|
} else if _delay_spin.value() as u64 == 0 {
|
||||||
let _area_capture = area_capture.borrow_mut();
|
let _area_capture = area_capture.borrow_mut();
|
||||||
match _ffmpeg_record_interface.borrow_mut().start_record(
|
let start_record = _ffmpeg_record_interface.borrow_mut().start_record(
|
||||||
_area_capture.x,
|
_area_capture.x,
|
||||||
_area_capture.y,
|
_area_capture.y,
|
||||||
_area_capture.width,
|
_area_capture.width,
|
||||||
_area_capture.height,
|
_area_capture.height,
|
||||||
) {
|
);
|
||||||
None => {
|
match start_record {
|
||||||
// Do nothing if the start_record function return nothing
|
Err(ref error) => {
|
||||||
|
if error.kind() == ErrorKind::Interrupted {
|
||||||
|
// Do nothing if the start_record function interrupted
|
||||||
|
} else {
|
||||||
|
error_dialog_label.set_label(&get_bundle("start-error", None));
|
||||||
|
let text_buffer = TextBuffer::new(None);
|
||||||
|
text_buffer.set_text(&error.to_string());
|
||||||
|
error_message.set_buffer(Some(&text_buffer));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
start_timer(record_time_label.clone());
|
start_timer(record_time_label.clone());
|
||||||
@ -645,6 +655,11 @@ pub fn build_ui(application: &Application) {
|
|||||||
_ffmpeg_record_interface.borrow_mut().clone().play_record();
|
_ffmpeg_record_interface.borrow_mut().clone().play_record();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Error Dialog
|
||||||
|
error_dialog.set_title(Some(&get_bundle("error-dialog", None)));
|
||||||
|
error_dialog_button.set_label(&get_bundle("close-error-dialog", None));
|
||||||
|
error_expander_label.set_label(&get_bundle("details-button", None));
|
||||||
|
|
||||||
// About Dialog
|
// About Dialog
|
||||||
let mut about_icon_path = {
|
let mut about_icon_path = {
|
||||||
let mut current_exec_dir = std::env::current_exe().unwrap();
|
let mut current_exec_dir = std::env::current_exe().unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user