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