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.StringFilter;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import glib.c.functions;
30 private import gobject.ObjectG;
31 private import gtk.Expression;
32 private import gtk.Filter;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 
36 
37 /**
38  * `GtkStringFilter` determines whether to include items by comparing
39  * strings to a fixed search term.
40  * 
41  * The strings are obtained from the items by evaluating a `GtkExpression`
42  * set with [method@Gtk.StringFilter.set_expression], and they are
43  * compared against a search term set with [method@Gtk.StringFilter.set_search].
44  * 
45  * `GtkStringFilter` has several different modes of comparison - it
46  * can match the whole string, just a prefix, or any substring. Use
47  * [method@Gtk.StringFilter.set_match_mode] choose a mode.
48  * 
49  * It is also possible to make case-insensitive comparisons, with
50  * [method@Gtk.StringFilter.set_ignore_case].
51  */
52 public class StringFilter : Filter
53 {
54 	/** the main Gtk struct */
55 	protected GtkStringFilter* gtkStringFilter;
56 
57 	/** Get the main Gtk struct */
58 	public GtkStringFilter* getStringFilterStruct(bool transferOwnership = false)
59 	{
60 		if (transferOwnership)
61 			ownedRef = false;
62 		return gtkStringFilter;
63 	}
64 
65 	/** the main Gtk struct as a void* */
66 	protected override void* getStruct()
67 	{
68 		return cast(void*)gtkStringFilter;
69 	}
70 
71 	/**
72 	 * Sets our main struct and passes it to the parent class.
73 	 */
74 	public this (GtkStringFilter* gtkStringFilter, bool ownedRef = false)
75 	{
76 		this.gtkStringFilter = gtkStringFilter;
77 		super(cast(GtkFilter*)gtkStringFilter, ownedRef);
78 	}
79 
80 
81 	/** */
82 	public static GType getType()
83 	{
84 		return gtk_string_filter_get_type();
85 	}
86 
87 	/**
88 	 * Creates a new string filter.
89 	 *
90 	 * You will want to set up the filter by providing a string to search for
91 	 * and by providing a property to look up on the item.
92 	 *
93 	 * Params:
94 	 *     expression = The expression to evaluate
95 	 *         or %NULL for none
96 	 *
97 	 * Returns: a new `GtkStringFilter`
98 	 *
99 	 * Throws: ConstructionException GTK+ fails to create the object.
100 	 */
101 	public this(Expression expression)
102 	{
103 		auto __p = gtk_string_filter_new((expression is null) ? null : expression.getExpressionStruct(true));
104 
105 		if(__p is null)
106 		{
107 			throw new ConstructionException("null returned by new");
108 		}
109 
110 		this(cast(GtkStringFilter*) __p, true);
111 	}
112 
113 	/**
114 	 * Gets the expression that the string filter uses to
115 	 * obtain strings from items.
116 	 *
117 	 * Returns: a `GtkExpression`
118 	 */
119 	public Expression getExpression()
120 	{
121 		auto __p = gtk_string_filter_get_expression(gtkStringFilter);
122 
123 		if(__p is null)
124 		{
125 			return null;
126 		}
127 
128 		return ObjectG.getDObject!(Expression)(cast(GtkExpression*) __p);
129 	}
130 
131 	/**
132 	 * Returns whether the filter ignores case differences.
133 	 *
134 	 * Returns: %TRUE if the filter ignores case
135 	 */
136 	public bool getIgnoreCase()
137 	{
138 		return gtk_string_filter_get_ignore_case(gtkStringFilter) != 0;
139 	}
140 
141 	/**
142 	 * Returns the match mode that the filter is using.
143 	 *
144 	 * Returns: the match mode of the filter
145 	 */
146 	public GtkStringFilterMatchMode getMatchMode()
147 	{
148 		return gtk_string_filter_get_match_mode(gtkStringFilter);
149 	}
150 
151 	/**
152 	 * Gets the search term.
153 	 *
154 	 * Returns: The search term
155 	 */
156 	public string getSearch()
157 	{
158 		return Str.toString(gtk_string_filter_get_search(gtkStringFilter));
159 	}
160 
161 	/**
162 	 * Sets the expression that the string filter uses to
163 	 * obtain strings from items.
164 	 *
165 	 * The expression must have a value type of %G_TYPE_STRING.
166 	 *
167 	 * Params:
168 	 *     expression = a `GtkExpression`
169 	 */
170 	public void setExpression(Expression expression)
171 	{
172 		gtk_string_filter_set_expression(gtkStringFilter, (expression is null) ? null : expression.getExpressionStruct());
173 	}
174 
175 	/**
176 	 * Sets whether the filter ignores case differences.
177 	 *
178 	 * Params:
179 	 *     ignoreCase = %TRUE to ignore case
180 	 */
181 	public void setIgnoreCase(bool ignoreCase)
182 	{
183 		gtk_string_filter_set_ignore_case(gtkStringFilter, ignoreCase);
184 	}
185 
186 	/**
187 	 * Sets the match mode for the filter.
188 	 *
189 	 * Params:
190 	 *     mode = the new match mode
191 	 */
192 	public void setMatchMode(GtkStringFilterMatchMode mode)
193 	{
194 		gtk_string_filter_set_match_mode(gtkStringFilter, mode);
195 	}
196 
197 	/**
198 	 * Sets the string to search for.
199 	 *
200 	 * Params:
201 	 *     search = The string to search for
202 	 *         or %NULL to clear the search
203 	 */
204 	public void setSearch(string search)
205 	{
206 		gtk_string_filter_set_search(gtkStringFilter, Str.toStringz(search));
207 	}
208 }