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#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
31#error "Only <gtk/gtk.h> can be included directly."
32#endif
33
34#include <gdk/gdk.h>
35#include <gtk/gtkrc.h>
36
37G_BEGIN_DECLS
38
39typedef struct _GtkIconFactoryClass GtkIconFactoryClass;
40
41#define GTK_TYPE_ICON_FACTORY (gtk_icon_factory_get_type ())
42#define GTK_ICON_FACTORY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_ICON_FACTORY, GtkIconFactory))
43#define GTK_ICON_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_FACTORY, GtkIconFactoryClass))
44#define GTK_IS_ICON_FACTORY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_ICON_FACTORY))
45#define GTK_IS_ICON_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_FACTORY))
46#define GTK_ICON_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_FACTORY, GtkIconFactoryClass))
47#define GTK_TYPE_ICON_SET (gtk_icon_set_get_type ())
48#define GTK_TYPE_ICON_SOURCE (gtk_icon_source_get_type ())
49
50struct _GtkIconFactory
51{
52 GObject parent_instance;
53
54 GHashTable *GSEAL (icons);
55};
56
57struct _GtkIconFactoryClass
58{
59 GObjectClass parent_class;
60
61 /* Padding for future expansion */
62 void (*_gtk_reserved1) (void);
63 void (*_gtk_reserved2) (void);
64 void (*_gtk_reserved3) (void);
65 void (*_gtk_reserved4) (void);
66};
67
68#ifdef G_OS_WIN32
69/* Reserve old names for DLL ABI backward compatibility */
70#define gtk_icon_source_set_filename gtk_icon_source_set_filename_utf8
71#define gtk_icon_source_get_filename gtk_icon_source_get_filename_utf8
72#endif
73
74GType gtk_icon_factory_get_type (void) G_GNUC_CONST;
75GtkIconFactory* gtk_icon_factory_new (void);
76void gtk_icon_factory_add (GtkIconFactory *factory,
77 const gchar *stock_id,
78 GtkIconSet *icon_set);
79GtkIconSet* gtk_icon_factory_lookup (GtkIconFactory *factory,
80 const gchar *stock_id);
81
82/* Manage the default icon factory stack */
83
84void gtk_icon_factory_add_default (GtkIconFactory *factory);
85void gtk_icon_factory_remove_default (GtkIconFactory *factory);
86GtkIconSet* gtk_icon_factory_lookup_default (const gchar *stock_id);
87
88/* Get preferred real size from registered semantic size. Note that
89 * themes SHOULD use this size, but they aren't required to; for size
90 * requests and such, you should get the actual pixbuf from the icon
91 * set and see what size was rendered.
92 *
93 * This function is intended for people who are scaling icons,
94 * rather than for people who are displaying already-scaled icons.
95 * That is, if you are displaying an icon, you should get the
96 * size from the rendered pixbuf, not from here.
97 */
98
99#ifndef GDK_MULTIHEAD_SAFE
100gboolean gtk_icon_size_lookup (GtkIconSize size,
101 gint *width,
102 gint *height);
103#endif /* GDK_MULTIHEAD_SAFE */
104gboolean gtk_icon_size_lookup_for_settings (GtkSettings *settings,
105 GtkIconSize size,
106 gint *width,
107 gint *height);
108
109GtkIconSize gtk_icon_size_register (const gchar *name,
110 gint width,
111 gint height);
112void gtk_icon_size_register_alias (const gchar *alias,
113 GtkIconSize target);
114GtkIconSize gtk_icon_size_from_name (const gchar *name);
115const gchar * gtk_icon_size_get_name (GtkIconSize size);
116
117/* Icon sets */
118
119GType gtk_icon_set_get_type (void) G_GNUC_CONST;
120GtkIconSet* gtk_icon_set_new (void);
121GtkIconSet* gtk_icon_set_new_from_pixbuf (GdkPixbuf *pixbuf);
122
123GtkIconSet* gtk_icon_set_ref (GtkIconSet *icon_set);
124void gtk_icon_set_unref (GtkIconSet *icon_set);
125GtkIconSet* gtk_icon_set_copy (GtkIconSet *icon_set);
126
127/* Get one of the icon variants in the set, creating the variant if
128 * necessary.
129 */
130GdkPixbuf* gtk_icon_set_render_icon (GtkIconSet *icon_set,
131 GtkStyle *style,
132 GtkTextDirection direction,
133 GtkStateType state,
134 GtkIconSize size,
135 GtkWidget *widget,
136 const char *detail);
137
138
139void gtk_icon_set_add_source (GtkIconSet *icon_set,
140 const GtkIconSource *source);
141
142void gtk_icon_set_get_sizes (GtkIconSet *icon_set,
143 GtkIconSize **sizes,
144 gint *n_sizes);
145
146GType gtk_icon_source_get_type (void) G_GNUC_CONST;
147GtkIconSource* gtk_icon_source_new (void);
148GtkIconSource* gtk_icon_source_copy (const GtkIconSource *source);
149void gtk_icon_source_free (GtkIconSource *source);
150
151void gtk_icon_source_set_filename (GtkIconSource *source,
152 const gchar *filename);
153void gtk_icon_source_set_icon_name (GtkIconSource *source,
154 const gchar *icon_name);
155void gtk_icon_source_set_pixbuf (GtkIconSource *source,
156 GdkPixbuf *pixbuf);
157
158const gchar* gtk_icon_source_get_filename (const GtkIconSource *source);
159const gchar* gtk_icon_source_get_icon_name (const GtkIconSource *source);
160GdkPixbuf* gtk_icon_source_get_pixbuf (const GtkIconSource *source);
161
162void gtk_icon_source_set_direction_wildcarded (GtkIconSource *source,
163 gboolean setting);
164void gtk_icon_source_set_state_wildcarded (GtkIconSource *source,
165 gboolean setting);
166void gtk_icon_source_set_size_wildcarded (GtkIconSource *source,
167 gboolean setting);
168gboolean gtk_icon_source_get_size_wildcarded (const GtkIconSource *source);
169gboolean gtk_icon_source_get_state_wildcarded (const GtkIconSource *source);
170gboolean gtk_icon_source_get_direction_wildcarded (const GtkIconSource *source);
171void gtk_icon_source_set_direction (GtkIconSource *source,
172 GtkTextDirection direction);
173void gtk_icon_source_set_state (GtkIconSource *source,
174 GtkStateType state);
175void gtk_icon_source_set_size (GtkIconSource *source,
176 GtkIconSize size);
177GtkTextDirection gtk_icon_source_get_direction (const GtkIconSource *source);
178GtkStateType gtk_icon_source_get_state (const GtkIconSource *source);
179GtkIconSize gtk_icon_source_get_size (const GtkIconSource *source);
180
181
182/* ignore this */
183void _gtk_icon_set_invalidate_caches (void);
184GList* _gtk_icon_factory_list_ids (void);
185void _gtk_icon_factory_ensure_default_icons (void);
186
187G_END_DECLS
188
189#endif /* __GTK_ICON_FACTORY_H__ */
190