gtkimage.h 7.18 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
Elliot Lee's avatar
Elliot Lee committed
2 3 4
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 *
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
Elliot Lee's avatar
Elliot Lee committed
6 7 8 9 10 11
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
Elliot Lee's avatar
Elliot Lee committed
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15 16 17
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
18
 */
19 20

/*
21
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22 23
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * 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 29 30
#error "Only <gtk/gtk.h> can be included directly."
#endif

Elliot Lee's avatar
Elliot Lee committed
31 32 33 34
#ifndef __GTK_IMAGE_H__
#define __GTK_IMAGE_H__


35
#include <gio/gio.h>
Elliot Lee's avatar
Elliot Lee committed
36 37 38
#include <gtk/gtkmisc.h>


39
G_BEGIN_DECLS
Elliot Lee's avatar
Elliot Lee committed
40

41
#define GTK_TYPE_IMAGE                  (gtk_image_get_type ())
Manish Singh's avatar
Manish Singh committed
42 43 44 45 46
#define GTK_IMAGE(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IMAGE, GtkImage))
#define GTK_IMAGE_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IMAGE, GtkImageClass))
#define GTK_IS_IMAGE(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IMAGE))
#define GTK_IS_IMAGE_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMAGE))
#define GTK_IMAGE_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IMAGE, GtkImageClass))
Elliot Lee's avatar
Elliot Lee committed
47 48


49 50 51
typedef struct _GtkImage              GtkImage;
typedef struct _GtkImagePrivate       GtkImagePrivate;
typedef struct _GtkImageClass         GtkImageClass;
Elliot Lee's avatar
Elliot Lee committed
52

53 54 55
typedef struct _GtkImagePixbufData  GtkImagePixbufData;
typedef struct _GtkImageStockData   GtkImageStockData;
typedef struct _GtkImageIconSetData GtkImageIconSetData;
Havoc Pennington's avatar
Havoc Pennington committed
56
typedef struct _GtkImageAnimationData GtkImageAnimationData;
57
typedef struct _GtkImageIconNameData  GtkImageIconNameData;
58
typedef struct _GtkImageGIconData     GtkImageGIconData;
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

struct _GtkImagePixbufData
{
  GdkPixbuf *pixbuf;
};

struct _GtkImageStockData
{
  gchar *stock_id;
};

struct _GtkImageIconSetData
{
  GtkIconSet *icon_set;
};

Havoc Pennington's avatar
Havoc Pennington committed
75 76 77 78 79 80 81
struct _GtkImageAnimationData
{
  GdkPixbufAnimation *anim;
  GdkPixbufAnimationIter *iter;
  guint frame_timeout;
};

82 83 84 85 86 87 88
struct _GtkImageIconNameData
{
  gchar *icon_name;
  GdkPixbuf *pixbuf;
  guint theme_change_id;
};

89 90 91 92 93 94 95
struct _GtkImageGIconData
{
  GIcon *icon;
  GdkPixbuf *pixbuf;
  guint theme_change_id;
};

96 97 98 99
/**
 * GtkImageType:
 * @GTK_IMAGE_EMPTY: there is no image displayed by the widget
 * @GTK_IMAGE_PIXBUF: the widget contains a #GdkPixbuf
100 101
 * @GTK_IMAGE_STOCK: the widget contains a stock icon name (see
 *  <xref linkend="gtk3-Stock-Items"/>)
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
 * @GTK_IMAGE_ICON_SET: the widget contains a #GtkIconSet
 * @GTK_IMAGE_ANIMATION: the widget contains a #GdkPixbufAnimation
 * @GTK_IMAGE_ICON_NAME: the widget contains a named icon.
 *  This image type was added in GTK+ 2.6
 * @GTK_IMAGE_GICON: the widget contains a #GIcon.
 *  This image type was added in GTK+ 2.14
 *
 * Describes the image data representation used by a #GtkImage. If you
 * want to get the image from the widget, you can only get the
 * currently-stored representation. e.g.  if the
 * gtk_image_get_storage_type() returns #GTK_IMAGE_PIXBUF, then you can
 * call gtk_image_get_pixbuf() but not gtk_image_get_stock().  For empty
 * images, you can request any storage type (call any of the "get"
 * functions), but they will all return %NULL values.
 */
