alternative to assert
[gtkD.git] / gtkD / src / gtk / MessageDialog.d
blob4dc01ba46ae248f3a41b3a728a606b78a031aa3c
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkMessageDialog.html
26 * outPack = gtk
27 * outFile = MessageDialog
28 * strct = GtkMessageDialog
29 * realStrct=
30 * ctorStrct=
31 * clss = MessageDialog
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_message_dialog_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * - gtk_message_dialog_new
45 * - gtk_message_dialog_new_with_markup
46 * imports:
47 * - glib.Str
48 * - gtk.Window
49 * structWrap:
50 * - GtkWindow* -> Window
51 * module aliases:
52 * local aliases:
55 module gtk.MessageDialog;
57 version(noAssert)
59 version(Tango)
61 import tango.io.Stdout; // use the tango loging?
65 private import gtkc.gtktypes;
67 private import gtkc.gtk;
70 private import glib.Str;
71 private import gtk.Window;
76 /**
77 * Description
78 * GtkMessageDialog presents a dialog with an image representing the type of
79 * message (Error, Question, etc.) alongside some message text. It's simply a
80 * convenience widget; you could construct the equivalent of GtkMessageDialog
81 * from GtkDialog without too much effort, but GtkMessageDialog saves typing.
82 * The easiest way to do a modal message dialog is to use gtk_dialog_run(), though
83 * you can also pass in the GTK_DIALOG_MODAL flag, gtk_dialog_run() automatically
84 * makes the dialog modal and waits for the user to respond to it. gtk_dialog_run()
85 * returns when any dialog button is clicked.
86 * Example2.A modal dialog.
87 * dialog = gtk_message_dialog_new (main_application_window,
88 * GTK_DIALOG_DESTROY_WITH_PARENT,
89 * GTK_MESSAGE_ERROR,
90 * GTK_BUTTONS_CLOSE,
91 * "Error loading file '%s': %s",
92 * filename, g_strerror (errno));
93 * gtk_dialog_run (GTK_DIALOG (dialog));
94 * gtk_widget_destroy (dialog);
95 * You might do a non-modal GtkMessageDialog as follows:
96 * Example3.A non-modal dialog.
97 * dialog = gtk_message_dialog_new (main_application_window,
98 * GTK_DIALOG_DESTROY_WITH_PARENT,
99 * GTK_MESSAGE_ERROR,
100 * GTK_BUTTONS_CLOSE,
101 * "Error loading file '%s': %s",
102 * filename, g_strerror (errno));
103 * /+* Destroy the dialog when the user responds to it (e.g. clicks a button) +/
104 * g_signal_connect_swapped (dialog, "response",
105 * G_CALLBACK (gtk_widget_destroy),
106 * dialog);
108 private import gtk.Dialog;
109 public class MessageDialog : Dialog
112 /** the main Gtk struct */
113 protected GtkMessageDialog* gtkMessageDialog;
116 public GtkMessageDialog* getMessageDialogStruct()
118 return gtkMessageDialog;
122 /** the main Gtk struct as a void* */
123 protected void* getStruct()
125 return cast(void*)gtkMessageDialog;
129 * Sets our main struct and passes it to the parent class
131 public this (GtkMessageDialog* gtkMessageDialog)
133 version(noAssert)
135 if ( gtkMessageDialog is null )
137 int zero = 0;
138 version(Tango)
140 Stdout("struct gtkMessageDialog is null on constructor").newline;
142 else
144 printf("struct gtkMessageDialog is null on constructor");
146 zero = zero / zero;
149 else
151 assert(gtkMessageDialog !is null, "struct gtkMessageDialog is null on constructor");
153 super(cast(GtkDialog*)gtkMessageDialog);
154 this.gtkMessageDialog = gtkMessageDialog;
158 * Creates a new message dialog, which is a simple dialog with an icon
159 * indicating the dialog type (error, warning, etc.) and some text the
160 * user may want to see. When the user clicks a button a "response"
161 * signal is emitted with response IDs from GtkResponseType. See
162 * GtkDialog for more details.
163 * parent:
164 * transient parent, or NULL for none
165 * flags:
166 * flags
167 * type:
168 * type of message
169 * buttons:
170 * set of buttons to use
171 * message_format:
172 * printf()-style format string, or NULL
173 * message:
174 * the message - should be null, any formatting should be done prior to call this constructor
175 * arguments for message_format
176 * Returns:
177 * a new GtkMessageDialog
179 public this (Window parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, char[] messageFormat, char[] message=null )
181 this(parent, flags, type, buttons, false, messageFormat, message );
185 * Creates a new message dialog, which is a simple dialog with an icon
186 * indicating the dialog type (error, warning, etc.) and some text which
187 * is marked up with the Pango text markup language.
188 * When the user clicks a button a "response" signal is emitted with
189 * response IDs from GtkResponseType. See GtkDialog for more details.
191 * If Markup is true special XML characters in the printf() arguments passed to this
192 * function will automatically be escaped as necessary.
193 * (See g_markup_printf_escaped() for how this is implemented.)
194 * Usually this is what you want, but if you have an existing
195 * Pango markup string that you want to use literally as the
196 * label, then you need to use gtk_message_dialog_set_markup()
197 * instead, since you can't pass the markup string either
198 * as the format (it might contain '%' characters) or as a string
199 * argument.
200 * GtkWidget *dialog;
201 * dialog = gtk_message_dialog_new (main_application_window,
202 * GTK_DIALOG_DESTROY_WITH_PARENT,
203 * GTK_MESSAGE_ERROR,
204 * GTK_BUTTONS_CLOSE,
205 * NULL);
206 * gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
207 * markup);
208 * parent:
209 * transient parent, or NULL for none
210 * flags:
211 * flags
212 * type:
213 * type of message
214 * buttons:
215 * set of buttons to use
216 * message_format:
217 * printf()-style format string, or NULL
218 * message:
219 * the message - should be null, any formatting should be done prior to call this constructor
220 * ...:
221 * arguments for message_format
222 * Returns:
223 * a new GtkMessageDialog
224 * Since 2.4
226 public this (Window parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, bool markup, char[] messageFormat, char[] message=null )
228 if ( markup )
230 // GtkWidget* gtk_message_dialog_new_with_markup (GtkWindow *parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, const gchar *message_format, ...);
231 this(
232 cast(GtkMessageDialog*)gtk_message_dialog_new_with_markup(
233 parent is null ? null : parent.getWindowStruct(),
234 flags,
235 type,
236 buttons,
237 Str.toStringz(messageFormat),
238 Str.toStringz(message), // this should be null
239 null
243 else
245 // GtkWidget* gtk_message_dialog_new (GtkWindow *parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, const gchar *message_format, ...);
246 this(
247 cast(GtkMessageDialog*)gtk_message_dialog_new(
248 parent is null ? null : parent.getWindowStruct(),
249 flags,
250 type,
251 buttons,
252 Str.toStringz(messageFormat),
253 Str.toStringz(message), // this should be null
254 null
270 * Sets the text of the message dialog to be str, which is marked
271 * up with the Pango text markup
272 * language.
273 * message_dialog:
274 * a GtkMessageDialog
275 * str:
276 * markup string (see Pango markup format)
277 * Since 2.4
279 public void setMarkup(char[] str)
281 // void gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog, const gchar *str);
282 gtk_message_dialog_set_markup(gtkMessageDialog, Str.toStringz(str));
286 * Sets the dialog's image to image.
287 * dialog:
288 * a GtkMessageDialog
289 * image:
290 * the image
291 * Since 2.10
293 public void setImage(GtkWidget* image)
295 // void gtk_message_dialog_set_image (GtkMessageDialog *dialog, GtkWidget *image);
296 gtk_message_dialog_set_image(gtkMessageDialog, image);
300 * Sets the secondary text of the message dialog to be message_format
301 * (with printf()-style).
302 * Note that setting a secondary text makes the primary text become
303 * bold, unless you have provided explicit markup.
304 * message_dialog:
305 * a GtkMessageDialog
306 * message_format:
307 * printf()-style format string, or NULL
308 * ...:
309 * arguments for message_format
310 * Since 2.6
312 public void formatSecondaryText(char[] messageFormat, ... )
314 // void gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog, const gchar *message_format, ...);
315 gtk_message_dialog_format_secondary_text(gtkMessageDialog, Str.toStringz(messageFormat));
319 * Sets the secondary text of the message dialog to be message_format (with
320 * printf()-style), which is marked up with the
321 * Pango text markup language.
322 * Note that setting a secondary text makes the primary text become
323 * bold, unless you have provided explicit markup.
324 * Due to an oversight, this function does not escape special XML characters
325 * like gtk_message_dialog_new_with_markup() does. Thus, if the arguments
326 * may contain special XML characters, you should use g_markup_printf_escaped()
327 * to escape it.
328 * gchar *msg;
329 * msg = g_markup_printf_escaped (message_format, ...);
330 * gtk_message_dialog_format_secondary_markup (message_dialog, "%s", msg);
331 * g_free (msg);
332 * message_dialog:
333 * a GtkMessageDialog
334 * message_format:
335 * printf()-style markup string (see
336 * Pango markup format), or NULL
337 * ...:
338 * arguments for message_format
339 * Since 2.6
340 * Property Details
341 * The "buttons" property
342 * "buttons" GtkButtonsType : Write / Construct Only
343 * The buttons shown in the message dialog.
344 * Default value: GTK_BUTTONS_NONE
346 public void formatSecondaryMarkup(char[] messageFormat, ... )
348 // void gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog, const gchar *message_format, ...);
349 gtk_message_dialog_format_secondary_markup(gtkMessageDialog, Str.toStringz(messageFormat));