diff --git a/data/blue-recorder@x128.png b/data/blue-recorder@x128.png new file mode 100644 index 0000000..c060e51 Binary files /dev/null and b/data/blue-recorder@x128.png differ diff --git a/interfaces/main.ui b/interfaces/main.ui index 36b10c2..661a020 100644 --- a/interfaces/main.ui +++ b/interfaces/main.ui @@ -130,13 +130,12 @@ True - False - 0.99999999977648257 + True False center center - + True False False @@ -147,7 +146,6 @@ True True half - True True @@ -185,12 +183,35 @@ True True True - none + half - + True False - media-playback-stop + 2 + True + + + True + False + media-playback-stop + + + 0 + 0 + + + + + True + False + Stop Recording + + + 1 + 0 + + diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 54046be..7f3bb02 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -4,7 +4,7 @@ version: git # just for humans, typically '1.2+git' or '1.3.2' summary: A simple screen recorder for Linux desktop. Supports Wayland & Xorg # 79 char long summary description: | A simple desktop recorder for Linux systems. Built using Rust, GTK+ 3 and ffmpeg. It supports recording audio and video on almost all Linux interfaces with support for Wayland display server on GNOME session. - The following formats are currently supported: mkv, avi, mp4, wmv, gif and nut (And only WebM for Wayland's GNOME session). You can stop the recording process easily by right-clicking the icon and choosing "Stop Record". Or middle-clicking the recording icon in the notifications area (but doesn't work on all interfaces). + The following formats are currently supported: mkv, avi, mp4, wmv, gif and nut. You can stop the recording process easily by right-clicking the icon and choosing "Stop Record". Or middle-clicking the recording icon in the notifications area (but doesn't work on all interfaces). You can choose the audio input source you want from the list. You can also set the default values you want by simply changing them in the interface, and the program will save them for you for the next time you open it. Based on GREEN RECORDER but rewritten in RUST diff --git a/src/ffmpeg_interface.rs b/src/ffmpeg_interface.rs index 5af726f..2f3d150 100644 --- a/src/ffmpeg_interface.rs +++ b/src/ffmpeg_interface.rs @@ -1,8 +1,10 @@ extern crate subprocess; use chrono::prelude::*; +use gtk::prelude::*; use gtk::{ - CheckButton, ComboBoxExt, ComboBoxText, Entry, EntryExt, FileChooser, FileChooserExt, - SpinButton, SpinButtonExt, ToggleButtonExt, + CheckButton, ComboBoxText, Entry, EntryExt, FileChooser, + SpinButton, Dialog, ProgressBar, + Window }; use std::collections::HashMap; use std::path::PathBuf; @@ -15,6 +17,47 @@ use subprocess::Exec; use zbus::dbus_proxy; use zvariant::Value; +#[derive(Clone)] +pub struct ProgressWidget { + pub dialog: Dialog, + pub progress: ProgressBar, +} + +impl ProgressWidget { + pub fn new(window: &Window) -> ProgressWidget { + ProgressWidget { + dialog: Dialog::new(), + progress: ProgressBar::new() + }.init(&window) + } + + pub fn init(&self, window: &Window) -> ProgressWidget { + self.dialog.set_title("Progress"); + self.dialog.set_transient_for(Some(window)); + self.progress.set_fraction(0.0); + self.dialog.get_content_area().add(&self.progress); + self.progress.set_show_text(true); + self.dialog.set_deletable(false); + self.dialog.set_modal(true); + self.clone() + } + + pub fn set_progress(&self, title: String, value: i32, max: i32) { + let progress_precentage: f64 = value as f64 / max as f64; + self.progress.set_text(Some(&title)); + self.progress.set_fraction(progress_precentage); + } + + pub fn show(&self) { + self.progress.set_fraction(0.0); + self.dialog.show_all(); + } + + pub fn hide(&self) { + self.dialog.emit_close(); + } +} + trait GnomeScreencastResult {} #[dbus_proxy( @@ -54,6 +97,7 @@ pub struct Ffmpeg { pub process_id: Option, pub saved_filename: Option, pub unbound: Option>, + pub progress_widget: ProgressWidget } impl Ffmpeg { @@ -145,7 +189,9 @@ impl Ffmpeg { ffmpeg_command.arg("-i"); ffmpeg_command.arg(format!( "{}+{},{}", - std::env::var("DISPLAY").unwrap_or(":1".to_string()).as_str(), + std::env::var("DISPLAY") + .unwrap_or(":1".to_string()) + .as_str(), x, y )); @@ -175,8 +221,10 @@ impl Ffmpeg { } pub fn stop_record(&self) { + &self.progress_widget.show(); // kill the process to stop recording if self.process_id.is_some() { + &self.progress_widget.set_progress("Stop Recording".to_string(), 1, 5); Command::new("kill") .arg(format!("{}", self.process_id.unwrap())) .output() @@ -198,6 +246,7 @@ impl Ffmpeg { ) .exists(); if self.unbound.is_some() { + &self.progress_widget.set_progress("Stop Wayland Video Recording".to_string(), 2, 5); self.unbound .as_ref() .unwrap() @@ -230,6 +279,8 @@ impl Ffmpeg { .unwrap(); if is_audio_record { + &self.progress_widget.set_progress("Stop Wayland Audio Recording".to_string(), 3, 5); + // merge audio with video let mut ffmpeg_audio_merge_command = Command::new("ffmpeg"); ffmpeg_audio_merge_command.arg("-i"); @@ -264,6 +315,7 @@ impl Ffmpeg { } } } else if is_audio_record { + &self.progress_widget.set_progress("Convert Audio to choosen format".to_string(), 3, 5); println!("convert audio"); Command::new("ffmpeg") .arg("-f") @@ -286,8 +338,12 @@ impl Ffmpeg { // execute command after finish recording if !(self.command.get_text().trim() == "") { + &self.progress_widget.set_progress("execute custom command after finish".to_string(), 4, 5); Exec::shell(self.command.get_text().trim()).popen().unwrap(); } + + &self.progress_widget.set_progress("Finish".to_string(), 5, 5); + &self.progress_widget.hide(); } // Gnome screencast for record wayland diff --git a/src/main.rs b/src/main.rs index cc28582..d61adbc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,13 +8,14 @@ mod config_management; mod ffmpeg_interface; // use gio::prelude::*; +use ffmpeg_interface::{Ffmpeg, ProgressWidget}; use gettextrs::{bindtextdomain, gettext, setlocale, textdomain, LocaleCategory}; use glib::signal::Inhibit; use gtk::prelude::*; use gtk::ComboBoxText; use gtk::{ - AboutDialog, Builder, Button, CheckButton, CssProvider, Entry, FileChooser, Label, MenuItem, - SpinButton, Window, + AboutDialog, Builder, Button, CheckButton, CssProvider, Entry, FileChooser, Label, + MenuItem, SpinButton, Window, }; use libappindicator::{AppIndicator, AppIndicatorStatus}; use std::cell::RefCell; @@ -52,7 +53,9 @@ fn main() { current_exec_dir.pop(); current_exec_dir } - .join(Path::new("po")).to_str().unwrap(), + .join(Path::new("po")) + .to_str() + .unwrap(), ); textdomain("blue-recorder"); @@ -85,7 +88,6 @@ fn main() { let mouse_switch: CheckButton = builder.get_object("mouseswitch").unwrap(); let follow_mouse_switch: CheckButton = builder.get_object("followmouseswitch").unwrap(); let about_menu_item: MenuItem = builder.get_object("about_menu_item").unwrap(); - // --- default properties // Windows main_window.set_title(&gettext("Blue Recorder")); @@ -96,6 +98,9 @@ fn main() { &gdk::Screen::get_rgba_visual(&gdk::Screen::get_default().unwrap()).unwrap(), )); + stop_button.hide(); + play_button.hide(); + // Entries filename_entry.set_placeholder_text(Some(&gettext("Default filename:"))); command_entry.set_placeholder_text(Some(&gettext("Default command:"))); @@ -287,8 +292,8 @@ fn main() { }); // init record struct - let ffmpeg_record_interface: Rc> = - Rc::new(RefCell::new(ffmpeg_interface::Ffmpeg { + let ffmpeg_record_interface: Rc> = + Rc::new(RefCell::new(Ffmpeg { filename: (folder_chooser, filename_entry, format_chooser_combobox), record_video: video_switch, record_audio: audio_switch, @@ -301,6 +306,7 @@ fn main() { process_id: None, saved_filename: None, unbound: None, + progress_widget: ProgressWidget::new(&main_window) })); // App Indicator @@ -331,16 +337,25 @@ fn main() { // when indictor stop recording button clicked let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone(); let mut _indicator = indicator.clone(); + let _stop_button = stop_button.clone(); + let _play_button = play_button.clone(); + let _record_button = record_button.clone(); indicator_stop_recording.connect_activate(move |_| { _ffmpeg_record_interface.borrow_mut().clone().stop_record(); _indicator .borrow_mut() .set_status(AppIndicatorStatus::Passive); + + _record_button.show(); + _stop_button.hide(); + _play_button.show(); }); let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone(); let mut _area_capture = area_capture.clone(); let mut _indicator = indicator.clone(); + let _stop_button = stop_button.clone(); + let _record_button = record_button.clone(); record_button.connect_clicked(move |_| { let _area_capture = _area_capture.borrow_mut().clone(); _ffmpeg_record_interface.borrow_mut().start_record( @@ -352,15 +367,25 @@ fn main() { _indicator .borrow_mut() .set_status(AppIndicatorStatus::Active); + + _record_button.hide(); + _stop_button.show(); }); let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone(); let mut _indicator = indicator.clone(); + let _stop_button = stop_button.clone(); + let _play_button = play_button.clone(); + let _record_button = record_button.clone(); stop_button.connect_clicked(move |_| { _ffmpeg_record_interface.borrow_mut().clone().stop_record(); _indicator .borrow_mut() .set_status(AppIndicatorStatus::Passive); + + _record_button.show(); + _stop_button.hide(); + _play_button.show(); }); let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone();