1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-16 14:21:03 +02:00

refactor: address requested changes

This commit is contained in:
BowDown097 2025-02-04 09:48:10 -08:00
parent d1b4af4710
commit 40d449e011
5 changed files with 16 additions and 22 deletions

View file

@ -309,7 +309,7 @@ The following table lists each of the bar-level bar config options:
| `exclusive_zone` | `boolean` | `true` unless `start_hidden` is enabled. | Whether the bar should reserve an exclusive zone around it. |
| `popup_gap` | `integer` | `5` | The gap between the bar and popup window. |
| `icon_theme` | `string` | `null` | Name of the GTK icon theme to use. Leave blank to use default. |
| `icon_overrides` | `map<string, string>` | `null` | Map of app IDs (or classes) to icon names, overriding the app's default icon. |
| `icon_overrides` | `Map<string, string>` | `{}` | Map of app IDs (or classes) to icon names, overriding the app's default icon. |
| `start_hidden` | `boolean` | `false`, or `true` if `autohide` set | Whether the bar should be hidden when the application starts. Enabled by default when `autohide` is set. |
| `autohide` | `integer` | `null` | The duration in milliseconds before the bar is hidden after the cursor leaves. Leave unset to disable auto-hide behaviour. |
| `start` | `Module[]` | `[]` | Array of left or top modules. |

View file

@ -293,8 +293,9 @@ pub struct BarConfig {
/// Map of app IDs (or classes) to icon names,
/// overriding the app's default icon.
///
/// **Default**; `null`
pub icon_overrides: Option<HashMap<String, String>>,
/// **Default**; `{}`
#[serde(default)]
pub icon_overrides: HashMap<String, String>,
/// An array of modules to append to the start of the bar.
/// Depending on the orientation, this is either the top of the left edge.
@ -344,7 +345,7 @@ impl Default for BarConfig {
start_hidden: None,
autohide: None,
icon_theme: None,
icon_overrides: None,
icon_overrides: HashMap::default(),
start: Some(vec![ModuleConfig::Label(
LabelModule::new(" Using default config".to_string()).into(),
)]),

View file

@ -159,10 +159,8 @@ impl Module<gtk::Box> for FocusedModule {
if let Some((name, mut id)) = data {
if self.show_icon {
if let Some(ref overrides) = icon_overrides {
if let Some(icon) = overrides.get(&id) {
id = icon.clone();
}
if let Some(icon) = icon_overrides.get(&id) {
id = icon.clone();
}
match ImageProvider::parse(&id, &icon_theme, true, self.icon_size)

View file

@ -138,7 +138,7 @@ impl Module<gtk::Box> for LauncherModule {
fn spawn_controller(
&self,
_info: &ModuleInfo,
info: &ModuleInfo,
context: &WidgetContext<Self::SendMessage, Self::ReceiveMessage>,
mut rx: mpsc::Receiver<Self::ReceiveMessage>,
) -> crate::Result<()> {
@ -149,10 +149,9 @@ impl Module<gtk::Box> for LauncherModule {
favorites
.iter()
.map(|app_id| {
let icon_override = _info
let icon_override = info
.icon_overrides
.as_ref()
.and_then(|overrides| overrides.get(app_id))
.get(app_id)
.map_or_else(String::new, |v| v.to_string());
(
@ -166,7 +165,7 @@ impl Module<gtk::Box> for LauncherModule {
let items = arc_mut!(items);
let items2 = Arc::clone(&items);
let icon_overrides = arc_mut!(_info.icon_overrides.clone());
let icon_overrides = arc_mut!(info.icon_overrides.clone());
let icon_overrides2 = Arc::clone(&icon_overrides);
let tx = context.tx.clone();
@ -192,10 +191,8 @@ impl Module<gtk::Box> for LauncherModule {
let mut item = Item::from(info.clone());
let icon_overrides = lock!(icon_overrides);
if let Some(overrides) = icon_overrides.as_ref() {
if let Some(icon) = overrides.get(&info.app_id) {
item.icon_override = icon.clone();
}
if let Some(icon) = icon_overrides.get(&info.app_id) {
item.icon_override = icon.clone();
}
items.insert(info.app_id.clone(), item);
@ -231,10 +228,8 @@ impl Module<gtk::Box> for LauncherModule {
let mut item: Item = info.into();
let icon_overrides = lock!(icon_overrides);
if let Some(overrides) = icon_overrides.as_ref() {
if let Some(icon) = overrides.get(&app_id) {
item.icon_override = icon.clone();
}
if let Some(icon) = icon_overrides.get(&app_id) {
item.icon_override = icon.clone();
}
items.insert(app_id.clone(), item.clone());

View file

@ -72,7 +72,7 @@ pub struct ModuleInfo<'a> {
pub monitor: &'a Monitor,
pub output_name: &'a str,
pub icon_theme: &'a IconTheme,
pub icon_overrides: &'a Option<HashMap<String, String>>,
pub icon_overrides: &'a HashMap<String, String>,
}
#[derive(Debug, Clone)]