]> Pileus Git - ~andy/gtk/blob - gtk/gtkicontheme.h
c2fcdd48038349f47172b2a73391c785a4104747
[~andy/gtk] / gtk / gtkicontheme.h
1 /* GtkIconTheme - a loader for icon themes
2  * gtk-icon-loader.h Copyright (C) 2002, 2003 Red Hat, Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
21 #error "Only <gtk/gtk.h> can be included directly."
22 #endif
23
24 #ifndef __GTK_ICON_THEME_H__
25 #define __GTK_ICON_THEME_H__
26
27 #include <gdk-pixbuf/gdk-pixbuf.h>
28 #include <gdk/gdk.h>
29 #include <gtk/gtkstylecontext.h>
30
31 G_BEGIN_DECLS
32
33 #define GTK_TYPE_ICON_INFO              (gtk_icon_info_get_type ())
34
35 #define GTK_TYPE_ICON_THEME             (gtk_icon_theme_get_type ())
36 #define GTK_ICON_THEME(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_THEME, GtkIconTheme))
37 #define GTK_ICON_THEME_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_THEME, GtkIconThemeClass))
38 #define GTK_IS_ICON_THEME(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ICON_THEME))
39 #define GTK_IS_ICON_THEME_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_THEME))
40 #define GTK_ICON_THEME_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_THEME, GtkIconThemeClass))
41
42 /**
43  * GtkIconInfo:
44  *
45  * Contains information found when looking up an icon in
46  * an icon theme.
47  */
48 typedef struct _GtkIconInfo         GtkIconInfo;
49 typedef struct _GtkIconTheme        GtkIconTheme;
50 typedef struct _GtkIconThemeClass   GtkIconThemeClass;
51 typedef struct _GtkIconThemePrivate GtkIconThemePrivate;
52
53 /**
54  * GtkIconTheme:
55  *
56  * Acts as a database of information about an icon theme.
57  * Normally, you retrieve the icon theme for a particular
58  * screen using gtk_icon_theme_get_for_screen() and it
59  * will contain information about current icon theme for
60  * that screen, but you can also create a new #GtkIconTheme
61  * object and set the icon theme name explicitely using
62  * gtk_icon_theme_set_custom_theme().
63  */
64 struct _GtkIconTheme
65 {
66   /*< private >*/
67   GObject parent_instance;
68
69   GtkIconThemePrivate *priv;
70 };
71
72 struct _GtkIconThemeClass
73 {
74   GObjectClass parent_class;
75
76   void (* changed)  (GtkIconTheme *icon_theme);
77
78   /* Padding for future expansion */
79   void (*_gtk_reserved1) (void);
80   void (*_gtk_reserved2) (void);
81   void (*_gtk_reserved3) (void);
82   void (*_gtk_reserved4) (void);
83 };
84
85 /**
86  * GtkIconLookupFlags:
87  * @GTK_ICON_LOOKUP_NO_SVG: Never return SVG icons, even if gdk-pixbuf
88  *   supports them. Cannot be used together with %GTK_ICON_LOOKUP_FORCE_SVG.
89  * @GTK_ICON_LOOKUP_FORCE_SVG: Return SVG icons, even if gdk-pixbuf
90  *   doesn't support them.
91  *   Cannot be used together with %GTK_ICON_LOOKUP_NO_SVG.
92  * @GTK_ICON_LOOKUP_USE_BUILTIN: When passed to
93  *   gtk_icon_theme_lookup_icon() includes builtin icons
94  *   as well as files. For a builtin icon, gtk_icon_info_get_filename()
95  *   returns %NULL and you need to call gtk_icon_info_get_builtin_pixbuf().
96  * @GTK_ICON_LOOKUP_GENERIC_FALLBACK: Try to shorten icon name at '-'
97  *   characters before looking at inherited themes. For more general
98  *   fallback, see gtk_icon_theme_choose_icon(). Since 2.12.
99  * @GTK_ICON_LOOKUP_FORCE_SIZE: Always return the icon scaled to the
100  *   requested size. Since 2.14.
101  * 
102  * Used to specify options for gtk_icon_theme_lookup_icon()
103  **/
104 typedef enum
105 {
106   GTK_ICON_LOOKUP_NO_SVG           = 1 << 0,
107   GTK_ICON_LOOKUP_FORCE_SVG        = 1 << 1,
108   GTK_ICON_LOOKUP_USE_BUILTIN      = 1 << 2,
109   GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 3,
110   GTK_ICON_LOOKUP_FORCE_SIZE       = 1 << 4
111 } GtkIconLookupFlags;
112
113 /**
114  * GTK_ICON_THEME_ERROR:
115  *
116  * The #GQuark used for #GtkIconThemeError errors.
117  */
118 #define GTK_ICON_THEME_ERROR gtk_icon_theme_error_quark ()
119
120 /**
121  * GtkIconThemeError:
122  * @GTK_ICON_THEME_NOT_FOUND: The icon specified does not exist in the theme
123  * @GTK_ICON_THEME_FAILED: An unspecified error occurred.
124  * 
125  * Error codes for GtkIconTheme operations.
126  **/
127 typedef enum {
128   GTK_ICON_THEME_NOT_FOUND,
129   GTK_ICON_THEME_FAILED
130 } GtkIconThemeError;
131
132 GQuark gtk_icon_theme_error_quark (void);
133
134 GType         gtk_icon_theme_get_type              (void) G_GNUC_CONST;
135
136 GtkIconTheme *gtk_icon_theme_new                   (void);
137 GtkIconTheme *gtk_icon_theme_get_default           (void);
138 GtkIconTheme *gtk_icon_theme_get_for_screen        (GdkScreen                   *screen);
139 void          gtk_icon_theme_set_screen            (GtkIconTheme                *icon_theme,
140                                                     GdkScreen                   *screen);
141
142 void          gtk_icon_theme_set_search_path       (GtkIconTheme                *icon_theme,
143                                                     const gchar                 *path[],
144                                                     gint                         n_elements);
145 void          gtk_icon_theme_get_search_path       (GtkIconTheme                *icon_theme,
146                                                     gchar                      **path[],
147                                                     gint                        *n_elements);
148 void          gtk_icon_theme_append_search_path    (GtkIconTheme                *icon_theme,
149                                                     const gchar                 *path);
150 void          gtk_icon_theme_prepend_search_path   (GtkIconTheme                *icon_theme,
151                                                     const gchar                 *path);
152
153 void          gtk_icon_theme_set_custom_theme      (GtkIconTheme                *icon_theme,
154                                                     const gchar                 *theme_name);
155
156 gboolean      gtk_icon_theme_has_icon              (GtkIconTheme                *icon_theme,
157                                                     const gchar                 *icon_name);
158 gint         *gtk_icon_theme_get_icon_sizes        (GtkIconTheme                *icon_theme,
159                                                     const gchar                 *icon_name);
160 GtkIconInfo * gtk_icon_theme_lookup_icon           (GtkIconTheme                *icon_theme,
161                                                     const gchar                 *icon_name,
162                                                     gint                         size,
163                                                     GtkIconLookupFlags           flags);
164 GtkIconInfo * gtk_icon_theme_choose_icon           (GtkIconTheme                *icon_theme,
165                                                     const gchar                 *icon_names[],
166                                                     gint                         size,
167                                                     GtkIconLookupFlags           flags);
168 GdkPixbuf *   gtk_icon_theme_load_icon             (GtkIconTheme                *icon_theme,
169                                                     const gchar                 *icon_name,
170                                                     gint                         size,
171                                                     GtkIconLookupFlags           flags,
172                                                     GError                     **error);
173
174 GtkIconInfo * gtk_icon_theme_lookup_by_gicon       (GtkIconTheme                *icon_theme,
175                                                     GIcon                       *icon,
176                                                     gint                         size,
177                                                     GtkIconLookupFlags           flags);
178
179 GList *       gtk_icon_theme_list_icons            (GtkIconTheme                *icon_theme,
180                                                     const gchar                 *context);
181 GList *       gtk_icon_theme_list_contexts         (GtkIconTheme                *icon_theme);
182 char *        gtk_icon_theme_get_example_icon_name (GtkIconTheme                *icon_theme);
183
184 gboolean      gtk_icon_theme_rescan_if_needed      (GtkIconTheme                *icon_theme);
185
186 void          gtk_icon_theme_add_builtin_icon      (const gchar *icon_name,
187                                                     gint         size,
188                                                     GdkPixbuf   *pixbuf);
189
190 GType                 gtk_icon_info_get_type           (void) G_GNUC_CONST;
191 GtkIconInfo *         gtk_icon_info_copy               (GtkIconInfo  *icon_info);
192 void                  gtk_icon_info_free               (GtkIconInfo  *icon_info);
193
194 GtkIconInfo *         gtk_icon_info_new_for_pixbuf     (GtkIconTheme  *icon_theme,
195                                                         GdkPixbuf     *pixbuf);
196
197 gint                  gtk_icon_info_get_base_size      (GtkIconInfo   *icon_info);
198 const gchar *         gtk_icon_info_get_filename       (GtkIconInfo   *icon_info);
199 GdkPixbuf *           gtk_icon_info_get_builtin_pixbuf (GtkIconInfo   *icon_info);
200 GdkPixbuf *           gtk_icon_info_load_icon          (GtkIconInfo   *icon_info,
201                                                         GError       **error);
202 GdkPixbuf *           gtk_icon_info_load_symbolic      (GtkIconInfo   *icon_info,
203                                                         const GdkRGBA *fg,
204                                                         const GdkRGBA *success_color,
205                                                         const GdkRGBA *warning_color,
206                                                         const GdkRGBA *error_color,
207                                                         gboolean      *was_symbolic,
208                                                         GError       **error);
209 GdkPixbuf *           gtk_icon_info_load_symbolic_for_context (GtkIconInfo      *icon_info,
210                                                                GtkStyleContext  *context,
211                                                                gboolean         *was_symbolic,
212                                                                GError          **error);
213 GDK_DEPRECATED_IN_3_0_FOR(gtk_icon_info_load_symbol_for_context)
214 GdkPixbuf *           gtk_icon_info_load_symbolic_for_style  (GtkIconInfo   *icon_info,
215                                                               GtkStyle      *style,
216                                                               GtkStateType   state,
217                                                               gboolean      *was_symbolic,
218                                                               GError       **error);
219 void                  gtk_icon_info_set_raw_coordinates (GtkIconInfo  *icon_info,
220                                                          gboolean      raw_coordinates);
221
222 gboolean              gtk_icon_info_get_embedded_rect (GtkIconInfo    *icon_info,
223                                                        GdkRectangle   *rectangle);
224 gboolean              gtk_icon_info_get_attach_points (GtkIconInfo    *icon_info,
225                                                        GdkPoint      **points,
226                                                        gint           *n_points);
227 const gchar *         gtk_icon_info_get_display_name  (GtkIconInfo    *icon_info);
228
229 /* Non-public methods */
230 void _gtk_icon_theme_check_reload                     (GdkDisplay *display);
231 void _gtk_icon_theme_ensure_builtin_cache             (void);
232
233 G_END_DECLS
234
235 #endif /* __GTK_ICON_THEME_H__ */