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