mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-09-12 20:42:02 +00:00
feat: init resources and gettext
This commit is contained in:
parent
9e90c1b253
commit
35b0ab9c12
4 changed files with 121 additions and 7 deletions
73
Cargo.lock
generated
73
Cargo.lock
generated
|
@ -8,6 +8,15 @@ version = "1.0.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.71"
|
||||
|
@ -86,6 +95,12 @@ dependencies = [
|
|||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-expr"
|
||||
version = "0.15.2"
|
||||
|
@ -441,6 +456,26 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gettext-rs"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e49ea8a8fad198aaa1f9655a2524b64b70eb06b2f3ff37da407566c93054f364"
|
||||
dependencies = [
|
||||
"gettext-sys",
|
||||
"locale_config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gettext-sys"
|
||||
version = "0.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c63ce2e00f56a206778276704bbe38564c8695249fdc8f354b4ef71c57c3839d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"temp-dir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gio"
|
||||
version = "0.17.10"
|
||||
|
@ -753,6 +788,19 @@ version = "0.2.145"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc86cde3ff845662b8f4ef6cb50ea0e20c524eb3d29ae048287e06a1b3fa6a81"
|
||||
|
||||
[[package]]
|
||||
name = "locale_config"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d2c35b16f4483f6c26f0e4e9550717a2f6575bcd6f12a53ff0c490a94a6934"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"objc",
|
||||
"objc-foundation",
|
||||
"regex",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.9"
|
||||
|
@ -1064,6 +1112,23 @@ dependencies = [
|
|||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
|
||||
|
||||
[[package]]
|
||||
name = "relm4"
|
||||
version = "0.6.0"
|
||||
|
@ -1118,7 +1183,9 @@ dependencies = [
|
|||
name = "rex2"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"expect-dialog",
|
||||
"gettext-rs",
|
||||
"gtk4",
|
||||
"nix",
|
||||
"relm4",
|
||||
|
@ -1282,6 +1349,12 @@ version = "0.12.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5"
|
||||
|
||||
[[package]]
|
||||
name = "temp-dir"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af547b166dd1ea4b472165569fc456cfb6818116f854690b0ff205e636523dab"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.40"
|
||||
|
|
|
@ -6,7 +6,11 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.71"
|
||||
expect-dialog = "1.0.0"
|
||||
gettext-rs = { version = "0.7.0", features = [
|
||||
"gettext-system"
|
||||
] }
|
||||
gtk4 = { version = "0.6.6", features = [
|
||||
"v4_6",
|
||||
"v4_10"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
pub const APP_NAME: &str = "@PRETTY_NAME@";
|
||||
pub const APP_ID: &str = "@APP_ID@";
|
||||
pub const PKG_DATA_DIR: &str = "@PKGDATADIR@";
|
||||
pub const RESOURCES: &str = concat!("@PKGDATADIR@", "/resources.gresource");
|
||||
pub const CMD_NAME: &str = "@CMD_NAME@";
|
||||
pub const VERSION: &str = "@VERSION@";
|
||||
pub const REPO_URL: &str = "@UPSTREAM_REPO_URL@";
|
||||
|
|
50
src/main.rs
50
src/main.rs
|
@ -1,5 +1,11 @@
|
|||
use constants::APP_ID;
|
||||
use relm4::RelmApp;
|
||||
use anyhow::Result;
|
||||
use constants::{APP_ID, APP_NAME, GETTEXT_PACKAGE, LOCALE_DIR, RESOURCES};
|
||||
use gettextrs::LocaleCategory;
|
||||
use relm4::{
|
||||
adw,
|
||||
gtk::{self, gio, glib, gdk},
|
||||
RelmApp,
|
||||
};
|
||||
use ui::app::App;
|
||||
|
||||
pub mod builders;
|
||||
|
@ -9,15 +15,45 @@ pub mod depcheck;
|
|||
pub mod dependencies;
|
||||
pub mod file_builders;
|
||||
pub mod file_utils;
|
||||
pub mod paths;
|
||||
pub mod profile;
|
||||
pub mod profiles;
|
||||
pub mod runner;
|
||||
pub mod ui;
|
||||
pub mod runner_pipeline;
|
||||
pub mod paths;
|
||||
pub mod ui;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
// Prepare i18n
|
||||
gettextrs::setlocale(LocaleCategory::LcAll, "");
|
||||
gettextrs::bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR).expect("Unable to bind the text domain");
|
||||
gettextrs::textdomain(GETTEXT_PACKAGE).expect("Unable to switch to the text domain");
|
||||
|
||||
gtk::init()?;
|
||||
glib::set_application_name(APP_NAME);
|
||||
|
||||
{
|
||||
let res = gio::Resource::load(RESOURCES).expect("Could not load gresource file");
|
||||
gio::resources_register(&res);
|
||||
}
|
||||
|
||||
let provider = gtk::CssProvider::new();
|
||||
provider.load_from_resource("/org/gabmus/rex2/style.css");
|
||||
if let Some(display) = gdk::Display::default() {
|
||||
gtk::style_context_add_provider_for_display(
|
||||
&display,
|
||||
&provider,
|
||||
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
);
|
||||
}
|
||||
gtk::Window::set_default_icon_name(APP_ID);
|
||||
|
||||
fn main() {
|
||||
let app = RelmApp::new(APP_ID);
|
||||
relm4_icons::initialize_icons();
|
||||
app.run::<App>(())
|
||||
let main_app = adw::Application::builder()
|
||||
.application_id(APP_ID)
|
||||
.flags(gio::ApplicationFlags::empty())
|
||||
.resource_base_path("/org/gabmus/rex2")
|
||||
.build();
|
||||
let app = RelmApp::from_app(main_app);
|
||||
app.run::<App>(());
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue