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 = GtkSearchBar.html 27 * outPack = gtk 28 * outFile = SearchBar 29 * strct = GtkSearchBar 30 * realStrct= 31 * ctorStrct= 32 * clss = SearchBar 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_search_bar_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - gdk.Event 47 * - gtk.Entry 48 * structWrap: 49 * - GdkEvent* -> Event 50 * - GtkEntry* -> Entry 51 * module aliases: 52 * local aliases: 53 * overrides: 54 */ 55 56 module gtk.SearchBar; 57 58 public import gtkc.gtktypes; 59 60 private import gtkc.gtk; 61 private import glib.ConstructionException; 62 private import gobject.ObjectG; 63 64 private import gdk.Event; 65 private import gtk.Entry; 66 67 68 private import gtk.Bin; 69 70 /** 71 * GtkSearchBar is a container made to have a search entry (possibly 72 * with additional connex widgets, such as drop-down menus, or buttons) 73 * built-in. The search bar would appear when a search is started through 74 * typing on the keyboard, or the application's search mode is toggled on. 75 * 76 * For keyboard presses to start a search, events will need to be 77 * forwarded from the top-level window that contains the search bar. 78 * See gtk_search_bar_handle_event() for example code. Common shortcuts 79 * such as Ctrl+F should be handled as an application action, or through 80 * the menu items. 81 * 82 * You will also need to tell the search bar about which entry you 83 * are using as your search entry using gtk_search_bar_connect_entry(). 84 * The following example shows you how to create a more complex search 85 * entry. 86 * 87 * $(DDOC_COMMENT example) 88 */ 89 public class SearchBar : Bin 90 { 91 92 /** the main Gtk struct */ 93 protected GtkSearchBar* gtkSearchBar; 94 95 96 /** Get the main Gtk struct */ 97 public GtkSearchBar* getSearchBarStruct() 98 { 99 return gtkSearchBar; 100 } 101 102 103 /** the main Gtk struct as a void* */ 104 protected override void* getStruct() 105 { 106 return cast(void*)gtkSearchBar; 107 } 108 109 /** 110 * Sets our main struct and passes it to the parent class 111 */ 112 public this (GtkSearchBar* gtkSearchBar) 113 { 114 super(cast(GtkBin*)gtkSearchBar); 115 this.gtkSearchBar = gtkSearchBar; 116 } 117 118 protected override void setStruct(GObject* obj) 119 { 120 super.setStruct(obj); 121 gtkSearchBar = cast(GtkSearchBar*)obj; 122 } 123 124 /** 125 */ 126 127 /** 128 * Creates a GtkSearchBar. You will need to tell it about 129 * which widget is going to be your text entry using 130 * gtk_search_bar_set_entry(). 131 * Throws: ConstructionException GTK+ fails to create the object. 132 */ 133 public this () 134 { 135 // GtkWidget * gtk_search_bar_new (void); 136 auto p = gtk_search_bar_new(); 137 if(p is null) 138 { 139 throw new ConstructionException("null returned by gtk_search_bar_new()"); 140 } 141 this(cast(GtkSearchBar*) p); 142 } 143 144 /** 145 * Connects the GtkEntry widget passed as the one to be used in 146 * this search bar. The entry should be a descendant of the search bar. 147 * This is only required if the entry isn't the direct child of the 148 * search bar (as in our main example). 149 * Params: 150 * entry = a GtkEntry 151 * Since 3.10 152 */ 153 public void connectEntry(Entry entry) 154 { 155 // void gtk_search_bar_connect_entry (GtkSearchBar *bar, GtkEntry *entry); 156 gtk_search_bar_connect_entry(gtkSearchBar, (entry is null) ? null : entry.getEntryStruct()); 157 } 158 159 /** 160 * Returns whether the search mode is on or off. 161 * Returns: whether search mode is toggled on Since 3.10 162 */ 163 public int getSearchMode() 164 { 165 // gboolean gtk_search_bar_get_search_mode (GtkSearchBar *bar); 166 return gtk_search_bar_get_search_mode(gtkSearchBar); 167 } 168 169 /** 170 * Switches the search mode on or off. 171 * Params: 172 * searchMode = the new state of the search mode 173 * Since 3.10 174 */ 175 public void setSearchMode(int searchMode) 176 { 177 // void gtk_search_bar_set_search_mode (GtkSearchBar *bar, gboolean search_mode); 178 gtk_search_bar_set_search_mode(gtkSearchBar, searchMode); 179 } 180 181 /** 182 * Returns whether the close button is shown. 183 * Returns: whether the close button is shown Since 3.10 184 */ 185 public int getShowCloseButton() 186 { 187 // gboolean gtk_search_bar_get_show_close_button (GtkSearchBar *bar); 188 return gtk_search_bar_get_show_close_button(gtkSearchBar); 189 } 190 191 /** 192 * Shows or hides the close button. Applications that 193 * already have a "search" toggle button should not show a close 194 * button in their search bar, as it duplicates the role of the 195 * toggle button. 196 * Params: 197 * visible = whether the close button will be shown or not 198 * Since 3.10 199 */ 200 public void setShowCloseButton(int visible) 201 { 202 // void gtk_search_bar_set_show_close_button (GtkSearchBar *bar, gboolean visible); 203 gtk_search_bar_set_show_close_button(gtkSearchBar, visible); 204 } 205 206 /** 207 * This function should be called when the top-level 208 * window which contains the search bar received a key event. 209 * If the key event is handled by the search bar, the bar will 210 * be shown, the entry populated with the entered text and GDK_EVENT_STOP 211 * will be returned. The caller should ensure that events are 212 * not propagated further. 213 * If no entry has been connected to the search bar, using 214 * gtk_search_bar_connect_entry(), this function will return 215 * immediately with a warning. 216 * $(DDOC_COMMENT example) 217 * Params: 218 * event = a GdkEvent containing key press events 219 * Returns: GDK_EVENT_STOP if the key press event resulted in text being entered in the search entry (and revealing the search bar if necessary), GDK_EVENT_PROPAGATE otherwise. Since 3.10 220 */ 221 public int handleEvent(Event event) 222 { 223 // gboolean gtk_search_bar_handle_event (GtkSearchBar *bar, GdkEvent *event); 224 return gtk_search_bar_handle_event(gtkSearchBar, (event is null) ? null : event.getEventStruct()); 225 } 226 }