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.Widget;
32 private import gtk.Window;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 
36 
37 /**
38  * `GtkMessageDialog` presents a dialog with some message text.
39  * 
40  * ![An example GtkMessageDialog](messagedialog.png)
41  * 
42  * It’s simply a convenience widget; you could construct the equivalent of
43  * `GtkMessageDialog` from `GtkDialog` without too much effort, but
44  * `GtkMessageDialog` saves typing.
45  * 
46  * The easiest way to do a modal message dialog is to use the %GTK_DIALOG_MODAL
47  * flag, which will call [method@Gtk.Window.set_modal] internally. The dialog will
48  * prevent interaction with the parent window until it's hidden or destroyed.
49  * You can use the [signal@Gtk.Dialog::response] signal to know when the user
50  * dismissed the dialog.
51  * 
52  * An example for using a modal dialog:
53  * ```c
54  * GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL;
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  * // Destroy the dialog when the user responds to it
63  * // (e.g. clicks a button)
64  * 
65  * g_signal_connect (dialog, "response",
66  * G_CALLBACK (gtk_window_destroy),
67  * NULL);
68  * ```
69  * 
70  * You might do a non-modal `GtkMessageDialog` simply by omitting the
71  * %GTK_DIALOG_MODAL flag:
72  * 
73  * ```c
74  * GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
75  * dialog = gtk_message_dialog_new (parent_window,
76  * flags,
77  * GTK_MESSAGE_ERROR,
78  * GTK_BUTTONS_CLOSE,
79  * "Error reading “%s”: %s",
80  * filename,
81  * g_strerror (errno));
82  * 
83  * // Destroy the dialog when the user responds to it
84  * // (e.g. clicks a button)
85  * g_signal_connect (dialog, "response",
86  * G_CALLBACK (gtk_window_destroy),
87  * NULL);
88  * ```
89  * 
90  * # GtkMessageDialog as GtkBuildable
91  * 
92  * The `GtkMessageDialog` implementation of the `GtkBuildable` interface exposes
93  * the message area as an internal child with the name “message_area”.
94  */
95 public class MessageDialog : Dialog
96 {
97 	/** the main Gtk struct */
98 	protected GtkMessageDialog* gtkMessageDialog;
99 
100 	/** Get the main Gtk struct */
101 	public GtkMessageDialog* getMessageDialogStruct(bool transferOwnership = false)
102 	{
103 		if (transferOwnership)
104 			ownedRef = false;
105 		return gtkMessageDialog;
106 	}
107 
108 	/** the main Gtk struct as a void* */
109 	protected override void* getStruct()
110 	{
111 		return cast(void*)gtkMessageDialog;
112 	}
113 
114 	/**
115 	 * Sets our main struct and passes it to the parent class.
116 	 */
117 	public this (GtkMessageDialog* gtkMessageDialog, bool ownedRef = false)
118 	{
119 		this.gtkMessageDialog = gtkMessageDialog;
120 		super(cast(GtkDialog*)gtkMessageDialog, ownedRef);
121 	}
122 
123 	/**
124 	 * Creates a new message dialog, which is a simple dialog with an icon
125 	 * indicating the dialog type (error, warning, etc.) and some text the
126 	 * user may want to see. When the user clicks a button a "response"
127 	 * signal is emitted with response IDs from GtkResponseType. See
128 	 * GtkDialog for more details.
129 	 *
130 	 * If you have an existing Pango markup string that you want to use
131 	 * literally as the label, then you need to use setMarkup() instead.
132 	 *
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 	 *    	message = the message
139 	 * Returns:
140 	 *  a new GtkMessageDialog
141 	 */
142 	public this (Window parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, string message)
143 	{
144 		auto __p = cast(GtkMessageDialog*)gtk_message_dialog_new(
145 			parent is null ? null : parent.getWindowStruct(),
146 			flags,
147 			type,
148 			buttons,
149 			Str.toStringz(message),
150 			null,
151 			null
152 		);
153 
154 		if(__p is null)
155 		{
156 			throw new ConstructionException("null returned by gtk_message_dialog_new()");
157 		}
158 
159 		this(__p);
160 	}
161 
162 	/**
163 	 */
164 
165 	/** */
166 	public static GType getType()
167 	{
168 		return gtk_message_dialog_get_type();
169 	}
170 
171 	/**
172 	 * Returns the message area of the dialog.
173 	 *
174 	 * This is the box where the dialog’s primary and secondary labels
175 	 * are packed. You can add your own extra content to that box and it
176 	 * will appear below those labels. See [method@Gtk.Dialog.get_content_area]
177 	 * for the corresponding function in the parent [class@Gtk.Dialog].
178 	 *
179 	 * Returns: A `GtkBox` corresponding to the
180 	 *     “message area” in the @message_dialog.
181 	 */
182 	public Widget getMessageArea()
183 	{
184 		auto __p = gtk_message_dialog_get_message_area(gtkMessageDialog);
185 
186 		if(__p is null)
187 		{
188 			return null;
189 		}
190 
191 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
192 	}
193 
194 	/**
195 	 * Sets the text of the message dialog.
196 	 *
197 	 * Params:
198 	 *     str = string with Pango markup
199 	 */
200 	public void setMarkup(string str)
201 	{
202 		gtk_message_dialog_set_markup(gtkMessageDialog, Str.toStringz(str));
203 	}
204 }