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 65 66 private import gtk.Entry; 67 68 /** 69 * GtkSearchEntry is a subclass of GtkEntry that has 70 * been tailored for use as a search entry. 71 * 72 * It will show an inactive symbolic "find" icon when the 73 * search entry is empty, and a symbolic "clear" icon when 74 * there is text. Clicking on the "clear" icon will empty 75 * the search entry. 76 * 77 * Note that the search/clear icon is shown using a secondary 78 * icon, and thus does not work if you are using the secondary 79 * icon position for some other purpose. 80 * 81 * To make filtering appear more reactive, it is a good idea to 82 * not react to every change in the entry text immediately, but 83 * only after a short delay. To support this, GtkSearchEntry 84 * emits the "search-changed" signal which can 85 * be used instead of the "changed" signal. 86 */ 87 public class SearchEntry : Entry 88 { 89 90 /** the main Gtk struct */ 91 protected GtkSearchEntry* gtkSearchEntry; 92 93 94 public GtkSearchEntry* getSearchEntryStruct() 95 { 96 return gtkSearchEntry; 97 } 98 99 100 /** the main Gtk struct as a void* */ 101 protected override void* getStruct() 102 { 103 return cast(void*)gtkSearchEntry; 104 } 105 106 /** 107 * Sets our main struct and passes it to the parent class 108 */ 109 public this (GtkSearchEntry* gtkSearchEntry) 110 { 111 super(cast(GtkEntry*)gtkSearchEntry); 112 this.gtkSearchEntry = gtkSearchEntry; 113 } 114 115 protected override void setStruct(GObject* obj) 116 { 117 super.setStruct(obj); 118 gtkSearchEntry = cast(GtkSearchEntry*)obj; 119 } 120 121 /** 122 */ 123 int[string] connectedSignals; 124 125 void delegate(SearchEntry)[] onSearchChangedListeners; 126 /** 127 * The "search-changed" signal is emitted with a short 128 * delay of 150 milliseconds after the last change to the entry text. 129 * Since 3.10 130 */ 131 void addOnSearchChanged(void delegate(SearchEntry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 132 { 133 if ( !("search-changed" in connectedSignals) ) 134 { 135 Signals.connectData( 136 getStruct(), 137 "search-changed", 138 cast(GCallback)&callBackSearchChanged, 139 cast(void*)this, 140 null, 141 connectFlags); 142 connectedSignals["search-changed"] = 1; 143 } 144 onSearchChangedListeners ~= dlg; 145 } 146 extern(C) static void callBackSearchChanged(GtkSearchEntry* entryStruct, SearchEntry _searchEntry) 147 { 148 foreach ( void delegate(SearchEntry) dlg ; _searchEntry.onSearchChangedListeners ) 149 { 150 dlg(_searchEntry); 151 } 152 } 153 154 155 /** 156 * Creates a GtkSearchEntry, with a find icon when the search field is 157 * empty, and a clear icon when it isn't. 158 * Throws: ConstructionException GTK+ fails to create the object. 159 */ 160 public this () 161 { 162 // GtkWidget * gtk_search_entry_new (void); 163 auto p = gtk_search_entry_new(); 164 if(p is null) 165 { 166 throw new ConstructionException("null returned by gtk_search_entry_new()"); 167 } 168 this(cast(GtkSearchEntry*) p); 169 } 170 }