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