Skip to content

Commit

Permalink
New bundle_icons syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
dastansam committed Oct 3, 2024
1 parent 668333b commit 059bb06
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
51 changes: 22 additions & 29 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use fluent_static_codegen::{generate, MessageBundleCodeGenerator};
use relm4_icons_build::Config;
use std::path::Path;
use std::{env, fs};

Expand Down Expand Up @@ -30,32 +29,26 @@ fn main() {
res.compile().unwrap();
}

let config = Config {
icons: Some(
vec![
"ssd",
"size-horizontally",
"cross",
"checkmark",
"wallet2",
"warning",
"puzzle-piece",
"pause",
"menu-large",
"processor",
"speedometer2",
"speedometer3",
"speedometer4",
"grid-filled",
]
.iter()
.map(|s| s.to_string())
.collect(),
),
app_id: Some("com.github.autonomys.space-acres".to_string()),
base_resource_path: None,
icons_folder: None,
};

relm4_icons_build::bundle_icons(config);
relm4_icons_build::bundle_icons(
"icon_names.rs",
Some("xyz.autonomys.space_acres"),
None::<&str>,
None::<&str>,
[
"ssd",
"size-horizontally",
"cross",
"checkmark",
"wallet2",
"warning",
"puzzle-piece",
"pause",
"menu-large",
"processor",
"speedometer2",
"speedometer3",
"speedometer4",
"grid-filled",
],
);
}
6 changes: 3 additions & 3 deletions src/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::frontend::loading::{LoadingInput, LoadingView};
use crate::frontend::new_version::NewVersion;
use crate::frontend::running::{RunningInit, RunningInput, RunningOutput, RunningView};
use crate::frontend::translations::{AsDefaultStr, T};
use crate::{icon_names, AppStatusCode, AppStatusCode};
use crate::{icon_names, AppStatusCode};
use futures::channel::mpsc;
use futures::{SinkExt, StreamExt};
use gtk::glib;
Expand All @@ -23,8 +23,8 @@ use notify_rust::Notification;
use relm4::actions::{RelmAction, RelmActionGroup};
use relm4::prelude::*;
use relm4::{Sender, ShutdownReceiver};
use relm4_icons::icon_name;
use std::cell::Cell;
use std::any::Any;
use std::cell::{Cell, LazyCell};
use std::future::Future;
use std::path::PathBuf;
use std::rc::Rc;
Expand Down
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ use tracing_subscriber::EnvFilter;
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
mod icon_names {
include!(concat!(env!("OUT_DIR"), "/icon_names.rs"));
pub(crate) const GRESOURCE_BYTES: &'static [u8] =
include_bytes!(concat!(env!("OUT_DIR"), "/resources.gresource"));
}

/// Number of log files to keep
Expand Down Expand Up @@ -276,7 +278,10 @@ impl Cli {
});

app.set_global_css(GLOBAL_CSS);
relm4_icons::initialize_icons!(icon_names::BASE_RESOURCE_PATH, icon_names::APP_ID);
println!("Initializing icons");
println!("icon names example: {:?}", icon_names::MENU_LARGE);
println!("icon bytes size: {:?}", icon_names::GRESOURCE_BYTES.len());
relm4_icons::initialize_icons(icon_names::GRESOURCE_BYTES);

// Prefer dark theme in cross-platform way if environment is configured that way
if let Some(settings) = gtk::Settings::default() {
Expand Down

0 comments on commit 059bb06

Please sign in to comment.