diff --git a/src/ffmpeg_interface.rs b/src/ffmpeg_interface.rs index a956e96..d355f22 100644 --- a/src/ffmpeg_interface.rs +++ b/src/ffmpeg_interface.rs @@ -51,7 +51,7 @@ impl ProgressWidget { } pub fn hide(&self) { - self.dialog.emit_close(); + self.dialog.hide(); } } diff --git a/src/main.rs b/src/main.rs index d61adbc..cc2cd03 100644 --- a/src/main.rs +++ b/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> = - 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> = 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(