1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-17 14:51:04 +02:00

fix(ipc): support querying against duplicate bar names

It is possible/valid to define multiple bars by the same name by setting `name` on the top-level bar object, but not specifying monitors. This updates IPC to support this scenario.

Allow IPC to act on multiple bars by the same name (#777)
This commit is contained in:
Ridan Vandenbergh 2024-11-16 21:48:12 +01:00 committed by GitHub
parent e7c56ee09b
commit 42e25f5ef2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 75 additions and 45 deletions

View file

@ -267,17 +267,18 @@ impl Ironbar {
.clone()
}
/// Gets a clone of a bar by its unique name.
/// Gets clones of bars by their name.
///
/// Since the bar contains mostly GTK objects,
/// Since the bars contain mostly GTK objects,
/// the clone is cheap enough to not worry about.
#[must_use]
pub fn bar_by_name(&self, name: &str) -> Option<Bar> {
pub fn bars_by_name(&self, name: &str) -> Vec<Bar> {
self.bars
.borrow()
.iter()
.find(|&bar| bar.name() == name)
.filter(|&bar| bar.name() == name)
.cloned()
.collect()
}
/// Re-reads the config file from disk and replaces the active config.