GNOME Bugzilla – Bug 396901
Generic icon fallback a la icon naming spec
Last modified: 2007-05-18 20:18:34 UTC
From Icon Naming Spec: The dash “-” character is used to separate levels of specificity in icon names, for all contexts other than MimeTypes. For instance, we use “input-mouse” as the generic item for all mouse devices, and we use “input-mouse-usb” for a USB mouse device. However, if the more specific item does not exist in the current theme, and does exist in a parent theme, the generic icon from the current theme is preferred, in order to keep consistent style. < http://standards.freedesktop.org/icon-naming-spec/latest/ar01s03.html > GTK+ should allow applications to fallback to generic icon when requested specific icon is not available in current theme. Example: currently gnome-icon-theme is providing only "media-optical" named icon for a generic optical disk media, as defined in Icon Naming Spec. But HAL and gnome-vfs are able to identify the exact type of media, so they should be able to use named icons "media-optical-cd", "media-optical-cdr", "media-optical-cdrw", "media-optical-dvd-video", ... "media-optical-blueray" in sources, even if those icons are not defined in the standard or provided by the icon theme.
One way to expose this in the api would be to just add a GTK_ICON_LOOKUP_DO_NAME_FALLBACKS flag that would make gtk do the right thing (split the icon name at '-' and try the more generic names before falling back to other themes)
Rodney, what about RTL/LTR support in Icon Naming Spec? Simply add a trailing -rtl suffing to use the icon in the right context?
FWIW, gtk currently uses explicit -ltr/-rtl for both directions currently, if icons have variants.
Created attachment 81407 [details] [review] generic fallback
Luca, we haven't made a decision on how to do ltr/rtl in the naming spec yet. It seems to me that appending rtl to the icon might work best. I am not sure yet though. Perhaps some discussion on xdg list will render a conclusion.
FWIW, Alex' recommends that we add a new function that takes a list of icon names to look for instead of hardcoding the "-"-fallback.
We should do both actually. I think alex's recommendation is mostly based on his proposal for the MIME type fallback icons, which I mostly agree with. However, I think for icons in the contexts other than mimetypes, the simple "-" fallback mechanism is the best solution. This would be optimal for the device icons, for example, where we can fall back through the hierarchy, without having to specify every level by hand. So, my vote is that we get this patch in, as well as continue working toward better solutions for special case needs, such as MIME types.
Here is an untested patch to add a lookup_iocn variant that takes an array of names.
Created attachment 86619 [details] [review] choose-icon.patch
2007-05-18 Matthias Clasen <mclasen@redhat.com> * gtk/gtk.symbols: * gtk/gtkicontheme.h: * gtk/gtkicontheme.c: Add a function to look up an icon from a list of icon names. (#396901, Luca Ferretti)