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 gtk.SearchEntry; 26 27 private import gdk.Event; 28 private import glib.ConstructionException; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gtk.Entry; 32 private import gtk.Widget; 33 private import gtk.c.functions; 34 public import gtk.c.types; 35 public import gtkc.gtktypes; 36 private import std.algorithm; 37 38 39 /** 40 * #GtkSearchEntry is a subclass of #GtkEntry that has been 41 * tailored for use as a search entry. 42 * 43 * It will show an inactive symbolic “find” icon when the search 44 * entry is empty, and a symbolic “clear” icon when there is text. 45 * Clicking on the “clear” icon will empty the search entry. 46 * 47 * Note that the search/clear icon is shown using a secondary 48 * icon, and thus does not work if you are using the secondary 49 * icon position for some other purpose. 50 * 51 * To make filtering appear more reactive, it is a good idea to 52 * not react to every change in the entry text immediately, but 53 * only after a short delay. To support this, #GtkSearchEntry 54 * emits the #GtkSearchEntry::search-changed signal which can 55 * be used instead of the #GtkEditable::changed signal. 56 * 57 * The #GtkSearchEntry::previous-match, #GtkSearchEntry::next-match 58 * and #GtkSearchEntry::stop-search signals can be used to implement 59 * moving between search results and ending the search. 60 * 61 * Often, GtkSearchEntry will be fed events by means of being 62 * placed inside a #GtkSearchBar. If that is not the case, 63 * you can use gtk_search_entry_handle_event() to pass events. 64 */ 65 public class SearchEntry : Entry 66 { 67 /** the main Gtk struct */ 68 protected GtkSearchEntry* gtkSearchEntry; 69 70 /** Get the main Gtk struct */ 71 public GtkSearchEntry* getSearchEntryStruct(bool transferOwnership = false) 72 { 73 if (transferOwnership) 74 ownedRef = false; 75 return gtkSearchEntry; 76 } 77 78 /** the main Gtk struct as a void* */ 79 protected override void* getStruct() 80 { 81 return cast(void*)gtkSearchEntry; 82 } 83 84 /** 85 * Sets our main struct and passes it to the parent class. 86 */ 87 public this (GtkSearchEntry* gtkSearchEntry, bool ownedRef = false) 88 { 89 this.gtkSearchEntry = gtkSearchEntry; 90 super(cast(GtkEntry*)gtkSearchEntry, ownedRef); 91 } 92 93 94 /** */ 95 public static GType getType() 96 { 97 return gtk_search_entry_get_type(); 98 } 99 100 /** 101 * Creates a #GtkSearchEntry, with a find icon when the search field is 102 * empty, and a clear icon when it isn't. 103 * 104 * Returns: a new #GtkSearchEntry 105 * 106 * Since: 3.6 107 * 108 * Throws: ConstructionException GTK+ fails to create the object. 109 */ 110 public this() 111 { 112 auto p = gtk_search_entry_new(); 113 114 if(p is null) 115 { 116 throw new ConstructionException("null returned by new"); 117 } 118 119 this(cast(GtkSearchEntry*) p); 120 } 121 122 /** 123 * This function should be called when the top-level window 124 * which contains the search entry received a key event. If 125 * the entry is part of a #GtkSearchBar, it is preferable 126 * to call gtk_search_bar_handle_event() instead, which will 127 * reveal the entry in addition to passing the event to this 128 * function. 129 * 130 * If the key event is handled by the search entry and starts 131 * or continues a search, %GDK_EVENT_STOP will be returned. 132 * The caller should ensure that the entry is shown in this 133 * case, and not propagate the event further. 134 * 135 * Params: 136 * event = a key event 137 * 138 * Returns: %GDK_EVENT_STOP if the key press event resulted 139 * in a search beginning or continuing, %GDK_EVENT_PROPAGATE 140 * otherwise. 141 * 142 * Since: 3.16 143 */ 144 public bool handleEvent(Event event) 145 { 146 return gtk_search_entry_handle_event(gtkSearchEntry, (event is null) ? null : event.getEventStruct()) != 0; 147 } 148 149 /** 150 * The ::next-match signal is a [keybinding signal][GtkBindingSignal] 151 * which gets emitted when the user initiates a move to the next match 152 * for the current search string. 153 * 154 * Applications should connect to it, to implement moving between 155 * matches. 156 * 157 * The default bindings for this signal is Ctrl-g. 158 * 159 * Since: 3.16 160 */ 161 gulong addOnNextMatch(void delegate(SearchEntry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 162 { 163 return Signals.connect(this, "next-match", dlg, connectFlags ^ ConnectFlags.SWAPPED); 164 } 165 166 /** 167 * The ::previous-match signal is a [keybinding signal][GtkBindingSignal] 168 * which gets emitted when the user initiates a move to the previous match 169 * for the current search string. 170 * 171 * Applications should connect to it, to implement moving between 172 * matches. 173 * 174 * The default bindings for this signal is Ctrl-Shift-g. 175 * 176 * Since: 3.16 177 */ 178 gulong addOnPreviousMatch(void delegate(SearchEntry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 179 { 180 return Signals.connect(this, "previous-match", dlg, connectFlags ^ ConnectFlags.SWAPPED); 181 } 182 183 /** 184 * The #GtkSearchEntry::search-changed signal is emitted with a short 185 * delay of 150 milliseconds after the last change to the entry text. 186 * 187 * Since: 3.10 188 */ 189 gulong addOnSearchChanged(void delegate(SearchEntry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 190 { 191 return Signals.connect(this, "search-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 192 } 193 194 /** 195 * The ::stop-search signal is a [keybinding signal][GtkBindingSignal] 196 * which gets emitted when the user stops a search via keyboard input. 197 * 198 * Applications should connect to it, to implement hiding the search 199 * entry in this case. 200 * 201 * The default bindings for this signal is Escape. 202 * 203 * Since: 3.16 204 */ 205 gulong addOnStopSearch(void delegate(SearchEntry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 206 { 207 return Signals.connect(this, "stop-search", dlg, connectFlags ^ ConnectFlags.SWAPPED); 208 } 209 }