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