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 * GCompletion provides support for automatic completion of a string 71 * using any group of target strings. It is typically used for file 72 * name completion as is common in many UNIX shells. 73 * 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 * 81 * Items in the completion can be simple strings (e.g. filenames), or 82 * pointers to arbitrary data structures. If data structures are used 83 * you must provide a GCompletionFunc in g_completion_new(), which 84 * retrieves the item's string from the data structure. You can change 85 * the way in which strings are compared by setting a different 86 * GCompletionStrncmpFunc in g_completion_set_compare(). 87 * 88 * GCompletion has been marked as deprecated, since this API is rarely 89 * used and not very actively maintained. 90 */ 91 public class StringCompletion 92 { 93 94 /** the main Gtk struct */ 95 protected GCompletion* gCompletion; 96 97 98 public GCompletion* getStringCompletionStruct() 99 { 100 return gCompletion; 101 } 102 103 104 /** the main Gtk struct as a void* */ 105 protected void* getStruct() 106 { 107 return cast(void*)gCompletion; 108 } 109 110 /** 111 * Sets our main struct and passes it to the parent class 112 */ 113 public this (GCompletion* gCompletion) 114 { 115 this.gCompletion = gCompletion; 116 } 117 118 /** 119 */ 120 121 /** 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. [transfer none] 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. The items are not freed, so if the memory 157 * was dynamically allocated, free items with g_list_free_full() after calling 158 * this function. 159 * Params: 160 * items = the items to remove. [transfer none] 161 */ 162 public void removeItems(ListG items) 163 { 164 // void g_completion_remove_items (GCompletion *cmp, GList *items); 165 g_completion_remove_items(gCompletion, (items is null) ? null : items.getListGStruct()); 166 } 167 168 /** 169 * Warning 170 * g_completion_clear_items has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API 171 * Removes all items from the GCompletion. The items are not freed, so if the 172 * memory was dynamically allocated, it should be freed after calling this 173 * function. 174 */ 175 public void clearItems() 176 { 177 // void g_completion_clear_items (GCompletion *cmp); 178 g_completion_clear_items(gCompletion); 179 } 180 181 /** 182 * Warning 183 * g_completion_complete has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API 184 * Attempts to complete the string prefix using the GCompletion 185 * target items. 186 * Params: 187 * prefix = the prefix string, typically typed by the user, which is 188 * compared with each of the items. 189 * newPrefix = if non-NULL, returns the longest prefix which is 190 * common to all items that matched prefix, or NULL if 191 * no items matched prefix. This string should be freed 192 * when no longer needed. 193 * Returns: the list of items whose strings begin with prefix. This should not be changed. [transfer none] 194 */ 195 public ListG complete(string prefix, out string newPrefix) 196 { 197 // GList * g_completion_complete (GCompletion *cmp, const gchar *prefix, gchar **new_prefix); 198 char* outnewPrefix = null; 199 200 auto p = g_completion_complete(gCompletion, Str.toStringz(prefix), &outnewPrefix); 201 202 newPrefix = Str.toString(outnewPrefix); 203 204 if(p is null) 205 { 206 return null; 207 } 208 209 return new ListG(cast(GList*) p); 210 } 211 212 /** 213 * Warning 214 * g_completion_complete_utf8 has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API 215 * Attempts to complete the string prefix using the GCompletion target items. 216 * In contrast to g_completion_complete(), this function returns the largest common 217 * prefix that is a valid UTF-8 string, omitting a possible common partial 218 * character. 219 * You should use this function instead of g_completion_complete() if your 220 * items are UTF-8 strings. 221 * Since 2.4 222 * Params: 223 * prefix = the prefix string, typically used by the user, which is compared 224 * with each of the items 225 * newPrefix = if non-NULL, returns the longest prefix which is common to all 226 * items that matched prefix, or NULL if no items matched prefix. 227 * This string should be freed when no longer needed. 228 * Returns: the list of items whose strings begin with prefix. This should not be changed. [element-type utf8][transfer none] 229 */ 230 public ListG completeUtf8(string prefix, out string newPrefix) 231 { 232 // GList * g_completion_complete_utf8 (GCompletion *cmp, const gchar *prefix, gchar **new_prefix); 233 char* outnewPrefix = null; 234 235 auto p = g_completion_complete_utf8(gCompletion, Str.toStringz(prefix), &outnewPrefix); 236 237 newPrefix = Str.toString(outnewPrefix); 238 239 if(p is null) 240 { 241 return null; 242 } 243 244 return new ListG(cast(GList*) p); 245 } 246 247 /** 248 * Warning 249 * g_completion_set_compare has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API 250 * Sets the function to use for string comparisons. The default string 251 * comparison function is strncmp(). 252 * Params: 253 * cmp = a GCompletion. 254 * strncmpFunc = the string comparison function. 255 */ 256 public void setCompare(GCompletionStrncmpFunc strncmpFunc) 257 { 258 // void g_completion_set_compare (GCompletion *cmp, GCompletionStrncmpFunc strncmp_func); 259 g_completion_set_compare(gCompletion, strncmpFunc); 260 } 261 262 /** 263 * Warning 264 * g_completion_free has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API 265 * Frees all memory used by the GCompletion. The items are not freed, so if 266 * the memory was dynamically allocated, it should be freed after calling this 267 * function. 268 */ 269 public void free() 270 { 271 // void g_completion_free (GCompletion *cmp); 272 g_completion_free(gCompletion); 273 } 274 }