Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial gtk4 migration #39

Merged
merged 50 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
6f48df3
Initial gtk4 migration
ochibani Sep 24, 2022
3c0ea6e
fix window size by changing main.ui
ochibani Sep 28, 2022
78d3fb6
display home icons in folder chooser
ochibani Sep 29, 2022
84cc6b3
area chooser window redesigned
ochibani Sep 30, 2022
8092950
spell check
ochibani Oct 1, 2022
835e466
remove wayland from ffmpeg-interface
ochibani Oct 14, 2022
3428d6d
Remove buggy video formats
ochibani Oct 14, 2022
56f5598
fix is_file_already_exists & play button
ochibani Oct 16, 2022
d9e7458
use system theme colors
xlmnxp Oct 18, 2022
a6ca6d3
look like fixed the video and audio merge
xlmnxp Oct 18, 2022
828074a
fix Progress dialog
xlmnxp Oct 18, 2022
336e8e4
hide window selection in wayland
ochibani Oct 18, 2022
71edab6
folder chooser parent
ochibani Oct 19, 2022
cec2d85
folder chooser hide
ochibani Oct 19, 2022
d1c4706
fix FileChooserButton
ochibani Oct 20, 2022
257c5b4
remove progress button
ochibani Oct 20, 2022
ad01c74
remove audio only record code
ochibani Oct 24, 2022
a3dbd29
add delay timer
ochibani Nov 1, 2022
f7c72ff
add recording timer
ochibani Nov 2, 2022
cbcb44d
add hours to timer
ochibani Nov 2, 2022
3e37cc9
minor change
ochibani Nov 4, 2022
258cda8
Edit indicator.rs
ochibani Nov 26, 2022
78ec81d
Working X11 version
ochibani Nov 26, 2022
fb32ebe
use 60fps as default
xlmnxp Feb 22, 2023
86303da
Merge branch 'blue-recorder-gtk4' of https://github.com/ochibani/blue…
xlmnxp Feb 22, 2023
c5189de
bug fixes, force select audio or video to record
xlmnxp Feb 22, 2023
a8f025e
use of Childs instead of kill command (Work cross multiple operating …
xlmnxp Feb 22, 2023
d82d71b
Simplify the implementation of Ffmpeg
xlmnxp Feb 23, 2023
b5b10cf
fix video and audio merges and fix audio recording issue
xlmnxp Feb 28, 2023
2ed389d
include tr.po with migration to GTK4
xlmnxp Mar 1, 2023
af982be
auto detect dark mode and change icons
xlmnxp Mar 1, 2023
3695530
improve style of select buttons
xlmnxp Oct 14, 2023
f857ba5
remove overwrite switch and fix message dialog
xlmnxp Oct 14, 2023
329c4a7
add wayland recorder
xlmnxp Oct 14, 2023
29b0a61
little improvements
xlmnxp Oct 15, 2023
aa9213a
little improvements
xlmnxp Oct 15, 2023
5d8f19f
update ui
ochibani Oct 16, 2023
7688528
update ui
ochibani Oct 17, 2023
8b7343c
add auto hide
ochibani Oct 19, 2023
b959262
add wayland record and mouse toggle
xlmnxp Oct 19, 2023
0e95762
refactor of code
xlmnxp Oct 21, 2023
5f847a0
remove progress dialog
xlmnxp Oct 21, 2023
5f079b8
fix borrow_mut
xlmnxp Oct 21, 2023
75df858
enable recording of window or screen
xlmnxp Oct 21, 2023
6c049e4
remove temporary video file when recording video only
xlmnxp Oct 21, 2023
510a1e5
enable recording of window or screen
xlmnxp Oct 21, 2023
5af98f9
remember last decision to record window or screen
xlmnxp Oct 22, 2023
4e4756e
update ui
ochibani Oct 23, 2023
591a671
remove appid from gtk part
xlmnxp Oct 27, 2023
d10fdf7
upgrade snap packaging
xlmnxp Oct 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
hide window selection in wayland
  • Loading branch information
ochibani committed Oct 18, 2022
commit 336e8e42c597909f8771bb73dc28ff7db46eb697
2 changes: 1 addition & 1 deletion src/area_capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate regex;
use regex::Regex;
use std::process::Command;

// this struct use "xwininfo" to get area x, y, width and height
// This struct use "xwininfo" to get area x, y, width and height
#[derive(Debug, Copy, Clone)]
pub struct AreaCapture {
pub x: u16,
Expand Down
4 changes: 2 additions & 2 deletions src/config_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn initialize() -> PathBuf {
.join("blue-recorder")
.join("config.ini");

// fatch and make the config file
// Fatch and make the config file
if !&config_path.exists() {
let config_directories = &mut config_path.to_owned();
config_directories.pop();
Expand Down Expand Up @@ -53,7 +53,7 @@ fn merge_previous_version() -> Option<PathBuf> {
.join("blue-recorder")
.join("config.ini");

// return none if config.ini not exists
// Return none if config.ini not exists
if !&config_path.exists() {
return None;
}
Expand Down
20 changes: 10 additions & 10 deletions src/ffmpeg_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl Ffmpeg {
if self.record_video.is_active() {
let mut ffmpeg_command: Command = Command::new("ffmpeg");

// record video with specified width and hight
// Record video with specified width and hight
ffmpeg_command.arg("-video_size");
ffmpeg_command.arg(format!("{}x{}", width, height));
ffmpeg_command.arg("-framerate");
Expand All @@ -155,15 +155,15 @@ impl Ffmpeg {
y
));

// if show mouse switch is enabled, draw the mouse to video
// If show mouse switch is enabled, draw the mouse to video
ffmpeg_command.arg("-draw_mouse");
if self.record_mouse.is_active() {
ffmpeg_command.arg("1");
} else {
ffmpeg_command.arg("0");
}

// if follow mouse switch is enabled, follow the mouse
// If follow mouse switch is enabled, follow the mouse
if self.follow_mouse.is_active() {
ffmpeg_command.arg("-follow_mouse");
ffmpeg_command.arg("centered");
Expand All @@ -172,9 +172,9 @@ impl Ffmpeg {
ffmpeg_command.arg("1");
ffmpeg_command.arg(self.saved_filename.as_ref().unwrap());
ffmpeg_command.arg("-y");
// sleep for delay
// Sleep for delay
sleep(Duration::from_secs(self.record_delay.value() as u64));
// start recording and return the process id
// Start recording and return the process id
self.video_process_id = Some(ffmpeg_command.spawn().unwrap().id());
return (self.video_process_id, self.audio_process_id);
}
Expand All @@ -184,7 +184,7 @@ impl Ffmpeg {

pub fn stop_record(&self) {
self.progress_widget.show();
// kill the process to stop recording
// Kill the process to stop recording
self.progress_widget.set_progress("".to_string(), 1, 6);

if self.video_process_id.is_some() {
Expand Down Expand Up @@ -246,7 +246,7 @@ impl Ffmpeg {

self.progress_widget.set_progress("".to_string(), 4, 6);

// if audio record, then merge video with audio
// If audio record, then merge video with audio
if is_audio_record {
self.progress_widget
.set_progress("Save Audio Recording".to_string(), 4, 6);
Expand Down Expand Up @@ -283,7 +283,7 @@ impl Ffmpeg {
.unwrap();
}
}
// if only audio is recording then convert it to chosen format
// If only audio is recording then convert it to chosen format
else if is_audio_record {
self.progress_widget
.set_progress("Convert Audio to choosen format".to_string(), 4, 6);
Expand All @@ -308,7 +308,7 @@ impl Ffmpeg {

self.progress_widget.set_progress("".to_string(), 5, 6);

// execute command after finish recording
// Execute command after finish recording
if self.command.text().trim() != "" {
self.progress_widget.set_progress(
"execute custom command after finish".to_string(),
Expand All @@ -326,7 +326,7 @@ impl Ffmpeg {
pub fn play_record(self) {
if self.saved_filename.is_some() {
if is_snap() {
// open the video using snapctrl for snap package
// Open the video using snapctrl for snap package
Command::new("snapctl")
.arg("user-open")
.arg(self.saved_filename.unwrap())
Expand Down
48 changes: 32 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ use std::process::{Command, Stdio};
use std::rc::Rc;

fn main() {
//create new application
//Create new application
let application = Application::new(Some("sa.sy.blue-recorder"), Default::default(),);
application.connect_activate(build_ui);
application.run();
}

pub fn build_ui(application: &Application) {
// use "GDK_BACKEND=x11" to make xwininfo work in Wayland by using XWayland
// Use "GDK_BACKEND=x11" to make xwininfo work in Wayland by using XWayland
std::env::set_var("GDK_BACKEND", "x11");
if gtk::init().is_err() {
println!("Failed to initialize GTK.");
Expand All @@ -34,7 +34,7 @@ pub fn build_ui(application: &Application) {
let ui_src = include_str!("../interfaces/main.ui").to_string();
let builder: Builder = Builder::from_string(ui_src.as_str());

// translate
// Translate
let mut po_path_abs = {
let mut current_exec_dir = std::env::current_exe().unwrap();
current_exec_dir.pop();
Expand All @@ -53,10 +53,10 @@ pub fn build_ui(application: &Application) {
bindtextdomain("blue-recorder", po_path_abs.to_str().unwrap()).unwrap();
textdomain("blue-recorder").unwrap();

// config initialize
// Config initialize
config_management::initialize();

// get Objects from UI
// Get Objects from UI
let area_chooser_window: Window = builder.object("area_chooser_window").unwrap();
let area_grab_button: ToggleButton = builder.object("area_grab_button").unwrap();
let area_grab_icon: Image = builder.object("area_grab_icon").unwrap();
Expand Down Expand Up @@ -99,10 +99,15 @@ pub fn build_ui(application: &Application) {
main_window.set_application(Some(application));
area_chooser_window.set_title(Some(&gettext("Area Chooser"))); //title is hidden

//hide stop & play buttons
//Hide stop & play buttons
stop_button.hide();
play_button.hide();

//Hide window grab button in Wayland
if is_wayland() {
window_grab_button.hide();
}

// Entries
filename_entry.set_placeholder_text(Some(&gettext("Default filename:")));
command_entry.set_placeholder_text(Some(&gettext("Default command:")));
Expand All @@ -122,7 +127,7 @@ pub fn build_ui(application: &Application) {
//format_chooser_combobox.append(Some("nut"), &gettext("NUT (NUT Recording Format)"));
format_chooser_combobox.set_active(Some(0));

// get audio sources
// Get audio sources
let sources_descriptions: Vec<String> = {
let list_sources_child = Command::new("pactl")
.args(&["list", "sources"])
Expand Down Expand Up @@ -303,14 +308,19 @@ pub fn build_ui(application: &Application) {
folder_chooser_label.set_label(&folder_chooser_name.to_string_lossy());
let folder_chooser_icon = config_management::folder_icon(folder_chooser_name.to_str());
folder_chooser_image.set_icon_name(Some(folder_chooser_icon));
// show file chooser dialog
// Show file chooser dialog
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| {
if response == gtk::ResponseType::Accept {
let folder_chooser = folder_chooser_native.file().unwrap();
let folder_chooser_name = folder_chooser.basename().unwrap();
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_native.destroy();
Expand All @@ -319,7 +329,7 @@ pub fn build_ui(application: &Application) {
}));

// --- 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();
about_button.connect_clicked(move |_| {
_about_dialog.show();
Expand Down Expand Up @@ -365,7 +375,7 @@ pub fn build_ui(application: &Application) {
_progress_dialog.hide();
});

// init record struct
// Init record struct
let ffmpeg_record_interface: Rc<RefCell<Ffmpeg>> = Rc::new(RefCell::new(Ffmpeg {
filename: (folder_chooser, filename_entry, format_chooser_combobox),
record_video: video_switch,
Expand Down Expand Up @@ -397,7 +407,7 @@ pub fn build_ui(application: &Application) {
_area_capture.height,
) {
(None, None) => {
// do nothing if the start_record function return nothing
// Do nothing if the start_record function return nothing
}
_ => {
_record_button.hide();
Expand Down Expand Up @@ -463,22 +473,22 @@ pub fn build_ui(application: &Application) {
about_dialog.set_modal(true);

// Windows
// hide area chooser after it deleted.
// Hide area chooser after it deleted.
let _area_chooser_window = area_chooser_window.clone();
area_chooser_window.connect_close_request (move |_| {
_area_chooser_window.hide();
gtk::Inhibit(true)
});

// close the application when main window destroy
// Close the application when main window destroy
main_window.connect_destroy(move |main_window| {
let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone();
// stop recording before close the application
// Stop recording before close the application
_ffmpeg_record_interface.borrow_mut().clone().stop_record();
main_window.close();
});

// apply css
// Apply css
let provider = CssProvider::new();
provider
.load_from_data(include_str!("styles/global.css").as_bytes());
Expand All @@ -488,5 +498,11 @@ pub fn build_ui(application: &Application) {
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
);

fn is_wayland() -> bool {
std::env::var("XDG_SESSION_TYPE")
.unwrap_or_default()
.eq_ignore_ascii_case("wayland")
}

main_window.show();
}