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 = GtkSearchEntry.html 27 * outPack = gtk 28 * outFile = SearchEntry 29 * strct = GtkSearchEntry 30 * realStrct= 31 * ctorStrct= 32 * clss = SearchEntry 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_search_entry_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * structWrap: 47 * module aliases: 48 * local aliases: 49 * overrides: 50 */ 51 52 module gtk.SearchEntry; 53 54 public import gtkc.gtktypes; 55 56 private import gtkc.gtk; 57 private import glib.ConstructionException; 58 private import gobject.ObjectG; 59 60 private import gobject.Signals; 61 public import gtkc.gdktypes; 62 63 64 private import gtk.Entry; 65 66 /** 67 * GtkSearchEntry is a subclass of GtkEntry that has 68 * been tailored for use as a search entry. 69 * 70 * It will show an inactive symbolic "find" icon when the 71 * search entry is empty, and a symbolic "clear" icon when 72 * there is text. Clicking on the "clear" icon will empty 73 * the search entry. 74 * 75 * Note that the search/clear icon is shown using a secondary 76 * icon, and thus does not work if you are using the secondary 77 * icon position for some other purpose. 78 * 79 * To make filtering appear more reactive, it is a good idea to 80 * not react to every change in the entry text immediately, but 81 * only after a short delay. To support this, GtkSearchEntry 82 * emits the "search-changed" signal which can 83 * be used instead of the "changed" signal. 84 */ 85 public class SearchEntry : Entry 86 { 87 88 /** the main Gtk struct */ 89 protected GtkSearchEntry* gtkSearchEntry; 90 91 92 /** Get the main Gtk struct */ 93 public GtkSearchEntry* getSearchEntryStruct() 94 { 95 return gtkSearchEntry; 96 } 97 98 99 /** the main Gtk struct as a void* */ 100 protected override void* getStruct() 101 { 102 return cast(void*)gtkSearchEntry; 103 } 104 105 /** 106 * Sets our main struct and passes it to the parent class 107 */ 108 public this (GtkSearchEntry* gtkSearchEntry) 109 { 110 super(cast(GtkEntry*)gtkSearchEntry); 111 this.gtkSearchEntry = gtkSearchEntry; 112 } 113 114 protected override void setStruct(GObject* obj) 115 { 116 super.setStruct(obj); 117 gtkSearchEntry = cast(GtkSearchEntry*)obj; 118 } 119 120 /** 121 */ 122 int[string] connectedSignals; 123 124 void delegate(SearchEntry)[] onSearchChangedListeners; 125 /** 126 * The "search-changed" signal is emitted with a short 127 * delay of 150 milliseconds after the last change to the entry text. 128 * Since 3.10 129 */ 130 void addOnSearchChanged(void delegate(SearchEntry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 131 { 132 if ( !("search-changed" in connectedSignals) ) 133 { 134 Signals.connectData( 135 getStruct(), 136 "search-changed", 137 cast(GCallback)&callBackSearchChanged, 138 cast(void*)this, 139 null, 140 connectFlags); 141 connectedSignals["search-changed"] = 1; 142 } 143 onSearchChangedListeners ~= dlg; 144 } 145 extern(C) static void callBackSearchChanged(GtkSearchEntry* entryStruct, SearchEntry _searchEntry) 146 { 147 foreach ( void delegate(SearchEntry) dlg ; _searchEntry.onSearchChangedListeners ) 148 { 149 dlg(_searchEntry); 150 } 151 } 152 153 154 /** 155 * Creates a GtkSearchEntry, with a find icon when the search field is 156 * empty, and a clear icon when it isn't. 157 * Throws: ConstructionException GTK+ fails to create the object. 158 */ 159 public this () 160 { 161 // GtkWidget * gtk_search_entry_new (void); 162 auto p = gtk_search_entry_new(); 163 if(p is null) 164 { 165 throw new ConstructionException("null returned by gtk_search_entry_new()"); 166 } 167 this(cast(GtkSearchEntry*) p); 168 } 169 }