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