mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 14:51:04 +02:00
refactor: address requested changes
This commit is contained in:
parent
d1b4af4710
commit
40d449e011
5 changed files with 16 additions and 22 deletions
|
@ -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. |
|
| `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. |
|
| `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_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. |
|
| `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. |
|
| `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. |
|
| `start` | `Module[]` | `[]` | Array of left or top modules. |
|
||||||
|
|
|
@ -293,8 +293,9 @@ pub struct BarConfig {
|
||||||
/// Map of app IDs (or classes) to icon names,
|
/// Map of app IDs (or classes) to icon names,
|
||||||
/// overriding the app's default icon.
|
/// overriding the app's default icon.
|
||||||
///
|
///
|
||||||
/// **Default**; `null`
|
/// **Default**; `{}`
|
||||||
pub icon_overrides: Option<HashMap<String, String>>,
|
#[serde(default)]
|
||||||
|
pub icon_overrides: HashMap<String, String>,
|
||||||
|
|
||||||
/// An array of modules to append to the start of the bar.
|
/// 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.
|
/// Depending on the orientation, this is either the top of the left edge.
|
||||||
|
@ -344,7 +345,7 @@ impl Default for BarConfig {
|
||||||
start_hidden: None,
|
start_hidden: None,
|
||||||
autohide: None,
|
autohide: None,
|
||||||
icon_theme: None,
|
icon_theme: None,
|
||||||
icon_overrides: None,
|
icon_overrides: HashMap::default(),
|
||||||
start: Some(vec![ModuleConfig::Label(
|
start: Some(vec![ModuleConfig::Label(
|
||||||
LabelModule::new("ℹ️ Using default config".to_string()).into(),
|
LabelModule::new("ℹ️ Using default config".to_string()).into(),
|
||||||
)]),
|
)]),
|
||||||
|
|
|
@ -159,10 +159,8 @@ impl Module<gtk::Box> for FocusedModule {
|
||||||
if let Some((name, mut id)) = data {
|
if let Some((name, mut id)) = data {
|
||||||
if self.show_icon {
|
if self.show_icon {
|
||||||
|
|
||||||
if let Some(ref overrides) = icon_overrides {
|
if let Some(icon) = icon_overrides.get(&id) {
|
||||||
if let Some(icon) = overrides.get(&id) {
|
id = icon.clone();
|
||||||
id = icon.clone();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match ImageProvider::parse(&id, &icon_theme, true, self.icon_size)
|
match ImageProvider::parse(&id, &icon_theme, true, self.icon_size)
|
||||||
|
|
|
@ -138,7 +138,7 @@ impl Module<gtk::Box> for LauncherModule {
|
||||||
|
|
||||||
fn spawn_controller(
|
fn spawn_controller(
|
||||||
&self,
|
&self,
|
||||||
_info: &ModuleInfo,
|
info: &ModuleInfo,
|
||||||
context: &WidgetContext<Self::SendMessage, Self::ReceiveMessage>,
|
context: &WidgetContext<Self::SendMessage, Self::ReceiveMessage>,
|
||||||
mut rx: mpsc::Receiver<Self::ReceiveMessage>,
|
mut rx: mpsc::Receiver<Self::ReceiveMessage>,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
|
@ -149,10 +149,9 @@ impl Module<gtk::Box> for LauncherModule {
|
||||||
favorites
|
favorites
|
||||||
.iter()
|
.iter()
|
||||||
.map(|app_id| {
|
.map(|app_id| {
|
||||||
let icon_override = _info
|
let icon_override = info
|
||||||
.icon_overrides
|
.icon_overrides
|
||||||
.as_ref()
|
.get(app_id)
|
||||||
.and_then(|overrides| overrides.get(app_id))
|
|
||||||
.map_or_else(String::new, |v| v.to_string());
|
.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 items = arc_mut!(items);
|
||||||
let items2 = Arc::clone(&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 icon_overrides2 = Arc::clone(&icon_overrides);
|
||||||
|
|
||||||
let tx = context.tx.clone();
|
let tx = context.tx.clone();
|
||||||
|
@ -192,10 +191,8 @@ impl Module<gtk::Box> for LauncherModule {
|
||||||
let mut item = Item::from(info.clone());
|
let mut item = Item::from(info.clone());
|
||||||
let icon_overrides = lock!(icon_overrides);
|
let icon_overrides = lock!(icon_overrides);
|
||||||
|
|
||||||
if let Some(overrides) = icon_overrides.as_ref() {
|
if let Some(icon) = icon_overrides.get(&info.app_id) {
|
||||||
if let Some(icon) = overrides.get(&info.app_id) {
|
item.icon_override = icon.clone();
|
||||||
item.icon_override = icon.clone();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
items.insert(info.app_id.clone(), item);
|
items.insert(info.app_id.clone(), item);
|
||||||
|
@ -231,10 +228,8 @@ impl Module<gtk::Box> for LauncherModule {
|
||||||
let mut item: Item = info.into();
|
let mut item: Item = info.into();
|
||||||
let icon_overrides = lock!(icon_overrides);
|
let icon_overrides = lock!(icon_overrides);
|
||||||
|
|
||||||
if let Some(overrides) = icon_overrides.as_ref() {
|
if let Some(icon) = icon_overrides.get(&app_id) {
|
||||||
if let Some(icon) = overrides.get(&app_id) {
|
item.icon_override = icon.clone();
|
||||||
item.icon_override = icon.clone();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
items.insert(app_id.clone(), item.clone());
|
items.insert(app_id.clone(), item.clone());
|
||||||
|
|
|
@ -72,7 +72,7 @@ pub struct ModuleInfo<'a> {
|
||||||
pub monitor: &'a Monitor,
|
pub monitor: &'a Monitor,
|
||||||
pub output_name: &'a str,
|
pub output_name: &'a str,
|
||||||
pub icon_theme: &'a IconTheme,
|
pub icon_theme: &'a IconTheme,
|
||||||
pub icon_overrides: &'a Option<HashMap<String, String>>,
|
pub icon_overrides: &'a HashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue