source: appstream-generator/build/girepo/gio/MountT.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 23.7 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.MountT;
22
23public  import gi.gio;
24public  import gi.giotypes;
25public  import gio.AsyncResultIF;
26public  import gio.Cancellable;
27public  import gio.Drive;
28public  import gio.DriveIF;
29public  import gio.File;
30public  import gio.FileIF;
31public  import gio.Icon;
32public  import gio.IconIF;
33public  import gio.MountOperation;
34public  import gio.Volume;
35public  import gio.VolumeIF;
36public  import glib.ErrorG;
37public  import glib.GException;
38public  import glib.Str;
39public  import gobject.ObjectG;
40public  import gobject.Signals;
41public  import std.algorithm;
42
43
44/**
45 * The #GMount interface represents user-visible mounts. Note, when
46 * porting from GnomeVFS, #GMount is the moral equivalent of #GnomeVFSVolume.
47 *
48 * #GMount is a "mounted" filesystem that you can access. Mounted is in
49 * quotes because it's not the same as a unix mount, it might be a gvfs
50 * mount, but you can still access the files on it if you use GIO. Might or
51 * might not be related to a volume object.
52 *
53 * Unmounting a #GMount instance is an asynchronous operation. For
54 * more information about asynchronous operations, see #GAsyncResult
55 * and #GTask. To unmount a #GMount instance, first call
56 * g_mount_unmount_with_operation() with (at least) the #GMount instance and a
57 * #GAsyncReadyCallback.  The callback will be fired when the
58 * operation has resolved (either with success or failure), and a
59 * #GAsyncReady structure will be passed to the callback.  That
60 * callback should then call g_mount_unmount_with_operation_finish() with the #GMount
61 * and the #GAsyncReady data to see if the operation was completed
62 * successfully.  If an @error is present when g_mount_unmount_with_operation_finish()
63 * is called, then it will be filled with any error information.
64 */
65public template MountT(TStruct)
66{
67        /** Get the main Gtk struct */
68        public GMount* getMountStruct()
69        {
70                return cast(GMount*)getStruct();
71        }
72
73
74        /**
75         * Checks if @mount can be eject.
76         *
77         * Returns: %TRUE if the @mount can be ejected.
78         */
79        public bool canEject()
80        {
81                return g_mount_can_eject(getMountStruct()) != 0;
82        }
83
84        /**
85         * Checks if @mount can be mounted.
86         *
87         * Returns: %TRUE if the @mount can be unmounted.
88         */
89        public bool canUnmount()
90        {
91                return g_mount_can_unmount(getMountStruct()) != 0;
92        }
93
94        /**
95         * Ejects a mount. This is an asynchronous operation, and is
96         * finished by calling g_mount_eject_finish() with the @mount
97         * and #GAsyncResult data returned in the @callback.
98         *
99         * Deprecated: Use g_mount_eject_with_operation() instead.
100         *
101         * Params:
102         *     flags = flags affecting the unmount if required for eject
103         *     cancellable = optional #GCancellable object, %NULL to ignore.
104         *     callback = a #GAsyncReadyCallback, or %NULL.
105         *     userData = user data passed to @callback.
106         */
107        public void eject(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
108        {
109                g_mount_eject(getMountStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
110        }
111
112        /**
113         * Finishes ejecting a mount. If any errors occurred during the operation,
114         * @error will be set to contain the errors and %FALSE will be returned.
115         *
116         * Deprecated: Use g_mount_eject_with_operation_finish() instead.
117         *
118         * Params:
119         *     result = a #GAsyncResult.
120         *
121         * Returns: %TRUE if the mount was successfully ejected. %FALSE otherwise.
122         *
123         * Throws: GException on failure.
124         */
125        public bool ejectFinish(AsyncResultIF result)
126        {
127                GError* err = null;
128               
129                auto p = g_mount_eject_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
130               
131                if (err !is null)
132                {
133                        throw new GException( new ErrorG(err) );
134                }
135               
136                return p;
137        }
138
139        /**
140         * Ejects a mount. This is an asynchronous operation, and is
141         * finished by calling g_mount_eject_with_operation_finish() with the @mount
142         * and #GAsyncResult data returned in the @callback.
143         *
144         * Params:
145         *     flags = flags affecting the unmount if required for eject
146         *     mountOperation = a #GMountOperation or %NULL to avoid
147         *         user interaction.
148         *     cancellable = optional #GCancellable object, %NULL to ignore.
149         *     callback = a #GAsyncReadyCallback, or %NULL.
150         *     userData = user data passed to @callback.
151         *
152         * Since: 2.22
153         */
154        public void ejectWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
155        {
156                g_mount_eject_with_operation(getMountStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
157        }
158
159        /**
160         * Finishes ejecting a mount. If any errors occurred during the operation,
161         * @error will be set to contain the errors and %FALSE will be returned.
162         *
163         * Params:
164         *     result = a #GAsyncResult.
165         *
166         * Returns: %TRUE if the mount was successfully ejected. %FALSE otherwise.
167         *
168         * Since: 2.22
169         *
170         * Throws: GException on failure.
171         */
172        public bool ejectWithOperationFinish(AsyncResultIF result)
173        {
174                GError* err = null;
175               
176                auto p = g_mount_eject_with_operation_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
177               
178                if (err !is null)
179                {
180                        throw new GException( new ErrorG(err) );
181                }
182               
183                return p;
184        }
185
186        /**
187         * Gets the default location of @mount. The default location of the given
188         * @mount is a path that reflects the main entry point for the user (e.g.
189         * the home directory, or the root of the volume).
190         *
191         * Returns: a #GFile.
192         *     The returned object should be unreffed with
193         *     g_object_unref() when no longer needed.
194         */
195        public FileIF getDefaultLocation()
196        {
197                auto p = g_mount_get_default_location(getMountStruct());
198               
199                if(p is null)
200                {
201                        return null;
202                }
203               
204                return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true);
205        }
206
207        /**
208         * Gets the drive for the @mount.
209         *
210         * This is a convenience method for getting the #GVolume and then
211         * using that object to get the #GDrive.
212         *
213         * Returns: a #GDrive or %NULL if @mount is not associated with a volume or a drive.
214         *     The returned object should be unreffed with
215         *     g_object_unref() when no longer needed.
216         */
217        public DriveIF getDrive()
218        {
219                auto p = g_mount_get_drive(getMountStruct());
220               
221                if(p is null)
222                {
223                        return null;
224                }
225               
226                return ObjectG.getDObject!(Drive, DriveIF)(cast(GDrive*) p, true);
227        }
228
229        /**
230         * Gets the icon for @mount.
231         *
232         * Returns: a #GIcon.
233         *     The returned object should be unreffed with
234         *     g_object_unref() when no longer needed.
235         */
236        public IconIF getIcon()
237        {
238                auto p = g_mount_get_icon(getMountStruct());
239               
240                if(p is null)
241                {
242                        return null;
243                }
244               
245                return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p, true);
246        }
247
248        /**
249         * Gets the name of @mount.
250         *
251         * Returns: the name for the given @mount.
252         *     The returned string should be freed with g_free()
253         *     when no longer needed.
254         */
255        public string getName()
256        {
257                auto retStr = g_mount_get_name(getMountStruct());
258               
259                scope(exit) Str.freeString(retStr);
260                return Str.toString(retStr);
261        }
262
263        /**
264         * Gets the root directory on @mount.
265         *
266         * Returns: a #GFile.
267         *     The returned object should be unreffed with
268         *     g_object_unref() when no longer needed.
269         */
270        public FileIF getRoot()
271        {
272                auto p = g_mount_get_root(getMountStruct());
273               
274                if(p is null)
275                {
276                        return null;
277                }
278               
279                return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p, true);
280        }
281
282        /**
283         * Gets the sort key for @mount, if any.
284         *
285         * Returns: Sorting key for @mount or %NULL if no such key is available.
286         *
287         * Since: 2.32
288         */
289        public string getSortKey()
290        {
291                return Str.toString(g_mount_get_sort_key(getMountStruct()));
292        }
293
294        /**
295         * Gets the symbolic icon for @mount.
296         *
297         * Returns: a #GIcon.
298         *     The returned object should be unreffed with
299         *     g_object_unref() when no longer needed.
300         *
301         * Since: 2.34
302         */
303        public IconIF getSymbolicIcon()
304        {
305                auto p = g_mount_get_symbolic_icon(getMountStruct());
306               
307                if(p is null)
308                {
309                        return null;
310                }
311               
312                return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p, true);
313        }
314
315        /**
316         * Gets the UUID for the @mount. The reference is typically based on
317         * the file system UUID for the mount in question and should be
318         * considered an opaque string. Returns %NULL if there is no UUID
319         * available.
320         *
321         * Returns: the UUID for @mount or %NULL if no UUID can be computed.
322         *     The returned string should be freed with g_free()
323         *     when no longer needed.
324         */
325        public string getUuid()
326        {
327                auto retStr = g_mount_get_uuid(getMountStruct());
328               
329                scope(exit) Str.freeString(retStr);
330                return Str.toString(retStr);
331        }
332
333        /**
334         * Gets the volume for the @mount.
335         *
336         * Returns: a #GVolume or %NULL if @mount is not associated with a volume.
337         *     The returned object should be unreffed with
338         *     g_object_unref() when no longer needed.
339         */
340        public VolumeIF getVolume()
341        {
342                auto p = g_mount_get_volume(getMountStruct());
343               
344                if(p is null)
345                {
346                        return null;
347                }
348               
349                return ObjectG.getDObject!(Volume, VolumeIF)(cast(GVolume*) p, true);
350        }
351
352        /**
353         * Tries to guess the type of content stored on @mount. Returns one or
354         * more textual identifiers of well-known content types (typically
355         * prefixed with "x-content/"), e.g. x-content/image-dcf for camera
356         * memory cards. See the
357         * [shared-mime-info](http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec)
358         * specification for more on x-content types.
359         *
360         * This is an asynchronous operation (see
361         * g_mount_guess_content_type_sync() for the synchronous version), and
362         * is finished by calling g_mount_guess_content_type_finish() with the
363         * @mount and #GAsyncResult data returned in the @callback.
364         *
365         * Params:
366         *     forceRescan = Whether to force a rescan of the content.
367         *         Otherwise a cached result will be used if available
368         *     cancellable = optional #GCancellable object, %NULL to ignore
369         *     callback = a #GAsyncReadyCallback
370         *     userData = user data passed to @callback
371         *
372         * Since: 2.18
373         */
374        public void guessContentType(bool forceRescan, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
375        {
376                g_mount_guess_content_type(getMountStruct(), forceRescan, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
377        }
378
379        /**
380         * Finishes guessing content types of @mount. If any errors occurred
381         * during the operation, @error will be set to contain the errors and
382         * %FALSE will be returned. In particular, you may get an
383         * %G_IO_ERROR_NOT_SUPPORTED if the mount does not support content
384         * guessing.
385         *
386         * Params:
387         *     result = a #GAsyncResult
388         *
389         * Returns: a %NULL-terminated array of content types or %NULL on error.
390         *     Caller should free this array with g_strfreev() when done with it.
391         *
392         * Since: 2.18
393         *
394         * Throws: GException on failure.
395         */
396        public string[] guessContentTypeFinish(AsyncResultIF result)
397        {
398                GError* err = null;
399               
400                auto retStr = g_mount_guess_content_type_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err);
401               
402                if (err !is null)
403                {
404                        throw new GException( new ErrorG(err) );
405                }
406               
407                scope(exit) Str.freeStringArray(retStr);
408                return Str.toStringArray(retStr);
409        }
410
411        /**
412         * Tries to guess the type of content stored on @mount. Returns one or
413         * more textual identifiers of well-known content types (typically
414         * prefixed with "x-content/"), e.g. x-content/image-dcf for camera
415         * memory cards. See the
416         * [shared-mime-info](http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec)
417         * specification for more on x-content types.
418         *
419         * This is an synchronous operation and as such may block doing IO;
420         * see g_mount_guess_content_type() for the asynchronous version.
421         *
422         * Params:
423         *     forceRescan = Whether to force a rescan of the content.
424         *         Otherwise a cached result will be used if available
425         *     cancellable = optional #GCancellable object, %NULL to ignore
426         *
427         * Returns: a %NULL-terminated array of content types or %NULL on error.
428         *     Caller should free this array with g_strfreev() when done with it.
429         *
430         * Since: 2.18
431         *
432         * Throws: GException on failure.
433         */
434        public string[] guessContentTypeSync(bool forceRescan, Cancellable cancellable)
435        {
436                GError* err = null;
437               
438                auto retStr = g_mount_guess_content_type_sync(getMountStruct(), forceRescan, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
439               
440                if (err !is null)
441                {
442                        throw new GException( new ErrorG(err) );
443                }
444               
445                scope(exit) Str.freeStringArray(retStr);
446                return Str.toStringArray(retStr);
447        }
448
449        /**
450         * Determines if @mount is shadowed. Applications or libraries should
451         * avoid displaying @mount in the user interface if it is shadowed.
452         *
453         * A mount is said to be shadowed if there exists one or more user
454         * visible objects (currently #GMount objects) with a root that is
455         * inside the root of @mount.
456         *
457         * One application of shadow mounts is when exposing a single file
458         * system that is used to address several logical volumes. In this
459         * situation, a #GVolumeMonitor implementation would create two
460         * #GVolume objects (for example, one for the camera functionality of
461         * the device and one for a SD card reader on the device) with
462         * activation URIs `gphoto2://[usb:001,002]/store1/`
463         * and `gphoto2://[usb:001,002]/store2/`. When the
464         * underlying mount (with root
465         * `gphoto2://[usb:001,002]/`) is mounted, said
466         * #GVolumeMonitor implementation would create two #GMount objects
467         * (each with their root matching the corresponding volume activation
468         * root) that would shadow the original mount.
469         *
470         * The proxy monitor in GVfs 2.26 and later, automatically creates and
471         * manage shadow mounts (and shadows the underlying mount) if the
472         * activation root on a #GVolume is set.
473         *
474         * Returns: %TRUE if @mount is shadowed.
475         *
476         * Since: 2.20
477         */
478        public bool isShadowed()
479        {
480                return g_mount_is_shadowed(getMountStruct()) != 0;
481        }
482
483        /**
484         * Remounts a mount. This is an asynchronous operation, and is
485         * finished by calling g_mount_remount_finish() with the @mount
486         * and #GAsyncResults data returned in the @callback.
487         *
488         * Remounting is useful when some setting affecting the operation
489         * of the volume has been changed, as these may need a remount to
490         * take affect. While this is semantically equivalent with unmounting
491         * and then remounting not all backends might need to actually be
492         * unmounted.
493         *
494         * Params:
495         *     flags = flags affecting the operation
496         *     mountOperation = a #GMountOperation or %NULL to avoid
497         *         user interaction.
498         *     cancellable = optional #GCancellable object, %NULL to ignore.
499         *     callback = a #GAsyncReadyCallback, or %NULL.
500         *     userData = user data passed to @callback.
501         */
502        public void remount(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
503        {
504                g_mount_remount(getMountStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
505        }
506
507        /**
508         * Finishes remounting a mount. If any errors occurred during the operation,
509         * @error will be set to contain the errors and %FALSE will be returned.
510         *
511         * Params:
512         *     result = a #GAsyncResult.
513         *
514         * Returns: %TRUE if the mount was successfully remounted. %FALSE otherwise.
515         *
516         * Throws: GException on failure.
517         */
518        public bool remountFinish(AsyncResultIF result)
519        {
520                GError* err = null;
521               
522                auto p = g_mount_remount_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
523               
524                if (err !is null)
525                {
526                        throw new GException( new ErrorG(err) );
527                }
528               
529                return p;
530        }
531
532        /**
533         * Increments the shadow count on @mount. Usually used by
534         * #GVolumeMonitor implementations when creating a shadow mount for
535         * @mount, see g_mount_is_shadowed() for more information. The caller
536         * will need to emit the #GMount::changed signal on @mount manually.
537         *
538         * Since: 2.20
539         */
540        public void shadow()
541        {
542                g_mount_shadow(getMountStruct());
543        }
544
545        /**
546         * Unmounts a mount. This is an asynchronous operation, and is
547         * finished by calling g_mount_unmount_finish() with the @mount
548         * and #GAsyncResult data returned in the @callback.
549         *
550         * Deprecated: Use g_mount_unmount_with_operation() instead.
551         *
552         * Params:
553         *     flags = flags affecting the operation
554         *     cancellable = optional #GCancellable object, %NULL to ignore.
555         *     callback = a #GAsyncReadyCallback, or %NULL.
556         *     userData = user data passed to @callback.
557         */
558        public void unmount(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
559        {
560                g_mount_unmount(getMountStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
561        }
562
563        /**
564         * Finishes unmounting a mount. If any errors occurred during the operation,
565         * @error will be set to contain the errors and %FALSE will be returned.
566         *
567         * Deprecated: Use g_mount_unmount_with_operation_finish() instead.
568         *
569         * Params:
570         *     result = a #GAsyncResult.
571         *
572         * Returns: %TRUE if the mount was successfully unmounted. %FALSE otherwise.
573         *
574         * Throws: GException on failure.
575         */
576        public bool unmountFinish(AsyncResultIF result)
577        {
578                GError* err = null;
579               
580                auto p = g_mount_unmount_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
581               
582                if (err !is null)
583                {
584                        throw new GException( new ErrorG(err) );
585                }
586               
587                return p;
588        }
589
590        /**
591         * Unmounts a mount. This is an asynchronous operation, and is
592         * finished by calling g_mount_unmount_with_operation_finish() with the @mount
593         * and #GAsyncResult data returned in the @callback.
594         *
595         * Params:
596         *     flags = flags affecting the operation
597         *     mountOperation = a #GMountOperation or %NULL to avoid
598         *         user interaction.
599         *     cancellable = optional #GCancellable object, %NULL to ignore.
600         *     callback = a #GAsyncReadyCallback, or %NULL.
601         *     userData = user data passed to @callback.
602         *
603         * Since: 2.22
604         */
605        public void unmountWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
606        {
607                g_mount_unmount_with_operation(getMountStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
608        }
609
610        /**
611         * Finishes unmounting a mount. If any errors occurred during the operation,
612         * @error will be set to contain the errors and %FALSE will be returned.
613         *
614         * Params:
615         *     result = a #GAsyncResult.
616         *
617         * Returns: %TRUE if the mount was successfully unmounted. %FALSE otherwise.
618         *
619         * Since: 2.22
620         *
621         * Throws: GException on failure.
622         */
623        public bool unmountWithOperationFinish(AsyncResultIF result)
624        {
625                GError* err = null;
626               
627                auto p = g_mount_unmount_with_operation_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
628               
629                if (err !is null)
630                {
631                        throw new GException( new ErrorG(err) );
632                }
633               
634                return p;
635        }
636
637        /**
638         * Decrements the shadow count on @mount. Usually used by
639         * #GVolumeMonitor implementations when destroying a shadow mount for
640         * @mount, see g_mount_is_shadowed() for more information. The caller
641         * will need to emit the #GMount::changed signal on @mount manually.
642         *
643         * Since: 2.20
644         */
645        public void unshadow()
646        {
647                g_mount_unshadow(getMountStruct());
648        }
649
650        protected class OnChangedDelegateWrapper
651        {
652                static OnChangedDelegateWrapper[] listeners;
653                void delegate(MountIF) dlg;
654                gulong handlerId;
655               
656                this(void delegate(MountIF) dlg)
657                {
658                        this.dlg = dlg;
659                        this.listeners ~= this;
660                }
661               
662                void remove(OnChangedDelegateWrapper source)
663                {
664                        foreach(index, wrapper; listeners)
665                        {
666                                if (wrapper.handlerId == source.handlerId)
667                                {
668                                        listeners[index] = null;
669                                        listeners = std.algorithm.remove(listeners, index);
670                                        break;
671                                }
672                        }
673                }
674        }
675
676        /**
677         * Emitted when the mount has been changed.
678         */
679        gulong addOnChanged(void delegate(MountIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
680        {
681                auto wrapper = new OnChangedDelegateWrapper(dlg);
682                wrapper.handlerId = Signals.connectData(
683                        this,
684                        "changed",
685                        cast(GCallback)&callBackChanged,
686                        cast(void*)wrapper,
687                        cast(GClosureNotify)&callBackChangedDestroy,
688                        connectFlags);
689                return wrapper.handlerId;
690        }
691       
692        extern(C) static void callBackChanged(GMount* mountStruct, OnChangedDelegateWrapper wrapper)
693        {
694                wrapper.dlg(wrapper.outer);
695        }
696       
697        extern(C) static void callBackChangedDestroy(OnChangedDelegateWrapper wrapper, GClosure* closure)
698        {
699                wrapper.remove(wrapper);
700        }
701
702        protected class OnPreUnmountDelegateWrapper
703        {
704                static OnPreUnmountDelegateWrapper[] listeners;
705                void delegate(MountIF) dlg;
706                gulong handlerId;
707               
708                this(void delegate(MountIF) dlg)
709                {
710                        this.dlg = dlg;
711                        this.listeners ~= this;
712                }
713               
714                void remove(OnPreUnmountDelegateWrapper source)
715                {
716                        foreach(index, wrapper; listeners)
717                        {
718                                if (wrapper.handlerId == source.handlerId)
719                                {
720                                        listeners[index] = null;
721                                        listeners = std.algorithm.remove(listeners, index);
722                                        break;
723                                }
724                        }
725                }
726        }
727
728        /**
729         * This signal is emitted when the #GMount is about to be
730         * unmounted.
731         *
732         * Since: 2.22
733         */
734        gulong addOnPreUnmount(void delegate(MountIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
735        {
736                auto wrapper = new OnPreUnmountDelegateWrapper(dlg);
737                wrapper.handlerId = Signals.connectData(
738                        this,
739                        "pre-unmount",
740                        cast(GCallback)&callBackPreUnmount,
741                        cast(void*)wrapper,
742                        cast(GClosureNotify)&callBackPreUnmountDestroy,
743                        connectFlags);
744                return wrapper.handlerId;
745        }
746       
747        extern(C) static void callBackPreUnmount(GMount* mountStruct, OnPreUnmountDelegateWrapper wrapper)
748        {
749                wrapper.dlg(wrapper.outer);
750        }
751       
752        extern(C) static void callBackPreUnmountDestroy(OnPreUnmountDelegateWrapper wrapper, GClosure* closure)
753        {
754                wrapper.remove(wrapper);
755        }
756
757        protected class OnUnmountedDelegateWrapper
758        {
759                static OnUnmountedDelegateWrapper[] listeners;
760                void delegate(MountIF) dlg;
761                gulong handlerId;
762               
763                this(void delegate(MountIF) dlg)
764                {
765                        this.dlg = dlg;
766                        this.listeners ~= this;
767                }
768               
769                void remove(OnUnmountedDelegateWrapper source)
770                {
771                        foreach(index, wrapper; listeners)
772                        {
773                                if (wrapper.handlerId == source.handlerId)
774                                {
775                                        listeners[index] = null;
776                                        listeners = std.algorithm.remove(listeners, index);
777                                        break;
778                                }
779                        }
780                }
781        }
782
783        /**
784         * This signal is emitted when the #GMount have been
785         * unmounted. If the recipient is holding references to the
786         * object they should release them so the object can be
787         * finalized.
788         */
789        gulong addOnUnmounted(void delegate(MountIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
790        {
791                auto wrapper = new OnUnmountedDelegateWrapper(dlg);
792                wrapper.handlerId = Signals.connectData(
793                        this,
794                        "unmounted",
795                        cast(GCallback)&callBackUnmounted,
796                        cast(void*)wrapper,
797                        cast(GClosureNotify)&callBackUnmountedDestroy,
798                        connectFlags);
799                return wrapper.handlerId;
800        }
801       
802        extern(C) static void callBackUnmounted(GMount* mountStruct, OnUnmountedDelegateWrapper wrapper)
803        {
804                wrapper.dlg(wrapper.outer);
805        }
806       
807        extern(C) static void callBackUnmountedDestroy(OnUnmountedDelegateWrapper wrapper, GClosure* closure)
808        {
809                wrapper.remove(wrapper);
810        }
811}
Note: See TracBrowser for help on using the repository browser.