mirror of
https://github.com/xlmnxp/blue-recorder.git
synced 2024-11-23 17:13:11 +03:00
little improvements
This commit is contained in:
parent
329c4a7d09
commit
29b0a61915
@ -12,6 +12,7 @@ gdk = { git = "https://github.com/gtk-rs/gtk4-rs.git", package = "gdk4"}
|
|||||||
gdk-pixbuf = "0.9.0"
|
gdk-pixbuf = "0.9.0"
|
||||||
gettext-rs = "0.7.0"
|
gettext-rs = "0.7.0"
|
||||||
gtk = { version = "0.4.8", package = "gtk4", features = ["v4_8"] }
|
gtk = { version = "0.4.8", package = "gtk4", features = ["v4_8"] }
|
||||||
|
gio = { version = "0.15.0" }
|
||||||
gtk-sys = "0.15"
|
gtk-sys = "0.15"
|
||||||
glib = "0.10.3"
|
glib = "0.10.3"
|
||||||
rust-ini = "0.16"
|
rust-ini = "0.16"
|
||||||
@ -21,7 +22,4 @@ subprocess = "0.2.6"
|
|||||||
dark-light = "1.0.0"
|
dark-light = "1.0.0"
|
||||||
async-std = {version = "1.12.0", features = ["attributes"]}
|
async-std = {version = "1.12.0", features = ["attributes"]}
|
||||||
gstreamer = "0.20.5"
|
gstreamer = "0.20.5"
|
||||||
zbus = "3.12.0"
|
zbus = "3.12.0"
|
||||||
|
|
||||||
[dependencies.gio]
|
|
||||||
version = "0.15.0"
|
|
@ -1,6 +1,6 @@
|
|||||||
|
extern crate dirs;
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
extern crate ini;
|
extern crate ini;
|
||||||
extern crate dirs;
|
|
||||||
|
|
||||||
use glib::get_user_data_dir;
|
use glib::get_user_data_dir;
|
||||||
use ini::Ini;
|
use ini::Ini;
|
||||||
@ -29,11 +29,19 @@ pub fn initialize() -> PathBuf {
|
|||||||
fn default() {
|
fn default() {
|
||||||
set("default", "frame", "60");
|
set("default", "frame", "60");
|
||||||
set("default", "delay", "0");
|
set("default", "delay", "0");
|
||||||
set("default", "folder",
|
set(
|
||||||
|
"default",
|
||||||
|
"folder",
|
||||||
String::from("file://")
|
String::from("file://")
|
||||||
.add(
|
.add(
|
||||||
glib::get_user_special_dir(glib::UserDirectory::Videos)
|
glib::get_user_special_dir(glib::UserDirectory::Videos)
|
||||||
.unwrap_or_else(|| PathBuf::from(std::env::var("HOME").unwrap_or_else(|_| "/".to_string()).as_str()))
|
.unwrap_or_else(|| {
|
||||||
|
PathBuf::from(
|
||||||
|
std::env::var("HOME")
|
||||||
|
.unwrap_or_else(|_| "/".to_string())
|
||||||
|
.as_str(),
|
||||||
|
)
|
||||||
|
})
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
@ -58,8 +66,12 @@ fn merge_previous_version() -> Option<PathBuf> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut config_string: String = String::from_utf8(std::fs::read(&config_path).unwrap()).unwrap();
|
let mut config_string: String =
|
||||||
config_string = config_string.replace("Options", "default").replace("True", "1").replace("False", "0");
|
String::from_utf8(std::fs::read(&config_path).unwrap()).unwrap();
|
||||||
|
config_string = config_string
|
||||||
|
.replace("Options", "default")
|
||||||
|
.replace("True", "1")
|
||||||
|
.replace("False", "0");
|
||||||
std::fs::write(&config_path, config_string).unwrap();
|
std::fs::write(&config_path, config_string).unwrap();
|
||||||
Some(config_path)
|
Some(config_path)
|
||||||
}
|
}
|
||||||
@ -96,21 +108,20 @@ pub fn set_bool(selection: &str, key: &str, value: bool) -> bool {
|
|||||||
|
|
||||||
pub fn folder_icon(folder_chooser_name: Option<&str>) -> &str {
|
pub fn folder_icon(folder_chooser_name: Option<&str>) -> &str {
|
||||||
let home_folder = dirs::home_dir().unwrap();
|
let home_folder = dirs::home_dir().unwrap();
|
||||||
if folder_chooser_name == home_folder.as_path().file_name().unwrap().to_str(){
|
if folder_chooser_name == home_folder.as_path().file_name().unwrap().to_str() {
|
||||||
"user-home"
|
"user-home"
|
||||||
}
|
} else {
|
||||||
else {
|
match folder_chooser_name {
|
||||||
match folder_chooser_name {
|
Some("/") => "drive-harddisk",
|
||||||
Some("/") => "drive-harddisk",
|
Some("Desktop") => "user-desktop",
|
||||||
Some("Desktop") => "user-desktop",
|
Some("Documents") => "folder-documents",
|
||||||
Some("Documents") => "folder-documents",
|
Some("Downloads") => "folder-download",
|
||||||
Some("Downloads") => "folder-download",
|
Some("Music") => "folder-music",
|
||||||
Some("Music") => "folder-music",
|
Some("Pictures") => "folder-pictures",
|
||||||
Some("Pictures") => "folder-pictures",
|
Some("Public") => "folder-publicshare",
|
||||||
Some("Public") => "folder-publicshare",
|
Some("Templates") => "folder-templates",
|
||||||
Some("Templates") => "folder-templates",
|
Some("Videos") => "folder-videos",
|
||||||
Some("Videos") => "folder-videos",
|
_ => "folder",
|
||||||
_ => "folder",
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
src/main.rs
15
src/main.rs
@ -7,6 +7,7 @@ mod config_management;
|
|||||||
mod ffmpeg_interface;
|
mod ffmpeg_interface;
|
||||||
mod timer;
|
mod timer;
|
||||||
mod wayland_record;
|
mod wayland_record;
|
||||||
|
mod utils;
|
||||||
|
|
||||||
use ffmpeg_interface::{Ffmpeg, ProgressWidget};
|
use ffmpeg_interface::{Ffmpeg, ProgressWidget};
|
||||||
use gettextrs::{bindtextdomain, gettext, setlocale, textdomain, LocaleCategory};
|
use gettextrs::{bindtextdomain, gettext, setlocale, textdomain, LocaleCategory};
|
||||||
@ -17,6 +18,7 @@ use gtk::{
|
|||||||
FileChooserAction, FileChooserNative, Image, Label, MessageDialog, ProgressBar, SpinButton,
|
FileChooserAction, FileChooserNative, Image, Label, MessageDialog, ProgressBar, SpinButton,
|
||||||
ToggleButton, Window,
|
ToggleButton, Window,
|
||||||
};
|
};
|
||||||
|
use utils::is_wayland;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@ -35,12 +37,7 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_ui(application: &Application) {
|
pub fn build_ui(application: &Application) {
|
||||||
// Use "GDK_BACKEND=x11" to make xwininfo work in Wayland by using XWayland
|
gtk::init().expect("Failed to initialize GTK.");
|
||||||
std::env::set_var("GDK_BACKEND", "x11");
|
|
||||||
if gtk::init().is_err() {
|
|
||||||
println!("Failed to initialize GTK.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let ui_src = include_str!("../interfaces/main.ui").to_string();
|
let ui_src = include_str!("../interfaces/main.ui").to_string();
|
||||||
let builder: Builder = Builder::from_string(ui_src.as_str());
|
let builder: Builder = Builder::from_string(ui_src.as_str());
|
||||||
@ -609,11 +606,5 @@ pub fn build_ui(application: &Application) {
|
|||||||
gtk::STYLE_PROVIDER_PRIORITY_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();
|
main_window.show();
|
||||||
}
|
}
|
||||||
|
5
src/utils.rs
Normal file
5
src/utils.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
pub fn is_wayland() -> bool {
|
||||||
|
std::env::var("XDG_SESSION_TYPE")
|
||||||
|
.unwrap_or_default()
|
||||||
|
.eq_ignore_ascii_case("wayland")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user