117 118 119 120 121
typedef enum
{
  GTK_IMAGE_EMPTY,
  GTK_IMAGE_PIXBUF,
  GTK_IMAGE_STOCK,
Havoc Pennington's avatar
Havoc Pennington committed
122
  GTK_IMAGE_ICON_SET,
123
  GTK_IMAGE_ANIMATION,
124 125
  GTK_IMAGE_ICON_NAME,
  GTK_IMAGE_GICON
126 127
} GtkImageType;

128 129 130 131 132 133
/**
 * GtkImage:
 *
 * This struct contain private data only and should be accessed by the functions
 * below.
 */
134 135 136 137
struct _GtkImage
{
  GtkMisc misc;

138
  /*< private >*/
139
  GtkImagePrivate *priv;
140 141
};

Elliot Lee's avatar
Elliot Lee committed
142 143 144
struct _GtkImageClass
{
  GtkMiscClass parent_class;
145 146 147 148 149 150

  /* Padding for future expansion */
  void (*_gtk_reserved1) (void);
  void (*_gtk_reserved2) (void);
  void (*_gtk_reserved3) (void);
  void (*_gtk_reserved4) (void);
Elliot Lee's avatar
Elliot Lee committed
151 152
};

Manish Singh's avatar
Manish Singh committed
153
GType      gtk_image_get_type (void) G_GNUC_CONST;
154

155
GtkWidget* gtk_image_new                (void);
Havoc Pennington's avatar
Havoc Pennington committed
156 157 158 159 160 161 162
GtkWidget* gtk_image_new_from_file      (const gchar     *filename);
GtkWidget* gtk_image_new_from_pixbuf    (GdkPixbuf       *pixbuf);
GtkWidget* gtk_image_new_from_stock     (const gchar     *stock_id,
                                         GtkIconSize      size);
GtkWidget* gtk_image_new_from_icon_set  (GtkIconSet      *icon_set,
                                         GtkIconSize      size);
GtkWidget* gtk_image_new_from_animation (GdkPixbufAnimation *animation);
163 164
GtkWidget* gtk_image_new_from_icon_name (const gchar     *icon_name,
					 GtkIconSize      size);
165 166
GtkWidget* gtk_image_new_from_gicon     (GIcon           *icon,
					 GtkIconSize      size);
Havoc Pennington's avatar
Havoc Pennington committed
167

168
void gtk_image_clear              (GtkImage        *image);
Havoc Pennington's avatar
Havoc Pennington committed
169 170 171 172 173 174 175 176 177 178 179 180
void gtk_image_set_from_file      (GtkImage        *image,
                                   const gchar     *filename);
void gtk_image_set_from_pixbuf    (GtkImage        *image,
                                   GdkPixbuf       *pixbuf);
void gtk_image_set_from_stock     (GtkImage        *image,
                                   const gchar     *stock_id,
                                   GtkIconSize      size);
void gtk_image_set_from_icon_set  (GtkImage        *image,
                                   GtkIconSet      *icon_set,
                                   GtkIconSize      size);
void gtk_image_set_from_animation (GtkImage           *image,
                                   GdkPixbufAnimation *animation);
181 182 183
void gtk_image_set_from_icon_name (GtkImage        *image,
				   const gchar     *icon_name,
				   GtkIconSize      size);
184 185 186
void gtk_image_set_from_gicon     (GtkImage        *image,
				   GIcon           *icon,
				   GtkIconSize      size);
187 188
void gtk_image_set_pixel_size     (GtkImage        *image,
				   gint             pixel_size);
189 190 191 192 193 194

GtkImageType gtk_image_get_storage_type (GtkImage   *image);

GdkPixbuf* gtk_image_get_pixbuf   (GtkImage         *image);
void       gtk_image_get_stock    (GtkImage         *image,
                                   gchar           **stock_id,
195
                                   GtkIconSize      *size);
196 197
void       gtk_image_get_icon_set (GtkImage         *image,
                                   GtkIconSet      **icon_set,
198
                                   GtkIconSize      *size);
Havoc Pennington's avatar
Havoc Pennington committed
199
GdkPixbufAnimation* gtk_image_get_animation (GtkImage *image);
200 201 202
void       gtk_image_get_icon_name (GtkImage              *image,
				    G_CONST_RETURN gchar **icon_name,
				    GtkIconSize           *size);
203 204 205
void       gtk_image_get_gicon     (GtkImage              *image,
				    GIcon                **gicon,
				    GtkIconSize           *size);
206
gint       gtk_image_get_pixel_size (GtkImage             *image);
207

208
G_END_DECLS
Elliot Lee's avatar
Elliot Lee committed
209 210

#endif /* __GTK_IMAGE_H__ */