play button error dialog

This commit is contained in:
ochibani 2024-07-06 02:57:31 +02:00
parent 965b303832
commit 2ce25c6ab0
No known key found for this signature in database
GPG Key ID: 2C6B61CE0C704ED4
6 changed files with 84 additions and 21 deletions

View File

@ -24,15 +24,12 @@ ffmpeg
gtk gtk
gdk gdk
gio gio
gettext
libappindicator3
x11-utils x11-utils
pulseaudio
``` ```
Install dependencies Ubuntu and Debian based distros: Install dependencies Ubuntu and Debian based distros:
``` ```
sudo apt install build-essential clang cargo libappindicator3-1 x11-utils gettext pulseaudio ffmpeg sudo apt install build-essential clang cargo x11-utils ffmpeg libgtk-3-dev libgtk-4-dev libatk1.0-dev librust-alsa-dev librust-gstreamer-dev
``` ```
Then use `Cargo` to build it: Then use `Cargo` to build it:
``` ```

View File

@ -10,6 +10,7 @@
<object class="GtkMessageDialog" id="error_dialog"> <object class="GtkMessageDialog" id="error_dialog">
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="destroy-with-parent">True</property> <property name="destroy-with-parent">True</property>
<property name="resizable">False</property>
<property name="modal">True</property> <property name="modal">True</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
@ -20,7 +21,7 @@
<object class="GtkImage" id="error_image"> <object class="GtkImage" id="error_image">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="pixel-size">32</property> <property name="pixel-size">48</property>
<property name="icon-name">dialog-error-symbolic</property> <property name="icon-name">dialog-error-symbolic</property>
</object> </object>
</child> </child>
@ -36,11 +37,21 @@
<child type="start"> <child type="start">
<object class="GtkExpander" id="error_expander"> <object class="GtkExpander" id="error_expander">
<property name="label-widget">expander_label</property> <property name="label-widget">expander_label</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hscrollbar-policy">never</property>
<child> <child>
<object class="GtkTextView" id="error_details"> <object class="GtkTextView" id="error_details">
<property name="receives-default">False</property> <property name="receives-default">False</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="editable">False</property> <property name="editable">False</property>
<property name="wrap-mode">word-char</property>
<property name="vexpand">True</property>
<property name="hexpand">True</property>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>

View File

@ -60,6 +60,9 @@ wmv-format = WMV (Windows Media Video)
# Name # Name
blue-recorder = المسجّل الأزرق blue-recorder = المسجّل الأزرق
# Close error dialog
close = Close
# Copy right # Copy right
copy-right = © 2021 Salem Yaslem copy-right = © 2021 Salem Yaslem
@ -87,6 +90,9 @@ details-button = Details
# Run command input # Run command input
enter-command = اكتب الأمر هنا.. enter-command = اكتب الأمر هنا..
# Error dialog title
error-title = Error
# Frames label # Frames label
file-name = اسم الملفّ الافتراضي: file-name = اسم الملفّ الافتراضي:

View File

@ -60,6 +60,9 @@ wmv-format = WMV (Windows Media Video)
# Name # Name
blue-recorder = Blue Recorder blue-recorder = Blue Recorder
# Close error dialog
close = Close
# Copy right # Copy right
copy-right = © 2021 Salem Yaslem copy-right = © 2021 Salem Yaslem
@ -87,6 +90,9 @@ details-button = Details
# Run command input # Run command input
enter-command = Enter your command here.. enter-command = Enter your command here..
# Error dialog title
error-title = Error
# Frames label # Frames label
file-name = Default filename: file-name = Default filename:

View File

