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.NativeDialog; 26 27 private import glib.Str; 28 private import glib.c.functions; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gtk.Window; 32 private import gtk.c.functions; 33 public import gtk.c.types; 34 private import std.algorithm; 35 36 37 /** 38 * Native dialogs are platform dialogs that don't use `GtkDialog`. 39 * 40 * They are used in order to integrate better with a platform, by 41 * looking the same as other native applications and supporting 42 * platform specific features. 43 * 44 * The [class@Gtk.Dialog] functions cannot be used on such objects, 45 * but we need a similar API in order to drive them. The `GtkNativeDialog` 46 * object is an API that allows you to do this. It allows you to set 47 * various common properties on the dialog, as well as show and hide 48 * it and get a [signal@Gtk.NativeDialog::response] signal when the user 49 * finished with the dialog. 50 * 51 * Note that unlike `GtkDialog`, `GtkNativeDialog` objects are not 52 * toplevel widgets, and GTK does not keep them alive. It is your 53 * responsibility to keep a reference until you are done with the 54 * object. 55 */ 56 public class NativeDialog : ObjectG 57 { 58 /** the main Gtk struct */ 59 protected GtkNativeDialog* gtkNativeDialog; 60 61 /** Get the main Gtk struct */ 62 public GtkNativeDialog* getNativeDialogStruct(bool transferOwnership = false) 63 { 64 if (transferOwnership) 65 ownedRef = false; 66 return gtkNativeDialog; 67 } 68 69 /** the main Gtk struct as a void* */ 70 protected override void* getStruct() 71 { 72 return cast(void*)gtkNativeDialog; 73 } 74 75 /** 76 * Sets our main struct and passes it to the parent class. 77 */ 78 public this (GtkNativeDialog* gtkNativeDialog, bool ownedRef = false) 79 { 80 this.gtkNativeDialog = gtkNativeDialog; 81 super(cast(GObject*)gtkNativeDialog, ownedRef); 82 } 83 84 85 /** */ 86 public static GType getType() 87 { 88 return gtk_native_dialog_get_type(); 89 } 90 91 /** 92 * Destroys a dialog. 93 * 94 * When a dialog is destroyed, it will break any references it holds 95 * to other objects. 96 * 97 * If it is visible it will be hidden and any underlying window system 98 * resources will be destroyed. 99 * 100 * Note that this does not release any reference to the object (as opposed 101 * to destroying a `GtkWindow`) because there is no reference from the 102 * windowing system to the `GtkNativeDialog`. 103 */ 104 public void destroy() 105 { 106 gtk_native_dialog_destroy(gtkNativeDialog); 107 } 108 109 /** 110 * Returns whether the dialog is modal. 111 * 112 * Returns: %TRUE if the dialog is set to be modal 113 */ 114 public bool getModal() 115 { 116 return gtk_native_dialog_get_modal(gtkNativeDialog) != 0; 117 } 118 119 /** 120 * Gets the title of the `GtkNativeDialog`. 121 * 122 * Returns: the title of the dialog, or %NULL if none has 123 * been set explicitly. The returned string is owned by the widget 124 * and must not be modified or freed. 125 */ 126 public string getTitle() 127 { 128 return Str.toString(gtk_native_dialog_get_title(gtkNativeDialog)); 129 } 130 131 /** 132 * Fetches the transient parent for this window. 133 * 134 * Returns: the transient parent for this window, 135 * or %NULL if no transient parent has been set. 136 */ 137 public Window getTransientFor() 138 { 139 auto __p = gtk_native_dialog_get_transient_for(gtkNativeDialog); 140 141 if(__p is null) 142 { 143 return null; 144 } 145 146 return ObjectG.getDObject!(Window)(cast(GtkWindow*) __p); 147 } 148 149 /** 150 * Determines whether the dialog is visible. 151 * 152 * Returns: %TRUE if the dialog is visible 153 */ 154 public bool getVisible() 155 { 156 return gtk_native_dialog_get_visible(gtkNativeDialog) != 0; 157 } 158 159 /** 160 * Hides the dialog if it is visible, aborting any interaction. 161 * 162 * Once this is called the [signal@Gtk.NativeDialog::response] signal 163 * will *not* be emitted until after the next call to 164 * [method@Gtk.NativeDialog.show]. 165 * 166 * If the dialog is not visible this does nothing. 167 */ 168 public void hide() 169 { 170 gtk_native_dialog_hide(gtkNativeDialog); 171 } 172 173 /** 174 * Sets a dialog modal or non-modal. 175 * 176 * Modal dialogs prevent interaction with other windows in the same 177 * application. To keep modal dialogs on top of main application 178 * windows, use [method@Gtk.NativeDialog.set_transient_for] to make 179 * the dialog transient for the parent; most window managers will 180 * then disallow lowering the dialog below the parent. 181 * 182 * Params: 183 * modal = whether the window is modal 184 */ 185 public void setModal(bool modal) 186 { 187 gtk_native_dialog_set_modal(gtkNativeDialog, modal); 188 } 189 190 /** 191 * Sets the title of the `GtkNativeDialog.` 192 * 193 * Params: 194 * title = title of the dialog 195 */ 196 public void setTitle(string title) 197 { 198 gtk_native_dialog_set_title(gtkNativeDialog, Str.toStringz(title)); 199 } 200 201 /** 202 * Dialog windows should be set transient for the main application 203 * window they were spawned from. 204 * 205 * This allows window managers to e.g. keep the dialog on top of the 206 * main window, or center the dialog over the main window. 207 * 208 * Passing %NULL for @parent unsets the current transient window. 209 * 210 * Params: 211 * parent = parent window, or %NULL 212 */ 213 public void setTransientFor(Window parent) 214 { 215 gtk_native_dialog_set_transient_for(gtkNativeDialog, (parent is null) ? null : parent.getWindowStruct()); 216 } 217 218 /** 219 * Shows the dialog on the display. 220 * 221 * When the user accepts the state of the dialog the dialog will 222 * be automatically hidden and the [signal@Gtk.NativeDialog::response] 223 * signal will be emitted. 224 * 225 * Multiple calls while the dialog is visible will be ignored. 226 */ 227 public void show() 228 { 229 gtk_native_dialog_show(gtkNativeDialog); 230 } 231 232 /** 233 * Emitted when the user responds to the dialog. 234 * 235 * When this is called the dialog has been hidden. 236 * 237 * If you call [method@Gtk.NativeDialog.hide] before the user 238 * responds to the dialog this signal will not be emitted. 239 * 240 * Params: 241 * responseId = the response ID 242 */ 243 gulong addOnResponse(void delegate(int, NativeDialog) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 244 { 245 return Signals.connect(this, "response", dlg, connectFlags ^ ConnectFlags.SWAPPED); 246 } 247 }