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 = GFilenameCompleter.html 27 * outPack = gio 28 * outFile = FilenameCompleter 29 * strct = GFilenameCompleter 30 * realStrct= 31 * ctorStrct= 32 * clss = FilenameCompleter 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_filename_completer_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * structWrap: 48 * module aliases: 49 * local aliases: 50 * overrides: 51 */ 52 53 module gio.FilenameCompleter; 54 55 public import gtkc.giotypes; 56 57 private import gtkc.gio; 58 private import glib.ConstructionException; 59 private import gobject.ObjectG; 60 61 private import gobject.Signals; 62 public import gtkc.gdktypes; 63 private import glib.Str; 64 65 66 private import gobject.ObjectG; 67 68 /** 69 * Completes partial file and directory names given a partial string by 70 * looking in the file system for clues. Can return a list of possible 71 * completion strings for widget implementations. 72 */ 73 public class FilenameCompleter : ObjectG 74 { 75 76 /** the main Gtk struct */ 77 protected GFilenameCompleter* gFilenameCompleter; 78 79 80 /** Get the main Gtk struct */ 81 public GFilenameCompleter* getFilenameCompleterStruct() 82 { 83 return gFilenameCompleter; 84 } 85 86 87 /** the main Gtk struct as a void* */ 88 protected override void* getStruct() 89 { 90 return cast(void*)gFilenameCompleter; 91 } 92 93 /** 94 * Sets our main struct and passes it to the parent class 95 */ 96 public this (GFilenameCompleter* gFilenameCompleter) 97 { 98 super(cast(GObject*)gFilenameCompleter); 99 this.gFilenameCompleter = gFilenameCompleter; 100 } 101 102 protected override void setStruct(GObject* obj) 103 { 104 super.setStruct(obj); 105 gFilenameCompleter = cast(GFilenameCompleter*)obj; 106 } 107 108 /** 109 */ 110 int[string] connectedSignals; 111 112 void delegate(FilenameCompleter)[] onGotCompletionDataListeners; 113 /** 114 * Emitted when the file name completion information comes available. 115 */ 116 void addOnGotCompletionData(void delegate(FilenameCompleter) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 117 { 118 if ( !("got-completion-data" in connectedSignals) ) 119 { 120 Signals.connectData( 121 getStruct(), 122 "got-completion-data", 123 cast(GCallback)&callBackGotCompletionData, 124 cast(void*)this, 125 null, 126 connectFlags); 127 connectedSignals["got-completion-data"] = 1; 128 } 129 onGotCompletionDataListeners ~= dlg; 130 } 131 extern(C) static void callBackGotCompletionData(GFilenameCompleter* arg0Struct, FilenameCompleter _filenameCompleter) 132 { 133 foreach ( void delegate(FilenameCompleter) dlg ; _filenameCompleter.onGotCompletionDataListeners ) 134 { 135 dlg(_filenameCompleter); 136 } 137 } 138 139 140 /** 141 * Creates a new filename completer. 142 * Throws: ConstructionException GTK+ fails to create the object. 143 */ 144 public this () 145 { 146 // GFilenameCompleter * g_filename_completer_new (void); 147 auto p = g_filename_completer_new(); 148 if(p is null) 149 { 150 throw new ConstructionException("null returned by g_filename_completer_new()"); 151 } 152 this(cast(GFilenameCompleter*) p); 153 } 154 155 /** 156 * Obtains a completion for initial_text from completer. 157 * Params: 158 * initialText = text to be completed. 159 * Returns: a completed string, or NULL if no completion exists. This string is not owned by GIO, so remember to g_free() it when finished. 160 */ 161 public string getCompletionSuffix(string initialText) 162 { 163 // char * g_filename_completer_get_completion_suffix (GFilenameCompleter *completer, const char *initial_text); 164 return Str.toString(g_filename_completer_get_completion_suffix(gFilenameCompleter, Str.toStringz(initialText))); 165 } 166 167 /** 168 * Gets an array of completion strings for a given initial text. 169 * Params: 170 * initialText = text to be completed. 171 * Returns: array of strings with possible completions for initial_text. This array must be freed by g_strfreev() when finished. [array zero-terminated=1][transfer full] 172 */ 173 public string[] getCompletions(string initialText) 174 { 175 // char ** g_filename_completer_get_completions (GFilenameCompleter *completer, const char *initial_text); 176 return Str.toStringArray(g_filename_completer_get_completions(gFilenameCompleter, Str.toStringz(initialText))); 177 } 178 179 /** 180 * If dirs_only is TRUE, completer will only 181 * complete directory names, and not file names. 182 * Params: 183 * dirsOnly = a gboolean. 184 * Signal Details 185 * The "got-completion-data" signal 186 * void user_function (GFilenameCompleter *arg0, 187 * gpointer user_data) : Run Last 188 * Emitted when the file name completion information comes available. 189 */ 190 public void setDirsOnly(int dirsOnly) 191 { 192 // void g_filename_completer_set_dirs_only (GFilenameCompleter *completer, gboolean dirs_only); 193 g_filename_completer_set_dirs_only(gFilenameCompleter, dirsOnly); 194 } 195 }