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 gtk.StringSorter;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gtk.Expression;
30 private import gtk.Sorter;
31 private import gtk.c.functions;
32 public  import gtk.c.types;
33 
34 
35 /**
36  * `GtkStringSorter` is a `GtkSorter` that compares strings.
37  * 
38  * It does the comparison in a linguistically correct way using the
39  * current locale by normalizing Unicode strings and possibly case-folding
40  * them before performing the comparison.
41  * 
42  * To obtain the strings to compare, this sorter evaluates a
43  * [class@Gtk.Expression].
44  */
45 public class StringSorter : Sorter
46 {
47 	/** the main Gtk struct */
48 	protected GtkStringSorter* gtkStringSorter;
49 
50 	/** Get the main Gtk struct */
51 	public GtkStringSorter* getStringSorterStruct(bool transferOwnership = false)
52 	{
53 		if (transferOwnership)
54 			ownedRef = false;
55 		return gtkStringSorter;
56 	}
57 
58 	/** the main Gtk struct as a void* */
59 	protected override void* getStruct()
60 	{
61 		return cast(void*)gtkStringSorter;
62 	}
63 
64 	/**
65 	 * Sets our main struct and passes it to the parent class.
66 	 */
67 	public this (GtkStringSorter* gtkStringSorter, bool ownedRef = false)
68 	{
69 		this.gtkStringSorter = gtkStringSorter;
70 		super(cast(GtkSorter*)gtkStringSorter, ownedRef);
71 	}
72 
73 
74 	/** */
75 	public static GType getType()
76 	{
77 		return gtk_string_sorter_get_type();
78 	}
79 
80 	/**
81 	 * Creates a new string sorter that compares items using the given
82 	 * @expression.
83 	 *
84 	 * Unless an expression is set on it, this sorter will always
85 	 * compare items as invalid.
86 	 *
87 	 * Params:
88 	 *     expression = The expression to evaluate
89 	 *
90 	 * Returns: a new `GtkStringSorter`
91 	 *
92 	 * Throws: ConstructionException GTK+ fails to create the object.
93 	 */
94 	public this(Expression expression)
95 	{
96 		auto __p = gtk_string_sorter_new((expression is null) ? null : expression.getExpressionStruct(true));
97 
98 		if(__p is null)
99 		{
100 			throw new ConstructionException("null returned by new");
101 		}
102 
103 		this(cast(GtkStringSorter*) __p, true);
104 	}
105 
106 	/**
107 	 * Gets the expression that is evaluated to obtain strings from items.
108 	 *
109 	 * Returns: a `GtkExpression`, or %NULL
110 	 */
111 	public Expression getExpression()
112 	{
113 		auto __p = gtk_string_sorter_get_expression(gtkStringSorter);
114 
115 		if(__p is null)
116 		{
117 			return null;
118 		}
119 
120 		return ObjectG.getDObject!(Expression)(cast(GtkExpression*) __p);
121 	}
122 
123 	/**
124 	 * Gets whether the sorter ignores case differences.
125 	 *
126 	 * Returns: %TRUE if @self is ignoring case differences
127 	 */
128 	public bool getIgnoreCase()
129 	{
130 		return gtk_string_sorter_get_ignore_case(gtkStringSorter) != 0;
131 	}
132 
133 	/**
134 	 * Sets the expression that is evaluated to obtain strings from items.
135 	 *
136 	 * The expression must have the type %G_TYPE_STRING.
137 	 *
138 	 * Params:
139 	 *     expression = a `GtkExpression`, or %NULL
140 	 */
141 	public void setExpression(Expression expression)
142 	{
143 		gtk_string_sorter_set_expression(gtkStringSorter, (expression is null) ? null : expression.getExpressionStruct());
144 	}
145 
146 	/**
147 	 * Sets whether the sorter will ignore case differences.
148 	 *
149 	 * Params:
150 	 *     ignoreCase = %TRUE to ignore case differences
151 	 */
152 	public void setIgnoreCase(bool ignoreCase)
153 	{
154 		gtk_string_sorter_set_ignore_case(gtkStringSorter, ignoreCase);
155 	}
156 }