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 	 * Gets a new #GUnixMountMonitor. The default rate limit for which the
80 	 * monitor will report consecutive changes for the mount and mount
81 	 * point entry files is the default for a #GFileMonitor. Use
82 	 * g_unix_mount_monitor_set_rate_limit() to change this.
83 	 *
84 	 * Return: a #GUnixMountMonitor.
85 	 *
86 	 * Throws: ConstructionException GTK+ fails to create the object.
87 	 */
88 	public this()
89 	{
90 		auto p = g_unix_mount_monitor_new();
91 		
92 		if(p is null)
93 		{
94 			throw new ConstructionException("null returned by new");
95 		}
96 		
97 		this(cast(GUnixMountMonitor*) p, true);
98 	}
99 
100 	/**
101 	 * Sets the rate limit to which the @mount_monitor will report
102 	 * consecutive change events to the mount and mount point entry files.
103 	 *
104 	 * Params:
105 	 *     limitMsec = a integer with the limit in milliseconds to
106 	 *         poll for changes.
107 	 *
108 	 * Since: 2.18
109 	 */
110 	public void setRateLimit(int limitMsec)
111 	{
112 		g_unix_mount_monitor_set_rate_limit(gUnixMountMonitor, limitMsec);
113 	}
114 
115 	int[string] connectedSignals;
116 
117 	void delegate(UnixMountMonitor)[] onMountpointsChangedListeners;
118 	/**
119 	 * Emitted when the unix mount points have changed.
120 	 */
121 	void addOnMountpointsChanged(void delegate(UnixMountMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
122 	{
123 		if ( "mountpoints-changed" !in connectedSignals )
124 		{
125 			Signals.connectData(
126 				this,
127 				"mountpoints-changed",
128 				cast(GCallback)&callBackMountpointsChanged,
129 				cast(void*)this,
130 				null,
131 				connectFlags);
132 			connectedSignals["mountpoints-changed"] = 1;
133 		}
134 		onMountpointsChangedListeners ~= dlg;
135 	}
136 	extern(C) static void callBackMountpointsChanged(GUnixMountMonitor* unixmountmonitorStruct, UnixMountMonitor _unixmountmonitor)
137 	{
138 		foreach ( void delegate(UnixMountMonitor) dlg; _unixmountmonitor.onMountpointsChangedListeners )
139 		{
140 			dlg(_unixmountmonitor);
141 		}
142 	}
143 
144 	void delegate(UnixMountMonitor)[] onMountsChangedListeners;
145 	/**
146 	 * Emitted when the unix mounts have changed.
147 	 */
148 	void addOnMountsChanged(void delegate(UnixMountMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
149 	{
150 		if ( "mounts-changed" !in connectedSignals )
151 		{
152 			Signals.connectData(
153 				this,
154 				"mounts-changed",
155 				cast(GCallback)&callBackMountsChanged,
156 				cast(void*)this,
157 				null,
158 				connectFlags);
159 			connectedSignals["mounts-changed"] = 1;
160 		}
161 		onMountsChangedListeners ~= dlg;
162 	}
163 	extern(C) static void callBackMountsChanged(GUnixMountMonitor* unixmountmonitorStruct, UnixMountMonitor _unixmountmonitor)
164 	{
165 		foreach ( void delegate(UnixMountMonitor) dlg; _unixmountmonitor.onMountsChangedListeners )
166 		{
167 			dlg(_unixmountmonitor);
168 		}
169 	}
170 }