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(bool transferOwnership = false)
99 	{
100 		if (transferOwnership)
101 			ownedRef = false;
102 		return gtkMessageDialog;
103 	}
104 
105 	/** the main Gtk struct as a void* */
106 	protected override void* getStruct()
107 	{
108 		return cast(void*)gtkMessageDialog;
109 	}
110 
111 	protected override void setStruct(GObject* obj)
112 	{
113 		gtkMessageDialog = cast(GtkMessageDialog*)obj;
114 		super.setStruct(obj);
115 	}
116 
117 	/**
118 	 * Sets our main struct and passes it to the parent class.
119 	 */
120 	public this (GtkMessageDialog* gtkMessageDialog, bool ownedRef = false)
121 	{
122 		this.gtkMessageDialog = gtkMessageDialog;
123 		super(cast(GtkDialog*)gtkMessageDialog, ownedRef);
124 	}
125 
126 	/**
127 	 * Creates a new message dialog, which is a simple dialog with an icon
128 	 * indicating the dialog type (error, warning, etc.) and some text the
129 	 * user may want to see. When the user clicks a button a "response"
130 	 * signal is emitted with response IDs from GtkResponseType. See
131 	 * GtkDialog for more details.
132 	 * Params:
133 	 *    	parent = transient parent, or NULL for none
134 	 *    	flags = flags
135 	 *    	type = type of message
136 	 *    	buttons= set of buttons to use
137 	 *    	messageFormat = printf()-style format string, or NULL
138 	 *    	message = the message - should be null, any formatting should be done prior to call this constructor
139 	 *  arguments for message_format
140 	 * Returns:
141 	 *  a new GtkMessageDialog
142 	 */
143 	public this (Window parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, string messageFormat, string message=null )
144 	{
145 		this(parent, flags, type, buttons, false, messageFormat, message );
146 	}
147 	
148 	/**
149 	 * Creates a new message dialog, which is a simple dialog with an icon
150 	 * indicating the dialog type (error, warning, etc.) and some text which
151 	 * is marked up with the Pango text markup language.
152 	 * When the user clicks a button a "response" signal is emitted with
153 	 * response IDs from GtkResponseType. See GtkDialog for more details.
154 	 *
155 	 * If Markup is true special XML characters in the printf() arguments passed to this
156 	 * function will automatically be escaped as necessary.
157 	 * (See g_markup_printf_escaped() for how this is implemented.)
158 	 * Usually this is what you want, but if you have an existing
159 	 * Pango markup string that you want to use literally as the
160 	 * label, then you need to use gtk_message_dialog_set_markup()
161 	 * instead, since you can't pass the markup string either
162 	 * as the format (it might contain '%' characters) or as a string
163 	 * argument.
164 	 * Since 2.4
165 	 * Examples:
166 	 * --------------------
167 	 *  GtkWidget *dialog;
168 	 *  dialog = gtk_message_dialog_new (main_application_window,
169 	 *  GTK_DIALOG_DESTROY_WITH_PARENT,
170 	 *  GTK_MESSAGE_ERROR,
171 	 *  GTK_BUTTONS_CLOSE,
172 	 *  NULL);
173 	 *  gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
174 	 *  markup);
175 	 * --------------------
176 	 * Params:
177 	 *  parent = transient parent, or NULL for none
178 	 *  flags = flags
179 	 *  type = type of message
180 	 *  buttons = set of buttons to use
181 	 *  messageFormat = printf()-style format string, or NULL
182 	 *  message = the message - should be null, any formatting should be done prior to call this constructor
183 	 * Throws: ConstructionException GTK+ fails to create the object.
184 	 */
185 	public this (Window parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, bool markup, string messageFormat, string message=null )
186 	{
187 		GtkMessageDialog* p;
188 		
189 		if ( markup )
190 		{
191 			// GtkWidget* gtk_message_dialog_new_with_markup  (GtkWindow *parent,  GtkDialogFlags flags,  GtkMessageType type,  GtkButtonsType buttons,  const gchar *message_format,  ...);
192 			p = cast(GtkMessageDialog*)gtk_message_dialog_new_with_markup(
193 				parent is null ? null : parent.getWindowStruct(),
194 				flags,
195 				type,
196 				buttons,
197 				Str.toStringz(messageFormat),
198 				Str.toStringz(message),	// this should be null
199 				null
200 			);
201 		}
202 		else
203 		{
204 			// GtkWidget* gtk_message_dialog_new (GtkWindow *parent,  GtkDialogFlags flags,  GtkMessageType type,  GtkButtonsType buttons,  const gchar *message_format,  ...);
205 			p = cast(GtkMessageDialog*)gtk_message_dialog_new(
206 				parent is null ? null : parent.getWindowStruct(),
207 				flags,
208 				type,
209 				buttons,
210 				Str.toStringz(messageFormat),
211 				Str.toStringz(message),	// this should be null
212 				null
213 			);
214 		}
215 		
216 		if(p is null)
217 		{
218 			throw new ConstructionException("null returned by gtk_button_new()");
219 		}
220 		
221 		this(p);
222 	}
223 	
224 	/**
225 	 * Since 2.22
226 	 * 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.
227 	 */
228 	public VBox getMessageArea()
229 	{
230 		// GtkWidget * gtk_message_dialog_get_message_area (GtkMessageDialog *message_dialog);
231 		auto p = gtk_message_dialog_get_message_area(gtkMessageDialog);
232 		if(p is null)
233 		{
234 			return null;
235 		}
236 		return new VBox(cast(GtkVBox*) p);
237 	}
238 
239 	/**
240 	 */
241 
242 	/** */
243 	public static GType getType()
244 	{
245 		return gtk_message_dialog_get_type();
246 	}
247 
248 	/**
249 	 * Gets the dialog’s image.
250 	 *
251 	 * Deprecated: Use #GtkDialog for dialogs with images
252 	 *
253 	 * Returns: the dialog’s image
254 	 *
255 	 * Since: 2.14
256 	 */
257 	public Widget getImage()
258 	{
259 		auto p = gtk_message_dialog_get_image(gtkMessageDialog);
260 		
261 		if(p is null)
262 		{
263 			return null;
264 		}
265 		
266 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
267 	}
268 
269 	/**
270 	 * Sets the dialog’s image to @image.
271 	 *
272 	 * Deprecated: Use #GtkDialog to create dialogs with images
273 	 *
274 	 * Params:
275 	 *     image = the image
276 	 *
277 	 * Since: 2.10
278 	 */
279 	public void setImage(Widget image)
280 	{
281 		gtk_message_dialog_set_image(gtkMessageDialog, (image is null) ? null : image.getWidgetStruct());
282 	}
283 
284 	/**
285 	 * Sets the text of the message dialog to be @str, which is marked
286 	 * up with the [Pango text markup language][PangoMarkupFormat].
287 	 *
288 	 * Params:
289 	 *     str = markup string (see [Pango markup format][PangoMarkupFormat])
290 	 *
291 	 * Since: 2.4
292 	 */
293 	public void setMarkup(string str)
294 	{
295 		gtk_message_dialog_set_markup(gtkMessageDialog, Str.toStringz(str));
296 	}
297 }