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