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 gdk.ContentSerializer; 26 27 private import gdk.c.functions; 28 public import gdk.c.types; 29 private import gio.AsyncResultIF; 30 private import gio.AsyncResultT; 31 private import gio.Cancellable; 32 private import gio.OutputStream; 33 private import glib.ErrorG; 34 private import glib.Str; 35 private import glib.c.functions; 36 private import gobject.ObjectG; 37 private import gobject.Value; 38 39 40 /** 41 * A `GdkContentSerializer` is used to serialize content for 42 * inter-application data transfers. 43 * 44 * The `GdkContentSerializer` transforms an object that is identified 45 * by a GType into a serialized form (i.e. a byte stream) that is 46 * identified by a mime type. 47 * 48 * GTK provides serializers and deserializers for common data types 49 * such as text, colors, images or file lists. To register your own 50 * serialization functions, use [func@content_register_serializer]. 51 * 52 * Also see [class@Gdk.ContentDeserializer]. 53 */ 54 public class ContentSerializer : ObjectG, AsyncResultIF 55 { 56 /** the main Gtk struct */ 57 protected GdkContentSerializer* gdkContentSerializer; 58 59 /** Get the main Gtk struct */ 60 public GdkContentSerializer* getContentSerializerStruct(bool transferOwnership = false) 61 { 62 if (transferOwnership) 63 ownedRef = false; 64 return gdkContentSerializer; 65 } 66 67 /** the main Gtk struct as a void* */ 68 protected override void* getStruct() 69 { 70 return cast(void*)gdkContentSerializer; 71 } 72 73 /** 74 * Sets our main struct and passes it to the parent class. 75 */ 76 public this (GdkContentSerializer* gdkContentSerializer, bool ownedRef = false) 77 { 78 this.gdkContentSerializer = gdkContentSerializer; 79 super(cast(GObject*)gdkContentSerializer, ownedRef); 80 } 81 82 // add the AsyncResult capabilities 83 mixin AsyncResultT!(GdkContentSerializer); 84 85 86 /** */ 87 public static GType getType() 88 { 89 return gdk_content_serializer_get_type(); 90 } 91 92 /** 93 * Gets the cancellable for the current operation. 94 * 95 * This is the `GCancellable` that was passed to [content_serialize_async]. 96 * 97 * Returns: the cancellable for the current operation 98 */ 99 public Cancellable getCancellable() 100 { 101 auto __p = gdk_content_serializer_get_cancellable(gdkContentSerializer); 102 103 if(__p is null) 104 { 105 return null; 106 } 107 108 return ObjectG.getDObject!(Cancellable)(cast(GCancellable*) __p); 109 } 110 111 /** 112 * Gets the `GType` to of the object to serialize. 113 * 114 * Returns: the `GType` for the current operation 115 */ 116 public GType getGtype() 117 { 118 return gdk_content_serializer_get_gtype(gdkContentSerializer); 119 } 120 121 /** 122 * Gets the mime type to serialize to. 123 * 124 * Returns: the mime type for the current operation 125 */ 126 public string getMimeType() 127 { 128 return Str.toString(gdk_content_serializer_get_mime_type(gdkContentSerializer)); 129 } 130 131 /** 132 * Gets the output stream for the current operation. 133 * 134 * This is the stream that was passed to [func@content_serialize_async]. 135 * 136 * Returns: the output stream for the current operation 137 */ 138 public OutputStream getOutputStream() 139 { 140 auto __p = gdk_content_serializer_get_output_stream(gdkContentSerializer); 141 142 if(__p is null) 143 { 144 return null; 145 } 146 147 return ObjectG.getDObject!(OutputStream)(cast(GOutputStream*) __p); 148 } 149 150 /** 151 * Gets the I/O priority for the current operation. 152 * 153 * This is the priority that was passed to [func@content_serialize_async]. 154 * 155 * Returns: the I/O priority for the current operation 156 */ 157 public int getPriority() 158 { 159 return gdk_content_serializer_get_priority(gdkContentSerializer); 160 } 161 162 /** 163 * Gets the data that was associated with the current operation. 164 * 165 * See [method@Gdk.ContentSerializer.set_task_data]. 166 * 167 * Returns: the task data for @serializer 168 */ 169 public void* getTaskData() 170 { 171 return gdk_content_serializer_get_task_data(gdkContentSerializer); 172 } 173 174 /** 175 * Gets the user data that was passed when the serializer was registered. 176 * 177 * Returns: the user data for this serializer 178 */ 179 public void* getUserData() 180 { 181 return gdk_content_serializer_get_user_data(gdkContentSerializer); 182 } 183 184 /** 185 * Gets the `GValue` to read the object to serialize from. 186 * 187 * Returns: the `GValue` for the current operation 188 */ 189 public Value getValue() 190 { 191 auto __p = gdk_content_serializer_get_value(gdkContentSerializer); 192 193 if(__p is null) 194 { 195 return null; 196 } 197 198 return ObjectG.getDObject!(Value)(cast(GValue*) __p); 199 } 200 201 /** 202 * Indicate that the serialization has ended with an error. 203 * 204 * This function consumes @error. 205 * 206 * Params: 207 * error = a `GError` 208 */ 209 public void returnError(ErrorG error) 210 { 211 gdk_content_serializer_return_error(gdkContentSerializer, (error is null) ? null : error.getErrorGStruct()); 212 } 213 214 /** 215 * Indicate that the serialization has been successfully completed. 216 */ 217 public void returnSuccess() 218 { 219 gdk_content_serializer_return_success(gdkContentSerializer); 220 } 221 222 /** 223 * Associate data with the current serialization operation. 224 * 225 * Params: 226 * data = data to associate with this operation 227 * notify = destroy notify for @data 228 */ 229 public void setTaskData(void* data, GDestroyNotify notify) 230 { 231 gdk_content_serializer_set_task_data(gdkContentSerializer, data, notify); 232 } 233 }