]> Pileus Git - ~andy/gtk/blob - gtk/gtkicontheme.h
stylecontext: Do invalidation on first resize container
[~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, see <http://www.gnu.org/licenses/>.
16  */
17
18 #ifndef __GTK_ICON_THEME_H__
19 #define __GTK_ICON_THEME_H__
20
21 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22 #error "Only <gtk/gtk.h> can be included directly."
23 #endif
24
25 #include <gdk-pixbuf/gdk-pixbuf.h>
26 #include <gdk/gdk.h>
27 #include <gtk/gtkstylecontext.h>
28
29 G_BEGIN_DECLS
30
31 #define GTK_TYPE_ICON_INFO              (gtk_icon_info_get_type ())
32 #define GTK_ICON_INFO(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_INFO, GtkIconInfo))
33 #define GTK_ICON_INFO_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_INFO, GtkIconInfoClass))
34 #define GTK_IS_ICON_INFO(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ICON_INFO))
35 #define GTK_IS_ICON_INFO_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_INFO))
36 #define GTK_ICON_INFO_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_INFO, GtkIconInfoClass))
37
38 #define GTK_TYPE_ICON_THEME             (gtk_icon_theme_get_type ())
39 #define GTK_ICON_THEME(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_THEME, GtkIconTheme))
40 #define GTK_ICON_THEME_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_THEME, GtkIconThemeClass))
41 #define GTK_IS_ICON_THEME(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ICON_THEME))
42 #define GTK_IS_ICON_THEME_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_THEME))
43 #define GTK_ICON_THEME_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_THEME, GtkIconThemeClass))
44
45 /**
46  * GtkIconInfo:
47  *
48  * Contains information found when looking up an icon in
49  * an icon theme.
50  */
51 typedef struct _GtkIconInfo         GtkIconInfo;
52 typedef struct _GtkIconInfoClass    GtkIconInfoClass;
53 typedef struct _GtkIconTheme        GtkIconTheme;
54 typedef struct _GtkIconThemeClass   GtkIconThemeClass;
55 typedef struct _GtkIconThemePrivate GtkIconThemePrivate;
56
57 /**
58  * GtkIconTheme:
59  *
60  * Acts as a database of information about an icon theme.
61  * Normally, you retrieve the icon theme for a particular
62  * screen using gtk_icon_theme_get_for_screen() and it
63  * will contain information about current icon theme for
64  * that screen, but you can also create a new #GtkIconTheme
65  * object and set the icon theme name explicitely using
66  * gtk_icon_theme_set_custom_theme().
67  */
68 struct _GtkIconTheme
69 {
70   /*< private >*/
71   GObject parent_instance;
72
73   GtkIconThemePrivate *priv;
74 };
75
76 struct _GtkIconThemeClass
77 {
78   GObjectClass parent_class;
79
80   void (* changed)  (GtkIconTheme *icon_theme);
81
82   /* Padding for future expansion */
83   void (*_gtk_reserved1) (void);
84   void (*_gtk_reserved2) (void);
85   void (*_gtk_reserved3) (void);
86   void (*_gtk_reserved4) (void);
87 };
88
89 /**
90  * GtkIconLookupFlags:
91  * @GTK_ICON_LOOKUP_NO_SVG: Never return SVG icons, even if gdk-pixbuf
92  *   supports them. Cannot be used together with %GTK_ICON_LOOKUP_FORCE_SVG.
93  * @GTK_ICON_LOOKUP_FORCE_SVG: Return SVG icons, even if gdk-pixbuf
94  *   doesn't support them.
95  *   Cannot be used together with %GTK_ICON_LOOKUP_NO_SVG.
96  * @GTK_ICON_LOOKUP_USE_BUILTIN: When passed to
97  *   gtk_icon_theme_lookup_icon() includes builtin icons
98  *   as well as files. For a builtin icon, gtk_icon_info_get_filename()
99  *   returns %NULL and you need to call gtk_icon_info_get_builtin_pixbuf().
100  * @GTK_ICON_LOOKUP_GENERIC_FALLBACK: Try to shorten icon name at '-'
101  *   characters before looking at inherited themes. For more general
102  *   fallback, see gtk_icon_theme_choose_icon(). Since 2.12.
103  * @GTK_ICON_LOOKUP_FORCE_SIZE: Always return the icon scaled to the
104  *   requested size. Since 2.14.
105  * 
106  * Used to specify options for gtk_icon_theme_lookup_icon()
107  **/
108 typedef enum
109 {
110   GTK_ICON_LOOKUP_NO_SVG           = 1 << 0,
111   GTK_ICON_LOOKUP_FORCE_SVG        = 1 << 1,
112   GTK_ICON_LOOKUP_USE_BUILTIN      = 1 << 2,
113   GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 3,
114   GTK_ICON_LOOKUP_FORCE_SIZE       = 1 << 4
115 } GtkIconLookupFlags;
116
117 /**
118  * GTK_ICON_THEME_ERROR:
119  *
120  * The #GQuark used for #GtkIconThemeError errors.
121  */
122 #define GTK_ICON_THEME_ERROR gtk_icon_theme_error_quark ()
123
124 /**
125  * GtkIconThemeError:
126  * @GTK_ICON_THEME_NOT_FOUND: The icon specified does not exist in the theme
127  * @GTK_ICON_THEME_FAILED: An unspecified error occurred.
128  * 
129  * Error codes for GtkIconTheme operations.
130  **/
131 typedef enum {
132   GTK_ICON_THEME_NOT_FOUND,
133   GTK_ICON_THEME_FAILED
134 } GtkIconThemeError;
135
136 GQuark gtk_icon_theme_error_quark (void);
137
138 GType         gtk_icon_theme_get_type              (void) G_GNUC_CONST;
139
140 GtkIconTheme *gtk_icon_theme_new                   (void);
141 GtkIconTheme *gtk_icon_theme_get_default           (void);
142 GtkIconTheme *gtk_icon_theme_get_for_screen        (GdkScreen                   *screen);
143 void          gtk_icon_theme_set_screen            (GtkIconTheme                *icon_theme,
144                                                     GdkScreen                   *screen);
145
146 void          gtk_icon_theme_set_search_path       (GtkIconTheme                *icon_theme,
147                                                     const gchar                 *path[],
148                                                     gint                         n_elements);
149 void          gtk_icon_theme_get_search_path       (GtkIconTheme                *icon_theme,
150                                                     gchar                      **path[],
151                                                     gint                        *n_elements);
152 void          gtk_icon_theme_append_search_path    (GtkIconTheme                *icon_theme,
153                                                     const gchar                 *path);
154 void          gtk_icon_theme_prepend_search_path   (GtkIconTheme                *icon_theme,
155                                                     const gchar                 *path);
156
157 void          gtk_icon_theme_set_custom_theme      (GtkIconTheme                *icon_theme,
158                                                     const gchar                 *theme_name);
159
160 gboolean      gtk_icon_theme_has_icon              (GtkIconTheme                *icon_theme,
161                                                     const gchar                 *icon_name);
162 gint         *gtk_icon_theme_get_icon_sizes        (GtkIconTheme                *icon_theme,
163                                                     const gchar                 *icon_name);
164 GtkIconInfo * gtk_icon_theme_lookup_icon           (GtkIconTheme                *icon_theme,
165                                                     const gchar                 *icon_name,
166                                                     gint                         size,
167                                                     GtkIconLookupFlags           flags);
168 GtkIconInfo * gtk_icon_theme_choose_icon           (GtkIconTheme                *icon_theme,
169                                                     const gchar                 *icon_names[],
170                                                     gint                         size,
171                                                     GtkIconLookupFlags           flags);
172 GdkPixbuf *   gtk_icon_theme_load_icon             (GtkIconTheme                *icon_theme,
173                                                     const gchar                 *icon_name,
174                                                     gint                         size,
175                                                     GtkIconLookupFlags           flags,
176                                                     GError                     **error);
177
178 GtkIconInfo * gtk_icon_theme_lookup_by_gicon       (GtkIconTheme                *icon_theme,
179                                                     GIcon                       *icon,
180                                                     gint                         size,
181                                                     GtkIconLookupFlags           flags);
182
183 GList *       gtk_icon_theme_list_icons            (GtkIconTheme                *icon_theme,
184                                                     const gchar                 *context);
185 GList *       gtk_icon_theme_list_contexts         (GtkIconTheme                *icon_theme);
186 char *        gtk_icon_theme_get_example_icon_name (GtkIconTheme                *icon_theme);
187
188 gboolean      gtk_icon_theme_rescan_if_needed      (GtkIconTheme                *icon_theme);
189
190 void          gtk_icon_theme_add_builtin_icon      (const gchar *icon_name,
191                                                     gint         size,
192                                                     GdkPixbuf   *pixbuf);
193
194 GType                 gtk_icon_info_get_type           (void) G_GNUC_CONST;
195 GDK_DEPRECATED_IN_3_8_FOR(g_object_ref)
196 GtkIconInfo *         gtk_icon_info_copy               (GtkIconInfo  *icon_info);
197 GDK_DEPRECATED_IN_3_8_FOR(g_object_unref)
198 void                  gtk_icon_info_free               (GtkIconInfo  *icon_info);
199
200 GtkIconInfo *         gtk_icon_info_new_for_pixbuf     (GtkIconTheme  *icon_theme,
201                                                         GdkPixbuf     *pixbuf);
202
203 gint                  gtk_icon_info_get_base_size      (GtkIconInfo   *icon_info);
204 const gchar *         gtk_icon_info_get_filename       (GtkIconInfo   *icon_info);
205 GdkPixbuf *           gtk_icon_info_get_builtin_pixbuf (GtkIconInfo   *icon_info);
206 GdkPixbuf *           gtk_icon_info_load_icon          (GtkIconInfo   *icon_info,
207                                                         GError       **error);
208 GDK_AVAILABLE_IN_3_8
209 void                  gtk_icon_info_load_icon_async   (GtkIconInfo          *icon_info,
210                                                        GCancellable         *cancellable,
211                                                        GAsyncReadyCallback   callback,
212                                                        gpointer              user_data);
213 GDK_AVAILABLE_IN_3_8
214 GdkPixbuf *           gtk_icon_info_load_icon_finish  (GtkIconInfo          *icon_info,
215                                                        GAsyncResult         *res,
216                                                        GError              **error);
217 GdkPixbuf *           gtk_icon_info_load_symbolic      (GtkIconInfo   *icon_info,
218                                                         const GdkRGBA *fg,
219                                                         const GdkRGBA *success_color,
220                                                         const GdkRGBA *warning_color,
221                                                         const GdkRGBA *error_color,
222                                                         gboolean      *was_symbolic,
223                                                         GError       **error);
224 GDK_AVAILABLE_IN_3_8
225 void                  gtk_icon_info_load_symbolic_async (GtkIconInfo   *icon_info,
226                                                          const GdkRGBA *fg,
227                                                          const GdkRGBA *success_color,
228                                                          const GdkRGBA *warning_color,
229                                                          const GdkRGBA *error_color,
230                                                          GCancellable         *cancellable,
231                                                          GAsyncReadyCallback   callback,
232                                                          gpointer              user_data);
233 GDK_AVAILABLE_IN_3_8
234 GdkPixbuf *           gtk_icon_info_load_symbolic_finish (GtkIconInfo   *icon_info,
235                                                           GAsyncResult         *res,
236                                                           gboolean      *was_symbolic,
237                                                           GError       **error);
238 GdkPixbuf *           gtk_icon_info_load_symbolic_for_context (GtkIconInfo      *icon_info,
239                                                                GtkStyleContext  *context,
240                                                                gboolean         *was_symbolic,
241                                                                GError          **error);
242 GDK_AVAILABLE_IN_3_8
243 void                  gtk_icon_info_load_symbolic_for_context_async (GtkIconInfo      *icon_info,
244                                                                      GtkStyleContext  *context,
245                                                                      GCancellable     *cancellable,
246                                                                      GAsyncReadyCallback callback,
247                                                                      gpointer          user_data);
248 GDK_AVAILABLE_IN_3_8
249 GdkPixbuf *           gtk_icon_info_load_symbolic_for_context_finish (GtkIconInfo      *icon_info,
250                                                                       GAsyncResult     *res,
251                                                                       gboolean         *was_symbolic,
252                                                                       GError          **error);
253 GDK_DEPRECATED_IN_3_0_FOR(gtk_icon_info_load_symbol_for_context)
254 GdkPixbuf *           gtk_icon_info_load_symbolic_for_style  (GtkIconInfo   *icon_info,
255                                                               GtkStyle      *style,
256                                                               GtkStateType   state,
257                                                               gboolean      *was_symbolic,
258                                                               GError       **error);
259 void                  gtk_icon_info_set_raw_coordinates (GtkIconInfo  *icon_info,
260                                                          gboolean      raw_coordinates);
261
262 gboolean              gtk_icon_info_get_embedded_rect (GtkIconInfo    *icon_info,
263                                                        GdkRectangle   *rectangle);
264 gboolean              gtk_icon_info_get_attach_points (GtkIconInfo    *icon_info,
265                                                        GdkPoint      **points,
266                                                        gint           *n_points);
267 const gchar *         gtk_icon_info_get_display_name  (GtkIconInfo    *icon_info);
268
269 /* Non-public methods */
270 void _gtk_icon_theme_check_reload                     (GdkDisplay *display);
271 void _gtk_icon_theme_ensure_builtin_cache             (void);
272
273 G_END_DECLS
274
275 #endif /* __GTK_ICON_THEME_H__ */