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