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 atk.DocumentT; 26 27 public import glib.Str; 28 public import gobject.Signals; 29 public import gtkc.atk; 30 public import gtkc.atktypes; 31 public import std.algorithm; 32 33 34 /** 35 * The AtkDocument interface should be supported by any object whose 36 * content is a representation or view of a document. The AtkDocument 37 * interface should appear on the toplevel container for the document 38 * content; however AtkDocument instances may be nested (i.e. an 39 * AtkDocument may be a descendant of another AtkDocument) in those 40 * cases where one document contains "embedded content" which can 41 * reasonably be considered a document in its own right. 42 */ 43 public template DocumentT(TStruct) 44 { 45 /** Get the main Gtk struct */ 46 public AtkDocument* getDocumentStruct() 47 { 48 return cast(AtkDocument*)getStruct(); 49 } 50 51 52 /** 53 * 54 * Params: 55 * attributeName = a character string representing the name of the attribute 56 * whose value is being queried. 57 * Returns: a string value associated with the named 58 * attribute for this document, or NULL if a value for 59 * #attribute_name has not been specified for this document. 60 * 61 * Since: 1.12 62 */ 63 public string getAttributeValue(string attributeName) 64 { 65 return Str.toString(atk_document_get_attribute_value(getDocumentStruct(), Str.toStringz(attributeName))); 66 } 67 68 /** 69 * Gets an AtkAttributeSet which describes document-wide 70 * attributes as name-value pairs. 71 * 72 * Returns: An AtkAttributeSet containing the explicitly 73 * set name-value-pair attributes associated with this document 74 * as a whole. 75 * 76 * Since: 1.12 77 */ 78 public override AtkAttributeSet* getAttributes() 79 { 80 return atk_document_get_attributes(getDocumentStruct()); 81 } 82 83 /** 84 * Returns: current page number inside @document. -1 if not 85 * implemented, not know by the implementor or irrelevant. 86 * 87 * Since: 2.12 88 */ 89 public int getCurrentPageNumber() 90 { 91 return atk_document_get_current_page_number(getDocumentStruct()); 92 } 93 94 /** 95 * Gets a %gpointer that points to an instance of the DOM. It is 96 * up to the caller to check atk_document_get_type to determine 97 * how to cast this pointer. 98 * 99 * Deprecated: Since 2.12. @document is already a representation of 100 * the document. Use it directly, or one of its children, as an 101 * instance of the DOM. 102 * 103 * Returns: a %gpointer that points to an instance of the DOM. 104 */ 105 public void* getDocument() 106 { 107 return atk_document_get_document(getDocumentStruct()); 108 } 109 110 /** 111 * Gets a string indicating the document type. 112 * 113 * Deprecated: Since 2.12. Please use atk_document_get_attributes() to 114 * ask for the document type if it applies. 115 * 116 * Returns: a string indicating the document type 117 */ 118 public string getDocumentType() 119 { 120 return Str.toString(atk_document_get_document_type(getDocumentStruct())); 121 } 122 123 /** 124 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale 125 * of the content of this document instance. Individual 126 * text substrings or images within this document may have 127 * a different locale, see atk_text_get_attributes and 128 * atk_image_get_image_locale. 129 * 130 * Deprecated: Please use atk_object_get_object_locale() instead. 131 * 132 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES 133 * locale of the document content as a whole, or NULL if 134 * the document content does not specify a locale. 135 */ 136 public string getLocale() 137 { 138 return Str.toString(atk_document_get_locale(getDocumentStruct())); 139 } 140 141 /** 142 * Returns: total page count of @document. -1 if not implemented, not 143 * know by the implementor or irrelevant. 144 * 145 * Since: 2.12 146 */ 147 public int getPageCount() 148 { 149 return atk_document_get_page_count(getDocumentStruct()); 150 } 151 152 /** 153 * 154 * Params: 155 * attributeName = a character string representing the name of the attribute 156 * whose value is being set. 157 * attributeValue = a string value to be associated with #attribute_name. 158 * Returns: TRUE if #value is successfully associated with #attribute_name 159 * for this document, FALSE otherwise (e.g. if the document does not 160 * allow the attribute to be modified). 161 * 162 * Since: 1.12 163 */ 164 public bool setAttributeValue(string attributeName, string attributeValue) 165 { 166 return atk_document_set_attribute_value(getDocumentStruct(), Str.toStringz(attributeName), Str.toStringz(attributeValue)) != 0; 167 } 168 169 protected class OnLoadCompleteDelegateWrapper 170 { 171 static OnLoadCompleteDelegateWrapper[] listeners; 172 void delegate(DocumentIF) dlg; 173 gulong handlerId; 174 175 this(void delegate(DocumentIF) dlg) 176 { 177 this.dlg = dlg; 178 this.listeners ~= this; 179 } 180 181 void remove(OnLoadCompleteDelegateWrapper source) 182 { 183 foreach(index, wrapper; listeners) 184 { 185 if (wrapper.handlerId == source.handlerId) 186 { 187 listeners[index] = null; 188 listeners = std.algorithm.remove(listeners, index); 189 break; 190 } 191 } 192 } 193 } 194 195 /** 196 * The 'load-complete' signal is emitted when a pending load of 197 * a static document has completed. This signal is to be 198 * expected by ATK clients if and when AtkDocument implementors 199 * expose ATK_STATE_BUSY. If the state of an AtkObject which 200 * implements AtkDocument does not include ATK_STATE_BUSY, it 201 * should be safe for clients to assume that the AtkDocument's 202 * static contents are fully loaded into the container. 203 * (Dynamic document contents should be exposed via other 204 * signals.) 205 */ 206 gulong addOnLoadComplete(void delegate(DocumentIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 207 { 208 auto wrapper = new OnLoadCompleteDelegateWrapper(dlg); 209 wrapper.handlerId = Signals.connectData( 210 this, 211 "load-complete", 212 cast(GCallback)&callBackLoadComplete, 213 cast(void*)wrapper, 214 cast(GClosureNotify)&callBackLoadCompleteDestroy, 215 connectFlags); 216 return wrapper.handlerId; 217 } 218 219 extern(C) static void callBackLoadComplete(AtkDocument* documentStruct, OnLoadCompleteDelegateWrapper wrapper) 220 { 221 wrapper.dlg(wrapper.outer); 222 } 223 224 extern(C) static void callBackLoadCompleteDestroy(OnLoadCompleteDelegateWrapper wrapper, GClosure* closure) 225 { 226 wrapper.remove(wrapper); 227 } 228 229 protected class OnLoadStoppedDelegateWrapper 230 { 231 static OnLoadStoppedDelegateWrapper[] listeners; 232 void delegate(DocumentIF) dlg; 233 gulong handlerId; 234 235 this(void delegate(DocumentIF) dlg) 236 { 237 this.dlg = dlg; 238 this.listeners ~= this; 239 } 240 241 void remove(OnLoadStoppedDelegateWrapper source) 242 { 243 foreach(index, wrapper; listeners) 244 { 245 if (wrapper.handlerId == source.handlerId) 246 { 247 listeners[index] = null; 248 listeners = std.algorithm.remove(listeners, index); 249 break; 250 } 251 } 252 } 253 } 254 255 /** 256 * The 'load-stopped' signal is emitted when a pending load of 257 * document contents is cancelled, paused, or otherwise 258 * interrupted by the user or application logic. It should not 259 * however be emitted while waiting for a resource (for instance 260 * while blocking on a file or network read) unless a 261 * user-significant timeout has occurred. 262 */ 263 gulong addOnLoadStopped(void delegate(DocumentIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 264 { 265 auto wrapper = new OnLoadStoppedDelegateWrapper(dlg); 266 wrapper.handlerId = Signals.connectData( 267 this, 268 "load-stopped", 269 cast(GCallback)&callBackLoadStopped, 270 cast(void*)wrapper, 271 cast(GClosureNotify)&callBackLoadStoppedDestroy, 272 connectFlags); 273 return wrapper.handlerId; 274 } 275 276 extern(C) static void callBackLoadStopped(AtkDocument* documentStruct, OnLoadStoppedDelegateWrapper wrapper) 277 { 278 wrapper.dlg(wrapper.outer); 279 } 280 281 extern(C) static void callBackLoadStoppedDestroy(OnLoadStoppedDelegateWrapper wrapper, GClosure* closure) 282 { 283 wrapper.remove(wrapper); 284 } 285 286 protected class OnPageChangedDelegateWrapper 287 { 288 static OnPageChangedDelegateWrapper[] listeners; 289 void delegate(int, DocumentIF) dlg; 290 gulong handlerId; 291 292 this(void delegate(int, DocumentIF) dlg) 293 { 294 this.dlg = dlg; 295 this.listeners ~= this; 296 } 297 298 void remove(OnPageChangedDelegateWrapper source) 299 { 300 foreach(index, wrapper; listeners) 301 { 302 if (wrapper.handlerId == source.handlerId) 303 { 304 listeners[index] = null; 305 listeners = std.algorithm.remove(listeners, index); 306 break; 307 } 308 } 309 } 310 } 311 312 /** 313 * The 'page-changed' signal is emitted when the current page of 314 * a document changes, e.g. pressing page up/down in a document 315 * viewer. 316 * 317 * Params: 318 * pageNumber = the new page number. If this value is unknown 319 * or not applicable, -1 should be provided. 320 * 321 * Since: 2.12 322 */ 323 gulong addOnPageChanged(void delegate(int, DocumentIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 324 { 325 auto wrapper = new OnPageChangedDelegateWrapper(dlg); 326 wrapper.handlerId = Signals.connectData( 327 this, 328 "page-changed", 329 cast(GCallback)&callBackPageChanged, 330 cast(void*)wrapper, 331 cast(GClosureNotify)&callBackPageChangedDestroy, 332 connectFlags); 333 return wrapper.handlerId; 334 } 335 336 extern(C) static void callBackPageChanged(AtkDocument* documentStruct, int pageNumber, OnPageChangedDelegateWrapper wrapper) 337 { 338 wrapper.dlg(pageNumber, wrapper.outer); 339 } 340 341 extern(C) static void callBackPageChangedDestroy(OnPageChangedDelegateWrapper wrapper, GClosure* closure) 342 { 343 wrapper.remove(wrapper); 344 } 345 346 protected class OnReloadDelegateWrapper 347 { 348 static OnReloadDelegateWrapper[] listeners; 349 void delegate(DocumentIF) dlg; 350 gulong handlerId; 351 352 this(void delegate(DocumentIF) dlg) 353 { 354 this.dlg = dlg; 355 this.listeners ~= this; 356 } 357 358 void remove(OnReloadDelegateWrapper source) 359 { 360 foreach(index, wrapper; listeners) 361 { 362 if (wrapper.handlerId == source.handlerId) 363 { 364 listeners[index] = null; 365 listeners = std.algorithm.remove(listeners, index); 366 break; 367 } 368 } 369 } 370 } 371 372 /** 373 * The 'reload' signal is emitted when the contents of a 374 * document is refreshed from its source. Once 'reload' has 375 * been emitted, a matching 'load-complete' or 'load-stopped' 376 * signal should follow, which clients may await before 377 * interrogating ATK for the latest document content. 378 */ 379 gulong addOnReload(void delegate(DocumentIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 380 { 381 auto wrapper = new OnReloadDelegateWrapper(dlg); 382 wrapper.handlerId = Signals.connectData( 383 this, 384 "reload", 385 cast(GCallback)&callBackReload, 386 cast(void*)wrapper, 387 cast(GClosureNotify)&callBackReloadDestroy, 388 connectFlags); 389 return wrapper.handlerId; 390 } 391 392 extern(C) static void callBackReload(AtkDocument* documentStruct, OnReloadDelegateWrapper wrapper) 393 { 394 wrapper.dlg(wrapper.outer); 395 } 396 397 extern(C) static void callBackReloadDestroy(OnReloadDelegateWrapper wrapper, GClosure* closure) 398 { 399 wrapper.remove(wrapper); 400 } 401 }