@ -1,13 +1,13 @@
extern crate subprocess; extern crate subprocess;
use crate::config_management; use crate::config_management;
use crate::utils::{is_snap, is_wayland}; use crate::utils::{get_bundle, is_snap, is_wayland};
use crate::wayland_record::{CursorModeTypes, RecordTypes, WaylandRecorder}; use crate::wayland_record::{CursorModeTypes, RecordTypes, WaylandRecorder};
use chrono::prelude::*; use chrono::prelude::*;
use ffmpeg_sidecar::child::FfmpegChild; use ffmpeg_sidecar::child::FfmpegChild;
use ffmpeg_sidecar::command::FfmpegCommand; use ffmpeg_sidecar::command::FfmpegCommand;
use gtk::{prelude::*, ResponseType}; use gtk::{prelude::*, ResponseType, TextBuffer, TextView};
use gtk::{ButtonsType, DialogFlags, MessageDialog, MessageType}; use gtk::{ButtonsType, DialogFlags, MessageDialog, MessageType};
use gtk::{CheckButton, ComboBoxText, Entry, FileChooserNative, SpinButton, Window}; use gtk::{CheckButton, ComboBoxText, Entry, FileChooserNative, Label, SpinButton, Window};
use std::cell::RefCell; use std::cell::RefCell;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Command; use std::process::Command;
@ -42,6 +42,9 @@ pub struct Ffmpeg {
pub bundle: String, pub bundle: String,
pub video_record_bitrate: SpinButton, pub video_record_bitrate: SpinButton,
pub audio_record_bitrate: SpinButton, pub audio_record_bitrate: SpinButton,
pub error_window: MessageDialog,
pub error_window_text: Label,
pub error_details: TextView,
} }
impl Ffmpeg { impl Ffmpeg {
@ -425,13 +428,42 @@ impl Ffmpeg {
if self.saved_filename.is_some() { if self.saved_filename.is_some() {
if is_snap() { if is_snap() {
// open the video using snapctrl for snap package // open the video using snapctrl for snap package
Command::new("snapctl") let snapctl = Command::new("snapctl")
.arg("user-open") .arg("user-open")
.arg(self.saved_filename.unwrap()) .arg(self.saved_filename.unwrap())
.spawn() .spawn();
.unwrap(); match snapctl {
Ok(_) => {
// Continue
},
Err(error) => {
let text_buffer = TextBuffer::new(None);
text_buffer.set_text(&error.to_string());
self.error_window.set_title(Some(&get_bundle("error-title", None)));
self.error_window_text.set_label(&get_bundle("play-error", None));
self.error_details.set_buffer(Some(&text_buffer));
self.error_window.set_transient_for(Some(&self.window));
self.error_window.show();
self.error_window.set_hide_on_close(true);
},
}
} else { } else {
open::that(self.saved_filename.unwrap()).unwrap(); let open_file = open::that(self.saved_filename.unwrap());
match open_file {
Ok(_) => {
// Continue
},
Err(error) => {
let text_buffer = TextBuffer::new(None);
text_buffer.set_text(&error.to_string());
self.error_window.set_title(Some(&get_bundle("error-title", None)));
self.error_window_text.set_label(&get_bundle("play-error", None));
self.error_details.set_buffer(Some(&text_buffer));
self.error_window.set_transient_for(Some(&self.window));
self.error_window.show();
self.error_window.set_hide_on_close(true);
},
}
} }
} }
} }

View File

@ -112,6 +112,14 @@ pub fn build_ui(application: &Application) {
stop_button.hide(); stop_button.hide();
play_button.hide(); play_button.hide();
// Error dialog
error_dialog_button.set_label(&get_bundle("close", None));
error_expander_label.set_label(&get_bundle("details-button", None));
let _error_dialog = error_dialog.clone();
error_dialog_button.connect_clicked(move |_|{
_error_dialog.close();
});
// Toggle button // Toggle button
config_management::set("default", "mode", "screen"); config_management::set("default", "mode", "screen");
screen_grab_button.set_active(true); screen_grab_button.set_active(true);
@ -569,9 +577,12 @@ pub fn build_ui(application: &Application) {
bundle: bundle_msg, bundle: bundle_msg,
video_record_bitrate: video_bitrate_spin, video_record_bitrate: video_bitrate_spin,
audio_record_bitrate: audio_bitrate_spin, audio_record_bitrate: audio_bitrate_spin,
error_window: error_dialog,
error_window_text: error_dialog_label,
error_details: error_message,
})); }));
// Record Button // Record button
let _delay_window = delay_window.clone(); let _delay_window = delay_window.clone();
let _delay_window_button = delay_window_button.clone(); let _delay_window_button = delay_window_button.clone();
let _ffmpeg_record_interface = ffmpeg_record_interface.clone(); let _ffmpeg_record_interface = ffmpeg_record_interface.clone();
@ -620,7 +631,7 @@ pub fn build_ui(application: &Application) {
} }
}); });
// Stop Record Button // Stop record button
let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone(); let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone();
let _play_button = play_button.clone(); let _play_button = play_button.clone();
let _stop_button = stop_button.clone(); let _stop_button = stop_button.clone();
@ -635,17 +646,17 @@ pub fn build_ui(application: &Application) {
_play_button.show(); _play_button.show();
}); });
// Delay Window Button // Delay window button
let _delay_window_button = delay_window_button.clone(); let _delay_window_button = delay_window_button.clone();
delay_window_button.connect_clicked(move |_| {}); delay_window_button.connect_clicked(move |_| {});
// Play Button // Play button
let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone(); let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone();
play_button.connect_clicked(move |_| { play_button.connect_clicked(move |_| {
_ffmpeg_record_interface.borrow_mut().clone().play_record(); _ffmpeg_record_interface.borrow_mut().clone().play_record();
}); });
// 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();
current_exec_dir.pop(); current_exec_dir.pop();