1

I am developing PyGTK app with appindicator. I create my appindicator similar like in this example. In this example "indicator-messages" stock icon is used.

So, I can:

  1. use stock icon (from existing theme)
  2. create custom icon

The question is, if I use stock icon, how can I determine what icons are available (is this consistent on all OS-es, is it provided by GTK)? Will this behave same on different Linux distributions?

Or, if I create custom icon, how can I detect which theme is active (I suppose I need to have dark and light icon version) and render appropriate icon? What is with other themes, looks like it's hard to support all of them?

On http://unity.ubuntu.com/projects/appindicators/ it says "Themable panel icons – you can set a specific icon to be a panel icon for an indicator: this should make it easier for creating single colour panel icons for light and dark themes." but it does not says how to achieve this?

I found Weather indicator does it, but with stock icons I think.

2 Answers 2

4

For your part of the question :

if I create custom icon, how can I detect which theme is active (I suppose I need to have dark and light icon version) and render appropriate icon? What is with other themes, looks like it's hard to support all of them?

you can use "gtk-theme-name" property defined in GtkSettings class to get the name of the theme which is being active.

For further information for GtkSettings check this

2
  • Thanks, that gives theme name (Ambiance, Radiance...). Now it is more then art to make icons fit all themes on most linux distributions :) But I think I can support this 2 and create fallback icon for other themes. I guess we can consider this part of my question answered. Still waiting for answer regarding stock icons. Thanks again.
    – umpirsky
    Dec 27, 2011 at 13:49
  • If I go with custom icons this should be good enough. I'm just not sure how to detect when theme is changed, so I can update icon. I found pygtk.org/docs/pygtk/class-gtkicontheme.html, there is changed callback, but I'm not sure how to use it. Is this the way to go?
    – umpirsky
    Dec 27, 2011 at 18:06
1

For the part of Stock ICons, I found this from the gnome dev center,

a stock item is of type GtkStockItem struct.

struct GtkStockItem {
  gchar *stock_id;
  gchar *label;
  GdkModifierType modifier;
  guint keyval;
  gchar *translation_domain;
};

here every stock item has a stock id, this same stock id is mapped to an icon from GtkIconFactory, see this from the gnome documentation :

Each stock ID can be associated with a GtkStockItem, which contains the user-visible label, keyboard accelerator, and translation domain of the menu or toolbar item; and/or with an icon stored in a GtkIconFactory

The connection between a GtkStockItem and stock icons is purely conventional (by virtue of using the same stock ID); it's possible to register a stock item but no icon, and vice versa. Stock icons may have a RTL variant which gets used for right-to-left locales.

For further information, you can refer to this

Sorry for posting it as 2nd answer and not as a comment, i was not able to type this much lengthy text in the comments.

1
  • Thanks. I use these in my toolbar. But appindicator examples use strings like "indicator-messages" which is not one of stock icons, but still here on Ubuntu for example. Is that common for Ubuntu apps to use some default icons which are part of OS distribution, but not part of GTK? I'm a bit confused.
    – umpirsky
    Dec 27, 2011 at 18:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .