Using a custom icon

Asked by Lauri Kainulainen

I'm building an application that uses appindicator and pygtk. I'm trying to use a custom icon, but can't get it to work. Could you please tell me what is wrong or missing in this piece of testing code:

[SNAP]
        pixbuf = gtk.gdk.pixbuf_new_from_file('/usr/share/app-install/icons/media-player-banshee.png')
        icons = gtk.IconSet(pixbuf)
        iconf = gtk.IconFactory()
        iconf.add_default()
        iconf.add('bss', icons)

        self.ind = appindicator.Indicator( "bss-app",
                                            'bss',
                                            appindicator.CATEGORY_APPLICATION_STATUS)
        self.ind.set_status(appindicator.STATUS_ACTIVE)
[/SNAP]

The rest of the application works normally, including the appindicator menu. Only the icon appears empty. Stock icons work perfectly (e.g. "preferences-desktop-wallpaper")

Question information

Language:
English Edit question
Status:
Solved
For:
Application Indicators Edit question
Assignee:
No assignee Edit question
Solved by:
Lauri Kainulainen
Solved:
Last query:
Last reply:
Revision history for this message
Lauri Kainulainen (luopio) said :
#1

Answering my own question after some research (I can't believe it took so much time to figure this out..).

One needs to install icons with xdg-icon-resource. E.g.:

sudo xdg-icon-resource install --theme hicolor --novendor --size 22 icon22.png fooicon

now you can use something like:

ind = appindicator.Indicator('fooapp',
                                            'fooicon',
                                            appindicator.CATEGORY_APPLICATION_STATUS)

had to just stop staring at the GTK manuals :)

More info can be found via the spec:
http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html