1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = 
27  * outPack = gtk
28  * outFile = IconFactory
29  * strct   = GtkIconFactory
30  * realStrct=
31  * ctorStrct=
32  * clss    = IconFactory
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- BuildableIF
40  * prefixes:
41  * 	- gtk_icon_factory_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gtk.IconSet
49  * 	- gtk.BuildableT
50  * 	- gtk.BuildableIF
51  * structWrap:
52  * 	- GtkIconSet* -> IconSet
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module gtk.IconFactory;
59 
60 public  import gtkc.gtktypes;
61 
62 private import gtkc.gtk;
63 private import glib.ConstructionException;
64 private import gobject.ObjectG;
65 
66 
67 private import glib.Str;
68 private import gtk.IconSet;
69 private import gtk.BuildableT;
70 private import gtk.BuildableIF;
71 
72 
73 
74 private import gobject.ObjectG;
75 
76 /**
77  * Browse the available stock icons in the list of stock IDs found here. You can also use
78  * the gtk-demo application for this purpose.
79  *
80  * An icon factory manages a collection of GtkIconSet; a GtkIconSet manages a
81  * set of variants of a particular icon (i.e. a GtkIconSet contains variants for
82  * different sizes and widget states). Icons in an icon factory are named by a
83  * stock ID, which is a simple string identifying the icon. Each GtkStyle has a
84  * list of GtkIconFactory derived from the current theme; those icon factories
85  * are consulted first when searching for an icon. If the theme doesn't set a
86  * particular icon, GTK+ looks for the icon in a list of default icon factories,
87  * maintained by gtk_icon_factory_add_default() and
88  * gtk_icon_factory_remove_default(). Applications with icons should add a default
89  * icon factory with their icons, which will allow themes to override the icons
90  * for the application.
91  *
92  * To display an icon, always use gtk_style_lookup_icon_set() on the widget that
93  * will display the icon, or the convenience function
94  * gtk_widget_render_icon(). These functions take the theme into account when
95  * looking up the icon to use for a given stock ID.
96  *
97  * GtkIconFactory as GtkBuildable
98  *
99  * GtkIconFactory supports a custom <sources> element, which can contain
100  * multiple <source> elements.
101  * The following attributes are allowed:
102  *
103  * stock-id
104  *
105  * The stock id of the source, a string.
106  * This attribute is mandatory
107  *
108  * filename
109  *
110  * The filename of the source, a string.
111  * This attribute is optional
112  *
113  * icon-name
114  *
115  * The icon name for the source, a string.
116  * This attribute is optional.
117  *
118  * size
119  *
120  * Size of the icon, a GtkIconSize enum value.
121  * This attribute is optional.
122  *
123  * direction
124  *
125  * Direction of the source, a GtkTextDirection enum value.
126  * This attribute is optional.
127  *
128  * state
129  *
130  * State of the source, a GtkStateType enum value.
131  * This attribute is optional.
132  *
133  * $(DDOC_COMMENT example)
134  */
135 public class IconFactory : ObjectG, BuildableIF
136 {
137 	
138 	/** the main Gtk struct */
139 	protected GtkIconFactory* gtkIconFactory;
140 	
141 	
142 	public GtkIconFactory* getIconFactoryStruct()
143 	{
144 		return gtkIconFactory;
145 	}
146 	
147 	
148 	/** the main Gtk struct as a void* */
149 	protected override void* getStruct()
150 	{
151 		return cast(void*)gtkIconFactory;
152 	}
153 	
154 	/**
155 	 * Sets our main struct and passes it to the parent class
156 	 */
157 	public this (GtkIconFactory* gtkIconFactory)
158 	{
159 		super(cast(GObject*)gtkIconFactory);
160 		this.gtkIconFactory = gtkIconFactory;
161 	}
162 	
163 	protected override void setStruct(GObject* obj)
164 	{
165 		super.setStruct(obj);
166 		gtkIconFactory = cast(GtkIconFactory*)obj;
167 	}
168 	
169 	// add the Buildable capabilities
170 	mixin BuildableT!(GtkIconFactory);
171 	
172 	/**
173 	 */
174 	
175 	/**
176 	 * Warning
177 	 * gtk_icon_factory_add has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
178 	 * Adds the given icon_set to the icon factory, under the name
179 	 * stock_id. stock_id should be namespaced for your application,
180 	 * e.g. "myapp-whatever-icon". Normally applications create a
181 	 * GtkIconFactory, then add it to the list of default factories with
182 	 * gtk_icon_factory_add_default(). Then they pass the stock_id to
183 	 * widgets such as GtkImage to display the icon. Themes can provide
184 	 * an icon with the same name (such as "myapp-whatever-icon") to
185 	 * override your application's default icons. If an icon already
186 	 * existed in factory for stock_id, it is unreferenced and replaced
187 	 * with the new icon_set.
188 	 * Params:
189 	 * stockId = icon name
190 	 * iconSet = icon set
191 	 */
192 	public void add(string stockId, IconSet iconSet)
193 	{
194 		// void gtk_icon_factory_add (GtkIconFactory *factory,  const gchar *stock_id,  GtkIconSet *icon_set);
195 		gtk_icon_factory_add(gtkIconFactory, Str.toStringz(stockId), (iconSet is null) ? null : iconSet.getIconSetStruct());
196 	}
197 	
198 	/**
199 	 * Warning
200 	 * gtk_icon_factory_add_default has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
201 	 * Adds an icon factory to the list of icon factories searched by
202 	 * gtk_style_lookup_icon_set(). This means that, for example,
203 	 * gtk_image_new_from_stock() will be able to find icons in factory.
204 	 * There will normally be an icon factory added for each library or
205 	 * application that comes with icons. The default icon factories
206 	 * can be overridden by themes.
207 	 */
208 	public void addDefault()
209 	{
210 		// void gtk_icon_factory_add_default (GtkIconFactory *factory);
211 		gtk_icon_factory_add_default(gtkIconFactory);
212 	}
213 	
214 	/**
215 	 * Warning
216 	 * gtk_icon_factory_lookup has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
217 	 * Looks up stock_id in the icon factory, returning an icon set
218 	 * if found, otherwise NULL. For display to the user, you should
219 	 * use gtk_style_lookup_icon_set() on the GtkStyle for the
220 	 * widget that will display the icon, instead of using this
221 	 * function directly, so that themes are taken into account.
222 	 * Params:
223 	 * stockId = an icon name
224 	 * Returns: icon set of stock_id. [transfer none]
225 	 */
226 	public IconSet lookup(string stockId)
227 	{
228 		// GtkIconSet * gtk_icon_factory_lookup (GtkIconFactory *factory,  const gchar *stock_id);
229 		auto p = gtk_icon_factory_lookup(gtkIconFactory, Str.toStringz(stockId));
230 		
231 		if(p is null)
232 		{
233 			return null;
234 		}
235 		
236 		return ObjectG.getDObject!(IconSet)(cast(GtkIconSet*) p);
237 	}
238 	
239 	/**
240 	 * Warning
241 	 * gtk_icon_factory_lookup_default has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
242 	 * Looks for an icon in the list of default icon factories. For
243 	 * display to the user, you should use gtk_style_lookup_icon_set() on
244 	 * the GtkStyle for the widget that will display the icon, instead of
245 	 * using this function directly, so that themes are taken into
246 	 * account.
247 	 * Params:
248 	 * stockId = an icon name
249 	 * Returns: a GtkIconSet, or NULL. [transfer none]
250 	 */
251 	public static IconSet lookupDefault(string stockId)
252 	{
253 		// GtkIconSet * gtk_icon_factory_lookup_default (const gchar *stock_id);
254 		auto p = gtk_icon_factory_lookup_default(Str.toStringz(stockId));
255 		
256 		if(p is null)
257 		{
258 			return null;
259 		}
260 		
261 		return ObjectG.getDObject!(IconSet)(cast(GtkIconSet*) p);
262 	}
263 	
264 	/**
265 	 * Warning
266 	 * gtk_icon_factory_new has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
267 	 * Creates a new GtkIconFactory. An icon factory manages a collection
268 	 * of GtkIconSets; a GtkIconSet manages a set of variants of a
269 	 * particular icon (i.e. a GtkIconSet contains variants for different
270 	 * sizes and widget states). Icons in an icon factory are named by a
271 	 * stock ID, which is a simple string identifying the icon. Each
272 	 * GtkStyle has a list of GtkIconFactorys derived from the current
273 	 * theme; those icon factories are consulted first when searching for
274 	 * an icon. If the theme doesn't set a particular icon, GTK+ looks for
275 	 * the icon in a list of default icon factories, maintained by
276 	 * gtk_icon_factory_add_default() and
277 	 * gtk_icon_factory_remove_default(). Applications with icons should
278 	 * add a default icon factory with their icons, which will allow
279 	 * themes to override the icons for the application.
280 	 * Throws: ConstructionException GTK+ fails to create the object.
281 	 */
282 	public this ()
283 	{
284 		// GtkIconFactory * gtk_icon_factory_new (void);
285 		auto p = gtk_icon_factory_new();
286 		if(p is null)
287 		{
288 			throw new ConstructionException("null returned by gtk_icon_factory_new()");
289 		}
290 		this(cast(GtkIconFactory*) p);
291 	}
292 	
293 	/**
294 	 * Warning
295 	 * gtk_icon_factory_remove_default has been deprecated since version 3.10 and should not be used in newly-written code. Use GtkIconTheme instead.
296 	 * Removes an icon factory from the list of default icon
297 	 * factories. Not normally used; you might use it for a library that
298 	 * can be unloaded or shut down.
299 	 */
300 	public void removeDefault()
301 	{
302 		// void gtk_icon_factory_remove_default (GtkIconFactory *factory);
303 		gtk_icon_factory_remove_default(gtkIconFactory);
304 	}
305 }