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 gio.CharsetConverter;
26 
27 private import gio.ConverterIF;
28 private import gio.ConverterT;
29 private import gio.InitableIF;
30 private import gio.InitableT;
31 private import glib.ConstructionException;
32 private import glib.ErrorG;
33 private import glib.GException;
34 private import glib.Str;
35 private import gobject.ObjectG;
36 private import gtkc.gio;
37 public  import gtkc.giotypes;
38 
39 
40 /**
41  * #GCharsetConverter is an implementation of #GConverter based on
42  * GIConv.
43  */
44 public class CharsetConverter : ObjectG, ConverterIF, InitableIF
45 {
46 	/** the main Gtk struct */
47 	protected GCharsetConverter* gCharsetConverter;
48 
49 	/** Get the main Gtk struct */
50 	public GCharsetConverter* getCharsetConverterStruct(bool transferOwnership = false)
51 	{
52 		if (transferOwnership)
53 			ownedRef = false;
54 		return gCharsetConverter;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected override void* getStruct()
59 	{
60 		return cast(void*)gCharsetConverter;
61 	}
62 
63 	protected override void setStruct(GObject* obj)
64 	{
65 		gCharsetConverter = cast(GCharsetConverter*)obj;
66 		super.setStruct(obj);
67 	}
68 
69 	/**
70 	 * Sets our main struct and passes it to the parent class.
71 	 */
72 	public this (GCharsetConverter* gCharsetConverter, bool ownedRef = false)
73 	{
74 		this.gCharsetConverter = gCharsetConverter;
75 		super(cast(GObject*)gCharsetConverter, ownedRef);
76 	}
77 
78 	// add the Converter capabilities
79 	mixin ConverterT!(GCharsetConverter);
80 
81 	// add the Initable capabilities
82 	mixin InitableT!(GCharsetConverter);
83 
84 
85 	/** */
86 	public static GType getType()
87 	{
88 		return g_charset_converter_get_type();
89 	}
90 
91 	/**
92 	 * Creates a new #GCharsetConverter.
93 	 *
94 	 * Params:
95 	 *     toCharset = destination charset
96 	 *     fromCharset = source charset
97 	 *
98 	 * Returns: a new #GCharsetConverter or %NULL on error.
99 	 *
100 	 * Since: 2.24
101 	 *
102 	 * Throws: GException on failure.
103 	 * Throws: ConstructionException GTK+ fails to create the object.
104 	 */
105 	public this(string toCharset, string fromCharset)
106 	{
107 		GError* err = null;
108 		
109 		auto p = g_charset_converter_new(Str.toStringz(toCharset), Str.toStringz(fromCharset), &err);
110 		
111 		if (err !is null)
112 		{
113 			throw new GException( new ErrorG(err) );
114 		}
115 		
116 		if(p is null)
117 		{
118 			throw new ConstructionException("null returned by new");
119 		}
120 		
121 		this(cast(GCharsetConverter*) p, true);
122 	}
123 
124 	/**
125 	 * Gets the number of fallbacks that @converter has applied so far.
126 	 *
127 	 * Returns: the number of fallbacks that @converter has applied
128 	 *
129 	 * Since: 2.24
130 	 */
131 	public uint getNumFallbacks()
132 	{
133 		return g_charset_converter_get_num_fallbacks(gCharsetConverter);
134 	}
135 
136 	/**
137 	 * Gets the #GCharsetConverter:use-fallback property.
138 	 *
139 	 * Returns: %TRUE if fallbacks are used by @converter
140 	 *
141 	 * Since: 2.24
142 	 */
143 	public bool getUseFallback()
144 	{
145 		return g_charset_converter_get_use_fallback(gCharsetConverter) != 0;
146 	}
147 
148 	/**
149 	 * Sets the #GCharsetConverter:use-fallback property.
150 	 *
151 	 * Params:
152 	 *     useFallback = %TRUE to use fallbacks
153 	 *
154 	 * Since: 2.24
155 	 */
156 	public void setUseFallback(bool useFallback)
157 	{
158 		g_charset_converter_set_use_fallback(gCharsetConverter, useFallback);
159 	}
160 }