mirror of
https://github.com/xlmnxp/blue-recorder.git
synced 2024-11-23 17:13:11 +03:00
support GIF
add environments for DATA_DIR, PO_DIR, INTERFACES_DIR fix(Gtk-CRITICAL): assertion 'GTK_IS_CONTAINER (container)' failed
This commit is contained in:
parent
3aba5eaf39
commit
c984d7b4d7
@ -51,7 +51,7 @@ impl ProgressWidget {
|
||||
}
|
||||
|
||||
pub fn hide(&self) {
|
||||
self.dialog.emit_close();
|
||||
self.dialog.hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
78
src/main.rs
78
src/main.rs
@ -14,11 +14,12 @@ 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;
|
||||
use std::ops::Add;
|
||||
use std::path::Path;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::rc::Rc;
|
||||
@ -41,22 +42,30 @@ fn main() {
|
||||
if user_interface_path_abs.exists() {
|
||||
builder = Builder::from_file(user_interface_path_abs);
|
||||
} else {
|
||||
builder = Builder::from_file("interfaces/main.ui");
|
||||
builder = Builder::from_file(
|
||||
std::env::var("INTERFACES_DIR")
|
||||
.unwrap_or(String::from("interfaces/"))
|
||||
.add("main.ui"),
|
||||
);
|
||||
}
|
||||
|
||||
// translate
|
||||
let mut po_path_abs = {
|
||||
let mut current_exec_dir = std::env::current_exe().unwrap();
|
||||
current_exec_dir.pop();
|
||||
current_exec_dir
|
||||
}
|
||||
.join(Path::new("po"));
|
||||
|
||||
if !po_path_abs.exists() {
|
||||
po_path_abs = std::fs::canonicalize(Path::new(
|
||||
&std::env::var("PO_DIR").unwrap_or(String::from("po")),
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
setlocale(LocaleCategory::LcAll, "");
|
||||
bindtextdomain(
|
||||
"blue-recorder",
|
||||
{
|
||||
let mut current_exec_dir = std::env::current_exe().unwrap();
|
||||
current_exec_dir.pop();
|
||||
current_exec_dir
|
||||
}
|
||||
.join(Path::new("po"))
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
);
|
||||
bindtextdomain("blue-recorder", po_path_abs.to_str().unwrap());
|
||||
textdomain("blue-recorder");
|
||||
|
||||
// config initialize
|
||||
@ -115,8 +124,7 @@ fn main() {
|
||||
format_chooser_combobox.append(Some("avi"), &gettext("AVI (Audio Video Interleaved)"));
|
||||
format_chooser_combobox.append(Some("mp4"), &gettext("MP4 (MPEG-4 Part 14)"));
|
||||
format_chooser_combobox.append(Some("wmv"), &gettext("WMV (Windows Media Video)"));
|
||||
// TODO: gif not work at this time, fix it!
|
||||
// format_chooser_combobox.append(Some("gif"), &gettext("GIF (Graphics Interchange Format)"));
|
||||
format_chooser_combobox.append(Some("gif"), &gettext("GIF (Graphics Interchange Format)"));
|
||||
format_chooser_combobox.append(Some("nut"), &gettext("NUT (NUT Recording Format)"));
|
||||
format_chooser_combobox.set_active(Some(0));
|
||||
|
||||
@ -292,22 +300,21 @@ fn main() {
|
||||
});
|
||||
|
||||
// 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,
|
||||
record_audio: audio_switch,
|
||||
audio_id: audio_source_combobox,
|
||||
record_mouse: mouse_switch,
|
||||
follow_mouse: follow_mouse_switch,
|
||||
record_frames: frames_spin,
|
||||
record_delay: delay_spin,
|
||||
command: command_entry,
|
||||
process_id: None,
|
||||
saved_filename: None,
|
||||
unbound: None,
|
||||
progress_widget: ProgressWidget::new(&main_window)
|
||||
}));
|
||||
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,
|
||||
audio_id: audio_source_combobox,
|
||||
record_mouse: mouse_switch,
|
||||
follow_mouse: follow_mouse_switch,
|
||||
record_frames: frames_spin,
|
||||
record_delay: delay_spin,
|
||||
command: command_entry,
|
||||
process_id: None,
|
||||
saved_filename: None,
|
||||
unbound: None,
|
||||
progress_widget: ProgressWidget::new(&main_window),
|
||||
}));
|
||||
|
||||
// App Indicator
|
||||
let mut indicator_icon_path = {
|
||||
@ -318,7 +325,12 @@ fn main() {
|
||||
.join(Path::new("data/blue-recorder.png"));
|
||||
|
||||
if !indicator_icon_path.exists() {
|
||||
indicator_icon_path = std::fs::canonicalize(Path::new("data/blue-recorder.png")).unwrap();
|
||||
indicator_icon_path = std::fs::canonicalize(Path::new(
|
||||
&std::env::var("DATA_DIR")
|
||||
.unwrap_or(String::from("data/"))
|
||||
.add("blue-recorder.png"),
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let indicator = Rc::new(RefCell::new(AppIndicator::new(
|
||||
|
Loading…
Reference in New Issue
Block a user