Jump to content
_bc

Python function to get theme icons

Recommended Posts

Hello there,

I'm running moksha 0.2.1, efl 1.20.7 and python-efl 1.20.01, and it seems the Icon function won't really fetch me my icons.

It got some applications and actions, but e.g. no mime icons, and efl doesn't really like 'normal' icon themes. Seems efl doesn't exactly read icons as many themes provide them.

So I wrote a simply python function to do the job :D

I will probably set up a github for my stuff, but right now I thought I might throw it into the world here, since I figure I'm not the only one struggling with this.

 

Just drop it into your project, import it, and load your Icon with

DeepIcon( parent, name, size)

Where parent is the widget's parent, name a string identifying the icon (either as found in most themes, i.e. "application-x-script", yes, it expects mimes with dashes, not slashes, a simple name, i.e. "firefox" or "folder" or a path).

The function tries to get the icon from your theme, then tries to fallback to the hicolor theme to produce an icon.

If it can't, it will try to load the icon 'image-missing', and if it can't do that either, it will show the standard icon 'close' (this will most likely be in your enlightenment theme).

Size is the wished icon size in pixels as a single integer, i.e. "32" or "48", not "32x32" or something like that.

Returns an elementary Icon object, or None.

 

Update:

I set up a github account and dropped the script there.

Currently the script will crawl the theme given by the 'E_ICON_THEME' environment, which makes it usable only in Moksha/e, feel free to help with some dconf/gconf detection and such :D

Furthermore it will cache the paths of the theme as well as the found icons (by size) to speed up future requests.

I'm no python master, so if you see the need for polish or find some bugs, let me know or feel welcome to fix it ;)

 

Find it here.

 

  • Thanks 1

Share this post


Link to post
Share on other sites

This could be useful. Thanks when I have time I will try it out. Update us if you ever put it in github or anything.

 

Share this post


Link to post
Share on other sites

Which theme had you problem with? I think I solved some icon troubles inside some edj themes. 

Share this post


Link to post
Share on other sites

It wasn't an enlightenment theme problem, those icons show fine ;)

I just didn't get icons for mime-types and some applications, i.e. 'acessoire-calculator' or 'audio-mp3' gave me

RuntimeWarning: Setting standard icon failed

Regardless of what my enlightenment theme does; the icons are present in my icon theme (I tested with elementary, Oxygen and gnome icon themes) and should show.

Nevertheless, looking at the code again I got some ideas to speed it up and make it more compliant :D    Done ✓

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×