]> Pileus Git - ~andy/gtk/blob - gtk/gtkiconfactory.h
53496a9c41de6d52cd019ea7c82f99c3858b0de5
[~andy/gtk] / gtk / gtkiconfactory.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2000 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 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #ifndef __GTK_ICON_FACTORY_H__
28 #define __GTK_ICON_FACTORY_H__
29
30 #include <gdk/gdk.h>
31 #include <gtk/gtkrc.h>
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif /* __cplusplus */
36
37 typedef struct _GtkIconFactoryClass GtkIconFactoryClass;
38
39 #define GTK_TYPE_ICON_FACTORY              (gtk_icon_factory_get_type ())
40 #define GTK_ICON_FACTORY(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_ICON_FACTORY, GtkIconFactory))
41 #define GTK_ICON_FACTORY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_FACTORY, GtkIconFactoryClass))
42 #define GTK_IS_ICON_FACTORY(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_ICON_FACTORY))
43 #define GTK_IS_ICON_FACTORY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_FACTORY))
44 #define GTK_ICON_FACTORY_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_FACTORY, GtkIconFactoryClass))
45
46 struct _GtkIconFactory
47 {
48   GObject parent_instance;
49
50   GHashTable *icons;
51 };
52
53 struct _GtkIconFactoryClass
54 {
55   GObjectClass parent_class;
56
57   /* Padding for future expansion */
58   void (*_gtk_reserved1) (void);
59   void (*_gtk_reserved2) (void);
60   void (*_gtk_reserved3) (void);
61   void (*_gtk_reserved4) (void);
62 };
63
64 GType           gtk_icon_factory_get_type (void);
65 GtkIconFactory* gtk_icon_factory_new      (void);
66 void            gtk_icon_factory_add      (GtkIconFactory *factory,
67                                            const gchar    *stock_id,
68                                            GtkIconSet     *icon_set);
69 GtkIconSet*     gtk_icon_factory_lookup   (GtkIconFactory *factory,
70                                            const gchar    *stock_id);
71
72 /* Manage the default icon factory stack */
73
74 void        gtk_icon_factory_add_default     (GtkIconFactory  *factory);
75 void        gtk_icon_factory_remove_default  (GtkIconFactory  *factory);
76 GtkIconSet* gtk_icon_factory_lookup_default  (const gchar     *stock_id);
77
78 /* Get preferred real size from registered semantic size.  Note that
79  * themes SHOULD use this size, but they aren't required to; for size
80  * requests and such, you should get the actual pixbuf from the icon
81  * set and see what size was rendered.
82  *
83  * This function is intended for people who are scaling icons,
84  * rather than for people who are displaying already-scaled icons.
85  * That is, if you are displaying an icon, you should get the
86  * size from the rendered pixbuf, not from here.
87  */
88
89 gboolean              gtk_icon_size_lookup         (GtkIconSize  size,
90                                                     gint        *width,
91                                                     gint        *height);
92 GtkIconSize           gtk_icon_size_register       (const gchar *name,
93                                                     gint         width,
94                                                     gint         height);
95 void                  gtk_icon_size_register_alias (const gchar *alias,
96                                                     GtkIconSize  target);
97 GtkIconSize           gtk_icon_size_from_name      (const gchar *name);
98 G_CONST_RETURN gchar* gtk_icon_size_get_name       (GtkIconSize  size);
99
100 /* Icon sets */
101
102 GtkIconSet* gtk_icon_set_new             (void);
103 GtkIconSet* gtk_icon_set_new_from_pixbuf (GdkPixbuf       *pixbuf);
104
105 GtkIconSet* gtk_icon_set_ref             (GtkIconSet      *icon_set);
106 void        gtk_icon_set_unref           (GtkIconSet      *icon_set);
107 GtkIconSet* gtk_icon_set_copy            (GtkIconSet      *icon_set);
108
109 /* Get one of the icon variants in the set, creating the variant if
110  * necessary.
111  */
112 GdkPixbuf*  gtk_icon_set_render_icon     (GtkIconSet      *icon_set,
113                                           GtkStyle        *style,
114                                           GtkTextDirection direction,
115                                           GtkStateType     state,
116                                           GtkIconSize      size,
117                                           GtkWidget       *widget,
118                                           const char      *detail);
119
120
121 void           gtk_icon_set_add_source   (GtkIconSet          *icon_set,
122                                           const GtkIconSource *source);
123
124 void           gtk_icon_set_get_sizes    (GtkIconSet          *icon_set,
125                                           GtkIconSize        **sizes,
126                                           gint                *n_sizes);
127
128 GtkIconSource* gtk_icon_source_new                      (void);
129 GtkIconSource* gtk_icon_source_copy                     (const GtkIconSource *source);
130 void           gtk_icon_source_free                     (GtkIconSource       *source);
131
132 void           gtk_icon_source_set_filename             (GtkIconSource       *source,
133                                                          const gchar         *filename);
134 void           gtk_icon_source_set_pixbuf               (GtkIconSource       *source,
135                                                          GdkPixbuf           *pixbuf);
136
137 G_CONST_RETURN gchar* gtk_icon_source_get_filename (const GtkIconSource *source);
138 GdkPixbuf*            gtk_icon_source_get_pixbuf   (const GtkIconSource *source);
139
140 void             gtk_icon_source_set_direction_wildcarded (GtkIconSource       *source,
141                                                            gboolean             setting);
142 void             gtk_icon_source_set_state_wildcarded     (GtkIconSource       *source,
143                                                            gboolean             setting);
144 void             gtk_icon_source_set_size_wildcarded      (GtkIconSource       *source,
145                                                            gboolean             setting);
146 gboolean         gtk_icon_source_get_size_wildcarded      (const GtkIconSource *source);
147 gboolean         gtk_icon_source_get_state_wildcarded     (const GtkIconSource *source);
148 gboolean         gtk_icon_source_get_direction_wildcarded (const GtkIconSource *source);
149 void             gtk_icon_source_set_direction            (GtkIconSource       *source,
150                                                            GtkTextDirection     direction);
151 void             gtk_icon_source_set_state                (GtkIconSource       *source,
152                                                            GtkStateType         state);
153 void             gtk_icon_source_set_size                 (GtkIconSource       *source,
154                                                            GtkIconSize          size);
155 GtkTextDirection gtk_icon_source_get_direction            (const GtkIconSource *source);
156 GtkStateType     gtk_icon_source_get_state                (const GtkIconSource *source);
157 GtkIconSize      gtk_icon_source_get_size                 (const GtkIconSource *source);
158
159
160 /* ignore this */
161 void _gtk_icon_set_invalidate_caches (void);
162 GSList* _gtk_icon_factory_list_ids (void);
163
164 #ifdef __cplusplus
165 }
166 #endif /* __cplusplus */
167
168 #endif /* __GTK_ICON_FACTORY_H__ */