Wrote the README_GIT file to be a proper tutorial on git, repo.or.cz and gtkD.
[gtkD.git] / gtkD / src / glib / StringCompletion.d
blobcbde6461bb2bc730093003d2887debd1b7a422de
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = glib-Automatic-String-Completion.html
26 * outPack = glib
27 * outFile = StringCompletion
28 * strct = GCompletion
29 * realStrct=
30 * ctorStrct=
31 * clss = StringCompletion
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_completion_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.ListG
45 * - glib.Str
46 * structWrap:
47 * - GList* -> ListG
48 * module aliases:
49 * local aliases:
52 module glib.StringCompletion;
54 version(noAssert)
56 version(Tango)
58 import tango.io.Stdout; // use the tango loging?
62 private import gtkc.glibtypes;
64 private import gtkc.glib;
67 private import glib.ListG;
68 private import glib.Str;
73 /**
74 * Description
75 * GCompletion provides support for automatic completion of a string using
76 * any group of target strings. It is typically used for file name completion
77 * as is common in many UNIX shells.
78 * A GCompletion is created using g_completion_new().
79 * Target items are added and removed with
80 * g_completion_add_items(), g_completion_remove_items() and
81 * g_completion_clear_items().
82 * A completion attempt is requested with g_completion_complete() or
83 * g_completion_complete_utf8().
84 * When no longer needed, the GCompletion is freed with g_completion_free().
85 * Items in the completion can be simple strings (e.g. filenames),
86 * or pointers to arbitrary data structures. If data structures are used
87 * you must provide a GCompletionFunc in g_completion_new(),
88 * which retrieves the item's string from the data structure.
89 * You can change the way in which strings are compared by setting
90 * a different GCompletionStrncmpFunc in g_completion_set_compare().
92 public class StringCompletion
95 /** the main Gtk struct */
96 protected GCompletion* gCompletion;
99 public GCompletion* getStringCompletionStruct()
101 return gCompletion;
105 /** the main Gtk struct as a void* */
106 protected void* getStruct()
108 return cast(void*)gCompletion;
112 * Sets our main struct and passes it to the parent class
114 public this (GCompletion* gCompletion)
116 version(noAssert)
118 if ( gCompletion is null )
120 int zero = 0;
121 version(Tango)
123 Stdout("struct gCompletion is null on constructor").newline;
125 else
127 printf("struct gCompletion is null on constructor");
129 zero = zero / zero;
132 else
134 assert(gCompletion !is null, "struct gCompletion is null on constructor");
136 this.gCompletion = gCompletion;
144 * Creates a new GCompletion.
145 * func:
146 * the function to be called to return the string representing an item
147 * in the GCompletion, or NULL if strings are going to be used as the
148 * GCompletion items.
149 * Returns:
150 * the new GCompletion.
152 public this (GCompletionFunc func)
154 // GCompletion* g_completion_new (GCompletionFunc func);
155 this(cast(GCompletion*)g_completion_new(func) );
160 * Adds items to the GCompletion.
161 * cmp:
162 * the GCompletion.
163 * items:
164 * the list of items to add.
166 public void addItems(ListG items)
168 // void g_completion_add_items (GCompletion *cmp, GList *items);
169 g_completion_add_items(gCompletion, (items is null) ? null : items.getListGStruct());
173 * Removes items from a GCompletion.
174 * cmp:
175 * the GCompletion.
176 * items:
177 * the items to remove.
179 public void removeItems(ListG items)
181 // void g_completion_remove_items (GCompletion *cmp, GList *items);
182 g_completion_remove_items(gCompletion, (items is null) ? null : items.getListGStruct());
186 * Removes all items from the GCompletion.
187 * cmp:
188 * the GCompletion.
190 public void clearItems()
192 // void g_completion_clear_items (GCompletion *cmp);
193 g_completion_clear_items(gCompletion);
197 * Attempts to complete the string prefix using the GCompletion target items.
198 * cmp:
199 * the GCompletion.
200 * prefix:
201 * the prefix string, typically typed by the user, which is compared
202 * with each of the items.
203 * new_prefix:
204 * if non-NULL, returns the longest prefix which is common to all
205 * items that matched prefix, or NULL if no items matched prefix.
206 * This string should be freed when no longer needed.
207 * Returns:
208 * the list of items whose strings begin with prefix. This should
209 * not be changed.
211 public ListG complete(char[] prefix, char** newPrefix)
213 // GList* g_completion_complete (GCompletion *cmp, const gchar *prefix, gchar **new_prefix);
214 return new ListG( g_completion_complete(gCompletion, Str.toStringz(prefix), newPrefix) );
218 * Attempts to complete the string prefix using the GCompletion target items.
219 * In contrast to g_completion_complete(), this function returns the largest common
220 * prefix that is a valid UTF-8 string, omitting a possible common partial
221 * character.
222 * You should use this function instead of g_completion_complete() if your
223 * items are UTF-8 strings.
224 * cmp:
225 * the GCompletion
226 * prefix:
227 * the prefix string, typically used by the user, which is compared
228 * with each of the items
229 * new_prefix:
230 * if non-NULL, returns the longest prefix which is common to all
231 * items that matched prefix, or NULL if no items matched prefix.
232 * This string should be freed when no longer needed.
233 * Returns:
234 * the list of items whose strings begin with prefix. This should
235 * not be changed.
236 * Since 2.4
238 public ListG completeUtf8(char[] prefix, char** newPrefix)
240 // GList* g_completion_complete_utf8 (GCompletion *cmp, const gchar *prefix, gchar **new_prefix);
241 return new ListG( g_completion_complete_utf8(gCompletion, Str.toStringz(prefix), newPrefix) );
245 * Sets the function to use for string comparisons. The default
246 * string comparison function is strncmp().
247 * cmp:
248 * a GCompletion.
249 * strncmp_func:
250 * the string comparison function.
252 public void setCompare(GCompletionStrncmpFunc strncmpFunc)
254 // void g_completion_set_compare (GCompletion *cmp, GCompletionStrncmpFunc strncmp_func);
255 g_completion_set_compare(gCompletion, strncmpFunc);
260 * Frees all memory used by the GCompletion.
261 * cmp:
262 * the GCompletion.
264 public void free()
266 // void g_completion_free (GCompletion *cmp);
267 g_completion_free(gCompletion);