1 module webkit2.ScriptDialog; 2 3 private import glib.Str; 4 private import gobject.ObjectG; 5 private import webkit2.c.functions; 6 public import webkit2.c.types; 7 8 9 /** */ 10 public class ScriptDialog 11 { 12 /** the main Gtk struct */ 13 protected WebKitScriptDialog* webKitScriptDialog; 14 protected bool ownedRef; 15 16 /** Get the main Gtk struct */ 17 public WebKitScriptDialog* getScriptDialogStruct(bool transferOwnership = false) 18 { 19 if (transferOwnership) 20 ownedRef = false; 21 return webKitScriptDialog; 22 } 23 24 /** the main Gtk struct as a void* */ 25 protected void* getStruct() 26 { 27 return cast(void*)webKitScriptDialog; 28 } 29 30 /** 31 * Sets our main struct and passes it to the parent class. 32 */ 33 public this (WebKitScriptDialog* webKitScriptDialog, bool ownedRef = false) 34 { 35 this.webKitScriptDialog = webKitScriptDialog; 36 this.ownedRef = ownedRef; 37 } 38 39 ~this () 40 { 41 if ( ownedRef ) 42 webkit_script_dialog_unref(webKitScriptDialog); 43 } 44 45 46 /** */ 47 public static GType getType() 48 { 49 return webkit_script_dialog_get_type(); 50 } 51 52 /** 53 * Close @dialog. When handling a #WebKitScriptDialog asynchronously (webkit_script_dialog_ref() 54 * was called in #WebKitWebView::script-dialog callback), this function needs to be called to notify 55 * that we are done with the script dialog. The dialog will be closed on destruction if this function 56 * hasn't been called before. 57 * 58 * Since: 2.24 59 */ 60 public void close() 61 { 62 webkit_script_dialog_close(webKitScriptDialog); 63 } 64 65 /** 66 * This method is used for %WEBKIT_SCRIPT_DIALOG_CONFIRM and %WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM dialogs when 67 * #WebKitWebView::script-dialog signal is emitted to set whether the user 68 * confirmed the dialog or not. The default implementation of #WebKitWebView::script-dialog 69 * signal sets %TRUE when the OK or Stay buttons are clicked and %FALSE otherwise. 70 * It's an error to use this method with a #WebKitScriptDialog that is not of type 71 * %WEBKIT_SCRIPT_DIALOG_CONFIRM or %WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM 72 * 73 * Params: 74 * confirmed = whether user confirmed the dialog 75 */ 76 public void confirmSetConfirmed(bool confirmed) 77 { 78 webkit_script_dialog_confirm_set_confirmed(webKitScriptDialog, confirmed); 79 } 80 81 /** 82 * Get the dialog type of a #WebKitScriptDialog. 83 * 84 * Returns: the #WebKitScriptDialogType of @dialog 85 */ 86 public WebKitScriptDialogType getDialogType() 87 { 88 return webkit_script_dialog_get_dialog_type(webKitScriptDialog); 89 } 90 91 /** 92 * Get the message of a #WebKitScriptDialog. 93 * 94 * Returns: the message of @dialog. 95 */ 96 public string getMessage() 97 { 98 return Str.toString(webkit_script_dialog_get_message(webKitScriptDialog)); 99 } 100 101 /** 102 * Get the default text of a #WebKitScriptDialog of type %WEBKIT_SCRIPT_DIALOG_PROMPT. 103 * It's an error to use this method with a #WebKitScriptDialog that is not of type 104 * %WEBKIT_SCRIPT_DIALOG_PROMPT. 105 * 106 * Returns: the default text of @dialog 107 */ 108 public string promptGetDefaultText() 109 { 110 return Str.toString(webkit_script_dialog_prompt_get_default_text(webKitScriptDialog)); 111 } 112 113 /** 114 * This method is used for %WEBKIT_SCRIPT_DIALOG_PROMPT dialogs when 115 * #WebKitWebView::script-dialog signal is emitted to set the text 116 * entered by the user. The default implementation of #WebKitWebView::script-dialog 117 * signal sets the text of the entry form when OK button is clicked, otherwise %NULL is set. 118 * It's an error to use this method with a #WebKitScriptDialog that is not of type 119 * %WEBKIT_SCRIPT_DIALOG_PROMPT. 120 * 121 * Params: 122 * text = the text to set 123 */ 124 public void promptSetText(string text) 125 { 126 webkit_script_dialog_prompt_set_text(webKitScriptDialog, Str.toStringz(text)); 127 } 128 129 alias doref = ref_; 130 /** 131 * Atomically increments the reference count of @dialog by one. This 132 * function is MT-safe and may be called from any thread. 133 * 134 * Returns: The passed in #WebKitScriptDialog 135 * 136 * Since: 2.24 137 */ 138 public ScriptDialog ref_() 139 { 140 auto __p = webkit_script_dialog_ref(webKitScriptDialog); 141 142 if(__p is null) 143 { 144 return null; 145 } 146 147 return ObjectG.getDObject!(ScriptDialog)(cast(WebKitScriptDialog*) __p, true); 148 } 149 150 /** 151 * Atomically decrements the reference count of @dialog by one. If the 152 * reference count drops to 0, all memory allocated by the #WebKitScriptdialog is 153 * released. This function is MT-safe and may be called from any 154 * thread. 155 * 156 * Since: 2.24 157 */ 158 public void unref() 159 { 160 webkit_script_dialog_unref(webKitScriptDialog); 161 } 162 }