Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I recently noticed that in ubuntu unity the application indicator (which replaces the system tray) does not show the custom icons I added to the gtk stock, but only the basic stock icons. In place of the correct icons I see "gtk-missing-image". On my apps toolbars and menus those icons are displayed properly, the problem is only with the top application indicator. I use gtk ui manager after integrating the stock icons this way:

factory = gtk.IconFactory()
pixbuf = gtk.gdk.pixbuf_new_from_file(filepath)
iconset = gtk.IconSet(pixbuf)
factory.add(stock_name, iconset)
factory.add_default()

then the appindicator code:

.....
try:
    import appindicator
    HAS_APPINDICATOR = True
except: HAS_APPINDICATOR = False
....
   if HAS_APPINDICATOR:
        self.ind = appindicator.Indicator("x-tile", "indicator-messages", appindicator.CATEGORY_APPLICATION_STATUS)
        self.ind.set_status(appindicator.STATUS_ACTIVE)
        self.ind.set_attention_icon("indicator-messages-new")
        self.ind.set_icon("x-tile")
        self.ind.set_menu(self.ui.get_widget("/SysTrayMenu"))
    else:
        self.status_icon = gtk.StatusIcon()
        self.status_icon.set_from_stock("Tile Quad")
        self.status_icon.connect('button-press-event', self.on_mouse_button_clicked_systray)
        self.status_icon.set_tooltip(_("Tile the Windows Upon your X Desktop"))

for full code:

hg clone https://giuspen-x-tile.googlecode.com/hg/ hg_x-tile
cd hg_x-tile
hg up x-tile2

The icons are visible when using system tray, not with application indicator If anybody solved this problem please help.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

It is not possible to use stock icons created on-the-fly in appindicators.

When using statusicons, your application is in full charge of building and displaying the menu. However, when using appindicators, what happens under-the-hood is that your application just makes a request and who really builds and displays the menu is a service running in the background.

This service is a independent program, completely separated from yours. Therefore it is not aware of things such as environment variables and stock icon names that you created on-the-fly.

The best workaround is using the set_icon_theme_path of the indicator to tell it where the icon is. You don't even need to change the stock in this case.

share|improve this answer
    
would it be possible to continue using gtk ui manager with your workaround? could you post a couple of lines of code to describe the workaround? thanks. –  giuspen Jan 13 '12 at 23:54
1  
Ugh, sorry for the delay, I thought AU would notify me of comments via email and it didn't... -_- Let's say your icon is "/home/giuspen/myicons/theicon.png". Then what you need to do is "self.ind.set_icon_theme_path('/home/giuspen/myicons')". After doing that, "self.ind.set_icon('theicon')" should work. –  Marcelo Hashimoto Jan 20 '12 at 18:35
    
ok it's just important that the new stock icons name is exactly the name of the icons files without the extension –  giuspen Sep 11 '12 at 14:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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