Application custom stock icons not visible in application indicator but visible in old system tray
Sebastian Wright 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 hg_x-tile
cd hg_x-tile
hg up x-tile2The icons are visible when using system tray, not with application indicator If anybody solved this problem please help.
1 Answer
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.
3