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  = GtkAppChooserWidget.html
27  * outPack = gtk
28  * outFile = AppChooserWidget
29  * strct   = GtkAppChooserWidget
30  * realStrct=
31  * ctorStrct=
32  * clss    = AppChooserWidget
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- AppChooserIF
40  * prefixes:
41  * 	- gtk_app_chooser_widget_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gio.AppInfo
49  * 	- gtk.Menu
50  * 	- gtk.AppChooserIF
51  * 	- gtk.AppChooserT
52  * structWrap:
53  * 	- GAppInfo* -> AppInfo
54  * 	- GtkMenu* -> Menu
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module gtk.AppChooserWidget;
61 
62 public  import gtkc.gtktypes;
63 
64 private import gtkc.gtk;
65 private import glib.ConstructionException;
66 private import gobject.ObjectG;
67 
68 private import gobject.Signals;
69 public  import gtkc.gdktypes;
70 private import glib.Str;
71 private import gio.AppInfo;
72 private import gtk.Menu;
73 private import gtk.AppChooserIF;
74 private import gtk.AppChooserT;
75 
76 
77 private import gtk.Box;
78 
79 /**
80  * GtkAppChooserWidget is a widget for selecting applications.
81  * It is the main building block for GtkAppChooserDialog. Most
82  * applications only need to use the latter; but you can use
83  * this widget as part of a larger widget if you have special needs.
84  *
85  * GtkAppChooserWidget offers detailed control over what applications
86  * are shown, using the
87  * "show-default",
88  * "show-recommended",
89  * "show-fallback",
90  * "show-other" and
91  * "show-all"
92  * properties. See the GtkAppChooser documentation for more information
93  * about these groups of applications.
94  *
95  * To keep track of the selected application, use the
96  * "application-selected" and "application-activated" signals.
97  */
98 public class AppChooserWidget : Box, AppChooserIF
99 {
100 	
101 	/** the main Gtk struct */
102 	protected GtkAppChooserWidget* gtkAppChooserWidget;
103 	
104 	
105 	/** Get the main Gtk struct */
106 	public GtkAppChooserWidget* getAppChooserWidgetStruct()
107 	{
108 		return gtkAppChooserWidget;
109 	}
110 	
111 	
112 	/** the main Gtk struct as a void* */
113 	protected override void* getStruct()
114 	{
115 		return cast(void*)gtkAppChooserWidget;
116 	}
117 	
118 	/**
119 	 * Sets our main struct and passes it to the parent class
120 	 */
121 	public this (GtkAppChooserWidget* gtkAppChooserWidget)
122 	{
123 		super(cast(GtkBox*)gtkAppChooserWidget);
124 		this.gtkAppChooserWidget = gtkAppChooserWidget;
125 	}
126 	
127 	protected override void setStruct(GObject* obj)
128 	{
129 		super.setStruct(obj);
130 		gtkAppChooserWidget = cast(GtkAppChooserWidget*)obj;
131 	}
132 	
133 	// add the AppChooser capabilities
134 	mixin AppChooserT!(GtkAppChooserWidget);
135 	
136 	/**
137 	 */
138 	int[string] connectedSignals;
139 	
140 	void delegate(AppInfo, AppChooserWidget)[] onApplicationActivatedListeners;
141 	/**
142 	 * Emitted when an application item is activated from the widget's list.
143 	 * This usually happens when the user double clicks an item, or an item
144 	 * is selected and the user presses one of the keys Space, Shift+Space,
145 	 * Return or Enter.
146 	 */
147 	void addOnApplicationActivated(void delegate(AppInfo, AppChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
148 	{
149 		if ( !("application-activated" in connectedSignals) )
150 		{
151 			Signals.connectData(
152 			getStruct(),
153 			"application-activated",
154 			cast(GCallback)&callBackApplicationActivated,
155 			cast(void*)this,
156 			null,
157 			connectFlags);
158 			connectedSignals["application-activated"] = 1;
159 		}
160 		onApplicationActivatedListeners ~= dlg;
161 	}
162 	extern(C) static void callBackApplicationActivated(GtkAppChooserWidget* selfStruct, GAppInfo* application, AppChooserWidget _appChooserWidget)
163 	{
164 		foreach ( void delegate(AppInfo, AppChooserWidget) dlg ; _appChooserWidget.onApplicationActivatedListeners )
165 		{
166 			dlg(ObjectG.getDObject!(AppInfo)(application), _appChooserWidget);
167 		}
168 	}
169 	
170 	void delegate(AppInfo, AppChooserWidget)[] onApplicationSelectedListeners;
171 	/**
172 	 * Emitted when an application item is selected from the widget's list.
173 	 */
174 	void addOnApplicationSelected(void delegate(AppInfo, AppChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
175 	{
176 		if ( !("application-selected" in connectedSignals) )
177 		{
178 			Signals.connectData(
179 			getStruct(),
180 			"application-selected",
181 			cast(GCallback)&callBackApplicationSelected,
182 			cast(void*)this,
183 			null,
184 			connectFlags);
185 			connectedSignals["application-selected"] = 1;
186 		}
187 		onApplicationSelectedListeners ~= dlg;
188 	}
189 	extern(C) static void callBackApplicationSelected(GtkAppChooserWidget* selfStruct, GAppInfo* application, AppChooserWidget _appChooserWidget)
190 	{
191 		foreach ( void delegate(AppInfo, AppChooserWidget) dlg ; _appChooserWidget.onApplicationSelectedListeners )
192 		{
193 			dlg(ObjectG.getDObject!(AppInfo)(application), _appChooserWidget);
194 		}
195 	}
196 	
197 	void delegate(Menu, AppInfo, AppChooserWidget)[] onPopulatePopupListeners;
198 	/**
199 	 * Emitted when a context menu is about to popup over an application item.
200 	 * Clients can insert menu items into the provided GtkMenu object in the
201 	 * callback of this signal; the context menu will be shown over the item
202 	 * if at least one item has been added to the menu.
203 	 */
204 	void addOnPopulatePopup(void delegate(Menu, AppInfo, AppChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
205 	{
206 		if ( !("populate-popup" in connectedSignals) )
207 		{
208 			Signals.connectData(
209 			getStruct(),
210 			"populate-popup",
211 			cast(GCallback)&callBackPopulatePopup,
212 			cast(void*)this,
213 			null,
214 			connectFlags);
215 			connectedSignals["populate-popup"] = 1;
216 		}
217 		onPopulatePopupListeners ~= dlg;
218 	}
219 	extern(C) static void callBackPopulatePopup(GtkAppChooserWidget* selfStruct, GtkMenu* menu, GAppInfo* application, AppChooserWidget _appChooserWidget)
220 	{
221 		foreach ( void delegate(Menu, AppInfo, AppChooserWidget) dlg ; _appChooserWidget.onPopulatePopupListeners )
222 		{
223 			dlg(ObjectG.getDObject!(Menu)(menu), ObjectG.getDObject!(AppInfo)(application), _appChooserWidget);
224 		}
225 	}
226 	
227 	
228 	/**
229 	 * Creates a new GtkAppChooserWidget for applications
230 	 * that can handle content of the given type.
231 	 * Params:
232 	 * contentType = the content type to show applications for
233 	 * Throws: ConstructionException GTK+ fails to create the object.
234 	 */
235 	public this (string contentType)
236 	{
237 		// GtkWidget * gtk_app_chooser_widget_new (const gchar *content_type);
238 		auto p = gtk_app_chooser_widget_new(Str.toStringz(contentType));
239 		if(p is null)
240 		{
241 			throw new ConstructionException("null returned by gtk_app_chooser_widget_new(Str.toStringz(contentType))");
242 		}
243 		this(cast(GtkAppChooserWidget*) p);
244 	}
245 	
246 	/**
247 	 * Sets whether the app chooser should show the default handler
248 	 * for the content type in a separate section.
249 	 * Params:
250 	 * setting = the new value for "show-default"
251 	 * Since 3.0
252 	 */
253 	public void setShowDefault(int setting)
254 	{
255 		// void gtk_app_chooser_widget_set_show_default  (GtkAppChooserWidget *self,  gboolean setting);
256 		gtk_app_chooser_widget_set_show_default(gtkAppChooserWidget, setting);
257 	}
258 	
259 	/**
260 	 * Returns the current value of the "show-default"
261 	 * property.
262 	 * Returns: the value of "show-default" Since 3.0
263 	 */
264 	public int getShowDefault()
265 	{
266 		// gboolean gtk_app_chooser_widget_get_show_default  (GtkAppChooserWidget *self);
267 		return gtk_app_chooser_widget_get_show_default(gtkAppChooserWidget);
268 	}
269 	
270 	/**
271 	 * Sets whether the app chooser should show recommended applications
272 	 * for the content type in a separate section.
273 	 * Params:
274 	 * setting = the new value for "show-recommended"
275 	 * Since 3.0
276 	 */
277 	public void setShowRecommended(int setting)
278 	{
279 		// void gtk_app_chooser_widget_set_show_recommended  (GtkAppChooserWidget *self,  gboolean setting);
280 		gtk_app_chooser_widget_set_show_recommended(gtkAppChooserWidget, setting);
281 	}
282 	
283 	/**
284 	 * Returns the current value of the "show-recommended"
285 	 * property.
286 	 * Returns: the value of "show-recommended" Since 3.0
287 	 */
288 	public int getShowRecommended()
289 	{
290 		// gboolean gtk_app_chooser_widget_get_show_recommended  (GtkAppChooserWidget *self);
291 		return gtk_app_chooser_widget_get_show_recommended(gtkAppChooserWidget);
292 	}
293 	
294 	/**
295 	 * Sets whether the app chooser should show related applications
296 	 * for the content type in a separate section.
297 	 * Params:
298 	 * setting = the new value for "show-fallback"
299 	 * Since 3.0
300 	 */
301 	public void setShowFallback(int setting)
302 	{
303 		// void gtk_app_chooser_widget_set_show_fallback  (GtkAppChooserWidget *self,  gboolean setting);
304 		gtk_app_chooser_widget_set_show_fallback(gtkAppChooserWidget, setting);
305 	}
306 	
307 	/**
308 	 * Returns the current value of the "show-fallback"
309 	 * property.
310 	 * Returns: the value of "show-fallback" Since 3.0
311 	 */
312 	public int getShowFallback()
313 	{
314 		// gboolean gtk_app_chooser_widget_get_show_fallback  (GtkAppChooserWidget *self);
315 		return gtk_app_chooser_widget_get_show_fallback(gtkAppChooserWidget);
316 	}
317 	
318 	/**
319 	 * Sets whether the app chooser should show applications
320 	 * which are unrelated to the content type.
321 	 * Params:
322 	 * setting = the new value for "show-other"
323 	 * Since 3.0
324 	 */
325 	public void setShowOther(int setting)
326 	{
327 		// void gtk_app_chooser_widget_set_show_other  (GtkAppChooserWidget *self,  gboolean setting);
328 		gtk_app_chooser_widget_set_show_other(gtkAppChooserWidget, setting);
329 	}
330 	
331 	/**
332 	 * Returns the current value of the "show-other"
333 	 * property.
334 	 * Returns: the value of "show-other" Since 3.0
335 	 */
336 	public int getShowOther()
337 	{
338 		// gboolean gtk_app_chooser_widget_get_show_other  (GtkAppChooserWidget *self);
339 		return gtk_app_chooser_widget_get_show_other(gtkAppChooserWidget);
340 	}
341 	
342 	/**
343 	 * Sets whether the app chooser should show all applications
344 	 * in a flat list.
345 	 * Params:
346 	 * setting = the new value for "show-all"
347 	 * Since 3.0
348 	 */
349 	public void setShowAll(int setting)
350 	{
351 		// void gtk_app_chooser_widget_set_show_all (GtkAppChooserWidget *self,  gboolean setting);
352 		gtk_app_chooser_widget_set_show_all(gtkAppChooserWidget, setting);
353 	}
354 	
355 	/**
356 	 * Returns the current value of the "show-all"
357 	 * property.
358 	 * Returns: the value of "show-all" Since 3.0
359 	 */
360 	public int getShowAll()
361 	{
362 		// gboolean gtk_app_chooser_widget_get_show_all (GtkAppChooserWidget *self);
363 		return gtk_app_chooser_widget_get_show_all(gtkAppChooserWidget);
364 	}
365 	
366 	/**
367 	 * Sets the text that is shown if there are not applications
368 	 * that can handle the content type.
369 	 * Params:
370 	 * text = the new value for "default-text"
371 	 */
372 	public void setDefaultText(string text)
373 	{
374 		// void gtk_app_chooser_widget_set_default_text  (GtkAppChooserWidget *self,  const gchar *text);
375 		gtk_app_chooser_widget_set_default_text(gtkAppChooserWidget, Str.toStringz(text));
376 	}
377 	
378 	/**
379 	 * Returns the text that is shown if there are not applications
380 	 * that can handle the content type.
381 	 * Returns: the value of "default-text" Since 3.0
382 	 */
383 	public string getDefaultText()
384 	{
385 		// const gchar * gtk_app_chooser_widget_get_default_text  (GtkAppChooserWidget *self);
386 		return Str.toString(gtk_app_chooser_widget_get_default_text(gtkAppChooserWidget));
387 	}
388 }