mirror of
https://github.com/xlmnxp/blue-recorder.git
synced 2024-11-23 17:13:11 +03:00
Hide buttons when it not in use; show dialog wth progress after stop recording to show video audio merge and converting to choosen formats
This commit is contained in:
parent
4ad16194a7
commit
89e1b40b0b
BIN
data/blue-recorder@x128.png
Normal file
BIN
data/blue-recorder@x128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
@ -130,13 +130,12 @@
|
||||
</object>
|
||||
<object class="GtkWindow" id="main_window">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="opacity">0.99999999977648257</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="gravity">center</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="headerbar1">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="has_subtitle">False</property>
|
||||
@ -147,7 +146,6 @@
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="relief">half</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
@ -185,12 +183,35 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="relief">half</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">media-playback-stop</property>
|
||||
<property name="column_spacing">2</property>
|
||||
<property name="row_homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">media-playback-stop</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Stop Recording</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -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
|
||||
|
||||
|
@ -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<u32>,
|
||||
pub saved_filename: Option<String>,
|
||||
pub unbound: Option<Sender<bool>>,
|
||||
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
|
||||
|
37
src/main.rs
37
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<RefCell<ffmpeg_interface::Ffmpeg>> =
|
||||
Rc::new(RefCell::new(ffmpeg_interface::Ffmpeg {
|
||||
let ffmpeg_record_interface: Rc<RefCell<Ffmpeg>> =
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user