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  = GtkAppChooserButton.html
27  * outPack = gtk
28  * outFile = AppChooserButton
29  * strct   = GtkAppChooserButton
30  * realStrct=
31  * ctorStrct=
32  * clss    = AppChooserButton
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_button_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gio.IconIF
49  * 	- gtk.AppChooserIF
50  * 	- gtk.AppChooserT
51  * structWrap:
52  * 	- GIcon* -> IconIF
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module gtk.AppChooserButton;
59 
60 public  import gtkc.gtktypes;
61 
62 private import gtkc.gtk;
63 private import glib.ConstructionException;
64 private import gobject.ObjectG;
65 
66 private import gobject.Signals;
67 public  import gtkc.gdktypes;
68 
69 private import glib.Str;
70 private import gio.IconIF;
71 private import gtk.AppChooserIF;
72 private import gtk.AppChooserT;
73 
74 
75 
76 private import gtk.ComboBox;
77 
78 /**
79  * The GtkAppChooserButton is a widget that lets the user select
80  * an application. It implements the GtkAppChooser interface.
81  *
82  * Initially, a GtkAppChooserButton selects the first application
83  * in its list, which will either be the most-recently used application
84  * or, if "show-default-item" is TRUE, the
85  * default application.
86  *
87  * The list of applications shown in a GtkAppChooserButton includes
88  * the recommended applications for the given content type. When
89  * "show-default-item" is set, the default application
90  * is also included. To let the user chooser other applications,
91  * you can set the "show-dialog-item" property,
92  * which allows to open a full GtkAppChooserDialog.
93  *
94  * It is possible to add custom items to the list, using
95  * gtk_app_chooser_button_append_custom_item(). These items cause
96  * the "custom-item-activated" signal to be
97  * emitted when they are selected.
98  *
99  * To track changes in the selected application, use the
100  * "changed" signal.
101  */
102 public class AppChooserButton : ComboBox, AppChooserIF
103 {
104 	
105 	/** the main Gtk struct */
106 	protected GtkAppChooserButton* gtkAppChooserButton;
107 	
108 	
109 	public GtkAppChooserButton* getAppChooserButtonStruct()
110 	{
111 		return gtkAppChooserButton;
112 	}
113 	
114 	
115 	/** the main Gtk struct as a void* */
116 	protected override void* getStruct()
117 	{
118 		return cast(void*)gtkAppChooserButton;
119 	}
120 	
121 	/**
122 	 * Sets our main struct and passes it to the parent class
123 	 */
124 	public this (GtkAppChooserButton* gtkAppChooserButton)
125 	{
126 		super(cast(GtkComboBox*)gtkAppChooserButton);
127 		this.gtkAppChooserButton = gtkAppChooserButton;
128 	}
129 	
130 	protected override void setStruct(GObject* obj)
131 	{
132 		super.setStruct(obj);
133 		gtkAppChooserButton = cast(GtkAppChooserButton*)obj;
134 	}
135 	
136 	// add the AppChooser capabilities
137 	mixin AppChooserT!(GtkAppChooserButton);
138 	
139 	/**
140 	 */
141 	int[string] connectedSignals;
142 	
143 	void delegate(string, AppChooserButton)[] onCustomItemActivatedListeners;
144 	/**
145 	 * Emitted when a custom item, previously added with
146 	 * gtk_app_chooser_button_append_custom_item(), is activated from the
147 	 * dropdown menu.
148 	 */
149 	void addOnCustomItemActivated(void delegate(string, AppChooserButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
150 	{
151 		if ( !("custom-item-activated" in connectedSignals) )
152 		{
153 			Signals.connectData(
154 			getStruct(),
155 			"custom-item-activated",
156 			cast(GCallback)&callBackCustomItemActivated,
157 			cast(void*)this,
158 			null,
159 			connectFlags);
160 			connectedSignals["custom-item-activated"] = 1;
161 		}
162 		onCustomItemActivatedListeners ~= dlg;
163 	}
164 	extern(C) static void callBackCustomItemActivated(GtkAppChooserButton* selfStruct, gchar* itemName, AppChooserButton _appChooserButton)
165 	{
166 		foreach ( void delegate(string, AppChooserButton) dlg ; _appChooserButton.onCustomItemActivatedListeners )
167 		{
168 			dlg(Str.toString(itemName), _appChooserButton);
169 		}
170 	}
171 	
172 	
173 	/**
174 	 * Creates a new GtkAppChooserButton for applications
175 	 * that can handle content of the given type.
176 	 * Params:
177 	 * contentType = the content type to show applications for
178 	 * Throws: ConstructionException GTK+ fails to create the object.
179 	 */
180 	public this (string contentType)
181 	{
182 		// GtkWidget * gtk_app_chooser_button_new (const gchar *content_type);
183 		auto p = gtk_app_chooser_button_new(Str.toStringz(contentType));
184 		if(p is null)
185 		{
186 			throw new ConstructionException("null returned by gtk_app_chooser_button_new(Str.toStringz(contentType))");
187 		}
188 		this(cast(GtkAppChooserButton*) p);
189 	}
190 	
191 	/**
192 	 * Appends a custom item to the list of applications that is shown
193 	 * in the popup; the item name must be unique per-widget.
194 	 * Clients can use the provided name as a detail for the
195 	 * "custom-item-activated" signal, to add a
196 	 * callback for the activation of a particular custom item in the list.
197 	 * See also gtk_app_chooser_button_append_separator().
198 	 * Params:
199 	 * name = the name of the custom item
200 	 * label = the label for the custom item
201 	 * icon = the icon for the custom item
202 	 * Since 3.0
203 	 */
204 	public void appendCustomItem(string name, string label, IconIF icon)
205 	{
206 		// void gtk_app_chooser_button_append_custom_item  (GtkAppChooserButton *self,  const gchar *name,  const gchar *label,  GIcon *icon);
207 		gtk_app_chooser_button_append_custom_item(gtkAppChooserButton, Str.toStringz(name), Str.toStringz(label), (icon is null) ? null : icon.getIconTStruct());
208 	}
209 	
210 	/**
211 	 * Appends a separator to the list of applications that is shown
212 	 * in the popup.
213 	 */
214 	public void appendSeparator()
215 	{
216 		// void gtk_app_chooser_button_append_separator  (GtkAppChooserButton *self);
217 		gtk_app_chooser_button_append_separator(gtkAppChooserButton);
218 	}
219 	
220 	/**
221 	 * Selects a custom item previously added with
222 	 * gtk_app_chooser_button_append_custom_item().
223 	 * Use gtk_app_chooser_refresh() to bring the selection
224 	 * to its initial state.
225 	 * Params:
226 	 * name = the name of the custom item
227 	 * Since 3.0
228 	 */
229 	public void setActiveCustomItem(string name)
230 	{
231 		// void gtk_app_chooser_button_set_active_custom_item  (GtkAppChooserButton *self,  const gchar *name);
232 		gtk_app_chooser_button_set_active_custom_item(gtkAppChooserButton, Str.toStringz(name));
233 	}
234 	
235 	/**
236 	 * Returns the current value of the "show-default-item"
237 	 * property.
238 	 * Returns: the value of "show-default-item" Since 3.2
239 	 */
240 	public int getShowDefaultItem()
241 	{
242 		// gboolean gtk_app_chooser_button_get_show_default_item  (GtkAppChooserButton *self);
243 		return gtk_app_chooser_button_get_show_default_item(gtkAppChooserButton);
244 	}
245 	
246 	/**
247 	 * Sets whether the dropdown menu of this button should show the
248 	 * default application for the given content type at top.
249 	 * Params:
250 	 * setting = the new value for "show-default-item"
251 	 * Since 3.2
252 	 */
253 	public void setShowDefaultItem(int setting)
254 	{
255 		// void gtk_app_chooser_button_set_show_default_item  (GtkAppChooserButton *self,  gboolean setting);
256 		gtk_app_chooser_button_set_show_default_item(gtkAppChooserButton, setting);
257 	}
258 	
259 	/**
260 	 * Returns the current value of the "show-dialog-item"
261 	 * property.
262 	 * Returns: the value of "show-dialog-item" Since 3.0
263 	 */
264 	public int getShowDialogItem()
265 	{
266 		// gboolean gtk_app_chooser_button_get_show_dialog_item  (GtkAppChooserButton *self);
267 		return gtk_app_chooser_button_get_show_dialog_item(gtkAppChooserButton);
268 	}
269 	
270 	/**
271 	 * Sets whether the dropdown menu of this button should show an
272 	 * entry to trigger a GtkAppChooserDialog.
273 	 * Params:
274 	 * setting = the new value for "show-dialog-item"
275 	 * Since 3.0
276 	 */
277 	public void setShowDialogItem(int setting)
278 	{
279 		// void gtk_app_chooser_button_set_show_dialog_item  (GtkAppChooserButton *self,  gboolean setting);
280 		gtk_app_chooser_button_set_show_dialog_item(gtkAppChooserButton, setting);
281 	}
282 	
283 	/**
284 	 * Returns the text to display at the top of the dialog.
285 	 * Returns: the text to display at the top of the dialog, or NULL, in which case a default text is displayed
286 	 */
287 	public string getHeading()
288 	{
289 		// const gchar * gtk_app_chooser_button_get_heading (GtkAppChooserButton *self);
290 		return Str.toString(gtk_app_chooser_button_get_heading(gtkAppChooserButton));
291 	}
292 	
293 	/**
294 	 * Sets the text to display at the top of the dialog.
295 	 * If the heading is not set, the dialog displays a default text.
296 	 * Params:
297 	 * heading = a string containing Pango markup
298 	 */
299 	public void setHeading(string heading)
300 	{
301 		// void gtk_app_chooser_button_set_heading (GtkAppChooserButton *self,  const gchar *heading);
302 		gtk_app_chooser_button_set_heading(gtkAppChooserButton, Str.toStringz(heading));
303 	}
304 }