| 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 |
* Conversion parameters: |
|---|
| 26 |
* inFile = GFileMonitor.html |
|---|
| 27 |
* outPack = gio |
|---|
| 28 |
* outFile = FileMonitor |
|---|
| 29 |
* strct = GFileMonitor |
|---|
| 30 |
* realStrct= |
|---|
| 31 |
* ctorStrct= |
|---|
| 32 |
* clss = FileMonitor |
|---|
| 33 |
* interf = |
|---|
| 34 |
* class Code: No |
|---|
| 35 |
* interface Code: No |
|---|
| 36 |
* template for: |
|---|
| 37 |
* extend = GObject |
|---|
| 38 |
* implements: |
|---|
| 39 |
* prefixes: |
|---|
| 40 |
* - g_file_monitor_ |
|---|
| 41 |
* omit structs: |
|---|
| 42 |
* omit prefixes: |
|---|
| 43 |
* omit code: |
|---|
| 44 |
* omit signals: |
|---|
| 45 |
* imports: |
|---|
| 46 |
* - gio.File |
|---|
| 47 |
* structWrap: |
|---|
| 48 |
* - GFile* -> File |
|---|
| 49 |
* module aliases: |
|---|
| 50 |
* local aliases: |
|---|
| 51 |
* overrides: |
|---|
| 52 |
*/ |
|---|
| 53 |
|
|---|
| 54 |
module gio.FileMonitor; |
|---|
| 55 |
|
|---|
| 56 |
public import gtkc.giotypes; |
|---|
| 57 |
|
|---|
| 58 |
private import gtkc.gio; |
|---|
| 59 |
private import glib.ConstructionException; |
|---|
| 60 |
|
|---|
| 61 |
private import gobject.Signals; |
|---|
| 62 |
public import gtkc.gdktypes; |
|---|
| 63 |
|
|---|
| 64 |
private import gio.File; |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
private import gobject.ObjectG; |
|---|
| 69 |
|
|---|
| 70 |
/** |
|---|
| 71 |
* Description |
|---|
| 72 |
* Monitors a file or directory for changes. |
|---|
| 73 |
* To obtain a GFileMonitor for a file or directory, use |
|---|
| 74 |
* g_file_monitor(), g_file_monitor_file(), or |
|---|
| 75 |
* g_file_monitor_directory(). |
|---|
| 76 |
* To get informed about changes to the file or directory you are |
|---|
| 77 |
* monitoring, connect to the "changed" signal. The |
|---|
| 78 |
* signal will be emitted in the thread-default main |
|---|
| 79 |
* context of the thread that the monitor was created in |
|---|
| 80 |
* (though if the global default main context is blocked, this may |
|---|
| 81 |
* cause notifications to be blocked even if the thread-default |
|---|
| 82 |
* context is still running). |
|---|
| 83 |
*/ |
|---|
| 84 |
public class FileMonitor : ObjectG |
|---|
| 85 |
{ |
|---|
| 86 |
|
|---|
| 87 |
/** the main Gtk struct */ |
|---|
| 88 |
protected GFileMonitor* gFileMonitor; |
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
public GFileMonitor* getFileMonitorStruct() |
|---|
| 92 |
{ |
|---|
| 93 |
return gFileMonitor; |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
/** the main Gtk struct as a void* */ |
|---|
| 98 |
protected override void* getStruct() |
|---|
| 99 |
{ |
|---|
| 100 |
return cast(void*)gFileMonitor; |
|---|
| 101 |
} |
|---|
| 102 |
|
|---|
| 103 |
/** |
|---|
| 104 |
* Sets our main struct and passes it to the parent class |
|---|
| 105 |
*/ |
|---|
| 106 |
public this (GFileMonitor* gFileMonitor) |
|---|
| 107 |
{ |
|---|
| 108 |
if(gFileMonitor is null) |
|---|
| 109 |
{ |
|---|
| 110 |
this = null; |
|---|
| 111 |
return; |
|---|
| 112 |
} |
|---|
| 113 |
//Check if there already is a D object for this gtk struct |
|---|
| 114 |
void* ptr = getDObject(cast(GObject*)gFileMonitor); |
|---|
| 115 |
if( ptr !is null ) |
|---|
| 116 |
{ |
|---|
| 117 |
this = cast(FileMonitor)ptr; |
|---|
| 118 |
return; |
|---|
| 119 |
} |
|---|
| 120 |
super(cast(GObject*)gFileMonitor); |
|---|
| 121 |
this.gFileMonitor = gFileMonitor; |
|---|
| 122 |
} |
|---|
| 123 |
|
|---|
| 124 |
protected override void setStruct(GObject* obj) |
|---|
| 125 |
{ |
|---|
| 126 |
super.setStruct(obj); |
|---|
| 127 |
gFileMonitor = cast(GFileMonitor*)obj; |
|---|
| 128 |
} |
|---|
| 129 |
|
|---|
| 130 |
/** |
|---|
| 131 |
*/ |
|---|
| 132 |
int[string] connectedSignals; |
|---|
| 133 |
|
|---|
| 134 |
void delegate(File, File, GFileMonitorEvent, FileMonitor)[] onChangedListeners; |
|---|
| 135 |
/** |
|---|
| 136 |
* Emitted when file has been changed. |
|---|
| 137 |
* If using G_FILE_MONITOR_SEND_MOVED flag and event_type is |
|---|
| 138 |
* G_FILE_MONITOR_SEND_MOVED, file will be set to a GFile containing the |
|---|
| 139 |
* old path, and other_file will be set to a GFile containing the new path. |
|---|
| 140 |
* In all the other cases, other_file will be set to NULL. |
|---|
| 141 |
*/ |
|---|
| 142 |
void addOnChanged(void delegate(File, File, GFileMonitorEvent, FileMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) |
|---|
| 143 |
{ |
|---|
| 144 |
if ( !("changed" in connectedSignals) ) |
|---|
| 145 |
{ |
|---|
| 146 |
Signals.connectData( |
|---|
| 147 |
getStruct(), |
|---|
| 148 |
"changed", |
|---|
| 149 |
cast(GCallback)&callBackChanged, |
|---|
| 150 |
cast(void*)this, |
|---|
| 151 |
null, |
|---|
| 152 |
connectFlags); |
|---|
| 153 |
connectedSignals["changed"] = 1; |
|---|
| 154 |
} |
|---|
| 155 |
onChangedListeners ~= dlg; |
|---|
| 156 |
} |
|---|
| 157 |
extern(C) static void callBackChanged(GFileMonitor* monitorStruct, GFile* file, GFile* otherFile, GFileMonitorEvent eventType, FileMonitor fileMonitor) |
|---|
| 158 |
{ |
|---|
| 159 |
foreach ( void delegate(File, File, GFileMonitorEvent, FileMonitor) dlg ; fileMonitor.onChangedListeners ) |
|---|
| 160 |
{ |
|---|
| 161 |
dlg(new File(file), new File(otherFile), eventType, fileMonitor); |
|---|
| 162 |
} |
|---|
| 163 |
} |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
/** |
|---|
| 167 |
* Cancels a file monitor. |
|---|
| 168 |
* Returns: TRUE if monitor was cancelled. |
|---|
| 169 |
*/ |
|---|
| 170 |
public int cancel() |
|---|
| 171 |
{ |
|---|
| 172 |
// gboolean g_file_monitor_cancel (GFileMonitor *monitor); |
|---|
| 173 |
return g_file_monitor_cancel(gFileMonitor); |
|---|
| 174 |
} |
|---|
| 175 |
|
|---|
| 176 |
/** |
|---|
| 177 |
* Returns whether the monitor is canceled. |
|---|
| 178 |
* Returns: TRUE if monitor is canceled. FALSE otherwise. |
|---|
| 179 |
*/ |
|---|
| 180 |
public int isCancelled() |
|---|
| 181 |
{ |
|---|
| 182 |
// gboolean g_file_monitor_is_cancelled (GFileMonitor *monitor); |
|---|
| 183 |
return g_file_monitor_is_cancelled(gFileMonitor); |
|---|
| 184 |
} |
|---|
| 185 |
|
|---|
| 186 |
/** |
|---|
| 187 |
* Sets the rate limit to which the monitor will report |
|---|
| 188 |
* consecutive change events to the same file. |
|---|
| 189 |
* Params: |
|---|
| 190 |
* limitMsecs = a non-negative integer with the limit in milliseconds |
|---|
| 191 |
* to poll for changes |
|---|
| 192 |
*/ |
|---|
| 193 |
public void setRateLimit(int limitMsecs) |
|---|
| 194 |
{ |
|---|
| 195 |
// void g_file_monitor_set_rate_limit (GFileMonitor *monitor, gint limit_msecs); |
|---|
| 196 |
g_file_monitor_set_rate_limit(gFileMonitor, limitMsecs); |
|---|
| 197 |
} |
|---|
| 198 |
|
|---|
| 199 |
/** |
|---|
| 200 |
* Emits the "changed" signal if a change |
|---|
| 201 |
* has taken place. Should be called from file monitor |
|---|
| 202 |
* implementations only. |
|---|
| 203 |
* The signal will be emitted from an idle handler (in the thread-default main |
|---|
| 204 |
* context). |
|---|
| 205 |
* Params: |
|---|
| 206 |
* child = a GFile. |
|---|
| 207 |
* otherFile = a GFile. |
|---|
| 208 |
* eventType = a set of GFileMonitorEvent flags. |
|---|
| 209 |
*/ |
|---|
| 210 |
public void emitEvent(File child, File otherFile, GFileMonitorEvent eventType) |
|---|
| 211 |
{ |
|---|
| 212 |
// void g_file_monitor_emit_event (GFileMonitor *monitor, GFile *child, GFile *other_file, GFileMonitorEvent event_type); |
|---|
| 213 |
g_file_monitor_emit_event(gFileMonitor, (child is null) ? null : child.getFileStruct(), (otherFile is null) ? null : otherFile.getFileStruct(), eventType); |
|---|
| 214 |
} |
|---|
| 215 |
} |
|---|