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