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()
60 	{
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!(Volume, 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!(Mount, 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!(Volume, 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 		static OnDriveChangedDelegateWrapper[] listeners;
271 		void delegate(DriveIF, VolumeMonitor) dlg;
272 		gulong handlerId;
273 		
274 		this(void delegate(DriveIF, VolumeMonitor) dlg)
275 		{
276 			this.dlg = dlg;
277 			this.listeners ~= this;
278 		}
279 		
280 		void remove(OnDriveChangedDelegateWrapper source)
281 		{
282 			foreach(index, wrapper; listeners)
283 			{
284 				if (wrapper.handlerId == source.handlerId)
285 				{
286 					listeners[index] = null;
287 					listeners = std.algorithm.remove(listeners, index);
288 					break;
289 				}
290 			}
291 		}
292 	}
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!(Drive, 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 		static OnDriveConnectedDelegateWrapper[] listeners;
326 		void delegate(DriveIF, VolumeMonitor) dlg;
327 		gulong handlerId;
328 		
329 		this(void delegate(DriveIF, VolumeMonitor) dlg)
330 		{
331 			this.dlg = dlg;
332 			this.listeners ~= this;
333 		}
334 		
335 		void remove(OnDriveConnectedDelegateWrapper source)
336 		{
337 			foreach(index, wrapper; listeners)
338 			{
339 				if (wrapper.handlerId == source.handlerId)
340 				{
341 					listeners[index] = null;
342 					listeners = std.algorithm.remove(listeners, index);
343 					break;
344 				}
345 			}
346 		}
347 	}
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!(Drive, 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 		static OnDriveDisconnectedDelegateWrapper[] listeners;
381 		void delegate(DriveIF, VolumeMonitor) dlg;
382 		gulong handlerId;
383 		
384 		this(void delegate(DriveIF, VolumeMonitor) dlg)
385 		{
386 			this.dlg = dlg;
387 			this.listeners ~= this;
388 		}
389 		
390 		void remove(OnDriveDisconnectedDelegateWrapper source)
391 		{
392 			foreach(index, wrapper; listeners)
393 			{
394 				if (wrapper.handlerId == source.handlerId)
395 				{
396 					listeners[index] = null;
397 					listeners = std.algorithm.remove(listeners, index);
398 					break;
399 				}
400 			}
401 		}
402 	}
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!(Drive, 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 		static OnDriveEjectButtonDelegateWrapper[] listeners;
436 		void delegate(DriveIF, VolumeMonitor) dlg;
437 		gulong handlerId;
438 		
439 		this(void delegate(DriveIF, VolumeMonitor) dlg)
440 		{
441 			this.dlg = dlg;
442 			this.listeners ~= this;
443 		}
444 		
445 		void remove(OnDriveEjectButtonDelegateWrapper source)
446 		{
447 			foreach(index, wrapper; listeners)
448 			{
449 				if (wrapper.handlerId == source.handlerId)
450 				{
451 					listeners[index] = null;
452 					listeners = std.algorithm.remove(listeners, index);
453 					break;
454 				}
455 			}
456 		}
457 	}
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!(Drive, 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 		static OnDriveStopButtonDelegateWrapper[] listeners;
493 		void delegate(DriveIF, VolumeMonitor) dlg;
494 		gulong handlerId;
495 		
496 		this(void delegate(DriveIF, VolumeMonitor) dlg)
497 		{
498 			this.dlg = dlg;
499 			this.listeners ~= this;
500 		}
501 		
502 		void remove(OnDriveStopButtonDelegateWrapper source)
503 		{
504 			foreach(index, wrapper; listeners)
505 			{
506 				if (wrapper.handlerId == source.handlerId)
507 				{
508 					listeners[index] = null;
509 					listeners = std.algorithm.remove(listeners, index);
510 					break;
511 				}
512 			}
513 		}
514 	}
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!(Drive, 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 		static OnMountAddedDelegateWrapper[] listeners;
550 		void delegate(MountIF, VolumeMonitor) dlg;
551 		gulong handlerId;
552 		
553 		this(void delegate(MountIF, VolumeMonitor) dlg)
554 		{
555 			this.dlg = dlg;
556 			this.listeners ~= this;
557 		}
558 		
559 		void remove(OnMountAddedDelegateWrapper source)
560 		{
561 			foreach(index, wrapper; listeners)
562 			{
563 				if (wrapper.handlerId == source.handlerId)
564 				{
565 					listeners[index] = null;
566 					listeners = std.algorithm.remove(listeners, index);
567 					break;
568 				}
569 			}
570 		}
571 	}
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!(Mount, 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 		static OnMountChangedDelegateWrapper[] listeners;
605 		void delegate(MountIF, VolumeMonitor) dlg;
606 		gulong handlerId;
607 		
608 		this(void delegate(MountIF, VolumeMonitor) dlg)
609 		{
610 			this.dlg = dlg;
611 			this.listeners ~= this;
612 		}
613 		
614 		void remove(OnMountChangedDelegateWrapper source)
615 		{
616 			foreach(index, wrapper; listeners)
617 			{
618 				if (wrapper.handlerId == source.handlerId)
619 				{
620 					listeners[index] = null;
621 					listeners = std.algorithm.remove(listeners, index);
622 					break;
623 				}
624 			}
625 		}
626 	}
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!(Mount, 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 		static OnMountPreUnmountDelegateWrapper[] listeners;
660 		void delegate(MountIF, VolumeMonitor) dlg;
661 		gulong handlerId;
662 		
663 		this(void delegate(MountIF, VolumeMonitor) dlg)
664 		{
665 			this.dlg = dlg;
666 			this.listeners ~= this;
667 		}
668 		
669 		void remove(OnMountPreUnmountDelegateWrapper source)
670 		{
671 			foreach(index, wrapper; listeners)
672 			{
673 				if (wrapper.handlerId == source.handlerId)
674 				{
675 					listeners[index] = null;
676 					listeners = std.algorithm.remove(listeners, index);
677 					break;
678 				}
679 			}
680 		}
681 	}
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!(Mount, 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 		static OnMountRemovedDelegateWrapper[] listeners;
715 		void delegate(MountIF, VolumeMonitor) dlg;
716 		gulong handlerId;
717 		
718 		this(void delegate(MountIF, VolumeMonitor) dlg)
719 		{
720 			this.dlg = dlg;
721 			this.listeners ~= this;
722 		}
723 		
724 		void remove(OnMountRemovedDelegateWrapper source)
725 		{
726 			foreach(index, wrapper; listeners)
727 			{
728 				if (wrapper.handlerId == source.handlerId)
729 				{
730 					listeners[index] = null;
731 					listeners = std.algorithm.remove(listeners, index);
732 					break;
733 				}
734 			}
735 		}
736 	}
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!(Mount, 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 		static OnVolumeAddedDelegateWrapper[] listeners;
770 		void delegate(VolumeIF, VolumeMonitor) dlg;
771 		gulong handlerId;
772 		
773 		this(void delegate(VolumeIF, VolumeMonitor) dlg)
774 		{
775 			this.dlg = dlg;
776 			this.listeners ~= this;
777 		}
778 		
779 		void remove(OnVolumeAddedDelegateWrapper source)
780 		{
781 			foreach(index, wrapper; listeners)
782 			{
783 				if (wrapper.handlerId == source.handlerId)
784 				{
785 					listeners[index] = null;
786 					listeners = std.algorithm.remove(listeners, index);
787 					break;
788 				}
789 			}
790 		}
791 	}
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!(Volume, 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 		static OnVolumeChangedDelegateWrapper[] listeners;
825 		void delegate(VolumeIF, VolumeMonitor) dlg;
826 		gulong handlerId;
827 		
828 		this(void delegate(VolumeIF, VolumeMonitor) dlg)
829 		{
830 			this.dlg = dlg;
831 			this.listeners ~= this;
832 		}
833 		
834 		void remove(OnVolumeChangedDelegateWrapper source)
835 		{
836 			foreach(index, wrapper; listeners)
837 			{
838 				if (wrapper.handlerId == source.handlerId)
839 				{
840 					listeners[index] = null;
841 					listeners = std.algorithm.remove(listeners, index);
842 					break;
843 				}
844 			}
845 		}
846 	}
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!(Volume, 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 		static OnVolumeRemovedDelegateWrapper[] listeners;
880 		void delegate(VolumeIF, VolumeMonitor) dlg;
881 		gulong handlerId;
882 		
883 		this(void delegate(VolumeIF, VolumeMonitor) dlg)
884 		{
885 			this.dlg = dlg;
886 			this.listeners ~= this;
887 		}
888 		
889 		void remove(OnVolumeRemovedDelegateWrapper source)
890 		{
891 			foreach(index, wrapper; listeners)
892 			{
893 				if (wrapper.handlerId == source.handlerId)
894 				{
895 					listeners[index] = null;
896 					listeners = std.algorithm.remove(listeners, index);
897 					break;
898 				}
899 			}
900 		}
901 	}
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!(Volume, VolumeIF)(volume), wrapper.outer);
925 	}
926 	
927 	extern(C) static void callBackVolumeRemovedDestroy(OnVolumeRemovedDelegateWrapper wrapper, GClosure* closure)
928 	{
929 		wrapper.remove(wrapper);
930 	}
931 }