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