CoreGTK  3.22.0
CoreGTK is an Objective-C language binding for the GTK+ widget toolkit
CGTKImage.m
1 /*
2  * CGTKImage.m
3  * This file is part of CoreGTK
4  *
5  * Copyright (C) 2017 - Tyler Burton
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /*
23  * Modified by the CoreGTK Team, 2017. See the AUTHORS file for a
24  * list of people on the CoreGTK Team.
25  * See the ChangeLog files for a list of changes.
26  *
27  */
28 
29 /*
30  * Objective-C imports
31  */
32 #import "CoreGTK/CGTKImage.h"
33 
34 @implementation CGTKImage
35 
36 -(id)init
37 {
38  self = [super initWithGObject:(GObject *)gtk_image_new()];
39 
40  if(self)
41  {
42  //Do nothing
43  }
44 
45  return self;
46 }
47 
48 -(id)initFromAnimation:(GdkPixbufAnimation*) animation
49 {
50  self = [super initWithGObject:(GObject *)gtk_image_new_from_animation(animation)];
51 
52  if(self)
53  {
54  //Do nothing
55  }
56 
57  return self;
58 }
59 
60 -(id)initFromFile:(NSString*) filename
61 {
62  self = [super initWithGObject:(GObject *)gtk_image_new_from_file([filename UTF8String])];
63 
64  if(self)
65  {
66  //Do nothing
67  }
68 
69  return self;
70 }
71 
72 -(id)initFromGiconWithIcon:(GIcon*) icon andSize:(GtkIconSize) size
73 {
74  self = [super initWithGObject:(GObject *)gtk_image_new_from_gicon(icon, size)];
75 
76  if(self)
77  {
78  //Do nothing
79  }
80 
81  return self;
82 }
83 
84 -(id)initFromIconNameWithIconName:(NSString*) iconName andSize:(GtkIconSize) size
85 {
86  self = [super initWithGObject:(GObject *)gtk_image_new_from_icon_name([iconName UTF8String], size)];
87 
88  if(self)
89  {
90  //Do nothing
91  }
92 
93  return self;
94 }
95 
96 -(id)initFromIconSetWithIconSet:(GtkIconSet*) iconSet andSize:(GtkIconSize) size
97 {
98  self = [super initWithGObject:(GObject *)gtk_image_new_from_icon_set(iconSet, size)];
99 
100  if(self)
101  {
102  //Do nothing
103  }
104 
105  return self;
106 }
107 
108 -(id)initFromPixbuf:(GdkPixbuf*) pixbuf
109 {
110  self = [super initWithGObject:(GObject *)gtk_image_new_from_pixbuf(pixbuf)];
111 
112  if(self)
113  {
114  //Do nothing
115  }
116 
117  return self;
118 }
119 
120 -(id)initFromResource:(NSString*) resourcePath
121 {
122  self = [super initWithGObject:(GObject *)gtk_image_new_from_resource([resourcePath UTF8String])];
123 
124  if(self)
125  {
126  //Do nothing
127  }
128 
129  return self;
130 }
131 
132 -(id)initFromStockWithStockId:(NSString*) stockId andSize:(GtkIconSize) size
133 {
134  self = [super initWithGObject:(GObject *)gtk_image_new_from_stock([stockId UTF8String], size)];
135 
136  if(self)
137  {
138  //Do nothing
139  }
140 
141  return self;
142 }
143 
144 -(id)initFromSurface:(cairo_surface_t*) surface
145 {
146  self = [super initWithGObject:(GObject *)gtk_image_new_from_surface(surface)];
147 
148  if(self)
149  {
150  //Do nothing
151  }
152 
153  return self;
154 }
155 
156 -(GtkImage*)IMAGE
157 {
158  return GTK_IMAGE([self GOBJECT]);
159 }
160 
161 -(void)clear
162 {
163  gtk_image_clear(GTK_IMAGE([self GOBJECT]));
164 }
165 
166 -(GdkPixbufAnimation*)getAnimation
167 {
168  return gtk_image_get_animation(GTK_IMAGE([self GOBJECT]));
169 }
170 
171 -(void)getGiconWithGicon:(GIcon**) gicon andSize:(GtkIconSize*) size
172 {
173  gtk_image_get_gicon(GTK_IMAGE([self GOBJECT]), gicon, size);
174 }
175 
176 -(void)getIconNameWithIconName:(const gchar**) iconName andSize:(GtkIconSize*) size
177 {
178  gtk_image_get_icon_name(GTK_IMAGE([self GOBJECT]), iconName, size);
179 }
180 
181 -(void)getIconSetWithIconSet:(GtkIconSet**) iconSet andSize:(GtkIconSize*) size
182 {
183  gtk_image_get_icon_set(GTK_IMAGE([self GOBJECT]), iconSet, size);
184 }
185 
186 -(GdkPixbuf*)getPixbuf
187 {
188  return gtk_image_get_pixbuf(GTK_IMAGE([self GOBJECT]));
189 }
190 
192 {
193  return gtk_image_get_pixel_size(GTK_IMAGE([self GOBJECT]));
194 }
195 
196 -(void)getStockWithStockId:(gchar**) stockId andSize:(GtkIconSize*) size
197 {
198  gtk_image_get_stock(GTK_IMAGE([self GOBJECT]), stockId, size);
199 }
200 
201 -(GtkImageType)getStorageType
202 {
203  return gtk_image_get_storage_type(GTK_IMAGE([self GOBJECT]));
204 }
205 
206 -(void)setFromAnimation:(GdkPixbufAnimation*) animation
207 {
208  gtk_image_set_from_animation(GTK_IMAGE([self GOBJECT]), animation);
209 }
210 
211 -(void)setFromFile:(NSString*) filename
212 {
213  gtk_image_set_from_file(GTK_IMAGE([self GOBJECT]), [filename UTF8String]);
214 }
215 
216 -(void)setFromGiconWithIcon:(GIcon*) icon andSize:(GtkIconSize) size
217 {
218  gtk_image_set_from_gicon(GTK_IMAGE([self GOBJECT]), icon, size);
219 }
220 
221 -(void)setFromIconNameWithIconName:(NSString*) iconName andSize:(GtkIconSize) size
222 {
223  gtk_image_set_from_icon_name(GTK_IMAGE([self GOBJECT]), [iconName UTF8String], size);
224 }
225 
226 -(void)setFromIconSetWithIconSet:(GtkIconSet*) iconSet andSize:(GtkIconSize) size
227 {
228  gtk_image_set_from_icon_set(GTK_IMAGE([self GOBJECT]), iconSet, size);
229 }
230 
231 -(void)setFromPixbuf:(GdkPixbuf*) pixbuf
232 {
233  gtk_image_set_from_pixbuf(GTK_IMAGE([self GOBJECT]), pixbuf);
234 }
235 
236 -(void)setFromResource:(NSString*) resourcePath
237 {
238  gtk_image_set_from_resource(GTK_IMAGE([self GOBJECT]), [resourcePath UTF8String]);
239 }
240 
241 -(void)setFromStockWithStockId:(NSString*) stockId andSize:(GtkIconSize) size
242 {
243  gtk_image_set_from_stock(GTK_IMAGE([self GOBJECT]), [stockId UTF8String], size);
244 }
245 
246 -(void)setFromSurface:(cairo_surface_t*) surface
247 {
248  gtk_image_set_from_surface(GTK_IMAGE([self GOBJECT]), surface);
249 }
250 
251 -(void)setPixelSize:(gint) pixelSize
252 {
253  gtk_image_set_pixel_size(GTK_IMAGE([self GOBJECT]), pixelSize);
254 }
255 
256 
257 @end
GObject * GOBJECT()
Definition: CGTKBase.m:82
GdkPixbufAnimation * getAnimation()
Definition: CGTKImage.m:166
id initWithGObject:(GObject *obj)
Definition: CGTKBase.m:48
GtkImage * IMAGE()
Definition: CGTKImage.m:156
void clear()
Definition: CGTKImage.m:161
GdkPixbuf * getPixbuf()
Definition: CGTKImage.m:186
id init()
Definition: CGTKImage.m:36
GtkImageType getStorageType()
Definition: CGTKImage.m:201
gint getPixelSize()
Definition: CGTKImage.m:191