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.UnixMountMonitor;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gobject.Signals;
30 public  import gtkc.gdktypes;
31 private import gtkc.gio;
32 public  import gtkc.giotypes;
33 
34 
35 /**
36  * Watches #GUnixMounts for changes.
37  */
38 public class UnixMountMonitor : ObjectG
39 {
40 	/** the main Gtk struct */
41 	protected GUnixMountMonitor* gUnixMountMonitor;
42 
43 	/** Get the main Gtk struct */
44 	public GUnixMountMonitor* getUnixMountMonitorStruct()
45 	{
46 		return gUnixMountMonitor;
47 	}
48 
49 	/** the main Gtk struct as a void* */
50 	protected override void* getStruct()
51 	{
52 		return cast(void*)gUnixMountMonitor;
53 	}
54 
55 	protected override void setStruct(GObject* obj)
56 	{
57 		gUnixMountMonitor = cast(GUnixMountMonitor*)obj;
58 		super.setStruct(obj);
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (GUnixMountMonitor* gUnixMountMonitor, bool ownedRef = false)
65 	{
66 		this.gUnixMountMonitor = gUnixMountMonitor;
67 		super(cast(GObject*)gUnixMountMonitor, ownedRef);
68 	}
69 
70 	/**
71 	 */
72 
73 	public static GType getType()
74 	{
75 		return g_unix_mount_monitor_get_type();
76 	}
77 
78 	/**
79 	 * Deprecated alias for g_unix_mount_monitor_get().
80 	 *
81 	 * This function was never a true constructor, which is why it was
82 	 * renamed.
83 	 *
84 	 * Deprecated: Use g_unix_mount_monitor_get() instead.
85 	 *
86 	 * Return: a #GUnixMountMonitor.
87 	 *
88 	 * Throws: ConstructionException GTK+ fails to create the object.
89 	 */
90 	public this()
91 	{
92 		auto p = g_unix_mount_monitor_new();
93 		
94 		if(p is null)
95 		{
96 			throw new ConstructionException("null returned by new");
97 		}
98 		
99 		this(cast(GUnixMountMonitor*) p, true);
100 	}
101 
102 	/**
103 	 * Gets the #GUnixMountMonitor for the current thread-default main
104 	 * context.
105 	 *
106 	 * The mount monitor can be used to monitor for changes to the list of
107 	 * mounted filesystems as well as the list of mount points (ie: fstab
108 	 * entries).
109 	 *
110 	 * You must only call g_object_unref() on the return value from under
111 	 * the same main context as you called this function.
112 	 *
113 	 * Return: the #GUnixMountMonitor.
114 	 *
115 	 * Since: 2.44
116 	 */
117 	public static UnixMountMonitor get()
118 	{
119 		auto p = g_unix_mount_monitor_get();
120 		
121 		if(p is null)
122 		{
123 			return null;
124 		}
125 		
126 		return ObjectG.getDObject!(UnixMountMonitor)(cast(GUnixMountMonitor*) p, true);
127 	}
128 
129 	/**
130 	 * This function does nothing.
131 	 *
132 	 * Before 2.44, this was a partially-effective way of controlling the
133 	 * rate at which events would be reported under some uncommon
134 	 * circumstances.  Since @mount_monitor is a singleton, it also meant
135 	 * that calling this function would have side effects for other users of
136 	 * the monitor.
137 	 *
138 	 * Deprecated: This function does nothing.  Don't call it.
139 	 *
140 	 * Params:
141 	 *     limitMsec = a integer with the limit in milliseconds to
142 	 *         poll for changes.
143 	 *
144 	 * Since: 2.18
145 	 */
146 	public void setRateLimit(int limitMsec)
147 	{
148 		g_unix_mount_monitor_set_rate_limit(gUnixMountMonitor, limitMsec);
149 	}
150 
151 	int[string] connectedSignals;
152 
153 	void delegate(UnixMountMonitor)[] onMountpointsChangedListeners;
154 	/**
155 	 * Emitted when the unix mount points have changed.
156 	 */
157 	void addOnMountpointsChanged(void delegate(UnixMountMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
158 	{
159 		if ( "mountpoints-changed" !in connectedSignals )
160 		{
161 			Signals.connectData(
162 				this,
163 				"mountpoints-changed",
164 				cast(GCallback)&callBackMountpointsChanged,
165 				cast(void*)this,
166 				null,
167 				connectFlags);
168 			connectedSignals["mountpoints-changed"] = 1;
169 		}
170 		onMountpointsChangedListeners ~= dlg;
171 	}
172 	extern(C) static void callBackMountpointsChanged(GUnixMountMonitor* unixmountmonitorStruct, UnixMountMonitor _unixmountmonitor)
173 	{
174 		foreach ( void delegate(UnixMountMonitor) dlg; _unixmountmonitor.onMountpointsChangedListeners )
175 		{
176 			dlg(_unixmountmonitor);
177 		}
178 	}
179 
180 	void delegate(UnixMountMonitor)[] onMountsChangedListeners;
181 	/**
182 	 * Emitted when the unix mounts have changed.
183 	 */
184 	void addOnMountsChanged(void delegate(UnixMountMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
185 	{
186 		if ( "mounts-changed" !in connectedSignals )
187 		{
188 			Signals.connectData(
189 				this,
190 				"mounts-changed",
191 				cast(GCallback)&callBackMountsChanged,
192 				cast(void*)this,
193 				null,
194 				connectFlags);
195 			connectedSignals["mounts-changed"] = 1;
196 		}
197 		onMountsChangedListeners ~= dlg;
198 	}
199 	extern(C) static void callBackMountsChanged(GUnixMountMonitor* unixmountmonitorStruct, UnixMountMonitor _unixmountmonitor)
200 	{
201 		foreach ( void delegate(UnixMountMonitor) dlg; _unixmountmonitor.onMountsChangedListeners )
202 		{
203 			dlg(_unixmountmonitor);
204 		}
205 	}
206 }