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 	/**
263 	 * Emitted when a drive changes.
264 	 *
265 	 * Params:
266 	 *     drive = the drive that changed
267 	 */
268 	gulong addOnDriveChanged(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
269 	{
270 		return Signals.connect(this, "drive-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
271 	}
272 
273 	/**
274 	 * Emitted when a drive is connected to the system.
275 	 *
276 	 * Params:
277 	 *     drive = a #GDrive that was connected.
278 	 */
279 	gulong addOnDriveConnected(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
280 	{
281 		return Signals.connect(this, "drive-connected", dlg, connectFlags ^ ConnectFlags.SWAPPED);
282 	}
283 
284 	/**
285 	 * Emitted when a drive is disconnected from the system.
286 	 *
287 	 * Params:
288 	 *     drive = a #GDrive that was disconnected.
289 	 */
290 	gulong addOnDriveDisconnected(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
291 	{
292 		return Signals.connect(this, "drive-disconnected", dlg, connectFlags ^ ConnectFlags.SWAPPED);
293 	}
294 
295 	/**
296 	 * Emitted when the eject button is pressed on @drive.
297 	 *
298 	 * Params:
299 	 *     drive = the drive where the eject button was pressed
300 	 *
301 	 * Since: 2.18
302 	 */
303 	gulong addOnDriveEjectButton(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
304 	{
305 		return Signals.connect(this, "drive-eject-button", dlg, connectFlags ^ ConnectFlags.SWAPPED);
306 	}
307 
308 	/**
309 	 * Emitted when the stop button is pressed on @drive.
310 	 *
311 	 * Params:
312 	 *     drive = the drive where the stop button was pressed
313 	 *
314 	 * Since: 2.22
315 	 */
316 	gulong addOnDriveStopButton(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
317 	{
318 		return Signals.connect(this, "drive-stop-button", dlg, connectFlags ^ ConnectFlags.SWAPPED);
319 	}
320 
321 	/**
322 	 * Emitted when a mount is added.
323 	 *
324 	 * Params:
325 	 *     mount = a #GMount that was added.
326 	 */
327 	gulong addOnMountAdded(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
328 	{
329 		return Signals.connect(this, "mount-added", dlg, connectFlags ^ ConnectFlags.SWAPPED);
330 	}
331 
332 	/**
333 	 * Emitted when a mount changes.
334 	 *
335 	 * Params:
336 	 *     mount = a #GMount that changed.
337 	 */
338 	gulong addOnMountChanged(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
339 	{
340 		return Signals.connect(this, "mount-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
341 	}
342 
343 	/**
344 	 * May be emitted when a mount is about to be removed.
345 	 *
346 	 * This signal depends on the backend and is only emitted if
347 	 * GIO was used to unmount.
348 	 *
349 	 * Params:
350 	 *     mount = a #GMount that is being unmounted.
351 	 */
352 	gulong addOnMountPreUnmount(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
353 	{
354 		return Signals.connect(this, "mount-pre-unmount", dlg, connectFlags ^ ConnectFlags.SWAPPED);
355 	}
356 
357 	/**
358 	 * Emitted when a mount is removed.
359 	 *
360 	 * Params:
361 	 *     mount = a #GMount that was removed.
362 	 */
363 	gulong addOnMountRemoved(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
364 	{
365 		return Signals.connect(this, "mount-removed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
366 	}
367 
368 	/**
369 	 * Emitted when a mountable volume is added to the system.
370 	 *
371 	 * Params:
372 	 *     volume = a #GVolume that was added.
373 	 */
374 	gulong addOnVolumeAdded(void delegate(VolumeIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
375 	{
376 		return Signals.connect(this, "volume-added", dlg, connectFlags ^ ConnectFlags.SWAPPED);
377 	}
378 
379 	/**
380 	 * Emitted when mountable volume is changed.
381 	 *
382 	 * Params:
383 	 *     volume = a #GVolume that changed.
384 	 */
385 	gulong addOnVolumeChanged(void delegate(VolumeIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
386 	{
387 		return Signals.connect(this, "volume-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
388 	}
389 
390 	/**
391 	 * Emitted when a mountable volume is removed from the system.
392 	 *
393 	 * Params:
394 	 *     volume = a #GVolume that was removed.
395 	 */
396 	gulong addOnVolumeRemoved(void delegate(VolumeIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
397 	{
398 		return Signals.connect(this, "volume-removed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
399 	}
400 }