Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add icons build script #265

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
451 changes: 321 additions & 130 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ frame-system = { git = "https://github.com/subspace/polkadot-sdk", rev = "562615
fs4 = "0.8.4"
futures = "0.3.30"
futures-timer = "3.0.3"
gtk = { version = "0.7.3", package = "gtk4" }
gtk = { version = "0.9", package = "gtk4" }
hex = "0.4.3"
image = { version = "0.25", default-features = false, features = ["png"] }
mimalloc = "0.1.43"
Expand All @@ -61,9 +61,9 @@ open = "5.2.0"
pallet-balances = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
parity-scale-codec = "3.6.12"
parking_lot = "0.12.3"
relm4 = "0.7.0-rc.1"
relm4-components = { version = "0.7.0-rc.1", default-features = false }
relm4-icons = { version = "0.7.0-alpha.2", features = ["checkmark", "cross", "grid-filled", "menu-large", "pause", "processor", "puzzle-piece", "size-horizontally", "speedometer2", "speedometer3", "speedometer4", "ssd", "wallet2", "warning"] }
relm4 = "0.9.0"
relm4-components = { version = "0.9.0", default-features = false }
relm4-icons = { path = "../icons" }
reqwest = { version = "0.12.4", default-features = false, features = ["json", "rustls-tls"] }
sc-client-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sc-client-db = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
Expand Down Expand Up @@ -124,6 +124,7 @@ ksni = "0.2.2"

[build-dependencies]
fluent-static-codegen = "0.3.2"
relm4-icons-build = { path = "../icons/build_icons" }

[target.'cfg(windows)'.build-dependencies]
winres = "0.1.12"
Expand Down
23 changes: 23 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,27 @@ fn main() {
res.set_icon("res\\windows\\space-acres.ico");
res.compile().unwrap();
}

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",
],
);
}
7 changes: 3 additions & 4 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::AppStatusCode;
use crate::{icon_names, AppStatusCode};
use futures::channel::mpsc;
use futures::{SinkExt, StreamExt};
use gtk::glib;
Expand All @@ -23,7 +23,6 @@ use notify_rust::Notification;
use relm4::actions::{RelmAction, RelmActionGroup};
use relm4::prelude::*;
use relm4::{Sender, ShutdownReceiver};
use relm4_icons::icon_name;
use std::any::Any;
use std::cell::{Cell, LazyCell};
use std::future::Future;
Expand Down Expand Up @@ -299,15 +298,15 @@ impl AsyncComponent for App {
// cases, would be nice to just hide corresponding menu item instead
gtk::MenuButton {
set_direction: gtk::ArrowType::None,
set_icon_name: icon_name::MENU_LARGE,
set_icon_name: icon_names::MENU_LARGE,
set_popover: Some(&gtk::PopoverMenu::from_model(Some(&main_menu_without_change_configuration))),
#[track = "model.changed_current_raw_config()"]
set_visible: model.current_raw_config.is_none(),
},

gtk::MenuButton {
set_direction: gtk::ArrowType::None,
set_icon_name: icon_name::MENU_LARGE,
set_icon_name: icon_names::MENU_LARGE,
set_popover: Some(&gtk::PopoverMenu::from_model(Some(&main_menu))),
#[track = "model.changed_current_raw_config()"]
set_visible: model.current_raw_config.is_some(),
Expand Down
10 changes: 5 additions & 5 deletions src/frontend/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use crate::frontend::configuration::farm::{
};
use crate::frontend::configuration::utils::is_directory_writable;
use crate::frontend::translations::{AsDefaultStr, T};
use crate::icon_names;
use gtk::glib;
use gtk::prelude::*;
use relm4::factory::AsyncFactoryVecDeque;
use relm4::prelude::*;
use relm4_components::open_dialog::{
OpenDialog, OpenDialogMsg, OpenDialogResponse, OpenDialogSettings,
};
use relm4_icons::icon_name;
use std::ops::Deref;
use std::path::PathBuf;
use subspace_farmer::utils::ss58::parse_ss58_reward_address;
Expand Down Expand Up @@ -104,9 +104,9 @@ where

fn icon(&self) -> Option<&'static str> {
if self.is_valid {
Some(icon_name::CHECKMARK)
Some(icon_names::CHECKMARK)
} else {
Some(icon_name::CROSS)
Some(icon_names::CROSS)
}
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ impl AsyncComponent for ConfigurationView {
)
.as_str(),
),
set_primary_icon_name: Some(icon_name::SSD),
set_primary_icon_name: Some(icon_names::SSD),
set_primary_icon_activatable: false,
set_primary_icon_sensitive: false,
#[track = "model.node_path.changed_is_valid()"]
Expand Down Expand Up @@ -290,7 +290,7 @@ impl AsyncComponent for ConfigurationView {
)
.as_str(),
),
set_primary_icon_name: Some(icon_name::WALLET2),
set_primary_icon_name: Some(icon_names::WALLET2),
set_primary_icon_activatable: false,
set_primary_icon_sensitive: false,
#[track = "model.reward_address.changed_is_valid()"]
Expand Down
10 changes: 5 additions & 5 deletions src/frontend/configuration/farm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::backend::config::{Farm, MIN_FARM_SIZE};
use crate::frontend::configuration::MaybeValid;
use crate::icon_names;
use bytesize::ByteSize;
use gtk::prelude::*;
use std::fmt;
Expand All @@ -11,7 +12,6 @@ use crate::frontend::configuration::utils::is_directory_writable;
use crate::frontend::translations::{AsDefaultStr, T};
use relm4::AsyncFactorySender;
use relm4_components::simple_combo_box::SimpleComboBox;
use relm4_icons::icon_name;
use std::path::PathBuf;
use std::str::FromStr;
use tracing::warn;
Expand Down Expand Up @@ -154,7 +154,7 @@ impl AsyncFactoryComponent for FarmWidget {
)
.as_str(),
),
set_primary_icon_name: Some(icon_name::SSD),
set_primary_icon_name: Some(icon_names::SSD),
set_primary_icon_activatable: false,
set_primary_icon_sensitive: false,
#[track = "self.path.changed_is_valid()"]
Expand Down Expand Up @@ -199,7 +199,7 @@ impl AsyncFactoryComponent for FarmWidget {
set_placeholder_text: Some(
&T.configuration_farm_fixed_size_placeholder(),
),
set_primary_icon_name: Some(icon_name::SIZE_HORIZONTALLY),
set_primary_icon_name: Some(icon_names::SIZE_HORIZONTALLY),
set_primary_icon_activatable: false,
set_primary_icon_sensitive: false,
#[track = "self.fixed_size.changed_is_valid()"]
Expand Down Expand Up @@ -231,7 +231,7 @@ impl AsyncFactoryComponent for FarmWidget {
set_placeholder_text: Some(
&T.configuration_farm_free_percentage_size_placeholder(),
),
set_primary_icon_name: Some(icon_name::SIZE_HORIZONTALLY),
set_primary_icon_name: Some(icon_names::SIZE_HORIZONTALLY),
set_primary_icon_activatable: false,
set_primary_icon_sensitive: false,
#[track = "self.free_percentage_size.changed_is_valid()"]
Expand All @@ -254,7 +254,7 @@ impl AsyncFactoryComponent for FarmWidget {
warn!("Can't send delete output");
}
},
set_icon_name: icon_name::CROSS,
set_icon_name: icon_names::CROSS,
set_tooltip: &T.configuration_farm_delete(),
},
},
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/running.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use crate::frontend::widgets::progress_circle::{
ProgressCircle, ProgressCircleInit, ProgressCircleInput,
};
use crate::frontend::NotificationExt;
use crate::icon_names;
use gtk::prelude::*;
use notify_rust::Notification;
use relm4::factory::FactoryHashMap;
use relm4::prelude::*;
use relm4_icons::icon_name;
use sp_consensus_subspace::ChainConstants;
use std::num::NonZeroU8;
use std::time::{Duration, Instant};
Expand Down Expand Up @@ -127,15 +127,15 @@ impl Component for RunningView {
connect_clicked => RunningInput::ToggleFarmDetails,
set_cursor_from_name: Some("pointer"),
set_has_frame: false,
set_icon_name: icon_name::GRID_FILLED,
set_icon_name: icon_names::GRID_FILLED,
set_tooltip: &T.running_farmer_button_expand_details(),
},
gtk::ToggleButton {
connect_clicked => RunningInput::TogglePausePlotting,
set_active: model.plotting_paused,
set_cursor_from_name: Some("pointer"),
set_has_frame: false,
set_icon_name: icon_name::PAUSE,
set_icon_name: icon_names::PAUSE,
set_tooltip: &T.running_farmer_button_pause_plotting(),
},
},
Expand Down
16 changes: 8 additions & 8 deletions src/frontend/running/farm.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::backend::farmer::DiskFarm;
use crate::frontend::translations::{AsDefaultStr, T};
use crate::frontend::NotificationExt;
use crate::icon_names;
use bytesize::ByteSize;
use gtk::prelude::*;
use notify_rust::Notification;
use relm4::prelude::*;
use relm4_icons::icon_name;
use simple_moving_average::{SingleSumSMA, SMA};
use std::collections::HashMap;
use std::path::PathBuf;
Expand Down Expand Up @@ -177,7 +177,7 @@ impl FactoryComponent for FarmWidget {
set_hexpand: true,

gtk::Image {
set_icon_name: Some(icon_name::WARNING),
set_icon_name: Some(icon_names::WARNING),
}
},
None => {
Expand Down Expand Up @@ -215,9 +215,9 @@ impl FactoryComponent for FarmWidget {
gtk::Image {
#[track = "self.changed_proving_result() || self.changed_auditing_time_score() || self.changed_proving_time_score()"]
set_icon_name: Some(match self.farm_score() {
..=0.4 => icon_name::SPEEDOMETER4,
..=0.8 => icon_name::SPEEDOMETER3,
_ => icon_name::SPEEDOMETER2,
..=0.4 => icon_names::SPEEDOMETER4,
..=0.8 => icon_names::SPEEDOMETER3,
_ => icon_names::SPEEDOMETER2,
}),
},
},
Expand All @@ -235,7 +235,7 @@ impl FactoryComponent for FarmWidget {
set_visible: self.farm_details && self.auditing_time.get_num_samples() > 0,

gtk::Image {
set_icon_name: Some(icon_name::PUZZLE_PIECE),
set_icon_name: Some(icon_names::PUZZLE_PIECE),
},

gtk::LevelBar {
Expand All @@ -259,7 +259,7 @@ impl FactoryComponent for FarmWidget {
set_visible: self.farm_details && self.proving_time.get_num_samples() > 0,

gtk::Image {
set_icon_name: Some(icon_name::PROCESSOR),
set_icon_name: Some(icon_names::PROCESSOR),
},

gtk::LevelBar {
Expand All @@ -271,7 +271,7 @@ impl FactoryComponent for FarmWidget {
},

gtk::Image {
set_icon_name: Some(icon_name::WARNING),
set_icon_name: Some(icon_names::WARNING),
#[track = "self.changed_non_fatal_farming_error()"]
set_tooltip: {
let last_error = self.non_fatal_farming_error
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/running/node.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::backend::node::{ChainInfo, SyncState};
use crate::backend::NodeNotification;
use crate::frontend::translations::{AsDefaultStr, T};
use crate::icon_names;
use bytesize::ByteSize;
use gtk::prelude::*;
use parking_lot::Mutex;
use relm4::prelude::*;
use relm4::{Sender, ShutdownReceiver};
use relm4_icons::icon_name;
use simple_moving_average::{SingleSumSMA, SMA};
use std::path::PathBuf;
use std::sync::Arc;
Expand Down Expand Up @@ -103,7 +103,7 @@ impl Component for NodeView {
.unwrap_or_default(),

gtk::Image {
set_icon_name: Some(icon_name::SSD),
set_icon_name: Some(icon_names::SSD),
},

gtk::LevelBar {
Expand Down
8 changes: 7 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ use tracing_subscriber::EnvFilter;

#[global_allocator]
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
const LOG_FILE_LIMIT_COUNT: usize = 5;
Expand Down Expand Up @@ -273,7 +278,8 @@ impl Cli {
});

app.set_global_css(GLOBAL_CSS);
relm4_icons::initialize_icons();

relm4_icons::initialize_icons(icon_names::GRESOURCE_BYTES, icon_names::RESOURCE_PREFIX);

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