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.AppChooserWidget;
26 
27 private import gio.AppInfoIF;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gobject.Signals;
32 private import gtk.AppChooserIF;
33 private import gtk.AppChooserT;
34 private import gtk.Box;
35 private import gtk.Menu;
36 private import gtk.Widget;
37 private import gtk.c.functions;
38 public  import gtk.c.types;
39 public  import gtkc.gtktypes;
40 private import std.algorithm;
41 
42 
43 /**
44  * #GtkAppChooserWidget is a widget for selecting applications.
45  * It is the main building block for #GtkAppChooserDialog. Most
46  * applications only need to use the latter; but you can use
47  * this widget as part of a larger widget if you have special needs.
48  * 
49  * #GtkAppChooserWidget offers detailed control over what applications
50  * are shown, using the
51  * #GtkAppChooserWidget:show-default,
52  * #GtkAppChooserWidget:show-recommended,
53  * #GtkAppChooserWidget:show-fallback,
54  * #GtkAppChooserWidget:show-other and
55  * #GtkAppChooserWidget:show-all
56  * properties. See the #GtkAppChooser documentation for more information
57  * about these groups of applications.
58  * 
59  * To keep track of the selected application, use the
60  * #GtkAppChooserWidget::application-selected and #GtkAppChooserWidget::application-activated signals.
61  * 
62  * # CSS nodes
63  * 
64  * GtkAppChooserWidget has a single CSS node with name appchooser.
65  */
66 public class AppChooserWidget : Box, AppChooserIF
67 {
68 	/** the main Gtk struct */
69 	protected GtkAppChooserWidget* gtkAppChooserWidget;
70 
71 	/** Get the main Gtk struct */
72 	public GtkAppChooserWidget* getAppChooserWidgetStruct(bool transferOwnership = false)
73 	{
74 		if (transferOwnership)
75 			ownedRef = false;
76 		return gtkAppChooserWidget;
77 	}
78 
79 	/** the main Gtk struct as a void* */
80 	protected override void* getStruct()
81 	{
82 		return cast(void*)gtkAppChooserWidget;
83 	}
84 
85 	/**
86 	 * Sets our main struct and passes it to the parent class.
87 	 */
88 	public this (GtkAppChooserWidget* gtkAppChooserWidget, bool ownedRef = false)
89 	{
90 		this.gtkAppChooserWidget = gtkAppChooserWidget;
91 		super(cast(GtkBox*)gtkAppChooserWidget, ownedRef);
92 	}
93 
94 	// add the AppChooser capabilities
95 	mixin AppChooserT!(GtkAppChooserWidget);
96 
97 
98 	/** */
99 	public static GType getType()
100 	{
101 		return gtk_app_chooser_widget_get_type();
102 	}
103 
104 	/**
105 	 * Creates a new #GtkAppChooserWidget for applications
106 	 * that can handle content of the given type.
107 	 *
108 	 * Params:
109 	 *     contentType = the content type to show applications for
110 	 *
111 	 * Returns: a newly created #GtkAppChooserWidget
112 	 *
113 	 * Since: 3.0
114 	 *
115 	 * Throws: ConstructionException GTK+ fails to create the object.
116 	 */
117 	public this(string contentType)
118 	{
119 		auto p = gtk_app_chooser_widget_new(Str.toStringz(contentType));
120 
121 		if(p is null)
122 		{
123 			throw new ConstructionException("null returned by new");
124 		}
125 
126 		this(cast(GtkAppChooserWidget*) p);
127 	}
128 
129 	/**
130 	 * Returns the text that is shown if there are not applications
131 	 * that can handle the content type.
132 	 *
133 	 * Returns: the value of #GtkAppChooserWidget:default-text
134 	 *
135 	 * Since: 3.0
136 	 */
137 	public string getDefaultText()
138 	{
139 		return Str.toString(gtk_app_chooser_widget_get_default_text(gtkAppChooserWidget));
140 	}
141 
142 	/**
143 	 * Returns the current value of the #GtkAppChooserWidget:show-all
144 	 * property.
145 	 *
146 	 * Returns: the value of #GtkAppChooserWidget:show-all
147 	 *
148 	 * Since: 3.0
149 	 */
150 	public bool getShowAll()
151 	{
152 		return gtk_app_chooser_widget_get_show_all(gtkAppChooserWidget) != 0;
153 	}
154 
155 	/**
156 	 * Returns the current value of the #GtkAppChooserWidget:show-default
157 	 * property.
158 	 *
159 	 * Returns: the value of #GtkAppChooserWidget:show-default
160 	 *
161 	 * Since: 3.0
162 	 */
163 	public bool getShowDefault()
164 	{
165 		return gtk_app_chooser_widget_get_show_default(gtkAppChooserWidget) != 0;
166 	}
167 
168 	/**
169 	 * Returns the current value of the #GtkAppChooserWidget:show-fallback
170 	 * property.
171 	 *
172 	 * Returns: the value of #GtkAppChooserWidget:show-fallback
173 	 *
174 	 * Since: 3.0
175 	 */
176 	public bool getShowFallback()
177 	{
178 		return gtk_app_chooser_widget_get_show_fallback(gtkAppChooserWidget) != 0;
179 	}
180 
181 	/**
182 	 * Returns the current value of the #GtkAppChooserWidget:show-other
183 	 * property.
184 	 *
185 	 * Returns: the value of #GtkAppChooserWidget:show-other
186 	 *
187 	 * Since: 3.0
188 	 */
189 	public bool getShowOther()
190 	{
191 		return gtk_app_chooser_widget_get_show_other(gtkAppChooserWidget) != 0;
192 	}
193 
194 	/**
195 	 * Returns the current value of the #GtkAppChooserWidget:show-recommended
196 	 * property.
197 	 *
198 	 * Returns: the value of #GtkAppChooserWidget:show-recommended
199 	 *
200 	 * Since: 3.0
201 	 */
202 	public bool getShowRecommended()
203 	{
204 		return gtk_app_chooser_widget_get_show_recommended(gtkAppChooserWidget) != 0;
205 	}
206 
207 	/**
208 	 * Sets the text that is shown if there are not applications
209 	 * that can handle the content type.
210 	 *
211 	 * Params:
212 	 *     text = the new value for #GtkAppChooserWidget:default-text
213 	 */
214 	public void setDefaultText(string text)
215 	{
216 		gtk_app_chooser_widget_set_default_text(gtkAppChooserWidget, Str.toStringz(text));
217 	}
218 
219 	/**
220 	 * Sets whether the app chooser should show all applications
221 	 * in a flat list.
222 	 *
223 	 * Params:
224 	 *     setting = the new value for #GtkAppChooserWidget:show-all
225 	 *
226 	 * Since: 3.0
227 	 */
228 	public void setShowAll(bool setting)
229 	{
230 		gtk_app_chooser_widget_set_show_all(gtkAppChooserWidget, setting);
231 	}
232 
233 	/**
234 	 * Sets whether the app chooser should show the default handler
235 	 * for the content type in a separate section.
236 	 *
237 	 * Params:
238 	 *     setting = the new value for #GtkAppChooserWidget:show-default
239 	 *
240 	 * Since: 3.0
241 	 */
242 	public void setShowDefault(bool setting)
243 	{
244 		gtk_app_chooser_widget_set_show_default(gtkAppChooserWidget, setting);
245 	}
246 
247 	/**
248 	 * Sets whether the app chooser should show related applications
249 	 * for the content type in a separate section.
250 	 *
251 	 * Params:
252 	 *     setting = the new value for #GtkAppChooserWidget:show-fallback
253 	 *
254 	 * Since: 3.0
255 	 */
256 	public void setShowFallback(bool setting)
257 	{
258 		gtk_app_chooser_widget_set_show_fallback(gtkAppChooserWidget, setting);
259 	}
260 
261 	/**
262 	 * Sets whether the app chooser should show applications
263 	 * which are unrelated to the content type.
264 	 *
265 	 * Params:
266 	 *     setting = the new value for #GtkAppChooserWidget:show-other
267 	 *
268 	 * Since: 3.0
269 	 */
270 	public void setShowOther(bool setting)
271 	{
272 		gtk_app_chooser_widget_set_show_other(gtkAppChooserWidget, setting);
273 	}
274 
275 	/**
276 	 * Sets whether the app chooser should show recommended applications
277 	 * for the content type in a separate section.
278 	 *
279 	 * Params:
280 	 *     setting = the new value for #GtkAppChooserWidget:show-recommended
281 	 *
282 	 * Since: 3.0
283 	 */
284 	public void setShowRecommended(bool setting)
285 	{
286 		gtk_app_chooser_widget_set_show_recommended(gtkAppChooserWidget, setting);
287 	}
288 
289 	/**
290 	 * Emitted when an application item is activated from the widget's list.
291 	 *
292 	 * This usually happens when the user double clicks an item, or an item
293 	 * is selected and the user presses one of the keys Space, Shift+Space,
294 	 * Return or Enter.
295 	 *
296 	 * Params:
297 	 *     application = the activated #GAppInfo
298 	 */
299 	gulong addOnApplicationActivated(void delegate(AppInfoIF, AppChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
300 	{
301 		return Signals.connect(this, "application-activated", dlg, connectFlags ^ ConnectFlags.SWAPPED);
302 	}
303 
304 	/**
305 	 * Emitted when an application item is selected from the widget's list.
306 	 *
307 	 * Params:
308 	 *     application = the selected #GAppInfo
309 	 */
310 	gulong addOnApplicationSelected(void delegate(AppInfoIF, AppChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
311 	{
312 		return Signals.connect(this, "application-selected", dlg, connectFlags ^ ConnectFlags.SWAPPED);
313 	}
314 
315 	/**
316 	 * Emitted when a context menu is about to popup over an application item.
317 	 * Clients can insert menu items into the provided #GtkMenu object in the
318 	 * callback of this signal; the context menu will be shown over the item
319 	 * if at least one item has been added to the menu.
320 	 *
321 	 * Params:
322 	 *     menu = the #GtkMenu to populate
323 	 *     application = the current #GAppInfo
324 	 */
325 	gulong addOnPopulatePopup(void delegate(Menu, AppInfoIF, AppChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
326 	{
327 		return Signals.connect(this, "populate-popup", dlg, connectFlags ^ ConnectFlags.SWAPPED);
328 	}
329 }