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.VolumeMonitor;
26 
27 private import gio.DriveIF;
28 private import gio.MountIF;
29 private import gio.VolumeIF;
30 private import gio.c.functions;
31 public  import gio.c.types;
32 private import glib.ConstructionException;
33 private import glib.ListG;
34 private import glib.Str;
35 private import gobject.ObjectG;
36 private import gobject.Signals;
37 public  import gtkc.giotypes;
38 private import std.algorithm;
39 
40 
41 /**
42  * #GVolumeMonitor is for listing the user interesting devices and volumes
43  * on the computer. In other words, what a file selector or file manager
44  * would show in a sidebar.
45  * 
46  * #GVolumeMonitor is not
47  * [thread-default-context aware][g-main-context-push-thread-default],
48  * and so should not be used other than from the main thread, with no
49  * thread-default-context active.
50  */
51 public class VolumeMonitor : ObjectG
52 {
53 	/** the main Gtk struct */
54 	protected GVolumeMonitor* gVolumeMonitor;
55 
56 	/** Get the main Gtk struct */
57 	public GVolumeMonitor* getVolumeMonitorStruct(bool transferOwnership = false)
58 	{
59 		if (transferOwnership)
60 			ownedRef = false;
61 		return gVolumeMonitor;
62 	}
63 
64 	/** the main Gtk struct as a void* */
65 	protected override void* getStruct()
66 	{
67 		return cast(void*)gVolumeMonitor;
68 	}
69 
70 	/**
71 	 * Sets our main struct and passes it to the parent class.
72 	 */
73 	public this (GVolumeMonitor* gVolumeMonitor, bool ownedRef = false)
74 	{
75 		this.gVolumeMonitor = gVolumeMonitor;
76 		super(cast(GObject*)gVolumeMonitor, ownedRef);
77 	}
78 
79 	/**
80 	 * Gets the volume monitor used by gio.
81 	 *
82 	 * Return: a reference to the #GVolumeMonitor used by gio. Call
83 	 *     g_object_unref() when done with it.
84 	 */
85 	public this()
86 	{
87 		auto p = g_volume_monitor_get();
88 
89 		if(p is null)
90 		{
91 			throw new ConstructionException("g_volume_monitor_get()");
92 		}
93 
94 		this(cast(GVolumeMonitor*) p, true);
95 	}
96 
97 	/**
98 	 */
99 
100 	/** */
101 	public static GType getType()
102 	{
103 		return g_volume_monitor_get_type();
104 	}
105 
106 	/**
107 	 * This function should be called by any #GVolumeMonitor
108 	 * implementation when a new #GMount object is created that is not
109 	 * associated with a #GVolume object. It must be called just before
110 	 * emitting the @mount_added signal.
111 	 *
112 	 * If the return value is not %NULL, the caller must associate the
113 	 * returned #GVolume object with the #GMount. This involves returning
114 	 * it in its g_mount_get_volume() implementation. The caller must
115 	 * also listen for the "removed" signal on the returned object
116 	 * and give up its reference when handling that signal
117 	 *
118 	 * Similary, if implementing g_volume_monitor_adopt_orphan_mount(),
119 	 * the implementor must take a reference to @mount and return it in
120 	 * its g_volume_get_mount() implemented. Also, the implementor must
121 	 * listen for the "unmounted" signal on @mount and give up its
122 	 * reference upon handling that signal.
123 	 *
124 	 * There are two main use cases for this function.
125 	 *
126 	 * One is when implementing a user space file system driver that reads
127 	 * blocks of a block device that is already represented by the native
128 	 * volume monitor (for example a CD Audio file system driver). Such
129 	 * a driver will generate its own #GMount object that needs to be
130 	 * associated with the #GVolume object that represents the volume.
131 	 *
132 	 * The other is for implementing a #GVolumeMonitor whose sole purpose
133 	 * is to return #GVolume objects representing entries in the users
134 	 * "favorite servers" list or similar.
135 	 *
136 	 * Deprecated: Instead of using this function, #GVolumeMonitor
137 	 * implementations should instead create shadow mounts with the URI of
138 	 * the mount they intend to adopt. See the proxy volume monitor in
139 	 * gvfs for an example of this. Also see g_mount_is_shadowed(),
140 	 * g_mount_shadow() and g_mount_unshadow() functions.
141 	 *
142 	 * Params:
143 	 *     mount = a #GMount object to find a parent for
144 	 *
145 	 * Returns: the #GVolume object that is the parent for @mount or %NULL
146 	 *     if no wants to adopt the #GMount.
147 	 */
148 	public static VolumeIF adoptOrphanMount(MountIF mount)
149 	{
150 		auto p = g_volume_monitor_adopt_orphan_mount((mount is null) ? null : mount.getMountStruct());
151 
152 		if(p is null)
153 		{
154 			return null;
155 		}
156 
157 		return ObjectG.getDObject!(VolumeIF)(cast(GVolume*) p, true);
158 	}
159 
160 	/**
161 	 * Gets a list of drives connected to the system.
162 	 *
163 	 * The returned list should be freed with g_list_free(), after
164 	 * its elements have been unreffed with g_object_unref().
165 	 *
166 	 * Returns: a #GList of connected #GDrive objects.
167 	 */
168 	public ListG getConnectedDrives()
169 	{
170 		auto p = g_volume_monitor_get_connected_drives(gVolumeMonitor);
171 
172 		if(p is null)
173 		{
174 			return null;
175 		}
176 
177 		return new ListG(cast(GList*) p, true);
178 	}
179 
180 	/**
181 	 * Finds a #GMount object by its UUID (see g_mount_get_uuid())
182 	 *
183 	 * Params:
184 	 *     uuid = the UUID to look for
185 	 *
186 	 * Returns: a #GMount or %NULL if no such mount is available.
187 	 *     Free the returned object with g_object_unref().
188 	 */
189 	public MountIF getMountForUuid(string uuid)
190 	{
191 		auto p = g_volume_monitor_get_mount_for_uuid(gVolumeMonitor, Str.toStringz(uuid));
192 
193 		if(p is null)
194 		{
195 			return null;
196 		}
197 
198 		return ObjectG.getDObject!(MountIF)(cast(GMount*) p, true);
199 	}
200 
201 	/**
202 	 * Gets a list of the mounts on the system.
203 	 *
204 	 * The returned list should be freed with g_list_free(), after
205 	 * its elements have been unreffed with g_object_unref().
206 	 *
207 	 * Returns: a #GList of #GMount objects.
208 	 */
209 	public ListG getMounts()
210 	{
211 		auto p = g_volume_monitor_get_mounts(gVolumeMonitor);
212 
213 		if(p is null)
214 		{
215 			return null;
216 		}
217 
218 		return new ListG(cast(GList*) p, true);
219 	}
220 
221 	/**
222 	 * Finds a #GVolume object by its UUID (see g_volume_get_uuid())
223 	 *
224 	 * Params:
225 	 *     uuid = the UUID to look for
226 	 *
227 	 * Returns: a #GVolume or %NULL if no such volume is available.
228 	 *     Free the returned object with g_object_unref().
229 	 */
230 	public VolumeIF getVolumeForUuid(string uuid)
231 	{
232 		auto p = g_volume_monitor_get_volume_for_uuid(gVolumeMonitor, Str.toStringz(uuid));
233 
234 		if(p is null)
235 		{
236 			return null;
237 		}
238 
239 		return ObjectG.getDObject!(VolumeIF)(cast(GVolume*) p, true);
240 	}
241 
242 	/**
243 	 * Gets a list of the volumes on the system.
244 	 *
245 	 * The returned list should be freed with g_list_free(), after
246 	 * its elements have been unreffed with g_object_unref().
247 	 *
248 	 * Returns: a #GList of #GVolume objects.
249 	 */
250 	public ListG getVolumes()
251 	{
252 		auto p = g_volume_monitor_get_volumes(gVolumeMonitor);
253 
254 		if(p is null)
255 		{
256 			return null;
257 		}
258 
259 		return new ListG(cast(GList*) p, true);
260 	}
261 
262 	protected class OnDriveChangedDelegateWrapper
263 	{
264 		void delegate(DriveIF, VolumeMonitor) dlg;
265 		gulong handlerId;
266 
267 		this(void delegate(DriveIF, VolumeMonitor) dlg)
268 		{
269 			this.dlg = dlg;
270 			onDriveChangedListeners ~= this;
271 		}
272 
273 		void remove(OnDriveChangedDelegateWrapper source)
274 		{
275 			foreach(index, wrapper; onDriveChangedListeners)
276 			{
277 				if (wrapper.handlerId == source.handlerId)
278 				{
279 					onDriveChangedListeners[index] = null;
280 					onDriveChangedListeners = std.algorithm.remove(onDriveChangedListeners, index);
281 					break;
282 				}
283 			}
284 		}
285 	}
286 	OnDriveChangedDelegateWrapper[] onDriveChangedListeners;
287 
288 	/**
289 	 * Emitted when a drive changes.
290 	 *
291 	 * Params:
292 	 *     drive = the drive that changed
293 	 */
294 	gulong addOnDriveChanged(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
295 	{
296 		auto wrapper = new OnDriveChangedDelegateWrapper(dlg);
297 		wrapper.handlerId = Signals.connectData(
298 			this,
299 			"drive-changed",
300 			cast(GCallback)&callBackDriveChanged,
301 			cast(void*)wrapper,
302 			cast(GClosureNotify)&callBackDriveChangedDestroy,
303 			connectFlags);
304 		return wrapper.handlerId;
305 	}
306 
307 	extern(C) static void callBackDriveChanged(GVolumeMonitor* volumemonitorStruct, GDrive* drive, OnDriveChangedDelegateWrapper wrapper)
308 	{
309 		wrapper.dlg(ObjectG.getDObject!(DriveIF)(drive), wrapper.outer);
310 	}
311 
312 	extern(C) static void callBackDriveChangedDestroy(OnDriveChangedDelegateWrapper wrapper, GClosure* closure)
313 	{
314 		wrapper.remove(wrapper);
315 	}
316 
317 	protected class OnDriveConnectedDelegateWrapper
318 	{
319 		void delegate(DriveIF, VolumeMonitor) dlg;
320 		gulong handlerId;
321 
322 		this(void delegate(DriveIF, VolumeMonitor) dlg)
323 		{
324 			this.dlg = dlg;
325 			onDriveConnectedListeners ~= this;
326 		}
327 
328 		void remove(OnDriveConnectedDelegateWrapper source)
329 		{
330 			foreach(index, wrapper; onDriveConnectedListeners)
331 			{
332 				if (wrapper.handlerId == source.handlerId)
333 				{
334 					onDriveConnectedListeners[index] = null;
335 					onDriveConnectedListeners = std.algorithm.remove(onDriveConnectedListeners, index);
336 					break;
337 				}
338 			}
339 		}
340 	}
341 	OnDriveConnectedDelegateWrapper[] onDriveConnectedListeners;
342 
343 	/**
344 	 * Emitted when a drive is connected to the system.
345 	 *
346 	 * Params:
347 	 *     drive = a #GDrive that was connected.
348 	 */
349 	gulong addOnDriveConnected(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
350 	{
351 		auto wrapper = new OnDriveConnectedDelegateWrapper(dlg);
352 		wrapper.handlerId = Signals.connectData(
353 			this,
354 			"drive-connected",
355 			cast(GCallback)&callBackDriveConnected,
356 			cast(void*)wrapper,
357 			cast(GClosureNotify)&callBackDriveConnectedDestroy,
358 			connectFlags);
359 		return wrapper.handlerId;
360 	}
361 
362 	extern(C) static void callBackDriveConnected(GVolumeMonitor* volumemonitorStruct, GDrive* drive, OnDriveConnectedDelegateWrapper wrapper)
363 	{
364 		wrapper.dlg(ObjectG.getDObject!(DriveIF)(drive), wrapper.outer);
365 	}
366 
367 	extern(C) static void callBackDriveConnectedDestroy(OnDriveConnectedDelegateWrapper wrapper, GClosure* closure)
368 	{
369 		wrapper.remove(wrapper);
370 	}
371 
372 	protected class OnDriveDisconnectedDelegateWrapper
373 	{
374 		void delegate(DriveIF, VolumeMonitor) dlg;
375 		gulong handlerId;
376 
377 		this(void delegate(DriveIF, VolumeMonitor) dlg)
378 		{
379 			this.dlg = dlg;
380 			onDriveDisconnectedListeners ~= this;
381 		}
382 
383 		void remove(OnDriveDisconnectedDelegateWrapper source)
384 		{
385 			foreach(index, wrapper; onDriveDisconnectedListeners)
386 			{
387 				if (wrapper.handlerId == source.handlerId)
388 				{
389 					onDriveDisconnectedListeners[index] = null;
390 					onDriveDisconnectedListeners = std.algorithm.remove(onDriveDisconnectedListeners, index);
391 					break;
392 				}
393 			}
394 		}
395 	}
396 	OnDriveDisconnectedDelegateWrapper[] onDriveDisconnectedListeners;
397 
398 	/**
399 	 * Emitted when a drive is disconnected from the system.
400 	 *
401 	 * Params:
402 	 *     drive = a #GDrive that was disconnected.
403 	 */
404 	gulong addOnDriveDisconnected(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
405 	{
406 		auto wrapper = new OnDriveDisconnectedDelegateWrapper(dlg);
407 		wrapper.handlerId = Signals.connectData(
408 			this,
409 			"drive-disconnected",
410 			cast(GCallback)&callBackDriveDisconnected,
411 			cast(void*)wrapper,
412 			cast(GClosureNotify)&callBackDriveDisconnectedDestroy,
413 			connectFlags);
414 		return wrapper.handlerId;
415 	}
416 
417 	extern(C) static void callBackDriveDisconnected(GVolumeMonitor* volumemonitorStruct, GDrive* drive, OnDriveDisconnectedDelegateWrapper wrapper)
418 	{
419 		wrapper.dlg(ObjectG.getDObject!(DriveIF)(drive), wrapper.outer);
420 	}
421 
422 	extern(C) static void callBackDriveDisconnectedDestroy(OnDriveDisconnectedDelegateWrapper wrapper, GClosure* closure)
423 	{
424 		wrapper.remove(wrapper);
425 	}
426 
427 	protected class OnDriveEjectButtonDelegateWrapper
428 	{
429 		void delegate(DriveIF, VolumeMonitor) dlg;
430 		gulong handlerId;
431 
432 		this(void delegate(DriveIF, VolumeMonitor) dlg)
433 		{
434 			this.dlg = dlg;
435 			onDriveEjectButtonListeners ~= this;
436 		}
437 
438 		void remove(OnDriveEjectButtonDelegateWrapper source)
439 		{
440 			foreach(index, wrapper; onDriveEjectButtonListeners)
441 			{
442 				if (wrapper.handlerId == source.handlerId)
443 				{
444 					onDriveEjectButtonListeners[index] = null;
445 					onDriveEjectButtonListeners = std.algorithm.remove(onDriveEjectButtonListeners, index);
446 					break;
447 				}
448 			}
449 		}
450 	}
451 	OnDriveEjectButtonDelegateWrapper[] onDriveEjectButtonListeners;
452 
453 	/**
454 	 * Emitted when the eject button is pressed on @drive.
455 	 *
456 	 * Params:
457 	 *     drive = the drive where the eject button was pressed
458 	 *
459 	 * Since: 2.18
460 	 */
461 	gulong addOnDriveEjectButton(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
462 	{
463 		auto wrapper = new OnDriveEjectButtonDelegateWrapper(dlg);
464 		wrapper.handlerId = Signals.connectData(
465 			this,
466 			"drive-eject-button",
467 			cast(GCallback)&callBackDriveEjectButton,
468 			cast(void*)wrapper,
469 			cast(GClosureNotify)&callBackDriveEjectButtonDestroy,
470 			connectFlags);
471 		return wrapper.handlerId;
472 	}
473 
474 	extern(C) static void callBackDriveEjectButton(GVolumeMonitor* volumemonitorStruct, GDrive* drive, OnDriveEjectButtonDelegateWrapper wrapper)
475 	{
476 		wrapper.dlg(ObjectG.getDObject!(DriveIF)(drive), wrapper.outer);
477 	}
478 
479 	extern(C) static void callBackDriveEjectButtonDestroy(OnDriveEjectButtonDelegateWrapper wrapper, GClosure* closure)
480 	{
481 		wrapper.remove(wrapper);
482 	}
483 
484 	protected class OnDriveStopButtonDelegateWrapper
485 	{
486 		void delegate(DriveIF, VolumeMonitor) dlg;
487 		gulong handlerId;
488 
489 		this(void delegate(DriveIF, VolumeMonitor) dlg)
490 		{
491 			this.dlg = dlg;
492 			onDriveStopButtonListeners ~= this;
493 		}
494 
495 		void remove(OnDriveStopButtonDelegateWrapper source)
496 		{
497 			foreach(index, wrapper; onDriveStopButtonListeners)
498 			{
499 				if (wrapper.handlerId == source.handlerId)
500 				{
501 					onDriveStopButtonListeners[index] = null;
502 					onDriveStopButtonListeners = std.algorithm.remove(onDriveStopButtonListeners, index);
503 					break;
504 				}
505 			}
506 		}
507 	}
508 	OnDriveStopButtonDelegateWrapper[] onDriveStopButtonListeners;
509 
510 	/**
511 	 * Emitted when the stop button is pressed on @drive.
512 	 *
513 	 * Params:
514 	 *     drive = the drive where the stop button was pressed
515 	 *
516 	 * Since: 2.22
517 	 */
518 	gulong addOnDriveStopButton(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
519 	{
520 		auto wrapper = new OnDriveStopButtonDelegateWrapper(dlg);
521 		wrapper.handlerId = Signals.connectData(
522 			this,
523 			"drive-stop-button",
524 			cast(GCallback)&callBackDriveStopButton,
525 			cast(void*)wrapper,
526 			cast(GClosureNotify)&callBackDriveStopButtonDestroy,
527 			connectFlags);
528 		return wrapper.handlerId;
529 	}
530 
531 	extern(C) static void callBackDriveStopButton(GVolumeMonitor* volumemonitorStruct, GDrive* drive, OnDriveStopButtonDelegateWrapper wrapper)
532 	{
533 		wrapper.dlg(ObjectG.getDObject!(DriveIF)(drive), wrapper.outer);
534 	}
535 
536 	extern(C) static void callBackDriveStopButtonDestroy(OnDriveStopButtonDelegateWrapper wrapper, GClosure* closure)
537 	{
538 		wrapper.remove(wrapper);
539 	}
540 
541 	protected class OnMountAddedDelegateWrapper
542 	{
543 		void delegate(MountIF, VolumeMonitor) dlg;
544 		gulong handlerId;
545 
546 		this(void delegate(MountIF, VolumeMonitor) dlg)
547 		{
548 			this.dlg = dlg;
549 			onMountAddedListeners ~= this;
550 		}
551 
552 		void remove(OnMountAddedDelegateWrapper source)
553 		{
554 			foreach(index, wrapper; onMountAddedListeners)
555 			{
556 				if (wrapper.handlerId == source.handlerId)
557 				{
558 					onMountAddedListeners[index] = null;
559 					onMountAddedListeners = std.algorithm.remove(onMountAddedListeners, index);
560 					break;
561 				}
562 			}
563 		}
564 	}
565 	OnMountAddedDelegateWrapper[] onMountAddedListeners;
566 
567 	/**
568 	 * Emitted when a mount is added.
569 	 *
570 	 * Params:
571 	 *     mount = a #GMount that was added.
572 	 */
573 	gulong addOnMountAdded(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
574 	{
575 		auto wrapper = new OnMountAddedDelegateWrapper(dlg);
576 		wrapper.handlerId = Signals.connectData(
577 			this,
578 			"mount-added",
579 			cast(GCallback)&callBackMountAdded,
580 			cast(void*)wrapper,
581 			cast(GClosureNotify)&callBackMountAddedDestroy,
582 			connectFlags);
583 		return wrapper.handlerId;
584 	}
585 
586 	extern(C) static void callBackMountAdded(GVolumeMonitor* volumemonitorStruct, GMount* mount, OnMountAddedDelegateWrapper wrapper)
587 	{
588 		wrapper.dlg(ObjectG.getDObject!(MountIF)(mount), wrapper.outer);
589 	}
590 
591 	extern(C) static void callBackMountAddedDestroy(OnMountAddedDelegateWrapper wrapper, GClosure* closure)
592 	{
593 		wrapper.remove(wrapper);
594 	}
595 
596 	protected class OnMountChangedDelegateWrapper
597 	{
598 		void delegate(MountIF, VolumeMonitor) dlg;
599 		gulong handlerId;
600 
601 		this(void delegate(MountIF, VolumeMonitor) dlg)
602 		{
603 			this.dlg = dlg;
604 			onMountChangedListeners ~= this;
605 		}
606 
607 		void remove(OnMountChangedDelegateWrapper source)
608 		{
609 			foreach(index, wrapper; onMountChangedListeners)
610 			{
611 				if (wrapper.handlerId == source.handlerId)
612 				{
613 					onMountChangedListeners[index] = null;
614 					onMountChangedListeners = std.algorithm.remove(onMountChangedListeners, index);
615 					break;
616 				}
617 			}
618 		}
619 	}
620 	OnMountChangedDelegateWrapper[] onMountChangedListeners;
621 
622 	/**
623 	 * Emitted when a mount changes.
624 	 *
625 	 * Params:
626 	 *     mount = a #GMount that changed.
627 	 */
628 	gulong addOnMountChanged(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
629 	{
630 		auto wrapper = new OnMountChangedDelegateWrapper(dlg);
631 		wrapper.handlerId = Signals.connectData(
632 			this,
633 			"mount-changed",
634 			cast(GCallback)&callBackMountChanged,
635 			cast(void*)wrapper,
636 			cast(GClosureNotify)&callBackMountChangedDestroy,
637 			connectFlags);
638 		return wrapper.handlerId;
639 	}
640 
641 	extern(C) static void callBackMountChanged(GVolumeMonitor* volumemonitorStruct, GMount* mount, OnMountChangedDelegateWrapper wrapper)
642 	{
643 		wrapper.dlg(ObjectG.getDObject!(MountIF)(mount), wrapper.outer);
644 	}
645 
646 	extern(C) static void callBackMountChangedDestroy(OnMountChangedDelegateWrapper wrapper, GClosure* closure)
647 	{
648 		wrapper.remove(wrapper);
649 	}
650 
651 	protected class OnMountPreUnmountDelegateWrapper
652 	{
653 		void delegate(MountIF, VolumeMonitor) dlg;
654 		gulong handlerId;
655 
656 		this(void delegate(MountIF, VolumeMonitor) dlg)
657 		{
658 			this.dlg = dlg;
659 			onMountPreUnmountListeners ~= this;
660 		}
661 
662 		void remove(OnMountPreUnmountDelegateWrapper source)
663 		{
664 			foreach(index, wrapper; onMountPreUnmountListeners)
665 			{
666 				if (wrapper.handlerId == source.handlerId)
667 				{
668 					onMountPreUnmountListeners[index] = null;
669 					onMountPreUnmountListeners = std.algorithm.remove(onMountPreUnmountListeners, index);
670 					break;
671 				}
672 			}
673 		}
674 	}
675 	OnMountPreUnmountDelegateWrapper[] onMountPreUnmountListeners;
676 
677 	/**
678 	 * Emitted when a mount is about to be removed.
679 	 *
680 	 * Params:
681 	 *     mount = a #GMount that is being unmounted.
682 	 */
683 	gulong addOnMountPreUnmount(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
684 	{
685 		auto wrapper = new OnMountPreUnmountDelegateWrapper(dlg);
686 		wrapper.handlerId = Signals.connectData(
687 			this,
688 			"mount-pre-unmount",
689 			cast(GCallback)&callBackMountPreUnmount,
690 			cast(void*)wrapper,
691 			cast(GClosureNotify)&callBackMountPreUnmountDestroy,
692 			connectFlags);
693 		return wrapper.handlerId;
694 	}
695 
696 	extern(C) static void callBackMountPreUnmount(GVolumeMonitor* volumemonitorStruct, GMount* mount, OnMountPreUnmountDelegateWrapper wrapper)
697 	{
698 		wrapper.dlg(ObjectG.getDObject!(MountIF)(mount), wrapper.outer);
699 	}
700 
701 	extern(C) static void callBackMountPreUnmountDestroy(OnMountPreUnmountDelegateWrapper wrapper, GClosure* closure)
702 	{
703 		wrapper.remove(wrapper);
704 	}
705 
706 	protected class OnMountRemovedDelegateWrapper
707 	{
708 		void delegate(MountIF, VolumeMonitor) dlg;
709 		gulong handlerId;
710 
711 		this(void delegate(MountIF, VolumeMonitor) dlg)
712 		{
713 			this.dlg = dlg;
714 			onMountRemovedListeners ~= this;
715 		}
716 
717 		void remove(OnMountRemovedDelegateWrapper source)
718 		{
719 			foreach(index, wrapper; onMountRemovedListeners)
720 			{
721 				if (wrapper.handlerId == source.handlerId)
722 				{
723 					onMountRemovedListeners[index] = null;
724 					onMountRemovedListeners = std.algorithm.remove(onMountRemovedListeners, index);
725 					break;
726 				}
727 			}
728 		}
729 	}
730 	OnMountRemovedDelegateWrapper[] onMountRemovedListeners;
731 
732 	/**
733 	 * Emitted when a mount is removed.
734 	 *
735 	 * Params:
736 	 *     mount = a #GMount that was removed.
737 	 */
738 	gulong addOnMountRemoved(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
739 	{
740 		auto wrapper = new OnMountRemovedDelegateWrapper(dlg);
741 		wrapper.handlerId = Signals.connectData(
742 			this,
743 			"mount-removed",
744 			cast(GCallback)&callBackMountRemoved,
745 			cast(void*)wrapper,
746 			cast(GClosureNotify)&callBackMountRemovedDestroy,
747 			connectFlags);
748 		return wrapper.handlerId;
749 	}
750 
751 	extern(C) static void callBackMountRemoved(GVolumeMonitor* volumemonitorStruct, GMount* mount, OnMountRemovedDelegateWrapper wrapper)
752 	{
753 		wrapper.dlg(ObjectG.getDObject!(MountIF)(mount), wrapper.outer);
754 	}
755 
756 	extern(C) static void callBackMountRemovedDestroy(OnMountRemovedDelegateWrapper wrapper, GClosure* closure)
757 	{
758 		wrapper.remove(wrapper);
759 	}
760 
761 	protected class OnVolumeAddedDelegateWrapper
762 	{
763 		void delegate(VolumeIF, VolumeMonitor) dlg;
764 		gulong handlerId;
765 
766 		this(void delegate(VolumeIF, VolumeMonitor) dlg)
767 		{
768 			this.dlg = dlg;
769 			onVolumeAddedListeners ~= this;
770 		}
771 
772 		void remove(OnVolumeAddedDelegateWrapper source)
773 		{
774 			foreach(index, wrapper; onVolumeAddedListeners)
775 			{
776 				if (wrapper.handlerId == source.handlerId)
777 				{
778 					onVolumeAddedListeners[index] = null;
779 					onVolumeAddedListeners = std.algorithm.remove(onVolumeAddedListeners, index);
780 					break;
781 				}
782 			}
783 		}
784 	}
785 	OnVolumeAddedDelegateWrapper[] onVolumeAddedListeners;
786 
787 	/**
788 	 * Emitted when a mountable volume is added to the system.
789 	 *
790 	 * Params:
791 	 *     volume = a #GVolume that was added.
792 	 */
793 	gulong addOnVolumeAdded(void delegate(VolumeIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
794 	{
795 		auto wrapper = new OnVolumeAddedDelegateWrapper(dlg);
796 		wrapper.handlerId = Signals.connectData(
797 			this,
798 			"volume-added",
799 			cast(GCallback)&callBackVolumeAdded,
800 			cast(void*)wrapper,
801 			cast(GClosureNotify)&callBackVolumeAddedDestroy,
802 			connectFlags);
803 		return wrapper.handlerId;
804 	}
805 
806 	extern(C) static void callBackVolumeAdded(GVolumeMonitor* volumemonitorStruct, GVolume* volume, OnVolumeAddedDelegateWrapper wrapper)
807 	{
808 		wrapper.dlg(ObjectG.getDObject!(VolumeIF)(volume), wrapper.outer);
809 	}
810 
811 	extern(C) static void callBackVolumeAddedDestroy(OnVolumeAddedDelegateWrapper wrapper, GClosure* closure)
812 	{
813 		wrapper.remove(wrapper);
814 	}
815 
816 	protected class OnVolumeChangedDelegateWrapper
817 	{
818 		void delegate(VolumeIF, VolumeMonitor) dlg;
819 		gulong handlerId;
820 
821 		this(void delegate(VolumeIF, VolumeMonitor) dlg)
822 		{
823 			this.dlg = dlg;
824 			onVolumeChangedListeners ~= this;
825 		}
826 
827 		void remove(OnVolumeChangedDelegateWrapper source)
828 		{
829 			foreach(index, wrapper; onVolumeChangedListeners)
830 			{
831 				if (wrapper.handlerId == source.handlerId)
832 				{
833 					onVolumeChangedListeners[index] = null;
834 					onVolumeChangedListeners = std.algorithm.remove(onVolumeChangedListeners, index);
835 					break;
836 				}
837 			}
838 		}
839 	}
840 	OnVolumeChangedDelegateWrapper[] onVolumeChangedListeners;
841 
842 	/**
843 	 * Emitted when mountable volume is changed.
844 	 *
845 	 * Params:
846 	 *     volume = a #GVolume that changed.
847 	 */
848 	gulong addOnVolumeChanged(void delegate(VolumeIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
849 	{
850 		auto wrapper = new OnVolumeChangedDelegateWrapper(dlg);
851 		wrapper.handlerId = Signals.connectData(
852 			this,
853 			"volume-changed",
854 			cast(GCallback)&callBackVolumeChanged,
855 			cast(void*)wrapper,
856 			cast(GClosureNotify)&callBackVolumeChangedDestroy,
857 			connectFlags);
858 		return wrapper.handlerId;
859 	}
860 
861 	extern(C) static void callBackVolumeChanged(GVolumeMonitor* volumemonitorStruct, GVolume* volume, OnVolumeChangedDelegateWrapper wrapper)
862 	{
863 		wrapper.dlg(ObjectG.getDObject!(VolumeIF)(volume), wrapper.outer);
864 	}
865 
866 	extern(C) static void callBackVolumeChangedDestroy(OnVolumeChangedDelegateWrapper wrapper, GClosure* closure)
867 	{
868 		wrapper.remove(wrapper);
869 	}
870 
871 	protected class OnVolumeRemovedDelegateWrapper
872 	{
873 		void delegate(VolumeIF, VolumeMonitor) dlg;
874 		gulong handlerId;
875 
876 		this(void delegate(VolumeIF, VolumeMonitor) dlg)
877 		{
878 			this.dlg = dlg;
879 			onVolumeRemovedListeners ~= this;
880 		}
881 
882 		void remove(OnVolumeRemovedDelegateWrapper source)
883 		{
884 			foreach(index, wrapper; onVolumeRemovedListeners)
885 			{
886 				if (wrapper.handlerId == source.handlerId)
887 				{
888 					onVolumeRemovedListeners[index] = null;
889 					onVolumeRemovedListeners = std.algorithm.remove(onVolumeRemovedListeners, index);
890 					break;
891 				}
892 			}
893 		}
894 	}
895 	OnVolumeRemovedDelegateWrapper[] onVolumeRemovedListeners;
896 
897 	/**
898 	 * Emitted when a mountable volume is removed from the system.
899 	 *
900 	 * Params:
901 	 *     volume = a #GVolume that was removed.
902 	 */
903 	gulong addOnVolumeRemoved(void delegate(VolumeIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
904 	{
905 		auto wrapper = new OnVolumeRemovedDelegateWrapper(dlg);
906 		wrapper.handlerId = Signals.connectData(
907 			this,
908 			"volume-removed",
909 			cast(GCallback)&callBackVolumeRemoved,
910 			cast(void*)wrapper,
911 			cast(GClosureNotify)&callBackVolumeRemovedDestroy,
912 			connectFlags);
913 		return wrapper.handlerId;
914 	}
915 
916 	extern(C) static void callBackVolumeRemoved(GVolumeMonitor* volumemonitorStruct, GVolume* volume, OnVolumeRemovedDelegateWrapper wrapper)
917 	{
918 		wrapper.dlg(ObjectG.getDObject!(VolumeIF)(volume), wrapper.outer);
919 	}
920 
921 	extern(C) static void callBackVolumeRemovedDestroy(OnVolumeRemovedDelegateWrapper wrapper, GClosure* closure)
922 	{
923 		wrapper.remove(wrapper);
924 	}
925 }