1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-04 04:01:03 +02:00

feat: ability to configure image icon sizes

Adds `icon_size` option to following widgets:

- `clipboard`
- `launcher`
- `music`
- `workspaces`

Also adds `cover_image_size` option to `music`.
This commit is contained in:
Jake Stanger 2023-04-22 22:18:36 +01:00
parent 618e97f1e8
commit 2da28b9bf5
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
10 changed files with 83 additions and 25 deletions

View file

@ -41,21 +41,29 @@ pub struct WorkspacesModule {
#[serde(default)]
sort: SortOrder,
#[serde(default = "default_icon_size")]
icon_size: i32,
#[serde(flatten)]
pub common: Option<CommonConfig>,
}
const fn default_icon_size() -> i32 {
32
}
/// Creates a button from a workspace
fn create_button(
name: &str,
focused: bool,
name_map: &HashMap<String, String>,
icon_theme: &IconTheme,
icon_size: i32,
tx: &Sender<String>,
) -> Button {
let label = name_map.get(name).map_or(name, String::as_str);
let button = new_icon_button(label, icon_theme, 32);
let button = new_icon_button(label, icon_theme, icon_size);
button.set_widget_name(name);
let style_context = button.style_context();
@ -157,6 +165,7 @@ impl Module<gtk::Box> for WorkspacesModule {
let container = container.clone();
let output_name = info.output_name.to_string();
let icon_theme = info.icon_theme.clone();
let icon_size = self.icon_size;
// keep track of whether init event has fired previously
// since it fires for every workspace subscriber
@ -174,6 +183,7 @@ impl Module<gtk::Box> for WorkspacesModule {
workspace.focused,
&name_map,
&icon_theme,
icon_size,
&context.controller_tx,
);
container.add(&item);
@ -209,6 +219,7 @@ impl Module<gtk::Box> for WorkspacesModule {
workspace.focused,
&name_map,
&icon_theme,
icon_size,
&context.controller_tx,
);
@ -233,6 +244,7 @@ impl Module<gtk::Box> for WorkspacesModule {
workspace.focused,
&name_map,
&icon_theme,
icon_size,
&context.controller_tx,
);