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
remove progress dialog
  • Loading branch information
xlmnxp committed Oct 21, 2023
commit 5f847a021c502bcc7cadf1476ccccda6b14fb811
22 changes: 0 additions & 22 deletions interfaces/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,6 @@
</object>
</child>
</object>
<object class="GtkMessageDialog" id="progress_dialog">
<property name="title">Progress</property>
<property name="transient-for">main_window</property>
<property name="deletable">False</property>
<property name="default-width">300</property>
<property name="modal">True</property>
<property name="message-type">info</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkProgressBar" id="progress_bar">
<property name="visible">True</property>
<property name="fraction">0.0</property>
<property name="show-text">True</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
</object>
</child>
</object>
</child>
</object>
<object class="GtkWindow" id="delay_window">
<property name="name">delay_window</property>
<property name="can-focus">True</property>
Expand Down
75 changes: 1 addition & 74 deletions src/ffmpeg_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use chrono::prelude::*;
use gettextrs::gettext;
use gtk::{prelude::*, ResponseType};
use gtk::{ButtonsType, DialogFlags, MessageDialog, MessageType};
use gtk::{CheckButton, ComboBoxText, Entry, FileChooserNative, ProgressBar, SpinButton, Window};
use gtk::{CheckButton, ComboBoxText, Entry, FileChooserNative, SpinButton, Window};
use std::cell::RefCell;
use std::path::PathBuf;
use std::process::{Child, Command};
Expand All @@ -15,37 +15,6 @@ use std::thread::sleep;
use std::time::Duration;
use subprocess::Exec;

#[derive(Clone)]
pub struct ProgressWidget {
pub progress_dialog: MessageDialog,
pub progress_bar: ProgressBar,
}

impl ProgressWidget {
pub fn new(progress_dialog: MessageDialog, progress_bar: ProgressBar) -> ProgressWidget {
ProgressWidget {
progress_dialog,
progress_bar,
}
}

pub fn set_progress(&self, title: String, value: i32, max: i32) {
glib::MainContext::default().block_on(async {
let progress_percentage: f64 = value as f64 / max as f64;
self.progress_bar.set_text(Some(&title));
self.progress_bar.set_fraction(progress_percentage);
});
}

pub fn show(&self) {
self.progress_dialog.show();
}

pub fn hide(&self) {
self.progress_dialog.hide();
}
}

#[derive(Clone)]
pub struct Ffmpeg {
pub filename: (FileChooserNative, Entry, ComboBoxText),
Expand All @@ -61,7 +30,6 @@ pub struct Ffmpeg {
pub audio_process: Option<Rc<RefCell<Child>>>,
pub saved_filename: Option<String>,
pub unbound: Option<Sender<bool>>,
pub progress_widget: ProgressWidget,
pub window: Window,
pub record_wayland: WaylandRecorder,
pub main_context: gtk::glib::MainContext,
Expand Down Expand Up @@ -211,16 +179,8 @@ impl Ffmpeg {
}

pub fn stop_record(&mut self) {
glib::MainContext::default().block_on(async {
self.progress_widget.show();
});
self.progress_widget.set_progress("".to_string(), 1, 7);

// kill the process to stop recording
if self.video_process.is_some() {
self.progress_widget
.set_progress("Stop Recording Video".to_string(), 1, 7);

Command::new("kill")
.arg(format!(
"{}",
Expand All @@ -241,12 +201,7 @@ impl Ffmpeg {
self.main_context.block_on(self.record_wayland.stop());
}

self.progress_widget.set_progress("".to_string(), 2, 7);

if self.audio_process.is_some() {
self.progress_widget
.set_progress("Stop Recording Audio".to_string(), 2, 7);

Command::new("kill")
.arg(format!(
"{}",
Expand Down Expand Up @@ -307,15 +262,7 @@ impl Ffmpeg {
]);
move_command.output().unwrap();
} else {
println!("convert webm to specified format");

// convert webm to specified format
self.progress_widget.set_progress(
"Convert screen-cast to specified format".to_string(),
4,
7,
);

Command::new("ffmpeg")
.args([
"-i",
Expand All @@ -334,14 +281,8 @@ impl Ffmpeg {
.output()
.unwrap();
}

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

// if audio record, then merge video with audio
if is_audio_record {
self.progress_widget
.set_progress("Save Audio Recording".to_string(), 5, 7);

Command::new("ffmpeg")
.args([
"-i",
Expand All @@ -368,9 +309,6 @@ impl Ffmpeg {
}
// 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(), 5, 7);

Command::new("ffmpeg")
.args([
"-f",
Expand All @@ -385,21 +323,10 @@ impl Ffmpeg {
std::fs::remove_file(audio_filename).unwrap();
}

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

// execute command after finish recording
if self.command.text().trim() != "" {
self.progress_widget.set_progress(
"execute custom command after finish".to_string(),
5,
6,
);
Exec::shell(self.command.text().trim()).popen().unwrap();
}

self.progress_widget
.set_progress("Finish".to_string(), 7, 7);
self.progress_widget.hide();
}

pub fn play_record(self) {
Expand Down
7 changes: 2 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ mod timer;
mod wayland_record;
mod utils;

use ffmpeg_interface::{Ffmpeg, ProgressWidget};
use ffmpeg_interface::Ffmpeg;
use gettextrs::{bindtextdomain, gettext, setlocale, textdomain, LocaleCategory};
use gtk::glib;
use gtk::prelude::*;
use gtk::{
AboutDialog, Application, Builder, Button, CheckButton, ComboBoxText, CssProvider, Entry,
FileChooserAction, FileChooserNative, Image, Label, MessageDialog, ProgressBar, SpinButton,
FileChooserAction, FileChooserNative, Image, Label, SpinButton,
ToggleButton, Window,
};
use utils::is_wayland;
Expand Down Expand Up @@ -92,8 +92,6 @@ pub fn build_ui(application: &Application) {
let frames_spin: SpinButton = builder.object("frames").unwrap();
let mouse_switch: CheckButton = builder.object("mouseswitch").unwrap();
let play_button: Button = builder.object("playbutton").unwrap();
let progress_dialog: MessageDialog = builder.object("progress_dialog").unwrap();
let progress_bar: ProgressBar = builder.object("progress_bar").unwrap();
let record_button: Button = builder.object("recordbutton").unwrap();
let record_time_label: Label = builder.object("record_time_label").unwrap();
let screen_grab_button: ToggleButton = builder.object("screen_grab_button").unwrap();
Expand Down Expand Up @@ -472,7 +470,6 @@ pub fn build_ui(application: &Application) {
audio_process: None,
saved_filename: None,
unbound: None,
progress_widget: ProgressWidget::new(progress_dialog, progress_bar),
window: main_window.clone(),
record_delay: delay_spin,
record_wayland: wayland_record,
Expand Down