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 gio.MountT;
26 
27 public  import gio.AsyncResultIF;
28 public  import gio.Cancellable;
29 public  import gio.Drive;
30 public  import gio.DriveIF;
31 public  import gio.File;
32 public  import gio.FileIF;
33 public  import gio.Icon;
34 public  import gio.IconIF;
35 public  import gio.MountOperation;
36 public  import gio.Volume;
37 public  import gio.VolumeIF;
38 public  import glib.ErrorG;
39 public  import glib.GException;
40 public  import glib.Str;
41 public  import gobject.ObjectG;
42 public  import gobject.Signals;
43 public  import gtkc.gio;
44 public  import gtkc.giotypes;
45 public  import std.algorithm;
46 
47 
48 /**
49  * The #GMount interface represents user-visible mounts. Note, when
50  * porting from GnomeVFS, #GMount is the moral equivalent of #GnomeVFSVolume.
51  * 
52  * #GMount is a "mounted" filesystem that you can access. Mounted is in
53  * quotes because it's not the same as a unix mount, it might be a gvfs
54  * mount, but you can still access the files on it if you use GIO. Might or
55  * might not be related to a volume object.
56  * 
57  * Unmounting a #GMount instance is an asynchronous operation. For
58  * more information about asynchronous operations, see #GAsyncResult
59  * and #GTask. To unmount a #GMount instance, first call
60  * g_mount_unmount_with_operation() with (at least) the #GMount instance and a
61  * #GAsyncReadyCallback.  The callback will be fired when the
62  * operation has resolved (either with success or failure), and a
63  * #GAsyncReady structure will be passed to the callback.  That
64  * callback should then call g_mount_unmount_with_operation_finish() with the #GMount
65  * and the #GAsyncReady data to see if the operation was completed
66  * successfully.  If an @error is present when g_mount_unmount_with_operation_finish()
67  * is called, then it will be filled with any error information.
68  */
69 public template MountT(TStruct)
70 {
71 	/** Get the main Gtk struct */
72 	public GMount* getMountStruct()
73 	{
74 		return cast(GMount*)getStruct();
75 	}
76 
77 
78 	/**
79 	 * Checks if @mount can be eject.
80 	 *
81 	 * Returns: %TRUE if the @mount can be ejected.
82 	 */
83 	public bool canEject()
84 	{
85 		return g_mount_can_eject(getMountStruct()) != 0;
86 	}
87 
88 	/**
89 	 * Checks if @mount can be mounted.
90 	 *
91 	 * Returns: %TRUE if the @mount can be unmounted.
92 	 */
93 	public bool canUnmount()
94 	{
95 		return g_mount_can_unmount(getMountStruct()) != 0;
96 	}
97 
98 	/**
99 	 * Ejects a mount. This is an asynchronous operation, and is
100 	 * finished by calling g_mount_eject_finish() with the @mount
101 	 * and #GAsyncResult data returned in the @callback.
102 	 *
103 	 * Deprecated: Use g_mount_eject_with_operation() instead.
104 	 *
105 	 * Params:
106 	 *     flags = flags affecting the unmount if required for eject
107 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
108 	 *     callback = a #GAsyncReadyCallback, or %NULL.
109 	 *     userData = user data passed to @callback.
110 	 */
111 	public void eject(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
112 	{
113 		g_mount_eject(getMountStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
114 	}
115 
116 	/**
117 	 * Finishes ejecting a mount. If any errors occurred during the operation,
118 	 * @error will be set to contain the errors and %FALSE will be returned.
119 	 *
120 	 * Deprecated: Use g_mount_eject_with_operation_finish() instead.
121 	 *
122 	 * Params:
123 	 *     result = a #GAsyncResult.
124 	 *
125 	 * Returns: %TRUE if the mount was successfully ejected. %FALSE otherwise.
126 	 *
127 	 * Throws: GException on failure.
128 	 */
129 	public bool ejectFinish(AsyncResultIF result)
130 	{
131 		GError* err = null;
132 		
133 		auto p = g_mount_eject_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
134 		
135 		if (err !is null)
136 		{
137 			throw new GException( new ErrorG(err) );
138 		}
139 		
140 		return p;
141 	}
142 
143 	/**
144 	 * Ejects a mount. This is an asynchronous operation, and is
145 	 * finished by calling g_mount_eject_with_operation_finish() with the @mount
146 	 * and #GAsyncResult data returned in the @callback.
147 	 *
148 	 * Params:
149 	 *     flags = flags affecting the unmount if required for eject
150 	 *     mountOperation = a #GMountOperation or %NULL to avoid
151 	 *         user interaction.
152 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
153 	 *     callback = a #GAsyncReadyCallback, or %NULL.
154 	 *     userData = user data passed to @callback.
155 	 *
156 	 * Since: 2.22
157 	 */
158 	public void ejectWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
159 	{
160 		g_mount_eject_with_operation(getMountStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
161 	}
162 
163 	/**
164 	 * Finishes ejecting a mount. If any errors occurred during the operation,
165 	 * @error will be set to contain the errors and %FALSE will be returned.
166 	 *
167 	 * Params:
168 	 *     result = a #GAsyncResult.
169 	 *
170 	 * Returns: %TRUE if the mount was successfully ejected. %FALSE otherwise.
171 	 *
172 	 * Since: 2.22
173 	 *
174 	 * Throws: GException on failure.
175 	 */
176 	public bool ejectWithOperationFinish(AsyncResultIF result)
177 	{
178 		GError* err = null;
179 		
180 		auto p = g_mount_eject_with_operation_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
181 		
182 		if (err !is null)
183 		{
184 			throw new GException( new ErrorG(err) );
185 		}
186 		
187 		return p;
188 	}
189 
190 	/**
191 	 * Gets the default location of @mount. The default location of the given
192 	 * @mount is a path that reflects the main entry point for the user (e.g.
193 	 * the home directory, or the root of the volume).
194 	 *
195 	 * Returns: a #GFile.
196 	 *     The returned object should be unreffed with
197 	 *     g_object_unref() when no longer needed.
198 	 */
199 	public FileIF getDefaultLocation()
200 	{
201 		auto p = g_mount_get_default_location(getMountStruct());
202 		
203 		if(p is null)
204 		{
205 			return null;
206 		}
207 		
208 		return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true);
209 	}
210 
211 	/**
212 	 * Gets the drive for the @mount.
213 	 *
214 	 * This is a convenience method for getting the #GVolume and then
215 	 * using that object to get the #GDrive.
216 	 *
217 	 * Returns: a #GDrive or %NULL if @mount is not associated with a volume or a drive.
218 	 *     The returned object should be unreffed with
219 	 *     g_object_unref() when no longer needed.
220 	 */
221 	public DriveIF getDrive()
222 	{
223 		auto p = g_mount_get_drive(getMountStruct());
224 		
225 		if(p is null)
226 		{
227 			return null;
228 		}
229 		
230 		return ObjectG.getDObject!(Drive, DriveIF)(cast(GDrive*) p, true);
231 	}
232 
233 	/**
234 	 * Gets the icon for @mount.
235 	 *
236 	 * Returns: a #GIcon.
237 	 *     The returned object should be unreffed with
238 	 *     g_object_unref() when no longer needed.
239 	 */
240 	public IconIF getIcon()
241 	{
242 		auto p = g_mount_get_icon(getMountStruct());
243 		
244 		if(p is null)
245 		{
246 			return null;
247 		}
248 		
249 		return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p, true);
250 	}
251 
252 	/**
253 	 * Gets the name of @mount.
254 	 *
255 	 * Returns: the name for the given @mount.
256 	 *     The returned string should be freed with g_free()
257 	 *     when no longer needed.
258 	 */
259 	public string getName()
260 	{
261 		auto retStr = g_mount_get_name(getMountStruct());
262 		
263 		scope(exit) Str.freeString(retStr);
264 		return Str.toString(retStr);
265 	}
266 
267 	/**
268 	 * Gets the root directory on @mount.
269 	 *
270 	 * Returns: a #GFile.
271 	 *     The returned object should be unreffed with
272 	 *     g_object_unref() when no longer needed.
273 	 */
274 	public FileIF getRoot()
275 	{
276 		auto p = g_mount_get_root(getMountStruct());
277 		
278 		if(p is null)
279 		{
280 			return null;
281 		}
282 		
283 		return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true);
284 	}
285 
286 	/**
287 	 * Gets the sort key for @mount, if any.
288 	 *
289 	 * Returns: Sorting key for @mount or %NULL if no such key is available.
290 	 *
291 	 * Since: 2.32
292 	 */
293 	public string getSortKey()
294 	{
295 		return Str.toString(g_mount_get_sort_key(getMountStruct()));
296 	}
297 
298 	/**
299 	 * Gets the symbolic icon for @mount.
300 	 *
301 	 * Returns: a #GIcon.
302 	 *     The returned object should be unreffed with
303 	 *     g_object_unref() when no longer needed.
304 	 *
305 	 * Since: 2.34
306 	 */
307 	public IconIF getSymbolicIcon()
308 	{
309 		auto p = g_mount_get_symbolic_icon(getMountStruct());
310 		
311 		if(p is null)
312 		{
313 			return null;
314 		}
315 		
316 		return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p, true);
317 	}
318 
319 	/**
320 	 * Gets the UUID for the @mount. The reference is typically based on
321 	 * the file system UUID for the mount in question and should be
322 	 * considered an opaque string. Returns %NULL if there is no UUID
323 	 * available.
324 	 *
325 	 * Returns: the UUID for @mount or %NULL if no UUID can be computed.
326 	 *     The returned string should be freed with g_free()
327 	 *     when no longer needed.
328 	 */
329 	public string getUuid()
330 	{
331 		auto retStr = g_mount_get_uuid(getMountStruct());
332 		
333 		scope(exit) Str.freeString(retStr);
334 		return Str.toString(retStr);
335 	}
336 
337 	/**
338 	 * Gets the volume for the @mount.
339 	 *
340 	 * Returns: a #GVolume or %NULL if @mount is not associated with a volume.
341 	 *     The returned object should be unreffed with
342 	 *     g_object_unref() when no longer needed.
343 	 */
344 	public VolumeIF getVolume()
345 	{
346 		auto p = g_mount_get_volume(getMountStruct());
347 		
348 		if(p is null)
349 		{
350 			return null;
351 		}
352 		
353 		return ObjectG.getDObject!(Volume, VolumeIF)(cast(GVolume*) p, true);
354 	}
355 
356 	/**
357 	 * Tries to guess the type of content stored on @mount. Returns one or
358 	 * more textual identifiers of well-known content types (typically
359 	 * prefixed with "x-content/"), e.g. x-content/image-dcf for camera
360 	 * memory cards. See the
361 	 * [shared-mime-info](http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec)
362 	 * specification for more on x-content types.
363 	 *
364 	 * This is an asynchronous operation (see
365 	 * g_mount_guess_content_type_sync() for the synchronous version), and
366 	 * is finished by calling g_mount_guess_content_type_finish() with the
367 	 * @mount and #GAsyncResult data returned in the @callback.
368 	 *
369 	 * Params:
370 	 *     forceRescan = Whether to force a rescan of the content.
371 	 *         Otherwise a cached result will be used if available
372 	 *     cancellable = optional #GCancellable object, %NULL to ignore
373 	 *     callback = a #GAsyncReadyCallback
374 	 *     userData = user data passed to @callback
375 	 *
376 	 * Since: 2.18
377 	 */
378 	public void guessContentType(bool forceRescan, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
379 	{
380 		g_mount_guess_content_type(getMountStruct(), forceRescan, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
381 	}
382 
383 	/**
384 	 * Finishes guessing content types of @mount. If any errors occurred
385 	 * during the operation, @error will be set to contain the errors and
386 	 * %FALSE will be returned. In particular, you may get an
387 	 * %G_IO_ERROR_NOT_SUPPORTED if the mount does not support content
388 	 * guessing.
389 	 *
390 	 * Params:
391 	 *     result = a #GAsyncResult
392 	 *
393 	 * Returns: a %NULL-terminated array of content types or %NULL on error.
394 	 *     Caller should free this array with g_strfreev() when done with it.
395 	 *
396 	 * Since: 2.18
397 	 *
398 	 * Throws: GException on failure.
399 	 */
400 	public string[] guessContentTypeFinish(AsyncResultIF result)
401 	{
402 		GError* err = null;
403 		
404 		auto retStr = g_mount_guess_content_type_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err);
405 		
406 		if (err !is null)
407 		{
408 			throw new GException( new ErrorG(err) );
409 		}
410 		
411 		scope(exit) Str.freeStringArray(retStr);
412 		return Str.toStringArray(retStr);
413 	}
414 
415 	/**
416 	 * Tries to guess the type of content stored on @mount. Returns one or
417 	 * more textual identifiers of well-known content types (typically
418 	 * prefixed with "x-content/"), e.g. x-content/image-dcf for camera
419 	 * memory cards. See the
420 	 * [shared-mime-info](http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec)
421 	 * specification for more on x-content types.
422 	 *
423 	 * This is an synchronous operation and as such may block doing IO;
424 	 * see g_mount_guess_content_type() for the asynchronous version.
425 	 *
426 	 * Params:
427 	 *     forceRescan = Whether to force a rescan of the content.
428 	 *         Otherwise a cached result will be used if available
429 	 *     cancellable = optional #GCancellable object, %NULL to ignore
430 	 *
431 	 * Returns: a %NULL-terminated array of content types or %NULL on error.
432 	 *     Caller should free this array with g_strfreev() when done with it.
433 	 *
434 	 * Since: 2.18
435 	 *
436 	 * Throws: GException on failure.
437 	 */
438 	public string[] guessContentTypeSync(bool forceRescan, Cancellable cancellable)
439 	{
440 		GError* err = null;
441 		
442 		auto retStr = g_mount_guess_content_type_sync(getMountStruct(), forceRescan, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
443 		
444 		if (err !is null)
445 		{
446 			throw new GException( new ErrorG(err) );
447 		}
448 		
449 		scope(exit) Str.freeStringArray(retStr);
450 		return Str.toStringArray(retStr);
451 	}
452 
453 	/**
454 	 * Determines if @mount is shadowed. Applications or libraries should
455 	 * avoid displaying @mount in the user interface if it is shadowed.
456 	 *
457 	 * A mount is said to be shadowed if there exists one or more user
458 	 * visible objects (currently #GMount objects) with a root that is
459 	 * inside the root of @mount.
460 	 *
461 	 * One application of shadow mounts is when exposing a single file
462 	 * system that is used to address several logical volumes. In this
463 	 * situation, a #GVolumeMonitor implementation would create two
464 	 * #GVolume objects (for example, one for the camera functionality of
465 	 * the device and one for a SD card reader on the device) with
466 	 * activation URIs `gphoto2://[usb:001,002]/store1/`
467 	 * and `gphoto2://[usb:001,002]/store2/`. When the
468 	 * underlying mount (with root
469 	 * `gphoto2://[usb:001,002]/`) is mounted, said
470 	 * #GVolumeMonitor implementation would create two #GMount objects
471 	 * (each with their root matching the corresponding volume activation
472 	 * root) that would shadow the original mount.
473 	 *
474 	 * The proxy monitor in GVfs 2.26 and later, automatically creates and
475 	 * manage shadow mounts (and shadows the underlying mount) if the
476 	 * activation root on a #GVolume is set.
477 	 *
478 	 * Returns: %TRUE if @mount is shadowed.
479 	 *
480 	 * Since: 2.20
481 	 */
482 	public bool isShadowed()
483 	{
484 		return g_mount_is_shadowed(getMountStruct()) != 0;
485 	}
486 
487 	/**
488 	 * Remounts a mount. This is an asynchronous operation, and is
489 	 * finished by calling g_mount_remount_finish() with the @mount
490 	 * and #GAsyncResults data returned in the @callback.
491 	 *
492 	 * Remounting is useful when some setting affecting the operation
493 	 * of the volume has been changed, as these may need a remount to
494 	 * take affect. While this is semantically equivalent with unmounting
495 	 * and then remounting not all backends might need to actually be
496 	 * unmounted.
497 	 *
498 	 * Params:
499 	 *     flags = flags affecting the operation
500 	 *     mountOperation = a #GMountOperation or %NULL to avoid
501 	 *         user interaction.
502 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
503 	 *     callback = a #GAsyncReadyCallback, or %NULL.
504 	 *     userData = user data passed to @callback.
505 	 */
506 	public void remount(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
507 	{
508 		g_mount_remount(getMountStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
509 	}
510 
511 	/**
512 	 * Finishes remounting a mount. If any errors occurred during the operation,
513 	 * @error will be set to contain the errors and %FALSE will be returned.
514 	 *
515 	 * Params:
516 	 *     result = a #GAsyncResult.
517 	 *
518 	 * Returns: %TRUE if the mount was successfully remounted. %FALSE otherwise.
519 	 *
520 	 * Throws: GException on failure.
521 	 */
522 	public bool remountFinish(AsyncResultIF result)
523 	{
524 		GError* err = null;
525 		
526 		auto p = g_mount_remount_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
527 		
528 		if (err !is null)
529 		{
530 			throw new GException( new ErrorG(err) );
531 		}
532 		
533 		return p;
534 	}
535 
536 	/**
537 	 * Increments the shadow count on @mount. Usually used by
538 	 * #GVolumeMonitor implementations when creating a shadow mount for
539 	 * @mount, see g_mount_is_shadowed() for more information. The caller
540 	 * will need to emit the #GMount::changed signal on @mount manually.
541 	 *
542 	 * Since: 2.20
543 	 */
544 	public void shadow()
545 	{
546 		g_mount_shadow(getMountStruct());
547 	}
548 
549 	/**
550 	 * Unmounts a mount. This is an asynchronous operation, and is
551 	 * finished by calling g_mount_unmount_finish() with the @mount
552 	 * and #GAsyncResult data returned in the @callback.
553 	 *
554 	 * Deprecated: Use g_mount_unmount_with_operation() instead.
555 	 *
556 	 * Params:
557 	 *     flags = flags affecting the operation
558 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
559 	 *     callback = a #GAsyncReadyCallback, or %NULL.
560 	 *     userData = user data passed to @callback.
561 	 */
562 	public void unmount(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
563 	{
564 		g_mount_unmount(getMountStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
565 	}
566 
567 	/**
568 	 * Finishes unmounting a mount. If any errors occurred during the operation,
569 	 * @error will be set to contain the errors and %FALSE will be returned.
570 	 *
571 	 * Deprecated: Use g_mount_unmount_with_operation_finish() instead.
572 	 *
573 	 * Params:
574 	 *     result = a #GAsyncResult.
575 	 *
576 	 * Returns: %TRUE if the mount was successfully unmounted. %FALSE otherwise.
577 	 *
578 	 * Throws: GException on failure.
579 	 */
580 	public bool unmountFinish(AsyncResultIF result)
581 	{
582 		GError* err = null;
583 		
584 		auto p = g_mount_unmount_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
585 		
586 		if (err !is null)
587 		{
588 			throw new GException( new ErrorG(err) );
589 		}
590 		
591 		return p;
592 	}
593 
594 	/**
595 	 * Unmounts a mount. This is an asynchronous operation, and is
596 	 * finished by calling g_mount_unmount_with_operation_finish() with the @mount
597 	 * and #GAsyncResult data returned in the @callback.
598 	 *
599 	 * Params:
600 	 *     flags = flags affecting the operation
601 	 *     mountOperation = a #GMountOperation or %NULL to avoid
602 	 *         user interaction.
603 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
604 	 *     callback = a #GAsyncReadyCallback, or %NULL.
605 	 *     userData = user data passed to @callback.
606 	 *
607 	 * Since: 2.22
608 	 */
609 	public void unmountWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
610 	{
611 		g_mount_unmount_with_operation(getMountStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
612 	}
613 
614 	/**
615 	 * Finishes unmounting a mount. If any errors occurred during the operation,
616 	 * @error will be set to contain the errors and %FALSE will be returned.
617 	 *
618 	 * Params:
619 	 *     result = a #GAsyncResult.
620 	 *
621 	 * Returns: %TRUE if the mount was successfully unmounted. %FALSE otherwise.
622 	 *
623 	 * Since: 2.22
624 	 *
625 	 * Throws: GException on failure.
626 	 */
627 	public bool unmountWithOperationFinish(AsyncResultIF result)
628 	{
629 		GError* err = null;
630 		
631 		auto p = g_mount_unmount_with_operation_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
632 		
633 		if (err !is null)
634 		{
635 			throw new GException( new ErrorG(err) );
636 		}
637 		
638 		return p;
639 	}
640 
641 	/**
642 	 * Decrements the shadow count on @mount. Usually used by
643 	 * #GVolumeMonitor implementations when destroying a shadow mount for
644 	 * @mount, see g_mount_is_shadowed() for more information. The caller
645 	 * will need to emit the #GMount::changed signal on @mount manually.
646 	 *
647 	 * Since: 2.20
648 	 */
649 	public void unshadow()
650 	{
651 		g_mount_unshadow(getMountStruct());
652 	}
653 
654 	protected class OnChangedDelegateWrapper
655 	{
656 		static OnChangedDelegateWrapper[] listeners;
657 		void delegate(MountIF) dlg;
658 		gulong handlerId;
659 		
660 		this(void delegate(MountIF) dlg)
661 		{
662 			this.dlg = dlg;
663 			this.listeners ~= this;
664 		}
665 		
666 		void remove(OnChangedDelegateWrapper source)
667 		{
668 			foreach(index, wrapper; listeners)
669 			{
670 				if (wrapper.handlerId == source.handlerId)
671 				{
672 					listeners[index] = null;
673 					listeners = std.algorithm.remove(listeners, index);
674 					break;
675 				}
676 			}
677 		}
678 	}
679 
680 	/**
681 	 * Emitted when the mount has been changed.
682 	 */
683 	gulong addOnChanged(void delegate(MountIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
684 	{
685 		auto wrapper = new OnChangedDelegateWrapper(dlg);
686 		wrapper.handlerId = Signals.connectData(
687 			this,
688 			"changed",
689 			cast(GCallback)&callBackChanged,
690 			cast(void*)wrapper,
691 			cast(GClosureNotify)&callBackChangedDestroy,
692 			connectFlags);
693 		return wrapper.handlerId;
694 	}
695 	
696 	extern(C) static void callBackChanged(GMount* mountStruct, OnChangedDelegateWrapper wrapper)
697 	{
698 		wrapper.dlg(wrapper.outer);
699 	}
700 	
701 	extern(C) static void callBackChangedDestroy(OnChangedDelegateWrapper wrapper, GClosure* closure)
702 	{
703 		wrapper.remove(wrapper);
704 	}
705 
706 	protected class OnPreUnmountDelegateWrapper
707 	{
708 		static OnPreUnmountDelegateWrapper[] listeners;
709 		void delegate(MountIF) dlg;
710 		gulong handlerId;
711 		
712 		this(void delegate(MountIF) dlg)
713 		{
714 			this.dlg = dlg;
715 			this.listeners ~= this;
716 		}
717 		
718 		void remove(OnPreUnmountDelegateWrapper source)
719 		{
720 			foreach(index, wrapper; listeners)
721 			{
722 				if (wrapper.handlerId == source.handlerId)
723 				{
724 					listeners[index] = null;
725 					listeners = std.algorithm.remove(listeners, index);
726 					break;
727 				}
728 			}
729 		}
730 	}
731 
732 	/**
733 	 * This signal is emitted when the #GMount is about to be
734 	 * unmounted.
735 	 *
736 	 * Since: 2.22
737 	 */
738 	gulong addOnPreUnmount(void delegate(MountIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
739 	{
740 		auto wrapper = new OnPreUnmountDelegateWrapper(dlg);
741 		wrapper.handlerId = Signals.connectData(
742 			this,
743 			"pre-unmount",
744 			cast(GCallback)&callBackPreUnmount,
745 			cast(void*)wrapper,
746 			cast(GClosureNotify)&callBackPreUnmountDestroy,
747 			connectFlags);
748 		return wrapper.handlerId;
749 	}
750 	
751 	extern(C) static void callBackPreUnmount(GMount* mountStruct, OnPreUnmountDelegateWrapper wrapper)
752 	{
753 		wrapper.dlg(wrapper.outer);
754 	}
755 	
756 	extern(C) static void callBackPreUnmountDestroy(OnPreUnmountDelegateWrapper wrapper, GClosure* closure)
757 	{
758 		wrapper.remove(wrapper);
759 	}
760 
761 	protected class OnUnmountedDelegateWrapper
762 	{
763 		static OnUnmountedDelegateWrapper[] listeners;
764 		void delegate(MountIF) dlg;
765 		gulong handlerId;
766 		
767 		this(void delegate(MountIF) dlg)
768 		{
769 			this.dlg = dlg;
770 			this.listeners ~= this;
771 		}
772 		
773 		void remove(OnUnmountedDelegateWrapper source)
774 		{
775 			foreach(index, wrapper; listeners)
776 			{
777 				if (wrapper.handlerId == source.handlerId)
778 				{
779 					listeners[index] = null;
780 					listeners = std.algorithm.remove(listeners, index);
781 					break;
782 				}
783 			}
784 		}
785 	}
786 
787 	/**
788 	 * This signal is emitted when the #GMount have been
789 	 * unmounted. If the recipient is holding references to the
790 	 * object they should release them so the object can be
791 	 * finalized.
792 	 */
793 	gulong addOnUnmounted(void delegate(MountIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
794 	{
795 		auto wrapper = new OnUnmountedDelegateWrapper(dlg);
796 		wrapper.handlerId = Signals.connectData(
797 			this,
798 			"unmounted",
799 			cast(GCallback)&callBackUnmounted,
800 			cast(void*)wrapper,
801 			cast(GClosureNotify)&callBackUnmountedDestroy,
802 			connectFlags);
803 		return wrapper.handlerId;
804 	}
805 	
806 	extern(C) static void callBackUnmounted(GMount* mountStruct, OnUnmountedDelegateWrapper wrapper)
807 	{
808 		wrapper.dlg(wrapper.outer);
809 	}
810 	
811 	extern(C) static void callBackUnmountedDestroy(OnUnmountedDelegateWrapper wrapper, GClosure* closure)
812 	{
813 		wrapper.remove(wrapper);
814 	}
815 }