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