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 gsv.SourceFile; 26 27 private import gio.FileIF; 28 private import glib.ConstructionException; 29 private import gobject.ObjectG; 30 private import gsv.SourceEncoding; 31 private import gsv.c.functions; 32 public import gsv.c.types; 33 public import gsvc.gsvtypes; 34 35 36 /** */ 37 public class SourceFile : ObjectG 38 { 39 /** the main Gtk struct */ 40 protected GtkSourceFile* gtkSourceFile; 41 42 /** Get the main Gtk struct */ 43 public GtkSourceFile* getSourceFileStruct(bool transferOwnership = false) 44 { 45 if (transferOwnership) 46 ownedRef = false; 47 return gtkSourceFile; 48 } 49 50 /** the main Gtk struct as a void* */ 51 protected override void* getStruct() 52 { 53 return cast(void*)gtkSourceFile; 54 } 55 56 protected override void setStruct(GObject* obj) 57 { 58 gtkSourceFile = cast(GtkSourceFile*)obj; 59 super.setStruct(obj); 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (GtkSourceFile* gtkSourceFile, bool ownedRef = false) 66 { 67 this.gtkSourceFile = gtkSourceFile; 68 super(cast(GObject*)gtkSourceFile, ownedRef); 69 } 70 71 72 /** */ 73 public static GType getType() 74 { 75 return gtk_source_file_get_type(); 76 } 77 78 /** 79 * Returns: a new #GtkSourceFile object. 80 * 81 * Since: 3.14 82 * 83 * Throws: ConstructionException GTK+ fails to create the object. 84 */ 85 public this() 86 { 87 auto p = gtk_source_file_new(); 88 89 if(p is null) 90 { 91 throw new ConstructionException("null returned by new"); 92 } 93 94 this(cast(GtkSourceFile*) p, true); 95 } 96 97 /** 98 * Checks synchronously the file on disk, to know whether the file is externally 99 * modified, or has been deleted, and whether the file is read-only. 100 * 101 * #GtkSourceFile doesn't create a #GFileMonitor to track those properties, so 102 * this function needs to be called instead. Creating lots of #GFileMonitor's 103 * would take lots of resources. 104 * 105 * Since this function is synchronous, it is advised to call it only on local 106 * files. See gtk_source_file_is_local(). 107 * 108 * Since: 3.18 109 */ 110 public void checkFileOnDisk() 111 { 112 gtk_source_file_check_file_on_disk(gtkSourceFile); 113 } 114 115 /** 116 * Returns: the compression type. 117 * 118 * Since: 3.14 119 */ 120 public GtkSourceCompressionType getCompressionType() 121 { 122 return gtk_source_file_get_compression_type(gtkSourceFile); 123 } 124 125 /** 126 * The encoding is initially %NULL. After a successful file loading or saving 127 * operation, the encoding is non-%NULL. 128 * 129 * Returns: the character encoding. 130 * 131 * Since: 3.14 132 */ 133 public SourceEncoding getEncoding() 134 { 135 auto p = gtk_source_file_get_encoding(gtkSourceFile); 136 137 if(p is null) 138 { 139 return null; 140 } 141 142 return ObjectG.getDObject!(SourceEncoding)(cast(GtkSourceEncoding*) p); 143 } 144 145 /** 146 * Returns: the #GFile. 147 * 148 * Since: 3.14 149 */ 150 public FileIF getLocation() 151 { 152 auto p = gtk_source_file_get_location(gtkSourceFile); 153 154 if(p is null) 155 { 156 return null; 157 } 158 159 return ObjectG.getDObject!(FileIF)(cast(GFile*) p); 160 } 161 162 /** 163 * Returns: the newline type. 164 * 165 * Since: 3.14 166 */ 167 public GtkSourceNewlineType getNewlineType() 168 { 169 return gtk_source_file_get_newline_type(gtkSourceFile); 170 } 171 172 /** 173 * Returns whether the file has been deleted. If the 174 * #GtkSourceFile:location is %NULL, returns %FALSE. 175 * 176 * To have an up-to-date value, you must first call 177 * gtk_source_file_check_file_on_disk(). 178 * 179 * Returns: whether the file has been deleted. 180 * 181 * Since: 3.18 182 */ 183 public bool isDeleted() 184 { 185 return gtk_source_file_is_deleted(gtkSourceFile) != 0; 186 } 187 188 /** 189 * Returns whether the file is externally modified. If the 190 * #GtkSourceFile:location is %NULL, returns %FALSE. 191 * 192 * To have an up-to-date value, you must first call 193 * gtk_source_file_check_file_on_disk(). 194 * 195 * Returns: whether the file is externally modified. 196 * 197 * Since: 3.18 198 */ 199 public bool isExternallyModified() 200 { 201 return gtk_source_file_is_externally_modified(gtkSourceFile) != 0; 202 } 203 204 /** 205 * Returns whether the file is local. If the #GtkSourceFile:location is %NULL, 206 * returns %FALSE. 207 * 208 * Returns: whether the file is local. 209 * 210 * Since: 3.18 211 */ 212 public bool isLocal() 213 { 214 return gtk_source_file_is_local(gtkSourceFile) != 0; 215 } 216 217 /** 218 * Returns whether the file is read-only. If the 219 * #GtkSourceFile:location is %NULL, returns %FALSE. 220 * 221 * To have an up-to-date value, you must first call 222 * gtk_source_file_check_file_on_disk(). 223 * 224 * Returns: whether the file is read-only. 225 * 226 * Since: 3.18 227 */ 228 public bool isReadonly() 229 { 230 return gtk_source_file_is_readonly(gtkSourceFile) != 0; 231 } 232 233 /** 234 * Sets the location. 235 * 236 * Params: 237 * location = the new #GFile, or %NULL. 238 * 239 * Since: 3.14 240 */ 241 public void setLocation(FileIF location) 242 { 243 gtk_source_file_set_location(gtkSourceFile, (location is null) ? null : location.getFileStruct()); 244 } 245 246 /** 247 * Sets a #GtkSourceMountOperationFactory function that will be called when a 248 * #GMountOperation must be created. This is useful for creating a 249 * #GtkMountOperation with the parent #GtkWindow. 250 * 251 * If a mount operation factory isn't set, g_mount_operation_new() will be 252 * called. 253 * 254 * Params: 255 * callback = a #GtkSourceMountOperationFactory to call when a 256 * #GMountOperation is needed. 257 * userData = the data to pass to the @callback function. 258 * notify = function to call on @user_data when the @callback is no 259 * longer needed, or %NULL. 260 * 261 * Since: 3.14 262 */ 263 public void setMountOperationFactory(GtkSourceMountOperationFactory callback, void* userData, GDestroyNotify notify) 264 { 265 gtk_source_file_set_mount_operation_factory(gtkSourceFile, callback, userData, notify); 266 } 267 }