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.AppChooserDialog;
26 
27 private import gio.FileIF;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gtk.AppChooserIF;
32 private import gtk.AppChooserT;
33 private import gtk.Dialog;
34 private import gtk.Widget;
35 private import gtk.Window;
36 private import gtkc.gtk;
37 public  import gtkc.gtktypes;
38 
39 
40 /**
41  * #GtkAppChooserDialog shows a #GtkAppChooserWidget inside a #GtkDialog.
42  * 
43  * Note that #GtkAppChooserDialog does not have any interesting methods
44  * of its own. Instead, you should get the embedded #GtkAppChooserWidget
45  * using gtk_app_chooser_dialog_get_widget() and call its methods if
46  * the generic #GtkAppChooser interface is not sufficient for your needs.
47  * 
48  * To set the heading that is shown above the #GtkAppChooserWidget,
49  * use gtk_app_chooser_dialog_set_heading().
50  */
51 public class AppChooserDialog : Dialog, AppChooserIF
52 {
53 	/** the main Gtk struct */
54 	protected GtkAppChooserDialog* gtkAppChooserDialog;
55 
56 	/** Get the main Gtk struct */
57 	public GtkAppChooserDialog* getAppChooserDialogStruct(bool transferOwnership = false)
58 	{
59 		if (transferOwnership)
60 			ownedRef = false;
61 		return gtkAppChooserDialog;
62 	}
63 
64 	/** the main Gtk struct as a void* */
65 	protected override void* getStruct()
66 	{
67 		return cast(void*)gtkAppChooserDialog;
68 	}
69 
70 	protected override void setStruct(GObject* obj)
71 	{
72 		gtkAppChooserDialog = cast(GtkAppChooserDialog*)obj;
73 		super.setStruct(obj);
74 	}
75 
76 	/**
77 	 * Sets our main struct and passes it to the parent class.
78 	 */
79 	public this (GtkAppChooserDialog* gtkAppChooserDialog, bool ownedRef = false)
80 	{
81 		this.gtkAppChooserDialog = gtkAppChooserDialog;
82 		super(cast(GtkDialog*)gtkAppChooserDialog, ownedRef);
83 	}
84 
85 	// add the AppChooser capabilities
86 	mixin AppChooserT!(GtkAppChooserDialog);
87 
88 
89 	/** */
90 	public static GType getType()
91 	{
92 		return gtk_app_chooser_dialog_get_type();
93 	}
94 
95 	/**
96 	 * Creates a new #GtkAppChooserDialog for the provided #GFile,
97 	 * to allow the user to select an application for it.
98 	 *
99 	 * Params:
100 	 *     parent = a #GtkWindow, or %NULL
101 	 *     flags = flags for this dialog
102 	 *     file = a #GFile
103 	 *
104 	 * Returns: a newly created #GtkAppChooserDialog
105 	 *
106 	 * Since: 3.0
107 	 *
108 	 * Throws: ConstructionException GTK+ fails to create the object.
109 	 */
110 	public this(Window parent, GtkDialogFlags flags, FileIF file)
111 	{
112 		auto p = gtk_app_chooser_dialog_new((parent is null) ? null : parent.getWindowStruct(), flags, (file is null) ? null : file.getFileStruct());
113 		
114 		if(p is null)
115 		{
116 			throw new ConstructionException("null returned by new");
117 		}
118 		
119 		this(cast(GtkAppChooserDialog*) p);
120 	}
121 
122 	/**
123 	 * Creates a new #GtkAppChooserDialog for the provided content type,
124 	 * to allow the user to select an application for it.
125 	 *
126 	 * Params:
127 	 *     parent = a #GtkWindow, or %NULL
128 	 *     flags = flags for this dialog
129 	 *     contentType = a content type string
130 	 *
131 	 * Returns: a newly created #GtkAppChooserDialog
132 	 *
133 	 * Since: 3.0
134 	 *
135 	 * Throws: ConstructionException GTK+ fails to create the object.
136 	 */
137 	public this(Window parent, GtkDialogFlags flags, string contentType)
138 	{
139 		auto p = gtk_app_chooser_dialog_new_for_content_type((parent is null) ? null : parent.getWindowStruct(), flags, Str.toStringz(contentType));
140 		
141 		if(p is null)
142 		{
143 			throw new ConstructionException("null returned by new_for_content_type");
144 		}
145 		
146 		this(cast(GtkAppChooserDialog*) p);
147 	}
148 
149 	/**
150 	 * Returns the text to display at the top of the dialog.
151 	 *
152 	 * Returns: the text to display at the top of the dialog, or %NULL, in which
153 	 *     case a default text is displayed
154 	 */
155 	public string getHeading()
156 	{
157 		return Str.toString(gtk_app_chooser_dialog_get_heading(gtkAppChooserDialog));
158 	}
159 
160 	/**
161 	 * Returns the #GtkAppChooserWidget of this dialog.
162 	 *
163 	 * Returns: the #GtkAppChooserWidget of @self
164 	 *
165 	 * Since: 3.0
166 	 */
167 	public Widget getWidget()
168 	{
169 		auto p = gtk_app_chooser_dialog_get_widget(gtkAppChooserDialog);
170 		
171 		if(p is null)
172 		{
173 			return null;
174 		}
175 		
176 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
177 	}
178 
179 	/**
180 	 * Sets the text to display at the top of the dialog.
181 	 * If the heading is not set, the dialog displays a default text.
182 	 *
183 	 * Params:
184 	 *     heading = a string containing Pango markup
185 	 */
186 	public void setHeading(string heading)
187 	{
188 		gtk_app_chooser_dialog_set_heading(gtkAppChooserDialog, Str.toStringz(heading));
189 	}
190 }