mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-09-16 03:36:58 +02:00
refactor: overhaul .desktop
and image resolver systems
Rewrites the desktop file parser code and image resolver code to introduce caching system and make fully async. They should be much faster now. BREAKING CHANGE: The `icon_theme` setting has been moved from per-bar to top-level
This commit is contained in:
parent
ca524f19f6
commit
3e55d87c3a
26 changed files with 1840 additions and 600 deletions
28
src/main.rs
28
src/main.rs
|
@ -29,6 +29,7 @@ use crate::channels::SyncSenderExt;
|
|||
use crate::clients::Clients;
|
||||
use crate::clients::wayland::OutputEventType;
|
||||
use crate::config::{Config, MonitorConfig};
|
||||
use crate::desktop_file::DesktopFiles;
|
||||
use crate::error::ExitCode;
|
||||
#[cfg(feature = "ipc")]
|
||||
use crate::ironvar::{VariableManager, WritableNamespace};
|
||||
|
@ -106,7 +107,7 @@ fn run_with_args() {
|
|||
error!("{err:#}");
|
||||
exit(ExitCode::IpcResponseError as i32)
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
None => start_ironbar(),
|
||||
|
@ -119,17 +120,26 @@ pub struct Ironbar {
|
|||
clients: Rc<RefCell<Clients>>,
|
||||
config: Rc<RefCell<Config>>,
|
||||
config_dir: PathBuf,
|
||||
|
||||
desktop_files: DesktopFiles,
|
||||
image_provider: image::Provider,
|
||||
}
|
||||
|
||||
impl Ironbar {
|
||||
fn new() -> Self {
|
||||
let (config, config_dir) = load_config();
|
||||
let (mut config, config_dir) = load_config();
|
||||
|
||||
let desktop_files = DesktopFiles::new();
|
||||
let image_provider =
|
||||
image::Provider::new(desktop_files.clone(), &mut config.icon_overrides);
|
||||
|
||||
Self {
|
||||
bars: Rc::new(RefCell::new(vec![])),
|
||||
clients: Rc::new(RefCell::new(Clients::new())),
|
||||
config: Rc::new(RefCell::new(config)),
|
||||
config_dir,
|
||||
desktop_files,
|
||||
image_provider,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,6 +225,10 @@ impl Ironbar {
|
|||
let _hold = activate_rx.recv().expect("to receive activation signal");
|
||||
debug!("Received activation signal, initialising bars");
|
||||
|
||||
instance
|
||||
.image_provider
|
||||
.set_icon_theme(instance.config.borrow().icon_theme.as_deref());
|
||||
|
||||
while let Ok(event) = rx_outputs.recv().await {
|
||||
match event.event_type {
|
||||
OutputEventType::New => {
|
||||
|
@ -270,6 +284,16 @@ impl Ironbar {
|
|||
.clone()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn desktop_files(&self) -> DesktopFiles {
|
||||
self.desktop_files.clone()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn image_provider(&self) -> image::Provider {
|
||||
self.image_provider.clone()
|
||||
}
|
||||
|
||||
/// Gets clones of bars by their name.
|
||||
///
|
||||
/// Since the bars contain mostly GTK objects,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue