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  * Conversion parameters:
26  * inFile  = glib-Automatic-String-Completion.html
27  * outPack = glib
28  * outFile = StringCompletion
29  * strct   = GCompletion
30  * realStrct=
31  * ctorStrct=
32  * clss    = StringCompletion
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_completion_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.ListG
47  * 	- glib.Str
48  * structWrap:
49  * 	- GList* -> ListG
50  * module aliases:
51  * local aliases:
52  * overrides:
53  */
54 
55 module glib.StringCompletion;
56 
57 public  import gtkc.glibtypes;
58 
59 private import gtkc.glib;
60 private import glib.ConstructionException;
61 
62 
63 private import glib.ListG;
64 private import glib.Str;
65 
66 
67 
68 
69 /**
70  * Description
71  * GCompletion provides support for automatic completion of a string
72  * using any group of target strings. It is typically used for file
73  * name completion as is common in many UNIX shells.
74  * A GCompletion is created using g_completion_new(). Target items are
75  * added and removed with g_completion_add_items(),
76  * g_completion_remove_items() and g_completion_clear_items(). A
77  * completion attempt is requested with g_completion_complete() or
78  * g_completion_complete_utf8(). When no longer needed, the
79  * GCompletion is freed with g_completion_free().
80  * Items in the completion can be simple strings (e.g. filenames), or
81  * pointers to arbitrary data structures. If data structures are used
82  * you must provide a GCompletionFunc in g_completion_new(), which
83  * retrieves the item's string from the data structure. You can change
84  * the way in which strings are compared by setting a different
85  * GCompletionStrncmpFunc in g_completion_set_compare().
86  * GCompletion has been marked as deprecated, since this API is rarely
87  * used and not very actively maintained.
88  */
89 public class StringCompletion
90 {
91 	
92 	/** the main Gtk struct */
93 	protected GCompletion* gCompletion;
94 	
95 	
96 	public GCompletion* getStringCompletionStruct()
97 	{
98 		return gCompletion;
99 	}
100 	
101 	
102 	/** the main Gtk struct as a void* */
103 	protected void* getStruct()
104 	{
105 		return cast(void*)gCompletion;
106 	}
107 	
108 	/**
109 	 * Sets our main struct and passes it to the parent class
110 	 */
111 	public this (GCompletion* gCompletion)
112 	{
113 		this.gCompletion = gCompletion;
114 	}
115 	
116 	/**
117 	 */
118 	
119 	/**
120 	 * Warning
121 	 * g_completion_new is deprecated and should not be used in newly-written code.
122 	 * Creates a new GCompletion.
123 	 * Params:
124 	 * func = the function to be called to return the string representing
125 	 * an item in the GCompletion, or NULL if strings are going to
126 	 * be used as the GCompletion items.
127 	 * Throws: ConstructionException GTK+ fails to create the object.
128 	 */
129 	public this (GCompletionFunc func)
130 	{
131 		// GCompletion * g_completion_new (GCompletionFunc func);
132 		auto p = g_completion_new(func);
133 		if(p is null)
134 		{
135 			throw new ConstructionException("null returned by g_completion_new(func)");
136 		}
137 		this(cast(GCompletion*) p);
138 	}
139 	
140 	/**
141 	 * Warning
142 	 * g_completion_add_items has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API
143 	 * Adds items to the GCompletion.
144 	 * Params:
145 	 * items = the list of items to add.
146 	 */
147 	public void addItems(ListG items)
148 	{
149 		// void g_completion_add_items (GCompletion *cmp,  GList *items);
150 		g_completion_add_items(gCompletion, (items is null) ? null : items.getListGStruct());
151 	}
152 	
153 	/**
154 	 * Warning
155 	 * g_completion_remove_items has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API
156 	 * Removes items from a GCompletion.
157 	 * Params:
158 	 * items = the items to remove.
159 	 */
160 	public void removeItems(ListG items)
161 	{
162 		// void g_completion_remove_items (GCompletion *cmp,  GList *items);
163 		g_completion_remove_items(gCompletion, (items is null) ? null : items.getListGStruct());
164 	}
165 	
166 	/**
167 	 * Warning
168 	 * g_completion_clear_items has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API
169 	 * Removes all items from the GCompletion.
170 	 */
171 	public void clearItems()
172 	{
173 		// void g_completion_clear_items (GCompletion *cmp);
174 		g_completion_clear_items(gCompletion);
175 	}
176 	
177 	/**
178 	 * Warning
179 	 * g_completion_complete has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API
180 	 * Attempts to complete the string prefix using the GCompletion
181 	 * target items.
182 	 * Params:
183 	 * prefix = the prefix string, typically typed by the user, which is
184 	 * compared with each of the items.
185 	 * newPrefix = if non-NULL, returns the longest prefix which is
186 	 * common to all items that matched prefix, or NULL if
187 	 * no items matched prefix. This string should be freed
188 	 * when no longer needed.
189 	 * Returns: the list of items whose strings begin with prefix. This should not be changed.
190 	 */
191 	public ListG complete(string prefix, out string newPrefix)
192 	{
193 		// GList * g_completion_complete (GCompletion *cmp,  const gchar *prefix,  gchar **new_prefix);
194 		char* outnewPrefix = null;
195 		
196 		auto p = g_completion_complete(gCompletion, Str.toStringz(prefix), &outnewPrefix);
197 		
198 		newPrefix = Str.toString(outnewPrefix);
199 		
200 		if(p is null)
201 		{
202 			return null;
203 		}
204 		
205 		return new ListG(cast(GList*) p);
206 	}
207 	
208 	/**
209 	 * Warning
210 	 * g_completion_complete_utf8 has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API
211 	 * Attempts to complete the string prefix using the GCompletion target items.
212 	 * In contrast to g_completion_complete(), this function returns the largest common
213 	 * prefix that is a valid UTF-8 string, omitting a possible common partial
214 	 * character.
215 	 * You should use this function instead of g_completion_complete() if your
216 	 * items are UTF-8 strings.
217 	 * Since 2.4
218 	 * Params:
219 	 * prefix = the prefix string, typically used by the user, which is compared
220 	 * with each of the items
221 	 * newPrefix = if non-NULL, returns the longest prefix which is common to all
222 	 * items that matched prefix, or NULL if no items matched prefix.
223 	 * This string should be freed when no longer needed.
224 	 * Returns: the list of items whose strings begin with prefix. This should not be changed.
225 	 */
226 	public ListG completeUtf8(string prefix, out string newPrefix)
227 	{
228 		// GList * g_completion_complete_utf8 (GCompletion *cmp,  const gchar *prefix,  gchar **new_prefix);
229 		char* outnewPrefix = null;
230 		
231 		auto p = g_completion_complete_utf8(gCompletion, Str.toStringz(prefix), &outnewPrefix);
232 		
233 		newPrefix = Str.toString(outnewPrefix);
234 		
235 		if(p is null)
236 		{
237 			return null;
238 		}
239 		
240 		return new ListG(cast(GList*) p);
241 	}
242 	
243 	/**
244 	 * Warning
245 	 * g_completion_set_compare has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API
246 	 * Sets the function to use for string comparisons. The default string
247 	 * comparison function is strncmp().
248 	 * Params:
249 	 * cmp = a GCompletion.
250 	 * strncmpFunc = the string comparison function.
251 	 */
252 	public void setCompare(GCompletionStrncmpFunc strncmpFunc)
253 	{
254 		// void g_completion_set_compare (GCompletion *cmp,  GCompletionStrncmpFunc strncmp_func);
255 		g_completion_set_compare(gCompletion, strncmpFunc);
256 	}
257 	
258 	/**
259 	 * Warning
260 	 * g_completion_free has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API
261 	 * Frees all memory used by the GCompletion.
262 	 */
263 	public void free()
264 	{
265 		// void g_completion_free (GCompletion *cmp);
266 		g_completion_free(gCompletion);
267 	}
268 }