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 gio.FilenameCompleter; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 public import gtkc.gdktypes; 32 private import gtkc.gio; 33 public import gtkc.giotypes; 34 35 36 /** 37 * Completes partial file and directory names given a partial string by 38 * looking in the file system for clues. Can return a list of possible 39 * completion strings for widget implementations. 40 */ 41 public class FilenameCompleter : ObjectG 42 { 43 /** the main Gtk struct */ 44 protected GFilenameCompleter* gFilenameCompleter; 45 46 /** Get the main Gtk struct */ 47 public GFilenameCompleter* getFilenameCompleterStruct() 48 { 49 return gFilenameCompleter; 50 } 51 52 /** the main Gtk struct as a void* */ 53 protected override void* getStruct() 54 { 55 return cast(void*)gFilenameCompleter; 56 } 57 58 protected override void setStruct(GObject* obj) 59 { 60 gFilenameCompleter = cast(GFilenameCompleter*)obj; 61 super.setStruct(obj); 62 } 63 64 /** 65 * Sets our main struct and passes it to the parent class. 66 */ 67 public this (GFilenameCompleter* gFilenameCompleter, bool ownedRef = false) 68 { 69 this.gFilenameCompleter = gFilenameCompleter; 70 super(cast(GObject*)gFilenameCompleter, ownedRef); 71 } 72 73 74 /** */ 75 public static GType getType() 76 { 77 return g_filename_completer_get_type(); 78 } 79 80 /** 81 * Creates a new filename completer. 82 * 83 * Return: a #GFilenameCompleter. 84 * 85 * Throws: ConstructionException GTK+ fails to create the object. 86 */ 87 public this() 88 { 89 auto p = g_filename_completer_new(); 90 91 if(p is null) 92 { 93 throw new ConstructionException("null returned by new"); 94 } 95 96 this(cast(GFilenameCompleter*) p, true); 97 } 98 99 /** 100 * Obtains a completion for @initial_text from @completer. 101 * 102 * Params: 103 * initialText = text to be completed. 104 * 105 * Return: a completed string, or %NULL if no completion exists. 106 * This string is not owned by GIO, so remember to g_free() it 107 * when finished. 108 */ 109 public string getCompletionSuffix(string initialText) 110 { 111 return Str.toString(g_filename_completer_get_completion_suffix(gFilenameCompleter, Str.toStringz(initialText))); 112 } 113 114 /** 115 * Gets an array of completion strings for a given initial text. 116 * 117 * Params: 118 * initialText = text to be completed. 119 * 120 * Return: array of strings with possible completions for @initial_text. 121 * This array must be freed by g_strfreev() when finished. 122 */ 123 public string[] getCompletions(string initialText) 124 { 125 return Str.toStringArray(g_filename_completer_get_completions(gFilenameCompleter, Str.toStringz(initialText))); 126 } 127 128 /** 129 * If @dirs_only is %TRUE, @completer will only 130 * complete directory names, and not file names. 131 * 132 * Params: 133 * dirsOnly = a #gboolean. 134 */ 135 public void setDirsOnly(bool dirsOnly) 136 { 137 g_filename_completer_set_dirs_only(gFilenameCompleter, dirsOnly); 138 } 139 140 int[string] connectedSignals; 141 142 void delegate(FilenameCompleter)[] onGotCompletionDataListeners; 143 /** 144 * Emitted when the file name completion information comes available. 145 */ 146 void addOnGotCompletionData(void delegate(FilenameCompleter) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 147 { 148 if ( "got-completion-data" !in connectedSignals ) 149 { 150 Signals.connectData( 151 this, 152 "got-completion-data", 153 cast(GCallback)&callBackGotCompletionData, 154 cast(void*)this, 155 null, 156 connectFlags); 157 connectedSignals["got-completion-data"] = 1; 158 } 159 onGotCompletionDataListeners ~= dlg; 160 } 161 extern(C) static void callBackGotCompletionData(GFilenameCompleter* filenamecompleterStruct, FilenameCompleter _filenamecompleter) 162 { 163 foreach ( void delegate(FilenameCompleter) dlg; _filenamecompleter.onGotCompletionDataListeners ) 164 { 165 dlg(_filenamecompleter); 166 } 167 } 168 }