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