1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 Looking up icons by name
7 <!-- ##### SECTION Long_Description ##### -->
9 #GtkIconTheme provides a facility for looking up icons by name
10 and size. The main reason for using a name rather than simply
11 providing a filename is to allow different icons to be used
12 depending on what <firstterm>icon theme</firstterm> is selected
13 by the user. The operation of icon themes on Linux and Unix
15 url="http://www.freedesktop.org/Standards/icon-theme-spec">Icon
16 Theme Specification</ulink>. There is a default icon theme,
17 named <literal>hicolor</literal> where applications should install
18 their icons, but more additional application themes can be
19 installed as operating system vendors and users choose.
22 Named icons are similar to the <xref linkend="gtk-Themeable-Stock-Images"/>
23 facility, and the distinction between the two may be a bit confusing.
24 A few things to keep in mind:
29 Stock images usually are used in conjunction with
30 <xref linkend="gtk-Stock-Items"/>., such as %GTK_STOCK_OK or
31 %GTK_STOCK_OPEN. Named icons are easier to set up and therefore
32 are more useful for new icons that an application wants to
33 add, such as application icons or window icons.
38 Stock images can only be loaded at the symbolic sizes defined
39 by the #GtkIconSize enumeration, or by custom sizes defined
40 by gtk_icon_size_register(), while named icons are more flexible
41 and any pixel size can be specified.
46 Because stock images are closely tied to stock items, and thus
47 to actions in the user interface, stock images may come in
48 multiple variants for different widget states or writing
54 A good rule of thumb is that if there is a stock image for what
55 you want to use, use it, otherwise use a named icon. It turns
56 out that internally stock images are generally defined in
57 terms of one or more named icons. (An example of the
58 more than one case is icons that depend on writing direction;
59 GTK_STOCK_GO_FORWARD uses the two themed icons
60 "gtk-stock-go-forward-ltr" and "gtk-stock-go-forward-rtl".)
63 In many cases, named themes are used indirectly, via #GtkImage
64 or stock items, rather than directly, but looking up icons
65 directly is also simple. The #GtkIconTheme object acts
66 as a database of all the icons in the current theme. You
67 can create new #GtkIconTheme objects, but its much more
68 efficient to use the standard icon theme for the #GdkScreen
69 so that the icon information is shared with other people
70 looking up icons. In the case where the default screen is
71 being used, looking up an icon can be as simple as:
76 GtkIconTheme *icon_theme;
79 icon_theme = gtk_icon_theme_get_default ();
80 pixbuf = gtk_icon_theme_load_icon (icon_theme,
81 "my-icon-name", /* icon name */
87 g_warning ("Couldn't load icon: %s", error->message);
93 g_object_unref (pixbuf);
98 <!-- ##### SECTION See_Also ##### -->
103 <!-- ##### SECTION Stability_Level ##### -->
106 <!-- ##### STRUCT GtkIconInfo ##### -->
108 Contains information found when looking up an icon in
113 <!-- ##### STRUCT GtkIconTheme ##### -->
115 Acts as a database of information about an icon theme.
116 Normally, you retrieve the icon theme for a particular
117 screen using gtk_icon_theme_get_for_screen() and it
118 will contain information about current icon theme for
119 that screen, but you can also create a new #GtkIconTheme
120 object and set the icon theme name explicitely using
121 gtk_icon_theme_set_custom_theme().
125 <!-- ##### SIGNAL GtkIconTheme::changed ##### -->
130 @icontheme: the object which received the signal.
132 <!-- ##### ENUM GtkIconLookupFlags ##### -->
137 @GTK_ICON_LOOKUP_NO_SVG:
138 @GTK_ICON_LOOKUP_FORCE_SVG:
139 @GTK_ICON_LOOKUP_USE_BUILTIN:
140 @GTK_ICON_LOOKUP_GENERIC_FALLBACK:
141 @GTK_ICON_LOOKUP_FORCE_SIZE:
143 <!-- ##### MACRO GTK_ICON_THEME_ERROR ##### -->
145 The #GQuark used for #GtkIconThemeError errors.
150 <!-- ##### ENUM GtkIconThemeError ##### -->
155 @GTK_ICON_THEME_NOT_FOUND:
156 @GTK_ICON_THEME_FAILED:
158 <!-- ##### FUNCTION gtk_icon_theme_new ##### -->
166 <!-- ##### FUNCTION gtk_icon_theme_get_default ##### -->
174 <!-- ##### FUNCTION gtk_icon_theme_get_for_screen ##### -->
183 <!-- ##### FUNCTION gtk_icon_theme_set_screen ##### -->
192 <!-- ##### FUNCTION gtk_icon_theme_set_search_path ##### -->
202 <!-- ##### FUNCTION gtk_icon_theme_get_search_path ##### -->
212 <!-- ##### FUNCTION gtk_icon_theme_append_search_path ##### -->
221 <!-- ##### FUNCTION gtk_icon_theme_prepend_search_path ##### -->
230 <!-- ##### FUNCTION gtk_icon_theme_set_custom_theme ##### -->
239 <!-- ##### FUNCTION gtk_icon_theme_has_icon ##### -->
249 <!-- ##### FUNCTION gtk_icon_theme_lookup_icon ##### -->
261 <!-- ##### FUNCTION gtk_icon_theme_choose_icon ##### -->
273 <!-- ##### FUNCTION gtk_icon_theme_lookup_by_gicon ##### -->
285 <!-- ##### FUNCTION gtk_icon_theme_load_icon ##### -->
298 <!-- ##### FUNCTION gtk_icon_theme_list_contexts ##### -->
307 <!-- ##### FUNCTION gtk_icon_theme_list_icons ##### -->
317 <!-- ##### FUNCTION gtk_icon_theme_get_icon_sizes ##### -->
327 <!-- ##### FUNCTION gtk_icon_theme_get_example_icon_name ##### -->
336 <!-- ##### FUNCTION gtk_icon_theme_rescan_if_needed ##### -->
345 <!-- ##### FUNCTION gtk_icon_theme_add_builtin_icon ##### -->
355 <!-- ##### FUNCTION gtk_icon_info_copy ##### -->
364 <!-- ##### FUNCTION gtk_icon_info_free ##### -->
372 <!-- ##### FUNCTION gtk_icon_info_new_for_pixbuf ##### -->
382 <!-- ##### FUNCTION gtk_icon_info_get_base_size ##### -->
391 <!-- ##### FUNCTION gtk_icon_info_get_filename ##### -->
400 <!-- ##### FUNCTION gtk_icon_info_get_builtin_pixbuf ##### -->
409 <!-- ##### FUNCTION gtk_icon_info_load_icon ##### -->
419 <!-- ##### FUNCTION gtk_icon_info_set_raw_coordinates ##### -->
428 <!-- ##### FUNCTION gtk_icon_info_get_embedded_rect ##### -->
438 <!-- ##### FUNCTION gtk_icon_info_get_attach_points ##### -->
449 <!-- ##### FUNCTION gtk_icon_info_get_display_name ##### -->