]> Pileus Git - ~andy/gtk/blob - gtk/gtkiconfactory.h
New function to create an icon set from a pixbuf.
[~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   
58 };
59
60 GType           gtk_icon_factory_get_type (void);
61 GtkIconFactory* gtk_icon_factory_new      (void);
62 void            gtk_icon_factory_add      (GtkIconFactory *factory,
63                                            const gchar    *stock_id,
64                                            GtkIconSet     *icon_set);
65 GtkIconSet*     gtk_icon_factory_lookup   (GtkIconFactory *factory,
66                                            const gchar    *stock_id);
67
68 /* Manage the default icon factory stack */
69
70 void        gtk_icon_factory_add_default     (GtkIconFactory  *factory);
71 void        gtk_icon_factory_remove_default  (GtkIconFactory  *factory);
72 GtkIconSet* gtk_icon_factory_lookup_default  (const gchar     *stock_id);
73
74 /* Get preferred real size from registered semantic size.  Note that
75  * themes SHOULD use this size, but they aren't required to; for size
76  * requests and such, you should get the actual pixbuf from the icon
77  * set and see what size was rendered.
78  *
79  * This function is intended for people who are scaling icons,
80  * rather than for people who are displaying already-scaled icons.
81  * That is, if you are displaying an icon, you should get the
82  * size from the rendered pixbuf, not from here.
83  */
84
85 gboolean gtk_icon_size_lookup         (const gchar *alias,
86                                        gint        *width,
87                                        gint        *height);
88 void     gtk_icon_size_register       (const gchar *alias,
89                                        gint         width,
90                                        gint         height);
91 void     gtk_icon_size_register_alias (const gchar *alias,
92                                        const gchar *target);
93
94
95 /* Standard sizes */
96
97 #define GTK_ICON_SIZE_MENU          "gtk-menu"
98 #define GTK_ICON_SIZE_SMALL_TOOLBAR "gtk-small-toolbar"
99 #define GTK_ICON_SIZE_LARGE_TOOLBAR "gtk-large-toolbar"
100 #define GTK_ICON_SIZE_BUTTON        "gtk-button"
101 #define GTK_ICON_SIZE_DIALOG        "gtk-dialog"
102
103 /* Icon sets */
104
105 GtkIconSet* gtk_icon_set_new             (void);
106 GtkIconSet* gtk_icon_set_new_from_pixbuf (GdkPixbuf       *pixbuf);
107
108 GtkIconSet* gtk_icon_set_ref             (GtkIconSet      *icon_set);
109 void        gtk_icon_set_unref           (GtkIconSet      *icon_set);
110 GtkIconSet* gtk_icon_set_copy            (GtkIconSet      *icon_set);
111
112 /* Get one of the icon variants in the set, creating the variant if
113  * necessary.
114  */
115 GdkPixbuf*  gtk_icon_set_render_icon     (GtkIconSet      *icon_set,
116                                           GtkStyle        *style,
117                                           GtkTextDirection direction,
118                                           GtkStateType     state,
119                                           const gchar     *size,
120                                           GtkWidget       *widget,
121                                           const char      *detail);
122
123
124 void           gtk_icon_set_add_source   (GtkIconSet          *icon_set,
125                                           const GtkIconSource *source);
126
127 /* INTERNAL */
128 void _gtk_icon_set_invalidate_caches (void);
129
130 struct _GtkIconSource
131 {
132   /* Either filename or pixbuf can be NULL. If both are non-NULL,
133    * the pixbuf is assumed to be the already-loaded contents of the
134    * file.
135    */
136   gchar *filename;
137   GdkPixbuf *pixbuf;
138
139   GtkTextDirection direction;
140   GtkStateType state;
141   gchar *size;
142
143   /* If TRUE, then the parameter is wildcarded, and the above
144    * fields should be ignored. If FALSE, the parameter is
145    * specified, and the above fields should be valid.
146    */
147   guint any_direction : 1;
148   guint any_state : 1;
149   guint any_size : 1;
150 };
151
152
153 GtkIconSource* gtk_icon_source_copy    (const GtkIconSource *source);
154 void           gtk_icon_source_free    (GtkIconSource       *source);
155
156 #ifdef __cplusplus
157 }
158 #endif /* __cplusplus */
159
160 #endif /* __GTK_ICON_FACTORY_H__ */