mirror of
https://github.com/JakeStanger/ironbar.git
synced 2026-07-11 12:15:22 +01:00
[GH-ISSUE #1039] GTK symbolic icons are not themed #324
Labels
No labels
A:Build
A:CI
A:Client
A:Config
A:Core
A:Documentation
A:Documentation
A:IPC
A:Testing
A:UX/UI
blocked
BREAKING CHANGE
duplicate
good first issue
GTK4
help wanted
invalid
M:Battery
M:Battery
M:Bindmode
M:Bluetooth
M:Brightness
M:Cairo
M:Clipboard
M:Clock
M:Clock
M:Custom
M:Focused
M:Keyboard
M:Launcher
M:Menu
M:Music
M:Music
M:Music
M:Network Manager
M:Notifications
M:SysInfo
M:Tray
M:Volume
M:Workspaces
partially resolved
P:Critical
P:High
P:Low
P:Medium
pull-request
T:Bug
T:Bug
T:Core Enhancement
T:Module Enhancement
T:New Module
T:Question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
JakeStanger/ironbar#324
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Rodrigodd on GitHub (Jun 9, 2025).
Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/1039
Describe the bug
The battery module, for example, displays a symbolic icon (
battery-missing-symbolicin my case), but the icon is not themed. The same happens with other uses of symbolic icons in Ironbar.To reproduce
Steps to reproduce the behavior:
battery.Expected behavior
My system is configure with theme "Adwaita:dark", so the icon should be white like so:
System information:
Possible fixes
In my fork, I’m using the following diff:
I found two possible approaches for this. One is to use
image.set_icon_name(Some(icon_name))instead of loading aPixbuf, but that does not respect theicon_themedefined in the Ironbar configuration.The other is to call
load_symbolicon theIconInforeturned bylookup_icon_for_scale, but that requires explicitly passing the colors for the icon, rather than inheriting them from the current GTK theme.Ideally, the fix should respect both the GTK icon theme set in the Ironbar configuration and whatever defines the colors for symbolic icons when using
Image::set_icon_name. Because I couldn't come up with a solution that satisfies both requirements, I haven't submitted a PR.@JakeStanger commented on GitHub (Jun 9, 2025):
The GTK documentation states you can pass
null(Nonein our case) to the colour arguments forload_symbolicand it uses the "default". Generally that means it should pick it up from the theme. Does it do that here?@Rodrigodd commented on GitHub (Jun 9, 2025):
I didn't notice that. I didn't test it but I believe it should work (so I didn't have to specify those colors in my diff). But that is the case only for the success, warning and error colors - the
fgcolor cannot beNUL/None, but I guess it should also come from the theme? Or respect some CSS variable? I am not that familiar with GTK theming system. It should at least be white on dark theme, and black on light theme (not sure how well Ironbar is suppose to handle light themes).@JakeStanger commented on GitHub (Jun 11, 2025):
It's supposed to handle them without issue! It's just an area that hasn't got as much love because I don't use light themes.
The correct approach (I think?) for loading the icon with the system foreground colour is to use load_symbolic_for_context. I've no idea how you get the context though. It looks like since all the style info is attached to the screen, you can just call
StyleContext::new()?@Rodrigodd commented on GitHub (Jun 18, 2025):
I tried using
load_symbolic_for_contextand it worked. But a problem is that the icon does not reload when changingstyles.css, and it does not respect the-gtk-icon-themeCSS property.diff
Using
Image::set_icon_nameaddresses both problems, but I could not find a good way to change the application default icon theme, respecting theicon_themefield in ironbar configuration file. The best idea I come up is generating and loading a CSS file at runtime with-gtk-icon-themeproperty set.Do you think that just removing the
icon_themefield from the configuration, and directing the user to configure-gtk-icon-themein styles.css instead is a good solution?diff
test-config
For reference, below is the configuration I was using to test the changes:
IRONBAR_CONFIG=test-configs/icons.corn IRONBAR_CSS=test-configs/icons.css cargo run@slowsage commented on GitHub (Nov 17, 2025):
@Rodrigodd , can you try https://github.com/slowsage/ironbar/tree/symbolic.
Can you check if the theme/color behavior matches what you expect? (I had a slightly different issue - would not even load).
@Rodrigodd commented on GitHub (Nov 17, 2025):
@slowsage Yes, it appears to work:
In the image above, the battery icon is themed correctly, since it uses
IconButton, and the Network Manager icons are unaffected because they usePicturedirectly.What your commit does is replace
PicturewithImagewhen the source is an icon, and useset_icon_name, right? Yeah, I think that’s the best solution available. Before the migration to GTK4, in my fork I was usingset_icon_nameinside theImageProvidertype, as I described in my previous comment. But I guess that now in GTK4 you need to usePicturefor some types of image sources.So the proper solution would be to create an abstraction like
IconButtonthat changes the underlying widget based on the image source, and use that in every widget instead ofPicturedirectly. But that has the effect of making theicon_themeconfiguration ineffective, as I mentioned in my previous comment.@slowsage commented on GitHub (Nov 19, 2025):
@Rodrigodd, Thanks a lot! Cleared up some things.
The code is now working with
icon_theme(tested with"breeze"- horizontal battery icon) but need to clean up. Will submit a pr in a few days. This is pretty core and may be missing something - lmk if any issues jump out.