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