1

I would like to use the refresh icon in my application. Rather than creating my own icon I would like to use the refresh icon used in Files, in a way that the icon will be updated when the user uses a different theme.

I found the refresh icon in this path "/usr/share/icons/HighContrast/16x16/actions/view-refresh.png".

However, instead of using the hardcoded path in the code I would like to use a reference path or alias to the above icon which will show the default refresh icon based on the theme in use. In case the image cannot be located I can default to a hard coded image which will be kept in my application default icon location.

Appreciate any sample vala code or pointers to implement the above.

Thanks, Sid.

6

You just load the icon using the name. Gtk will select the one appropriate for the current theme. In your case, you would use something like:

var icon = Gtk.Image.from_icon_name("view-refresh", Gtk.IconSize.SMALL_TOOLBAR);

See valadoc for more information.

  • 1
    Many thanks for the swift response and spot on with your suggestion as well. I went with the Button Image as I thought it gives the clickable action better than just a image itself. This is what I used: Button ports_refresh_button = new Button.from_icon_name ("view-refresh", IconSize.SMALL_TOOLBAR); .Thanks for putting me on the right track. – Siddhartha Das Sep 4 '15 at 9:59
  • As an afterthought I kind of like the refresh icon in the header bar in Pantheon Files (right end) better than the stock view-refresh one. What would be the name to get the Pantheon Files reload icon. <br> Another icon comes if I mention "reload" instead of "view-refresh" - is that better supported ? – Siddhartha Das Sep 4 '15 at 10:51
  • 1
    I believe the one used in Files is view-refresh-symbolic. – Michael Mims Sep 4 '15 at 12:07
  • Many thanks for your suggestion about "view-refresh-symbolic" - spot on again ! Is there any method or documentation on these icons or is it just your knowledge and exploration ? Many thanks again! – Siddhartha Das Sep 11 '15 at 18:18
  • 1
    Most of my knowledge is through exploration of /usr/share/icons. I did find the icon theme specification, which is somewhat helpful. – Michael Mims Sep 11 '15 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.