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 glib.c.functions;
31 private import gobject.ObjectG;
32 private import gobject.Signals;
33 private import gtk.AppChooserIF;
34 private import gtk.AppChooserT;
35 private import gtk.Widget;
36 private import gtk.c.functions;
37 public  import gtk.c.types;
38 private import std.algorithm;
39 
40 
41 /**
42  * `GtkAppChooserWidget` is a widget for selecting applications.
43  * 
44  * It is the main building block for [class@Gtk.AppChooserDialog].
45  * Most applications only need to use the latter; but you can use
46  * this widget as part of a larger widget if you have special needs.
47  * 
48  * `GtkAppChooserWidget` offers detailed control over what applications
49  * are shown, using the
50  * [property@Gtk.AppChooserWidget:show-default],
51  * [property@Gtk.AppChooserWidget:show-recommended],
52  * [property@Gtk.AppChooserWidget:show-fallback],
53  * [property@Gtk.AppChooserWidget:show-other] and
54  * [property@Gtk.AppChooserWidget:show-all] properties. See the
55  * [iface@Gtk.AppChooser] documentation for more information about these
56  * groups of applications.
57  * 
58  * To keep track of the selected application, use the
59  * [signal@Gtk.AppChooserWidget::application-selected] and
60  * [signal@Gtk.AppChooserWidget::application-activated] signals.
61  * 
62  * # CSS nodes
63  * 
64  * `GtkAppChooserWidget` has a single CSS node with name appchooser.
65  */
66 public class AppChooserWidget : Widget, 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(GtkWidget*)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 	 * Throws: ConstructionException GTK+ fails to create the object.
114 	 */
115 	public this(string contentType)
116 	{
117 		auto __p = gtk_app_chooser_widget_new(Str.toStringz(contentType));
118 
119 		if(__p is null)
120 		{
121 			throw new ConstructionException("null returned by new");
122 		}
123 
124 		this(cast(GtkAppChooserWidget*) __p);
125 	}
126 
127 	/**
128 	 * Returns the text that is shown if there are not applications
129 	 * that can handle the content type.
130 	 *
131 	 * Returns: the value of [property@Gtk.AppChooserWidget:default-text]
132 	 */
133 	public string getDefaultText()
134 	{
135 		return Str.toString(gtk_app_chooser_widget_get_default_text(gtkAppChooserWidget));
136 	}
137 
138 	/**
139 	 * Gets whether the app chooser should show all applications
140 	 * in a flat list.
141 	 *
142 	 * Returns: the value of [property@Gtk.AppChooserWidget:show-all]
143 	 */
144 	public bool getShowAll()
145 	{
146 		return gtk_app_chooser_widget_get_show_all(gtkAppChooserWidget) != 0;
147 	}
148 
149 	/**
150 	 * Gets whether the app chooser should show the default handler
151 	 * for the content type in a separate section.
152 	 *
153 	 * Returns: the value of [property@Gtk.AppChooserWidget:show-default]
154 	 */
155 	public bool getShowDefault()
156 	{
157 		return gtk_app_chooser_widget_get_show_default(gtkAppChooserWidget) != 0;
158 	}
159 
160 	/**
161 	 * Gets whether the app chooser should show related applications
162 	 * for the content type in a separate section.
163 	 *
164 	 * Returns: the value of [property@Gtk.AppChooserWidget:show-fallback]
165 	 */
166 	public bool getShowFallback()
167 	{
168 		return gtk_app_chooser_widget_get_show_fallback(gtkAppChooserWidget) != 0;
169 	}
170 
171 	/**
172 	 * Gets whether the app chooser should show applications
173 	 * which are unrelated to the content type.
174 	 *
175 	 * Returns: the value of [property@Gtk.AppChooserWidget:show-other]
176 	 */
177 	public bool getShowOther()
178 	{
179 		return gtk_app_chooser_widget_get_show_other(gtkAppChooserWidget) != 0;
180 	}
181 
182 	/**
183 	 * Gets whether the app chooser should show recommended applications
184 	 * for the content type in a separate section.
185 	 *
186 	 * Returns: the value of [property@Gtk.AppChooserWidget:show-recommended]
187 	 */
188 	public bool getShowRecommended()
189 	{
190 		return gtk_app_chooser_widget_get_show_recommended(gtkAppChooserWidget) != 0;
191 	}
192 
193 	/**
194 	 * Sets the text that is shown if there are not applications
195 	 * that can handle the content type.
196 	 *
197 	 * Params:
198 	 *     text = the new value for [property@Gtk.AppChooserWidget:default-text]
199 	 */
200 	public void setDefaultText(string text)
201 	{
202 		gtk_app_chooser_widget_set_default_text(gtkAppChooserWidget, Str.toStringz(text));
203 	}
204 
205 	/**
206 	 * Sets whether the app chooser should show all applications
207 	 * in a flat list.
208 	 *
209 	 * Params:
210 	 *     setting = the new value for [property@Gtk.AppChooserWidget:show-all]
211 	 */
212 	public void setShowAll(bool setting)
213 	{
214 		gtk_app_chooser_widget_set_show_all(gtkAppChooserWidget, setting);
215 	}
216 
217 	/**
218 	 * Sets whether the app chooser should show the default handler
219 	 * for the content type in a separate section.
220 	 *
221 	 * Params:
222 	 *     setting = the new value for [property@Gtk.AppChooserWidget:show-default]
223 	 */
224 	public void setShowDefault(bool setting)
225 	{
226 		gtk_app_chooser_widget_set_show_default(gtkAppChooserWidget, setting);
227 	}
228 
229 	/**
230 	 * Sets whether the app chooser should show related applications
231 	 * for the content type in a separate section.
232 	 *
233 	 * Params:
234 	 *     setting = the new value for [property@Gtk.AppChooserWidget:show-fallback]
235 	 */
236 	public void setShowFallback(bool setting)
237 	{
238 		gtk_app_chooser_widget_set_show_fallback(gtkAppChooserWidget, setting);
239 	}
240 
241 	/**
242 	 * Sets whether the app chooser should show applications
243 	 * which are unrelated to the content type.
244 	 *
245 	 * Params:
246 	 *     setting = the new value for [property@Gtk.AppChooserWidget:show-other]
247 	 */
248 	public void setShowOther(bool setting)
249 	{
250 		gtk_app_chooser_widget_set_show_other(gtkAppChooserWidget, setting);
251 	}
252 
253 	/**
254 	 * Sets whether the app chooser should show recommended applications
255 	 * for the content type in a separate section.
256 	 *
257 	 * Params:
258 	 *     setting = the new value for [property@Gtk.AppChooserWidget:show-recommended]
259 	 */
260 	public void setShowRecommended(bool setting)
261 	{
262 		gtk_app_chooser_widget_set_show_recommended(gtkAppChooserWidget, setting);
263 	}
264 
265 	/**
266 	 * Emitted when an application item is activated from the widget's list.
267 	 *
268 	 * This usually happens when the user double clicks an item, or an item
269 	 * is selected and the user presses one of the keys Space, Shift+Space,
270 	 * Return or Enter.
271 	 *
272 	 * Params:
273 	 *     application = the activated #GAppInfo
274 	 */
275 	gulong addOnApplicationActivated(void delegate(AppInfoIF, AppChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
276 	{
277 		return Signals.connect(this, "application-activated", dlg, connectFlags ^ ConnectFlags.SWAPPED);
278 	}
279 
280 	/**
281 	 * Emitted when an application item is selected from the widget's list.
282 	 *
283 	 * Params:
284 	 *     application = the selected #GAppInfo
285 	 */
286 	gulong addOnApplicationSelected(void delegate(AppInfoIF, AppChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
287 	{
288 		return Signals.connect(this, "application-selected", dlg, connectFlags ^ ConnectFlags.SWAPPED);
289 	}
290 }