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  * Conversion parameters:
26  * inFile  = GVolume.html
27  * outPack = gio
28  * outFile = VolumeT
29  * strct   = GVolume
30  * realStrct=
31  * ctorStrct=
32  * clss    = VolumeT
33  * interf  = VolumeIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- g_volume_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- glib.ErrorG
49  * 	- glib.GException
50  * 	- gobject.Signals
51  * 	- gio.AsyncResultIF
52  * 	- gio.Cancellable
53  * 	- gio.Drive
54  * 	- gio.DriveIF
55  * 	- gio.File
56  * 	- gio.Icon
57  * 	- gio.IconIF
58  * 	- gio.Mount
59  * 	- gio.MountIF
60  * 	- gio.MountOperation
61  * structWrap:
62  * 	- GAsyncResult* -> AsyncResultIF
63  * 	- GCancellable* -> Cancellable
64  * 	- GDrive* -> DriveIF
65  * 	- GFile* -> File
66  * 	- GIcon* -> IconIF
67  * 	- GMount* -> MountIF
68  * 	- GMountOperation* -> MountOperation
69  * module aliases:
70  * local aliases:
71  * overrides:
72  */
73 
74 module gio.VolumeT;
75 
76 public  import gtkc.giotypes;
77 
78 public import gtkc.gio;
79 public import glib.ConstructionException;
80 public import gobject.ObjectG;
81 
82 public import gobject.Signals;
83 public  import gtkc.gdktypes;
84 public import glib.Str;
85 public import glib.ErrorG;
86 public import glib.GException;
87 public import gobject.Signals;
88 public import gio.AsyncResultIF;
89 public import gio.Cancellable;
90 public import gio.Drive;
91 public import gio.DriveIF;
92 public import gio.File;
93 public import gio.Icon;
94 public import gio.IconIF;
95 public import gio.Mount;
96 public import gio.MountIF;
97 public import gio.MountOperation;
98 
99 
100 
101 /**
102  * The GVolume interface represents user-visible objects that can be
103  * mounted. Note, when porting from GnomeVFS, GVolume is the moral
104  * equivalent of GnomeVFSDrive.
105  *
106  * Mounting a GVolume instance is an asynchronous operation. For more
107  * information about asynchronous operations, see GAsyncResult and
108  * GTask. To mount a GVolume, first call g_volume_mount() with (at
109  * least) the GVolume instance, optionally a GMountOperation object
110  * and a GAsyncReadyCallback.
111  *
112  * Typically, one will only want to pass NULL for the
113  * GMountOperation if automounting all volumes when a desktop session
114  * starts since it's not desirable to put up a lot of dialogs asking
115  * for credentials.
116  *
117  * The callback will be fired when the operation has resolved (either
118  * with success or failure), and a GAsyncReady structure will be
119  * passed to the callback. That callback should then call
120  * g_volume_mount_finish() with the GVolume instance and the
121  * GAsyncReady data to see if the operation was completed
122  * successfully. If an error is present when g_volume_mount_finish()
123  * is called, then it will be filled with any error information.
124  *
125  * It is sometimes necessary to directly access the underlying
126  * operating system object behind a volume (e.g. for passing a volume
127  * to an application via the commandline). For this purpose, GIO
128  * allows to obtain an 'identifier' for the volume. There can be
129  * different kinds of identifiers, such as Hal UDIs, filesystem labels,
130  * traditional Unix devices (e.g. /dev/sda2),
131  * uuids. GIO uses predefind strings as names for the different kinds
132  * of identifiers: G_VOLUME_IDENTIFIER_KIND_HAL_UDI,
133  * G_VOLUME_IDENTIFIER_KIND_LABEL, etc. Use g_volume_get_identifier()
134  * to obtain an identifier for a volume.
135  *
136  * Note that G_VOLUME_IDENTIFIER_KIND_HAL_UDI will only be available
137  * when the gvfs hal volume monitor is in use. Other volume monitors
138  * will generally be able to provide the G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE
139  * identifier, which can be used to obtain a hal device by means of
140  * libhal_manager_find_device_string_match().
141  */
142 public template VolumeT(TStruct)
143 {
144 	
145 	/** the main Gtk struct */
146 	protected GVolume* gVolume;
147 	
148 	
149 	/** Get the main Gtk struct */
150 	public GVolume* getVolumeTStruct()
151 	{
152 		return cast(GVolume*)getStruct();
153 	}
154 	
155 	
156 	/**
157 	 */
158 	int[string] connectedSignals;
159 	
160 	void delegate(VolumeIF)[] _onChangedListeners;
161 	@property void delegate(VolumeIF)[] onChangedListeners()
162 	{
163 		return  _onChangedListeners;
164 	}
165 	/**
166 	 * Emitted when the volume has been changed.
167 	 */
168 	void addOnChanged(void delegate(VolumeIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
169 	{
170 		if ( !("changed" in connectedSignals) )
171 		{
172 			Signals.connectData(
173 			getStruct(),
174 			"changed",
175 			cast(GCallback)&callBackChanged,
176 			cast(void*)cast(VolumeIF)this,
177 			null,
178 			connectFlags);
179 			connectedSignals["changed"] = 1;
180 		}
181 		_onChangedListeners ~= dlg;
182 	}
183 	extern(C) static void callBackChanged(GVolume* arg0Struct, VolumeIF _volumeIF)
184 	{
185 		foreach ( void delegate(VolumeIF) dlg ; _volumeIF.onChangedListeners )
186 		{
187 			dlg(_volumeIF);
188 		}
189 	}
190 	
191 	void delegate(VolumeIF)[] _onRemovedListeners;
192 	@property void delegate(VolumeIF)[] onRemovedListeners()
193 	{
194 		return  _onRemovedListeners;
195 	}
196 	/**
197 	 * This signal is emitted when the GVolume have been removed. If
198 	 * the recipient is holding references to the object they should
199 	 * release them so the object can be finalized.
200 	 */
201 	void addOnRemoved(void delegate(VolumeIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
202 	{
203 		if ( !("removed" in connectedSignals) )
204 		{
205 			Signals.connectData(
206 			getStruct(),
207 			"removed",
208 			cast(GCallback)&callBackRemoved,
209 			cast(void*)cast(VolumeIF)this,
210 			null,
211 			connectFlags);
212 			connectedSignals["removed"] = 1;
213 		}
214 		_onRemovedListeners ~= dlg;
215 	}
216 	extern(C) static void callBackRemoved(GVolume* arg0Struct, VolumeIF _volumeIF)
217 	{
218 		foreach ( void delegate(VolumeIF) dlg ; _volumeIF.onRemovedListeners )
219 		{
220 			dlg(_volumeIF);
221 		}
222 	}
223 	
224 	
225 	/**
226 	 * Gets the name of volume.
227 	 * Returns: the name for the given volume. The returned string should be freed with g_free() when no longer needed.
228 	 */
229 	public string getName()
230 	{
231 		// char * g_volume_get_name (GVolume *volume);
232 		return Str.toString(g_volume_get_name(getVolumeTStruct()));
233 	}
234 	
235 	/**
236 	 * Gets the UUID for the volume. The reference is typically based on
237 	 * the file system UUID for the volume in question and should be
238 	 * considered an opaque string. Returns NULL if there is no UUID
239 	 * available.
240 	 * Returns: the UUID for volume or NULL if no UUID can be computed. The returned string should be freed with g_free() when no longer needed.
241 	 */
242 	public string getUuid()
243 	{
244 		// char * g_volume_get_uuid (GVolume *volume);
245 		return Str.toString(g_volume_get_uuid(getVolumeTStruct()));
246 	}
247 	
248 	/**
249 	 * Gets the icon for volume.
250 	 * Returns: a GIcon. The returned object should be unreffed with g_object_unref() when no longer needed. [transfer full]
251 	 */
252 	public IconIF getIcon()
253 	{
254 		// GIcon * g_volume_get_icon (GVolume *volume);
255 		auto p = g_volume_get_icon(getVolumeTStruct());
256 		
257 		if(p is null)
258 		{
259 			return null;
260 		}
261 		
262 		return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p);
263 	}
264 	
265 	/**
266 	 * Gets the symbolic icon for volume.
267 	 * Since 2.34
268 	 * Returns: a GIcon. The returned object should be unreffed with g_object_unref() when no longer needed. [transfer full]
269 	 */
270 	public IconIF getSymbolicIcon()
271 	{
272 		// GIcon * g_volume_get_symbolic_icon (GVolume *volume);
273 		auto p = g_volume_get_symbolic_icon(getVolumeTStruct());
274 		
275 		if(p is null)
276 		{
277 			return null;
278 		}
279 		
280 		return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p);
281 	}
282 	
283 	/**
284 	 * Gets the drive for the volume.
285 	 * Returns: a GDrive or NULL if volume is not associated with a drive. The returned object should be unreffed with g_object_unref() when no longer needed. [transfer full]
286 	 */
287 	public DriveIF getDrive()
288 	{
289 		// GDrive * g_volume_get_drive (GVolume *volume);
290 		auto p = g_volume_get_drive(getVolumeTStruct());
291 		
292 		if(p is null)
293 		{
294 			return null;
295 		}
296 		
297 		return ObjectG.getDObject!(Drive, DriveIF)(cast(GDrive*) p);
298 	}
299 	
300 	/**
301 	 * Gets the mount for the volume.
302 	 * Returns: a GMount or NULL if volume isn't mounted. The returned object should be unreffed with g_object_unref() when no longer needed. [transfer full]
303 	 */
304 	public MountIF getMount()
305 	{
306 		// GMount * g_volume_get_mount (GVolume *volume);
307 		auto p = g_volume_get_mount(getVolumeTStruct());
308 		
309 		if(p is null)
310 		{
311 			return null;
312 		}
313 		
314 		return ObjectG.getDObject!(Mount, MountIF)(cast(GMount*) p);
315 	}
316 	
317 	/**
318 	 * Checks if a volume can be mounted.
319 	 * Returns: TRUE if the volume can be mounted. FALSE otherwise.
320 	 */
321 	public int canMount()
322 	{
323 		// gboolean g_volume_can_mount (GVolume *volume);
324 		return g_volume_can_mount(getVolumeTStruct());
325 	}
326 	
327 	/**
328 	 * Returns whether the volume should be automatically mounted.
329 	 * Returns: TRUE if the volume should be automatically mounted.
330 	 */
331 	public int shouldAutomount()
332 	{
333 		// gboolean g_volume_should_automount (GVolume *volume);
334 		return g_volume_should_automount(getVolumeTStruct());
335 	}
336 	
337 	/**
338 	 * Gets the activation root for a GVolume if it is known ahead of
339 	 * mount time. Returns NULL otherwise. If not NULL and if volume
340 	 * is mounted, then the result of g_mount_get_root() on the
341 	 * GMount object obtained from g_volume_get_mount() will always
342 	 * either be equal or a prefix of what this function returns. In
343 	 * other words, in code
344 	 *  GMount *mount;
345 	 *  GFile *mount_root
346 	 *  GFile *volume_activation_root;
347 	 *  mount = g_volume_get_mount (volume); /+* mounted, so never NULL +/
348 	 *  mount_root = g_mount_get_root (mount);
349 	 *  volume_activation_root = g_volume_get_activation_root(volume); /+* assume not NULL +/
350 	 * then the expression
351 	 *  (g_file_has_prefix (volume_activation_root, mount_root) ||
352 	 *  g_file_equal (volume_activation_root, mount_root))
353 	 * will always be TRUE.
354 	 * Activation roots are typically used in GVolumeMonitor
355 	 * implementations to find the underlying mount to shadow, see
356 	 * g_mount_is_shadowed() for more details.
357 	 * Since 2.18
358 	 * Returns: the activation root of volume or NULL. Use g_object_unref() to free. [transfer full]
359 	 */
360 	public File getActivationRoot()
361 	{
362 		// GFile * g_volume_get_activation_root (GVolume *volume);
363 		auto p = g_volume_get_activation_root(getVolumeTStruct());
364 		
365 		if(p is null)
366 		{
367 			return null;
368 		}
369 		
370 		return ObjectG.getDObject!(File)(cast(GFile*) p);
371 	}
372 	
373 	/**
374 	 * Mounts a volume. This is an asynchronous operation, and is
375 	 * finished by calling g_volume_mount_finish() with the volume
376 	 * and GAsyncResult returned in the callback.
377 	 * Virtual: mount_fn
378 	 * Params:
379 	 * flags = flags affecting the operation
380 	 * mountOperation = a GMountOperation or NULL to avoid user interaction. [allow-none]
381 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
382 	 * callback = a GAsyncReadyCallback, or NULL. [allow-none]
383 	 * userData = user data that gets passed to callback
384 	 */
385 	public void mount(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
386 	{
387 		// void g_volume_mount (GVolume *volume,  GMountMountFlags flags,  GMountOperation *mount_operation,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
388 		g_volume_mount(getVolumeTStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
389 	}
390 	
391 	/**
392 	 * Finishes mounting a volume. If any errors occurred during the operation,
393 	 * error will be set to contain the errors and FALSE will be returned.
394 	 * If the mount operation succeeded, g_volume_get_mount() on volume
395 	 * is guaranteed to return the mount right after calling this
396 	 * function; there's no need to listen for the 'mount-added' signal on
397 	 * GVolumeMonitor.
398 	 * Params:
399 	 * result = a GAsyncResult
400 	 * Returns: TRUE, FALSE if operation failed.
401 	 * Throws: GException on failure.
402 	 */
403 	public int mountFinish(AsyncResultIF result)
404 	{
405 		// gboolean g_volume_mount_finish (GVolume *volume,  GAsyncResult *result,  GError **error);
406 		GError* err = null;
407 		
408 		auto p = g_volume_mount_finish(getVolumeTStruct(), (result is null) ? null : result.getAsyncResultTStruct(), &err);
409 		
410 		if (err !is null)
411 		{
412 			throw new GException( new ErrorG(err) );
413 		}
414 		
415 		return p;
416 	}
417 	
418 	/**
419 	 * Checks if a volume can be ejected.
420 	 * Returns: TRUE if the volume can be ejected. FALSE otherwise.
421 	 */
422 	public int canEject()
423 	{
424 		// gboolean g_volume_can_eject (GVolume *volume);
425 		return g_volume_can_eject(getVolumeTStruct());
426 	}
427 	
428 	/**
429 	 * Warning
430 	 * g_volume_eject has been deprecated since version 2.22 and should not be used in newly-written code. Use g_volume_eject_with_operation() instead.
431 	 * Ejects a volume. This is an asynchronous operation, and is
432 	 * finished by calling g_volume_eject_finish() with the volume
433 	 * and GAsyncResult returned in the callback.
434 	 * Params:
435 	 * flags = flags affecting the unmount if required for eject
436 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
437 	 * callback = a GAsyncReadyCallback, or NULL. [allow-none]
438 	 * userData = user data that gets passed to callback
439 	 */
440 	public void eject(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
441 	{
442 		// void g_volume_eject (GVolume *volume,  GMountUnmountFlags flags,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
443 		g_volume_eject(getVolumeTStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
444 	}
445 	
446 	/**
447 	 * Warning
448 	 * g_volume_eject_finish has been deprecated since version 2.22 and should not be used in newly-written code. Use g_volume_eject_with_operation_finish() instead.
449 	 * Finishes ejecting a volume. If any errors occurred during the operation,
450 	 * error will be set to contain the errors and FALSE will be returned.
451 	 * Params:
452 	 * result = a GAsyncResult.
453 	 * Returns: TRUE, FALSE if operation failed.
454 	 * Throws: GException on failure.
455 	 */
456 	public int ejectFinish(AsyncResultIF result)
457 	{
458 		// gboolean g_volume_eject_finish (GVolume *volume,  GAsyncResult *result,  GError **error);
459 		GError* err = null;
460 		
461 		auto p = g_volume_eject_finish(getVolumeTStruct(), (result is null) ? null : result.getAsyncResultTStruct(), &err);
462 		
463 		if (err !is null)
464 		{
465 			throw new GException( new ErrorG(err) );
466 		}
467 		
468 		return p;
469 	}
470 	
471 	/**
472 	 * Ejects a volume. This is an asynchronous operation, and is
473 	 * finished by calling g_volume_eject_with_operation_finish() with the volume
474 	 * and GAsyncResult data returned in the callback.
475 	 * Since 2.22
476 	 * Params:
477 	 * flags = flags affecting the unmount if required for eject
478 	 * mountOperation = a GMountOperation or NULL to
479 	 * avoid user interaction. [allow-none]
480 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
481 	 * callback = a GAsyncReadyCallback, or NULL. [allow-none]
482 	 * userData = user data passed to callback.
483 	 */
484 	public void ejectWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
485 	{
486 		// void g_volume_eject_with_operation (GVolume *volume,  GMountUnmountFlags flags,  GMountOperation *mount_operation,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
487 		g_volume_eject_with_operation(getVolumeTStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
488 	}
489 	
490 	/**
491 	 * Finishes ejecting a volume. If any errors occurred during the operation,
492 	 * error will be set to contain the errors and FALSE will be returned.
493 	 * Since 2.22
494 	 * Params:
495 	 * result = a GAsyncResult.
496 	 * Returns: TRUE if the volume was successfully ejected. FALSE otherwise.
497 	 * Throws: GException on failure.
498 	 */
499 	public int ejectWithOperationFinish(AsyncResultIF result)
500 	{
501 		// gboolean g_volume_eject_with_operation_finish  (GVolume *volume,  GAsyncResult *result,  GError **error);
502 		GError* err = null;
503 		
504 		auto p = g_volume_eject_with_operation_finish(getVolumeTStruct(), (result is null) ? null : result.getAsyncResultTStruct(), &err);
505 		
506 		if (err !is null)
507 		{
508 			throw new GException( new ErrorG(err) );
509 		}
510 		
511 		return p;
512 	}
513 	
514 	/**
515 	 * Gets the kinds of identifiers
516 	 * that volume has. Use g_volume_get_identifier() to obtain
517 	 * the identifiers themselves.
518 	 * Returns: a NULL-terminated array of strings containing kinds of identifiers. Use g_strfreev() to free. [array zero-terminated=1][transfer full]
519 	 */
520 	public string[] enumerateIdentifiers()
521 	{
522 		// char ** g_volume_enumerate_identifiers (GVolume *volume);
523 		return Str.toStringArray(g_volume_enumerate_identifiers(getVolumeTStruct()));
524 	}
525 	
526 	/**
527 	 * Gets the identifier of the given kind for volume.
528 	 * See the introduction
529 	 * for more information about volume identifiers.
530 	 * Params:
531 	 * kind = the kind of identifier to return
532 	 * Returns: a newly allocated string containing the requested identfier, or NULL if the GVolume doesn't have this kind of identifier
533 	 */
534 	public string getIdentifier(string kind)
535 	{
536 		// char * g_volume_get_identifier (GVolume *volume,  const char *kind);
537 		return Str.toString(g_volume_get_identifier(getVolumeTStruct(), Str.toStringz(kind)));
538 	}
539 	
540 	/**
541 	 * Gets the sort key for volume, if any.
542 	 * Since 2.32
543 	 * Signal Details
544 	 * The "changed" signal
545 	 * void user_function (GVolume *arg0,
546 	 *  gpointer user_data) : Run Last
547 	 * Emitted when the volume has been changed.
548 	 * Returns: Sorting key for volume or NULL if no such key is available.
549 	 */
550 	public string getSortKey()
551 	{
552 		// const gchar * g_volume_get_sort_key (GVolume *volume);
553 		return Str.toString(g_volume_get_sort_key(getVolumeTStruct()));
554 	}
555 }