How to use icons from Gnome Icons Libary ? #181
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
java
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
java-gi/java-gi#181
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?
Hi,
I'm trying to use icons from this app : https://flathub.org/apps/org.gnome.design.IconLibrary
in my app. I tried taking inspiration in examples (from java-gi-examples) that use resources, but with no success. I would like to use these icons with
ViewStack.addTitledWithIconfor instance.Currently I have :
src/main/resource/iconsfoldermyapp.gresource.xmlfile insrc/main/resourcefolderBut when running the gradle task, I get :
"Aucun fichier ou dossier de ce nom" means "No folder or directory of that name" in my locale
Could you provide an exemple app that shows how to use those custom icons ? Thanks in advance ! (and thanks for the awesome library)
Change
glib-implementation-resourcestoglib-compile-resources.Just tried it, go the same result 🤔
Does it work when you run
glib-compile-resourcesfrom the command line?if not, install the GLib development utilities. On Debian, it’s the
libglib2.0-dev-binpackage.That was it indeed, I installed the package and the gradle task now works.
I also updated the resource file to :
Because I got an error of file not found but no errors now.
But in my app, the icons still does not show (broken image logo instead) 🤔
The thing I'm least sure of is
You can choose the prefix yourself.
Use
Image.fromResource()to load the resource (use the prefix + filename) and then use that image as the icon.Oh and you might want to use an alias to strip the “icons” folder name from the filename:
You can then load the image from the resource as “/my/prefix/git-symbolic.svg”
Thanks it works !!
Maybe I contribute a page to the docs that explains all this ?
Sure! PRs are always welcome!
The website is in the
sitedocsfolder. Most of it is plain markdown files.Closing this issue.
Okay will do !
Last question : any idea on how to use a custom icon in
ViewSwitchertitle ?WiewStack.addTitledWithIcononly takes icon name as argument 🤔You have to add the resource to the current Gtk icon theme, and then you can refer to them by name:
I expect you can then refer to the icons using just the filename (without the prefix). But I haven't tested this myself; this is from the Gtk documentation.
Ok thanks again will try this out 👍
Tested today your recommendation about Gtk Icon Theme for the view switcher, but didn't work sadly. Thanks for looking it up though 👍
Also sent you a PR for the docs 😊
I'm afraid I don't have time to look into this further... It's not a Java-GI specific issue, so perhaps you can find examples in an existing application written in Vala or PyGObject.
No worries ! You helped me a lot already regarding this subject.
Will write here if I find something 👍