mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 23:01:04 +02:00
refactor: make icon overrides bar-level and apply to focused module
This commit is contained in:
parent
87c680122b
commit
d1b4af4710
7 changed files with 24 additions and 12 deletions
|
@ -133,6 +133,7 @@ impl Module<gtk::Box> for FocusedModule {
|
|||
info: &ModuleInfo,
|
||||
) -> Result<ModuleParts<gtk::Box>> {
|
||||
let icon_theme = info.icon_theme;
|
||||
let icon_overrides = info.icon_overrides;
|
||||
|
||||
let container = gtk::Box::new(info.bar_position.orientation(), 5);
|
||||
|
||||
|
@ -153,9 +154,17 @@ impl Module<gtk::Box> for FocusedModule {
|
|||
|
||||
{
|
||||
let icon_theme = icon_theme.clone();
|
||||
let icon_overrides = icon_overrides.clone();
|
||||
glib_recv!(context.subscribe(), data => {
|
||||
if let Some((name, id)) = data {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
match ImageProvider::parse(&id, &icon_theme, true, self.icon_size)
|
||||
.map(|image| image.load_into_image(&icon))
|
||||
{
|
||||
|
|
|
@ -15,7 +15,6 @@ use gtk::prelude::*;
|
|||
use gtk::{Button, Orientation};
|
||||
use indexmap::IndexMap;
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::{broadcast, mpsc};
|
||||
|
@ -30,12 +29,6 @@ pub struct LauncherModule {
|
|||
/// **Default**: `null`
|
||||
favorites: Option<Vec<String>>,
|
||||
|
||||
/// Map of app IDs (or classes) to icon names,
|
||||
/// overriding the app's default icon.
|
||||
///
|
||||
/// **Default**; `null`
|
||||
icon_overrides: Option<HashMap<String, String>>,
|
||||
|
||||
/// Whether to show application names on the bar.
|
||||
///
|
||||
/// **Default**: `false`
|
||||
|
@ -156,7 +149,7 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
favorites
|
||||
.iter()
|
||||
.map(|app_id| {
|
||||
let icon_override = self
|
||||
let icon_override = _info
|
||||
.icon_overrides
|
||||
.as_ref()
|
||||
.and_then(|overrides| overrides.get(app_id))
|
||||
|
@ -173,7 +166,7 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
let items = arc_mut!(items);
|
||||
let items2 = Arc::clone(&items);
|
||||
|
||||
let icon_overrides = arc_mut!(self.icon_overrides.clone());
|
||||
let icon_overrides = arc_mut!(_info.icon_overrides.clone());
|
||||
let icon_overrides2 = Arc::clone(&icon_overrides);
|
||||
|
||||
let tx = context.tx.clone();
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use std::collections::HashMap;
|
||||
use std::fmt::Debug;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
@ -71,6 +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>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue