]> Pileus Git - ~andy/gtk/blob - gtk/gtkimage.h
Merge remote-tracking branch 'origin/master' into gdk-backend-wayland
[~andy/gtk] / gtk / gtkimage.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
28 #error "Only <gtk/gtk.h> can be included directly."
29 #endif
30
31 #ifndef __GTK_IMAGE_H__
32 #define __GTK_IMAGE_H__
33
34
35 #include <gio/gio.h>
36 #include <gtk/gtkmisc.h>
37
38
39 G_BEGIN_DECLS
40
41 #define GTK_TYPE_IMAGE                  (gtk_image_get_type ())
42 #define GTK_IMAGE(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IMAGE, GtkImage))
43 #define GTK_IMAGE_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IMAGE, GtkImageClass))
44 #define GTK_IS_IMAGE(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IMAGE))
45 #define GTK_IS_IMAGE_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMAGE))
46 #define GTK_IMAGE_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IMAGE, GtkImageClass))
47
48
49 typedef struct _GtkImage              GtkImage;
50 typedef struct _GtkImagePrivate       GtkImagePrivate;
51 typedef struct _GtkImageClass         GtkImageClass;
52
53 /**
54  * GtkImageType:
55  * @GTK_IMAGE_EMPTY: there is no image displayed by the widget
56  * @GTK_IMAGE_PIXBUF: the widget contains a #GdkPixbuf
57  * @GTK_IMAGE_STOCK: the widget contains a stock icon name (see
58  *  <xref linkend="gtk3-Stock-Items"/>)
59  * @GTK_IMAGE_ICON_SET: the widget contains a #GtkIconSet
60  * @GTK_IMAGE_ANIMATION: the widget contains a #GdkPixbufAnimation
61  * @GTK_IMAGE_ICON_NAME: the widget contains a named icon.
62  *  This image type was added in GTK+ 2.6
63  * @GTK_IMAGE_GICON: the widget contains a #GIcon.
64  *  This image type was added in GTK+ 2.14
65  *
66  * Describes the image data representation used by a #GtkImage. If you
67  * want to get the image from the widget, you can only get the
68  * currently-stored representation. e.g.  if the
69  * gtk_image_get_storage_type() returns #GTK_IMAGE_PIXBUF, then you can
70  * call gtk_image_get_pixbuf() but not gtk_image_get_stock().  For empty
71  * images, you can request any storage type (call any of the "get"
72  * functions), but they will all return %NULL values.
73  */
74 typedef enum
75 {
76   GTK_IMAGE_EMPTY,
77   GTK_IMAGE_PIXBUF,
78   GTK_IMAGE_STOCK,
79   GTK_IMAGE_ICON_SET,
80   GTK_IMAGE_ANIMATION,
81   GTK_IMAGE_ICON_NAME,
82   GTK_IMAGE_GICON
83 } GtkImageType;
84
85 /**
86  * GtkImage:
87  *
88  * This struct contain private data only and should be accessed by the functions
89  * below.
90  */
91 struct _GtkImage
92 {
93   GtkMisc misc;
94
95   /*< private >*/
96   GtkImagePrivate *priv;
97 };
98
99 struct _GtkImageClass
100 {
101   GtkMiscClass parent_class;
102
103   /* Padding for future expansion */
104   void (*_gtk_reserved1) (void);
105   void (*_gtk_reserved2) (void);
106   void (*_gtk_reserved3) (void);
107   void (*_gtk_reserved4) (void);
108 };
109
110 GType      gtk_image_get_type (void) G_GNUC_CONST;
111
112 GtkWidget* gtk_image_new                (void);
113 GtkWidget* gtk_image_new_from_file      (const gchar     *filename);
114 GtkWidget* gtk_image_new_from_pixbuf    (GdkPixbuf       *pixbuf);
115 GtkWidget* gtk_image_new_from_stock     (const gchar     *stock_id,
116                                          GtkIconSize      size);
117 GtkWidget* gtk_image_new_from_icon_set  (GtkIconSet      *icon_set,
118                                          GtkIconSize      size);
119 GtkWidget* gtk_image_new_from_animation (GdkPixbufAnimation *animation);
120 GtkWidget* gtk_image_new_from_icon_name (const gchar     *icon_name,
121                                          GtkIconSize      size);
122 GtkWidget* gtk_image_new_from_gicon     (GIcon           *icon,
123                                          GtkIconSize      size);
124
125 void gtk_image_clear              (GtkImage        *image);
126 void gtk_image_set_from_file      (GtkImage        *image,
127                                    const gchar     *filename);
128 void gtk_image_set_from_pixbuf    (GtkImage        *image,
129                                    GdkPixbuf       *pixbuf);
130 void gtk_image_set_from_stock     (GtkImage        *image,
131                                    const gchar     *stock_id,
132                                    GtkIconSize      size);
133 void gtk_image_set_from_icon_set  (GtkImage        *image,
134                                    GtkIconSet      *icon_set,
135                                    GtkIconSize      size);
136 void gtk_image_set_from_animation (GtkImage           *image,
137                                    GdkPixbufAnimation *animation);
138 void gtk_image_set_from_icon_name (GtkImage        *image,
139                                    const gchar     *icon_name,
140                                    GtkIconSize      size);
141 void gtk_image_set_from_gicon     (GtkImage        *image,
142                                    GIcon           *icon,
143                                    GtkIconSize      size);
144 void gtk_image_set_pixel_size     (GtkImage        *image,
145                                    gint             pixel_size);
146
147 GtkImageType gtk_image_get_storage_type (GtkImage   *image);
148
149 GdkPixbuf* gtk_image_get_pixbuf   (GtkImage         *image);
150 void       gtk_image_get_stock    (GtkImage         *image,
151                                    gchar           **stock_id,
152                                    GtkIconSize      *size);
153 void       gtk_image_get_icon_set (GtkImage         *image,
154                                    GtkIconSet      **icon_set,
155                                    GtkIconSize      *size);
156 GdkPixbufAnimation* gtk_image_get_animation (GtkImage *image);
157 void       gtk_image_get_icon_name (GtkImage              *image,
158                                     G_CONST_RETURN gchar **icon_name,
159                                     GtkIconSize           *size);
160 void       gtk_image_get_gicon     (GtkImage              *image,
161                                     GIcon                **gicon,
162                                     GtkIconSize           *size);
163 gint       gtk_image_get_pixel_size (GtkImage             *image);
164
165 G_END_DECLS
166
167 #endif /* __GTK_IMAGE_H__ */