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.MessageDialog;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtk.Dialog;
31 private import gtk.VBox;
32 private import gtk.Widget;
33 private import gtk.Window;
34 private import gtkc.gtk;
35 public  import gtkc.gtktypes;
36 
37 
38 /**
39  * #GtkMessageDialog presents a dialog with some message text. It’s simply a
40  * convenience widget; you could construct the equivalent of #GtkMessageDialog
41  * from #GtkDialog without too much effort, but #GtkMessageDialog saves typing.
42  * 
43  * One difference from #GtkDialog is that #GtkMessageDialog sets the
44  * #GtkWindow:skip-taskbar-hint property to %TRUE, so that the dialog is hidden
45  * from the taskbar by default.
46  * 
47  * The easiest way to do a modal message dialog is to use gtk_dialog_run(), though
48  * you can also pass in the %GTK_DIALOG_MODAL flag, gtk_dialog_run() automatically
49  * makes the dialog modal and waits for the user to respond to it. gtk_dialog_run()
50  * returns when any dialog button is clicked.
51  * 
52  * An example for using a modal dialog:
53  * |[<!-- language="C" -->
54  * GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
55  * dialog = gtk_message_dialog_new (parent_window,
56  * flags,
57  * GTK_MESSAGE_ERROR,
58  * GTK_BUTTONS_CLOSE,
59  * "Error reading “%s”: %s",
60  * filename,
61  * g_strerror (errno));
62  * gtk_dialog_run (GTK_DIALOG (dialog));
63  * gtk_widget_destroy (dialog);
64  * ]|
65  * 
66  * You might do a non-modal #GtkMessageDialog as follows:
67  * 
68  * An example for a non-modal dialog:
69  * |[<!-- language="C" -->
70  * GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
71  * dialog = gtk_message_dialog_new (parent_window,
72  * flags,
73  * GTK_MESSAGE_ERROR,
74  * GTK_BUTTONS_CLOSE,
75  * "Error reading “%s”: %s",
76  * filename,
77  * g_strerror (errno));
78  * 
79  * // Destroy the dialog when the user responds to it
80  * // (e.g. clicks a button)
81  * 
82  * g_signal_connect_swapped (dialog, "response",
83  * G_CALLBACK (gtk_widget_destroy),
84  * dialog);
85  * ]|
86  * 
87  * # GtkMessageDialog as GtkBuildable
88  * 
89  * The GtkMessageDialog implementation of the GtkBuildable interface exposes
90  * the message area as an internal child with the name “message_area”.
91  */
92 public class MessageDialog : Dialog
93 {
94 	/** the main Gtk struct */
95 	protected GtkMessageDialog* gtkMessageDialog;
96 
97 	/** Get the main Gtk struct */
98 	public GtkMessageDialog* getMessageDialogStruct()
99 	{
100 		return gtkMessageDialog;
101 	}
102 
103 	/** the main Gtk struct as a void* */
104 	protected override void* getStruct()
105 	{
106 		return cast(void*)gtkMessageDialog;
107 	}
108 
109 	protected override void setStruct(GObject* obj)
110 	{
111 		gtkMessageDialog = cast(GtkMessageDialog*)obj;
112 		super.setStruct(obj);
113 	}
114 
115 	/**
116 	 * Sets our main struct and passes it to the parent class.
117 	 */
118 	public this (GtkMessageDialog* gtkMessageDialog, bool ownedRef = false)
119 	{
120 		this.gtkMessageDialog = gtkMessageDialog;
121 		super(cast(GtkDialog*)gtkMessageDialog, ownedRef);
122 	}
123 
124 	/**
125 	 * Creates a new message dialog, which is a simple dialog with an icon
126 	 * indicating the dialog type (error, warning, etc.) and some text the
127 	 * user may want to see. When the user clicks a button a "response"
128 	 * signal is emitted with response IDs from GtkResponseType. See
129 	 * GtkDialog for more details.
130 	 * Params:
131 	 *    	parent = transient parent, or NULL for none
132 	 *    	flags = flags
133 	 *    	type = type of message
134 	 *    	buttons= set of buttons to use
135 	 *    	messageFormat = printf()-style format string, or NULL
136 	 *    	message = the message - should be null, any formatting should be done prior to call this constructor
137 	 *  arguments for message_format
138 	 * Returns:
139 	 *  a new GtkMessageDialog
140 	 */
141 	public this (Window parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, string messageFormat, string message=null )
142 	{
143 		this(parent, flags, type, buttons, false, messageFormat, message );
144 	}
145 	
146 	/**
147 	 * Creates a new message dialog, which is a simple dialog with an icon
148 	 * indicating the dialog type (error, warning, etc.) and some text which
149 	 * is marked up with the Pango text markup language.
150 	 * When the user clicks a button a "response" signal is emitted with
151 	 * response IDs from GtkResponseType. See GtkDialog for more details.
152 	 *
153 	 * If Markup is true special XML characters in the printf() arguments passed to this
154 	 * function will automatically be escaped as necessary.
155 	 * (See g_markup_printf_escaped() for how this is implemented.)
156 	 * Usually this is what you want, but if you have an existing
157 	 * Pango markup string that you want to use literally as the
158 	 * label, then you need to use gtk_message_dialog_set_markup()
159 	 * instead, since you can't pass the markup string either
160 	 * as the format (it might contain '%' characters) or as a string
161 	 * argument.
162 	 * Since 2.4
163 	 * Examples:
164 	 * --------------------
165 	 *  GtkWidget *dialog;
166 	 *  dialog = gtk_message_dialog_new (main_application_window,
167 	 *  GTK_DIALOG_DESTROY_WITH_PARENT,
168 	 *  GTK_MESSAGE_ERROR,
169 	 *  GTK_BUTTONS_CLOSE,
170 	 *  NULL);
171 	 *  gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
172 	 *  markup);
173 	 * --------------------
174 	 * Params:
175 	 *  parent = transient parent, or NULL for none
176 	 *  flags = flags
177 	 *  type = type of message
178 	 *  buttons = set of buttons to use
179 	 *  messageFormat = printf()-style format string, or NULL
180 	 *  message = the message - should be null, any formatting should be done prior to call this constructor
181 	 * Throws: ConstructionException GTK+ fails to create the object.
182 	 */
183 	public this (Window parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, bool markup, string messageFormat, string message=null )
184 	{
185 		GtkMessageDialog* p;
186 		
187 		if ( markup )
188 		{
189 			// GtkWidget* gtk_message_dialog_new_with_markup  (GtkWindow *parent,  GtkDialogFlags flags,  GtkMessageType type,  GtkButtonsType buttons,  const gchar *message_format,  ...);
190 			p = cast(GtkMessageDialog*)gtk_message_dialog_new_with_markup(
191 				parent is null ? null : parent.getWindowStruct(),
192 				flags,
193 				type,
194 				buttons,
195 				Str.toStringz(messageFormat),
196 				Str.toStringz(message),	// this should be null
197 				null
198 			);
199 		}
200 		else
201 		{
202 			// GtkWidget* gtk_message_dialog_new (GtkWindow *parent,  GtkDialogFlags flags,  GtkMessageType type,  GtkButtonsType buttons,  const gchar *message_format,  ...);
203 			p = cast(GtkMessageDialog*)gtk_message_dialog_new(
204 				parent is null ? null : parent.getWindowStruct(),
205 				flags,
206 				type,
207 				buttons,
208 				Str.toStringz(messageFormat),
209 				Str.toStringz(message),	// this should be null
210 				null
211 			);
212 		}
213 		
214 		if(p is null)
215 		{
216 			throw new ConstructionException("null returned by gtk_button_new()");
217 		}
218 		
219 		this(p);
220 	}
221 	
222 	/**
223 	 * Since 2.22
224 	 * Returns: A GtkVBox corresponding to the "message area" in the message_dialog. This is the box where the dialog's primary and secondary labels are packed. You can add your own extra content to that box and it will appear below those labels, on the right side of the dialog's image (or on the left for right-to-left languages). See gtk_dialog_get_content_area() for the corresponding function in the parent GtkDialog.
225 	 */
226 	public VBox getMessageArea()
227 	{
228 		// GtkWidget * gtk_message_dialog_get_message_area (GtkMessageDialog *message_dialog);
229 		auto p = gtk_message_dialog_get_message_area(gtkMessageDialog);
230 		if(p is null)
231 		{
232 			return null;
233 		}
234 		return new VBox(cast(GtkVBox*) p);
235 	}
236 
237 	/**
238 	 */
239 
240 	public static GType getType()
241 	{
242 		return gtk_message_dialog_get_type();
243 	}
244 
245 	/**
246 	 * Gets the dialog’s image.
247 	 *
248 	 * Deprecated: Use #GtkDialog for dialogs with images
249 	 *
250 	 * Return: the dialog’s image
251 	 *
252 	 * Since: 2.14
253 	 */
254 	public Widget getImage()
255 	{
256 		auto p = gtk_message_dialog_get_image(gtkMessageDialog);
257 		
258 		if(p is null)
259 		{
260 			return null;
261 		}
262 		
263 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
264 	}
265 
266 	/**
267 	 * Sets the dialog’s image to @image.
268 	 *
269 	 * Deprecated: Use #GtkDialog to create dialogs with images
270 	 *
271 	 * Params:
272 	 *     image = the image
273 	 *
274 	 * Since: 2.10
275 	 */
276 	public void setImage(Widget image)
277 	{
278 		gtk_message_dialog_set_image(gtkMessageDialog, (image is null) ? null : image.getWidgetStruct());
279 	}
280 
281 	/**
282 	 * Sets the text of the message dialog to be @str, which is marked
283 	 * up with the [Pango text markup language][PangoMarkupFormat].
284 	 *
285 	 * Params:
286 	 *     str = markup string (see [Pango markup format][PangoMarkupFormat])
287 	 *
288 	 * Since: 2.4
289 	 */
290 	public void setMarkup(string str)
291 	{
292 		gtk_message_dialog_set_markup(gtkMessageDialog, Str.toStringz(str));
293 	}
294 }