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.AppChooserButton;
26 
27 private import gio.IconIF;
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  * The `GtkAppChooserButton` lets the user select an application.
43  * 
44  * ![An example GtkAppChooserButton](appchooserbutton.png)
45  * 
46  * Initially, a `GtkAppChooserButton` selects the first application
47  * in its list, which will either be the most-recently used application
48  * or, if [property@Gtk.AppChooserButton:show-default-item] is %TRUE, the
49  * default application.
50  * 
51  * The list of applications shown in a `GtkAppChooserButton` includes
52  * the recommended applications for the given content type. When
53  * [property@Gtk.AppChooserButton:show-default-item] is set, the default
54  * application is also included. To let the user chooser other applications,
55  * you can set the [property@Gtk.AppChooserButton:show-dialog-item] property,
56  * which allows to open a full [class@Gtk.AppChooserDialog].
57  * 
58  * It is possible to add custom items to the list, using
59  * [method@Gtk.AppChooserButton.append_custom_item]. These items cause
60  * the [signal@Gtk.AppChooserButton::custom-item-activated] signal to be
61  * emitted when they are selected.
62  * 
63  * To track changes in the selected application, use the
64  * [signal@Gtk.AppChooserButton::changed] signal.
65  * 
66  * # CSS nodes
67  * 
68  * `GtkAppChooserButton` has a single CSS node with the name “appchooserbutton”.
69  */
70 public class AppChooserButton : Widget, AppChooserIF
71 {
72 	/** the main Gtk struct */
73 	protected GtkAppChooserButton* gtkAppChooserButton;
74 
75 	/** Get the main Gtk struct */
76 	public GtkAppChooserButton* getAppChooserButtonStruct(bool transferOwnership = false)
77 	{
78 		if (transferOwnership)
79 			ownedRef = false;
80 		return gtkAppChooserButton;
81 	}
82 
83 	/** the main Gtk struct as a void* */
84 	protected override void* getStruct()
85 	{
86 		return cast(void*)gtkAppChooserButton;
87 	}
88 
89 	/**
90 	 * Sets our main struct and passes it to the parent class.
91 	 */
92 	public this (GtkAppChooserButton* gtkAppChooserButton, bool ownedRef = false)
93 	{
94 		this.gtkAppChooserButton = gtkAppChooserButton;
95 		super(cast(GtkWidget*)gtkAppChooserButton, ownedRef);
96 	}
97 
98 	// add the AppChooser capabilities
99 	mixin AppChooserT!(GtkAppChooserButton);
100 
101 
102 	/** */
103 	public static GType getType()
104 	{
105 		return gtk_app_chooser_button_get_type();
106 	}
107 
108 	/**
109 	 * Creates a new `GtkAppChooserButton` for applications
110 	 * that can handle content of the given type.
111 	 *
112 	 * Params:
113 	 *     contentType = the content type to show applications for
114 	 *
115 	 * Returns: a newly created `GtkAppChooserButton`
116 	 *
117 	 * Throws: ConstructionException GTK+ fails to create the object.
118 	 */
119 	public this(string contentType)
120 	{
121 		auto __p = gtk_app_chooser_button_new(Str.toStringz(contentType));
122 
123 		if(__p is null)
124 		{
125 			throw new ConstructionException("null returned by new");
126 		}
127 
128 		this(cast(GtkAppChooserButton*) __p);
129 	}
130 
131 	/**
132 	 * Appends a custom item to the list of applications that is shown
133 	 * in the popup.
134 	 *
135 	 * The item name must be unique per-widget. Clients can use the
136 	 * provided name as a detail for the
137 	 * [signal@Gtk.AppChooserButton::custom-item-activated] signal, to add a
138 	 * callback for the activation of a particular custom item in the list.
139 	 *
140 	 * See also [method@Gtk.AppChooserButton.append_separator].
141 	 *
142 	 * Params:
143 	 *     name = the name of the custom item
144 	 *     label = the label for the custom item
145 	 *     icon = the icon for the custom item
146 	 */
147 	public void appendCustomItem(string name, string label, IconIF icon)
148 	{
149 		gtk_app_chooser_button_append_custom_item(gtkAppChooserButton, Str.toStringz(name), Str.toStringz(label), (icon is null) ? null : icon.getIconStruct());
150 	}
151 
152 	/**
153 	 * Appends a separator to the list of applications that is shown
154 	 * in the popup.
155 	 */
156 	public void appendSeparator()
157 	{
158 		gtk_app_chooser_button_append_separator(gtkAppChooserButton);
159 	}
160 
161 	/**
162 	 * Returns the text to display at the top of the dialog.
163 	 *
164 	 * Returns: the text to display at the top of the dialog,
165 	 *     or %NULL, in which case a default text is displayed
166 	 */
167 	public string getHeading()
168 	{
169 		return Str.toString(gtk_app_chooser_button_get_heading(gtkAppChooserButton));
170 	}
171 
172 	/**
173 	 * Gets whether the dialog is modal.
174 	 *
175 	 * Returns: %TRUE if the dialog is modal
176 	 */
177 	public bool getModal()
178 	{
179 		return gtk_app_chooser_button_get_modal(gtkAppChooserButton) != 0;
180 	}
181 
182 	/**
183 	 * Returns whether the dropdown menu should show the default
184 	 * application at the top.
185 	 *
186 	 * Returns: the value of [property@Gtk.AppChooserButton:show-default-item]
187 	 */
188 	public bool getShowDefaultItem()
189 	{
190 		return gtk_app_chooser_button_get_show_default_item(gtkAppChooserButton) != 0;
191 	}
192 
193 	/**
194 	 * Returns whether the dropdown menu shows an item
195 	 * for a `GtkAppChooserDialog`.
196 	 *
197 	 * Returns: the value of [property@Gtk.AppChooserButton:show-dialog-item]
198 	 */
199 	public bool getShowDialogItem()
200 	{
201 		return gtk_app_chooser_button_get_show_dialog_item(gtkAppChooserButton) != 0;
202 	}
203 
204 	/**
205 	 * Selects a custom item.
206 	 *
207 	 * See [method@Gtk.AppChooserButton.append_custom_item].
208 	 *
209 	 * Use [method@Gtk.AppChooser.refresh] to bring the selection
210 	 * to its initial state.
211 	 *
212 	 * Params:
213 	 *     name = the name of the custom item
214 	 */
215 	public void setActiveCustomItem(string name)
216 	{
217 		gtk_app_chooser_button_set_active_custom_item(gtkAppChooserButton, Str.toStringz(name));
218 	}
219 
220 	/**
221 	 * Sets the text to display at the top of the dialog.
222 	 *
223 	 * If the heading is not set, the dialog displays a default text.
224 	 *
225 	 * Params:
226 	 *     heading = a string containing Pango markup
227 	 */
228 	public void setHeading(string heading)
229 	{
230 		gtk_app_chooser_button_set_heading(gtkAppChooserButton, Str.toStringz(heading));
231 	}
232 
233 	/**
234 	 * Sets whether the dialog should be modal.
235 	 *
236 	 * Params:
237 	 *     modal = %TRUE to make the dialog modal
238 	 */
239 	public void setModal(bool modal)
240 	{
241 		gtk_app_chooser_button_set_modal(gtkAppChooserButton, modal);
242 	}
243 
244 	/**
245 	 * Sets whether the dropdown menu of this button should show the
246 	 * default application for the given content type at top.
247 	 *
248 	 * Params:
249 	 *     setting = the new value for [property@Gtk.AppChooserButton:show-default-item]
250 	 */
251 	public void setShowDefaultItem(bool setting)
252 	{
253 		gtk_app_chooser_button_set_show_default_item(gtkAppChooserButton, setting);
254 	}
255 
256 	/**
257 	 * Sets whether the dropdown menu of this button should show an
258 	 * entry to trigger a `GtkAppChooserDialog`.
259 	 *
260 	 * Params:
261 	 *     setting = the new value for [property@Gtk.AppChooserButton:show-dialog-item]
262 	 */
263 	public void setShowDialogItem(bool setting)
264 	{
265 		gtk_app_chooser_button_set_show_dialog_item(gtkAppChooserButton, setting);
266 	}
267 
268 	/**
269 	 * Emitted when the active application changes.
270 	 */
271 	gulong addOnChanged(void delegate(AppChooserButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
272 	{
273 		return Signals.connect(this, "changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
274 	}
275 
276 	/**
277 	 * Emitted when a custom item is activated.
278 	 *
279 	 * Use [method@Gtk.AppChooserButton.append_custom_item],
280 	 * to add custom items.
281 	 *
282 	 * Params:
283 	 *     itemName = the name of the activated item
284 	 */
285 	gulong addOnCustomItemActivated(void delegate(string, AppChooserButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
286 	{
287 		return Signals.connect(this, "custom-item-activated", dlg, connectFlags ^ ConnectFlags.SWAPPED);
288 	}
289 }