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 module gdkpixbuf.PixbufFormat;
26 
27 private import gdkpixbuf.c.functions;
28 public  import gdkpixbuf.c.types;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 public  import gtkc.gdkpixbuftypes;
32 private import gtkd.Loader;
33 
34 
35 /** */
36 public class PixbufFormat
37 {
38 	/** the main Gtk struct */
39 	protected GdkPixbufFormat* gdkPixbufFormat;
40 	protected bool ownedRef;
41 
42 	/** Get the main Gtk struct */
43 	public GdkPixbufFormat* getPixbufFormatStruct(bool transferOwnership = false)
44 	{
45 		if (transferOwnership)
46 			ownedRef = false;
47 		return gdkPixbufFormat;
48 	}
49 
50 	/** the main Gtk struct as a void* */
51 	protected void* getStruct()
52 	{
53 		return cast(void*)gdkPixbufFormat;
54 	}
55 
56 	/**
57 	 * Sets our main struct and passes it to the parent class.
58 	 */
59 	public this (GdkPixbufFormat* gdkPixbufFormat, bool ownedRef = false)
60 	{
61 		this.gdkPixbufFormat = gdkPixbufFormat;
62 		this.ownedRef = ownedRef;
63 	}
64 
65 	~this ()
66 	{
67 		if ( Linker.isLoaded(LIBRARY_GDKPIXBUF) && ownedRef )
68 			gdk_pixbuf_format_free(gdkPixbufFormat);
69 	}
70 
71 
72 	/** */
73 	public static GType getType()
74 	{
75 		return gdk_pixbuf_format_get_type();
76 	}
77 
78 	/**
79 	 * Creates a copy of @format
80 	 *
81 	 * Returns: the newly allocated copy of a #GdkPixbufFormat. Use
82 	 *     gdk_pixbuf_format_free() to free the resources when done
83 	 *
84 	 * Since: 2.22
85 	 */
86 	public PixbufFormat copy()
87 	{
88 		auto p = gdk_pixbuf_format_copy(gdkPixbufFormat);
89 
90 		if(p is null)
91 		{
92 			return null;
93 		}
94 
95 		return ObjectG.getDObject!(PixbufFormat)(cast(GdkPixbufFormat*) p, true);
96 	}
97 
98 	/**
99 	 * Frees the resources allocated when copying a #GdkPixbufFormat
100 	 * using gdk_pixbuf_format_copy()
101 	 *
102 	 * Since: 2.22
103 	 */
104 	public void free()
105 	{
106 		gdk_pixbuf_format_free(gdkPixbufFormat);
107 		ownedRef = false;
108 	}
109 
110 	/**
111 	 * Returns a description of the format.
112 	 *
113 	 * Returns: a description of the format.
114 	 *
115 	 * Since: 2.2
116 	 */
117 	public string getDescription()
118 	{
119 		auto retStr = gdk_pixbuf_format_get_description(gdkPixbufFormat);
120 
121 		scope(exit) Str.freeString(retStr);
122 		return Str.toString(retStr);
123 	}
124 
125 	/**
126 	 * Returns the filename extensions typically used for files in the
127 	 * given format.
128 	 *
129 	 * Returns: a %NULL-terminated array of filename extensions which must be
130 	 *     freed with g_strfreev() when it is no longer needed.
131 	 *
132 	 * Since: 2.2
133 	 */
134 	public string[] getExtensions()
135 	{
136 		auto retStr = gdk_pixbuf_format_get_extensions(gdkPixbufFormat);
137 
138 		scope(exit) Str.freeStringArray(retStr);
139 		return Str.toStringArray(retStr);
140 	}
141 
142 	/**
143 	 * Returns information about the license of the image loader for the format. The
144 	 * returned string should be a shorthand for a wellknown license, e.g. "LGPL",
145 	 * "GPL", "QPL", "GPL/QPL", or "other" to indicate some other license.  This
146 	 * string should be freed with g_free() when it's no longer needed.
147 	 *
148 	 * Returns: a string describing the license of @format.
149 	 *
150 	 * Since: 2.6
151 	 */
152 	public string getLicense()
153 	{
154 		auto retStr = gdk_pixbuf_format_get_license(gdkPixbufFormat);
155 
156 		scope(exit) Str.freeString(retStr);
157 		return Str.toString(retStr);
158 	}
159 
160 	/**
161 	 * Returns the mime types supported by the format.
162 	 *
163 	 * Returns: a %NULL-terminated array of mime types which must be freed with
164 	 *     g_strfreev() when it is no longer needed.
165 	 *
166 	 * Since: 2.2
167 	 */
168 	public string[] getMimeTypes()
169 	{
170 		auto retStr = gdk_pixbuf_format_get_mime_types(gdkPixbufFormat);
171 
172 		scope(exit) Str.freeStringArray(retStr);
173 		return Str.toStringArray(retStr);
174 	}
175 
176 	/**
177 	 * Returns the name of the format.
178 	 *
179 	 * Returns: the name of the format.
180 	 *
181 	 * Since: 2.2
182 	 */
183 	public string getName()
184 	{
185 		auto retStr = gdk_pixbuf_format_get_name(gdkPixbufFormat);
186 
187 		scope(exit) Str.freeString(retStr);
188 		return Str.toString(retStr);
189 	}
190 
191 	/**
192 	 * Returns whether this image format is disabled. See
193 	 * gdk_pixbuf_format_set_disabled().
194 	 *
195 	 * Returns: whether this image format is disabled.
196 	 *
197 	 * Since: 2.6
198 	 */
199 	public bool isDisabled()
200 	{
201 		return gdk_pixbuf_format_is_disabled(gdkPixbufFormat) != 0;
202 	}
203 
204 	/**
205 	 * Returns %TRUE if the save option specified by @option_key is supported when
206 	 * saving a pixbuf using the module implementing @format.
207 	 * See gdk_pixbuf_save() for more information about option keys.
208 	 *
209 	 * Params:
210 	 *     optionKey = the name of an option
211 	 *
212 	 * Returns: %TRUE if the specified option is supported
213 	 *
214 	 * Since: 2.36
215 	 */
216 	public bool isSaveOptionSupported(string optionKey)
217 	{
218 		return gdk_pixbuf_format_is_save_option_supported(gdkPixbufFormat, Str.toStringz(optionKey)) != 0;
219 	}
220 
221 	/**
222 	 * Returns whether this image format is scalable. If a file is in a
223 	 * scalable format, it is preferable to load it at the desired size,
224 	 * rather than loading it at the default size and scaling the
225 	 * resulting pixbuf to the desired size.
226 	 *
227 	 * Returns: whether this image format is scalable.
228 	 *
229 	 * Since: 2.6
230 	 */
231 	public bool isScalable()
232 	{
233 		return gdk_pixbuf_format_is_scalable(gdkPixbufFormat) != 0;
234 	}
235 
236 	/**
237 	 * Returns whether pixbufs can be saved in the given format.
238 	 *
239 	 * Returns: whether pixbufs can be saved in the given format.
240 	 *
241 	 * Since: 2.2
242 	 */
243 	public bool isWritable()
244 	{
245 		return gdk_pixbuf_format_is_writable(gdkPixbufFormat) != 0;
246 	}
247 
248 	/**
249 	 * Disables or enables an image format. If a format is disabled,
250 	 * gdk-pixbuf won't use the image loader for this format to load
251 	 * images. Applications can use this to avoid using image loaders
252 	 * with an inappropriate license, see gdk_pixbuf_format_get_license().
253 	 *
254 	 * Params:
255 	 *     disabled = %TRUE to disable the format @format
256 	 *
257 	 * Since: 2.6
258 	 */
259 	public void setDisabled(bool disabled)
260 	{
261 		gdk_pixbuf_format_set_disabled(gdkPixbufFormat, disabled);
262 	}
263 }