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.ContentFormatsBuilder; 26 27 private import gdk.ContentFormats; 28 private import gdk.c.functions; 29 public import gdk.c.types; 30 private import glib.ConstructionException; 31 private import glib.Str; 32 private import gobject.ObjectG; 33 private import gtkd.Loader; 34 35 36 /** 37 * A `GdkContentFormatsBuilder` is an auxiliary struct used to create 38 * new `GdkContentFormats`, and should not be kept around. 39 */ 40 public class ContentFormatsBuilder 41 { 42 /** the main Gtk struct */ 43 protected GdkContentFormatsBuilder* gdkContentFormatsBuilder; 44 protected bool ownedRef; 45 46 /** Get the main Gtk struct */ 47 public GdkContentFormatsBuilder* getContentFormatsBuilderStruct(bool transferOwnership = false) 48 { 49 if (transferOwnership) 50 ownedRef = false; 51 return gdkContentFormatsBuilder; 52 } 53 54 /** the main Gtk struct as a void* */ 55 protected void* getStruct() 56 { 57 return cast(void*)gdkContentFormatsBuilder; 58 } 59 60 /** 61 * Sets our main struct and passes it to the parent class. 62 */ 63 public this (GdkContentFormatsBuilder* gdkContentFormatsBuilder, bool ownedRef = false) 64 { 65 this.gdkContentFormatsBuilder = gdkContentFormatsBuilder; 66 this.ownedRef = ownedRef; 67 } 68 69 ~this () 70 { 71 if ( Linker.isLoaded(LIBRARY_GDK) && ownedRef ) 72 gdk_content_formats_builder_unref(gdkContentFormatsBuilder); 73 } 74 75 76 /** */ 77 public static GType getType() 78 { 79 return gdk_content_formats_builder_get_type(); 80 } 81 82 /** 83 * Create a new `GdkContentFormatsBuilder` object. 84 * 85 * The resulting builder would create an empty `GdkContentFormats`. 86 * Use addition functions to add types to it. 87 * 88 * Returns: a new `GdkContentFormatsBuilder` 89 * 90 * Throws: ConstructionException GTK+ fails to create the object. 91 */ 92 public this() 93 { 94 auto __p = gdk_content_formats_builder_new(); 95 96 if(__p is null) 97 { 98 throw new ConstructionException("null returned by new"); 99 } 100 101 this(cast(GdkContentFormatsBuilder*) __p); 102 } 103 104 /** 105 * Appends all formats from @formats to @builder, skipping those that 106 * already exist. 107 * 108 * Params: 109 * formats = the formats to add 110 */ 111 public void addFormats(ContentFormats formats) 112 { 113 gdk_content_formats_builder_add_formats(gdkContentFormatsBuilder, (formats is null) ? null : formats.getContentFormatsStruct()); 114 } 115 116 /** 117 * Appends @type to @builder if it has not already been added. 118 * 119 * Params: 120 * type = a `GType` 121 */ 122 public void addGtype(GType type) 123 { 124 gdk_content_formats_builder_add_gtype(gdkContentFormatsBuilder, type); 125 } 126 127 /** 128 * Appends @mime_type to @builder if it has not already been added. 129 * 130 * Params: 131 * mimeType = a mime type 132 */ 133 public void addMimeType(string mimeType) 134 { 135 gdk_content_formats_builder_add_mime_type(gdkContentFormatsBuilder, Str.toStringz(mimeType)); 136 } 137 138 /** 139 * Creates a new `GdkContentFormats` from the current state of the 140 * given @builder, and frees the @builder instance. 141 * 142 * Returns: the newly created `GdkContentFormats` 143 * with all the formats added to @builder 144 */ 145 public ContentFormats freeToFormats() 146 { 147 auto __p = gdk_content_formats_builder_free_to_formats(gdkContentFormatsBuilder); 148 149 if(__p is null) 150 { 151 return null; 152 } 153 154 return ObjectG.getDObject!(ContentFormats)(cast(GdkContentFormats*) __p, true); 155 } 156 157 alias doref = ref_; 158 /** 159 * Acquires a reference on the given @builder. 160 * 161 * This function is intended primarily for bindings. 162 * `GdkContentFormatsBuilder` objects should not be kept around. 163 * 164 * Returns: the given `GdkContentFormatsBuilder` 165 * with its reference count increased 166 */ 167 public ContentFormatsBuilder ref_() 168 { 169 auto __p = gdk_content_formats_builder_ref(gdkContentFormatsBuilder); 170 171 if(__p is null) 172 { 173 return null; 174 } 175 176 return ObjectG.getDObject!(ContentFormatsBuilder)(cast(GdkContentFormatsBuilder*) __p); 177 } 178 179 /** 180 * Creates a new `GdkContentFormats` from the given @builder. 181 * 182 * The given `GdkContentFormatsBuilder` is reset once this function returns; 183 * you cannot call this function multiple times on the same @builder instance. 184 * 185 * This function is intended primarily for bindings. C code should use 186 * [method@Gdk.ContentFormatsBuilder.free_to_formats]. 187 * 188 * Returns: the newly created `GdkContentFormats` 189 * with all the formats added to @builder 190 */ 191 public ContentFormats toFormats() 192 { 193 auto __p = gdk_content_formats_builder_to_formats(gdkContentFormatsBuilder); 194 195 if(__p is null) 196 { 197 return null; 198 } 199 200 return ObjectG.getDObject!(ContentFormats)(cast(GdkContentFormats*) __p, true); 201 } 202 203 /** 204 * Releases a reference on the given @builder. 205 */ 206 public void unref() 207 { 208 gdk_content_formats_builder_unref(gdkContentFormatsBuilder); 209 } 210 }