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.VolumeMonitor; 26 27 private import gio.Drive; 28 private import gio.DriveIF; 29 private import gio.Mount; 30 private import gio.MountIF; 31 private import gio.Volume; 32 private import gio.VolumeIF; 33 private import glib.ConstructionException; 34 private import glib.ListG; 35 private import glib.Str; 36 private import gobject.ObjectG; 37 private import gobject.Signals; 38 public import gtkc.gdktypes; 39 private import gtkc.gio; 40 public import gtkc.giotypes; 41 private import std.algorithm; 42 43 44 /** 45 * #GVolumeMonitor is for listing the user interesting devices and volumes 46 * on the computer. In other words, what a file selector or file manager 47 * would show in a sidebar. 48 * 49 * #GVolumeMonitor is not 50 * [thread-default-context aware][g-main-context-push-thread-default], 51 * and so should not be used other than from the main thread, with no 52 * thread-default-context active. 53 */ 54 public class VolumeMonitor : ObjectG 55 { 56 /** the main Gtk struct */ 57 protected GVolumeMonitor* gVolumeMonitor; 58 59 /** Get the main Gtk struct */ 60 public GVolumeMonitor* getVolumeMonitorStruct() 61 { 62 return gVolumeMonitor; 63 } 64 65 /** the main Gtk struct as a void* */ 66 protected override void* getStruct() 67 { 68 return cast(void*)gVolumeMonitor; 69 } 70 71 protected override void setStruct(GObject* obj) 72 { 73 gVolumeMonitor = cast(GVolumeMonitor*)obj; 74 super.setStruct(obj); 75 } 76 77 /** 78 * Sets our main struct and passes it to the parent class. 79 */ 80 public this (GVolumeMonitor* gVolumeMonitor, bool ownedRef = false) 81 { 82 this.gVolumeMonitor = gVolumeMonitor; 83 super(cast(GObject*)gVolumeMonitor, ownedRef); 84 } 85 86 /** 87 * Gets the volume monitor used by gio. 88 * 89 * Return: a reference to the #GVolumeMonitor used by gio. Call 90 * g_object_unref() when done with it. 91 */ 92 public this() 93 { 94 auto p = g_volume_monitor_get(); 95 96 if(p is null) 97 { 98 throw new ConstructionException("g_volume_monitor_get()"); 99 } 100 101 this(cast(GVolumeMonitor*) p, true); 102 } 103 104 /** 105 */ 106 107 /** */ 108 public static GType getType() 109 { 110 return g_volume_monitor_get_type(); 111 } 112 113 /** 114 * This function should be called by any #GVolumeMonitor 115 * implementation when a new #GMount object is created that is not 116 * associated with a #GVolume object. It must be called just before 117 * emitting the @mount_added signal. 118 * 119 * If the return value is not %NULL, the caller must associate the 120 * returned #GVolume object with the #GMount. This involves returning 121 * it in its g_mount_get_volume() implementation. The caller must 122 * also listen for the "removed" signal on the returned object 123 * and give up its reference when handling that signal 124 * 125 * Similary, if implementing g_volume_monitor_adopt_orphan_mount(), 126 * the implementor must take a reference to @mount and return it in 127 * its g_volume_get_mount() implemented. Also, the implementor must 128 * listen for the "unmounted" signal on @mount and give up its 129 * reference upon handling that signal. 130 * 131 * There are two main use cases for this function. 132 * 133 * One is when implementing a user space file system driver that reads 134 * blocks of a block device that is already represented by the native 135 * volume monitor (for example a CD Audio file system driver). Such 136 * a driver will generate its own #GMount object that needs to be 137 * associated with the #GVolume object that represents the volume. 138 * 139 * The other is for implementing a #GVolumeMonitor whose sole purpose 140 * is to return #GVolume objects representing entries in the users 141 * "favorite servers" list or similar. 142 * 143 * Deprecated: Instead of using this function, #GVolumeMonitor 144 * implementations should instead create shadow mounts with the URI of 145 * the mount they intend to adopt. See the proxy volume monitor in 146 * gvfs for an example of this. Also see g_mount_is_shadowed(), 147 * g_mount_shadow() and g_mount_unshadow() functions. 148 * 149 * Params: 150 * mount = a #GMount object to find a parent for 151 * 152 * Return: the #GVolume object that is the parent for @mount or %NULL 153 * if no wants to adopt the #GMount. 154 */ 155 public static VolumeIF adoptOrphanMount(MountIF mount) 156 { 157 auto p = g_volume_monitor_adopt_orphan_mount((mount is null) ? null : mount.getMountStruct()); 158 159 if(p is null) 160 { 161 return null; 162 } 163 164 return ObjectG.getDObject!(Volume, VolumeIF)(cast(GVolume*) p, true); 165 } 166 167 /** 168 * Gets a list of drives connected to the system. 169 * 170 * The returned list should be freed with g_list_free(), after 171 * its elements have been unreffed with g_object_unref(). 172 * 173 * Return: a #GList of connected #GDrive objects. 174 */ 175 public ListG getConnectedDrives() 176 { 177 auto p = g_volume_monitor_get_connected_drives(gVolumeMonitor); 178 179 if(p is null) 180 { 181 return null; 182 } 183 184 return new ListG(cast(GList*) p, true); 185 } 186 187 /** 188 * Finds a #GMount object by its UUID (see g_mount_get_uuid()) 189 * 190 * Params: 191 * uuid = the UUID to look for 192 * 193 * Return: a #GMount or %NULL if no such mount is available. 194 * Free the returned object with g_object_unref(). 195 */ 196 public MountIF getMountForUuid(string uuid) 197 { 198 auto p = g_volume_monitor_get_mount_for_uuid(gVolumeMonitor, Str.toStringz(uuid)); 199 200 if(p is null) 201 { 202 return null; 203 } 204 205 return ObjectG.getDObject!(Mount, MountIF)(cast(GMount*) p, true); 206 } 207 208 /** 209 * Gets a list of the mounts on the system. 210 * 211 * The returned list should be freed with g_list_free(), after 212 * its elements have been unreffed with g_object_unref(). 213 * 214 * Return: a #GList of #GMount objects. 215 */ 216 public ListG getMounts() 217 { 218 auto p = g_volume_monitor_get_mounts(gVolumeMonitor); 219 220 if(p is null) 221 { 222 return null; 223 } 224 225 return new ListG(cast(GList*) p, true); 226 } 227 228 /** 229 * Finds a #GVolume object by its UUID (see g_volume_get_uuid()) 230 * 231 * Params: 232 * uuid = the UUID to look for 233 * 234 * Return: a #GVolume or %NULL if no such volume is available. 235 * Free the returned object with g_object_unref(). 236 */ 237 public VolumeIF getVolumeForUuid(string uuid) 238 { 239 auto p = g_volume_monitor_get_volume_for_uuid(gVolumeMonitor, Str.toStringz(uuid)); 240 241 if(p is null) 242 { 243 return null; 244 } 245 246 return ObjectG.getDObject!(Volume, VolumeIF)(cast(GVolume*) p, true); 247 } 248 249 /** 250 * Gets a list of the volumes on the system. 251 * 252 * The returned list should be freed with g_list_free(), after 253 * its elements have been unreffed with g_object_unref(). 254 * 255 * Return: a #GList of #GVolume objects. 256 */ 257 public ListG getVolumes() 258 { 259 auto p = g_volume_monitor_get_volumes(gVolumeMonitor); 260 261 if(p is null) 262 { 263 return null; 264 } 265 266 return new ListG(cast(GList*) p, true); 267 } 268 269 protected class OnDriveChangedDelegateWrapper 270 { 271 void delegate(DriveIF, VolumeMonitor) dlg; 272 gulong handlerId; 273 ConnectFlags flags; 274 this(void delegate(DriveIF, VolumeMonitor) dlg, gulong handlerId, ConnectFlags flags) 275 { 276 this.dlg = dlg; 277 this.handlerId = handlerId; 278 this.flags = flags; 279 } 280 } 281 protected OnDriveChangedDelegateWrapper[] onDriveChangedListeners; 282 283 /** 284 * Emitted when a drive changes. 285 * 286 * Params: 287 * drive = the drive that changed 288 */ 289 gulong addOnDriveChanged(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 290 { 291 onDriveChangedListeners ~= new OnDriveChangedDelegateWrapper(dlg, 0, connectFlags); 292 onDriveChangedListeners[onDriveChangedListeners.length - 1].handlerId = Signals.connectData( 293 this, 294 "drive-changed", 295 cast(GCallback)&callBackDriveChanged, 296 cast(void*)onDriveChangedListeners[onDriveChangedListeners.length - 1], 297 cast(GClosureNotify)&callBackDriveChangedDestroy, 298 connectFlags); 299 return onDriveChangedListeners[onDriveChangedListeners.length - 1].handlerId; 300 } 301 302 extern(C) static void callBackDriveChanged(GVolumeMonitor* volumemonitorStruct, GDrive* drive,OnDriveChangedDelegateWrapper wrapper) 303 { 304 wrapper.dlg(ObjectG.getDObject!(Drive, DriveIF)(drive), wrapper.outer); 305 } 306 307 extern(C) static void callBackDriveChangedDestroy(OnDriveChangedDelegateWrapper wrapper, GClosure* closure) 308 { 309 wrapper.outer.internalRemoveOnDriveChanged(wrapper); 310 } 311 312 protected void internalRemoveOnDriveChanged(OnDriveChangedDelegateWrapper source) 313 { 314 foreach(index, wrapper; onDriveChangedListeners) 315 { 316 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 317 { 318 onDriveChangedListeners[index] = null; 319 onDriveChangedListeners = std.algorithm.remove(onDriveChangedListeners, index); 320 break; 321 } 322 } 323 } 324 325 326 protected class OnDriveConnectedDelegateWrapper 327 { 328 void delegate(DriveIF, VolumeMonitor) dlg; 329 gulong handlerId; 330 ConnectFlags flags; 331 this(void delegate(DriveIF, VolumeMonitor) dlg, gulong handlerId, ConnectFlags flags) 332 { 333 this.dlg = dlg; 334 this.handlerId = handlerId; 335 this.flags = flags; 336 } 337 } 338 protected OnDriveConnectedDelegateWrapper[] onDriveConnectedListeners; 339 340 /** 341 * Emitted when a drive is connected to the system. 342 * 343 * Params: 344 * drive = a #GDrive that was connected. 345 */ 346 gulong addOnDriveConnected(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 347 { 348 onDriveConnectedListeners ~= new OnDriveConnectedDelegateWrapper(dlg, 0, connectFlags); 349 onDriveConnectedListeners[onDriveConnectedListeners.length - 1].handlerId = Signals.connectData( 350 this, 351 "drive-connected", 352 cast(GCallback)&callBackDriveConnected, 353 cast(void*)onDriveConnectedListeners[onDriveConnectedListeners.length - 1], 354 cast(GClosureNotify)&callBackDriveConnectedDestroy, 355 connectFlags); 356 return onDriveConnectedListeners[onDriveConnectedListeners.length - 1].handlerId; 357 } 358 359 extern(C) static void callBackDriveConnected(GVolumeMonitor* volumemonitorStruct, GDrive* drive,OnDriveConnectedDelegateWrapper wrapper) 360 { 361 wrapper.dlg(ObjectG.getDObject!(Drive, DriveIF)(drive), wrapper.outer); 362 } 363 364 extern(C) static void callBackDriveConnectedDestroy(OnDriveConnectedDelegateWrapper wrapper, GClosure* closure) 365 { 366 wrapper.outer.internalRemoveOnDriveConnected(wrapper); 367 } 368 369 protected void internalRemoveOnDriveConnected(OnDriveConnectedDelegateWrapper source) 370 { 371 foreach(index, wrapper; onDriveConnectedListeners) 372 { 373 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 374 { 375 onDriveConnectedListeners[index] = null; 376 onDriveConnectedListeners = std.algorithm.remove(onDriveConnectedListeners, index); 377 break; 378 } 379 } 380 } 381 382 383 protected class OnDriveDisconnectedDelegateWrapper 384 { 385 void delegate(DriveIF, VolumeMonitor) dlg; 386 gulong handlerId; 387 ConnectFlags flags; 388 this(void delegate(DriveIF, VolumeMonitor) dlg, gulong handlerId, ConnectFlags flags) 389 { 390 this.dlg = dlg; 391 this.handlerId = handlerId; 392 this.flags = flags; 393 } 394 } 395 protected OnDriveDisconnectedDelegateWrapper[] onDriveDisconnectedListeners; 396 397 /** 398 * Emitted when a drive is disconnected from the system. 399 * 400 * Params: 401 * drive = a #GDrive that was disconnected. 402 */ 403 gulong addOnDriveDisconnected(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 404 { 405 onDriveDisconnectedListeners ~= new OnDriveDisconnectedDelegateWrapper(dlg, 0, connectFlags); 406 onDriveDisconnectedListeners[onDriveDisconnectedListeners.length - 1].handlerId = Signals.connectData( 407 this, 408 "drive-disconnected", 409 cast(GCallback)&callBackDriveDisconnected, 410 cast(void*)onDriveDisconnectedListeners[onDriveDisconnectedListeners.length - 1], 411 cast(GClosureNotify)&callBackDriveDisconnectedDestroy, 412 connectFlags); 413 return onDriveDisconnectedListeners[onDriveDisconnectedListeners.length - 1].handlerId; 414 } 415 416 extern(C) static void callBackDriveDisconnected(GVolumeMonitor* volumemonitorStruct, GDrive* drive,OnDriveDisconnectedDelegateWrapper wrapper) 417 { 418 wrapper.dlg(ObjectG.getDObject!(Drive, DriveIF)(drive), wrapper.outer); 419 } 420 421 extern(C) static void callBackDriveDisconnectedDestroy(OnDriveDisconnectedDelegateWrapper wrapper, GClosure* closure) 422 { 423 wrapper.outer.internalRemoveOnDriveDisconnected(wrapper); 424 } 425 426 protected void internalRemoveOnDriveDisconnected(OnDriveDisconnectedDelegateWrapper source) 427 { 428 foreach(index, wrapper; onDriveDisconnectedListeners) 429 { 430 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 431 { 432 onDriveDisconnectedListeners[index] = null; 433 onDriveDisconnectedListeners = std.algorithm.remove(onDriveDisconnectedListeners, index); 434 break; 435 } 436 } 437 } 438 439 440 protected class OnDriveEjectButtonDelegateWrapper 441 { 442 void delegate(DriveIF, VolumeMonitor) dlg; 443 gulong handlerId; 444 ConnectFlags flags; 445 this(void delegate(DriveIF, VolumeMonitor) dlg, gulong handlerId, ConnectFlags flags) 446 { 447 this.dlg = dlg; 448 this.handlerId = handlerId; 449 this.flags = flags; 450 } 451 } 452 protected OnDriveEjectButtonDelegateWrapper[] onDriveEjectButtonListeners; 453 454 /** 455 * Emitted when the eject button is pressed on @drive. 456 * 457 * Params: 458 * drive = the drive where the eject button was pressed 459 * 460 * Since: 2.18 461 */ 462 gulong addOnDriveEjectButton(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 463 { 464 onDriveEjectButtonListeners ~= new OnDriveEjectButtonDelegateWrapper(dlg, 0, connectFlags); 465 onDriveEjectButtonListeners[onDriveEjectButtonListeners.length - 1].handlerId = Signals.connectData( 466 this, 467 "drive-eject-button", 468 cast(GCallback)&callBackDriveEjectButton, 469 cast(void*)onDriveEjectButtonListeners[onDriveEjectButtonListeners.length - 1], 470 cast(GClosureNotify)&callBackDriveEjectButtonDestroy, 471 connectFlags); 472 return onDriveEjectButtonListeners[onDriveEjectButtonListeners.length - 1].handlerId; 473 } 474 475 extern(C) static void callBackDriveEjectButton(GVolumeMonitor* volumemonitorStruct, GDrive* drive,OnDriveEjectButtonDelegateWrapper wrapper) 476 { 477 wrapper.dlg(ObjectG.getDObject!(Drive, DriveIF)(drive), wrapper.outer); 478 } 479 480 extern(C) static void callBackDriveEjectButtonDestroy(OnDriveEjectButtonDelegateWrapper wrapper, GClosure* closure) 481 { 482 wrapper.outer.internalRemoveOnDriveEjectButton(wrapper); 483 } 484 485 protected void internalRemoveOnDriveEjectButton(OnDriveEjectButtonDelegateWrapper source) 486 { 487 foreach(index, wrapper; onDriveEjectButtonListeners) 488 { 489 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 490 { 491 onDriveEjectButtonListeners[index] = null; 492 onDriveEjectButtonListeners = std.algorithm.remove(onDriveEjectButtonListeners, index); 493 break; 494 } 495 } 496 } 497 498 499 protected class OnDriveStopButtonDelegateWrapper 500 { 501 void delegate(DriveIF, VolumeMonitor) dlg; 502 gulong handlerId; 503 ConnectFlags flags; 504 this(void delegate(DriveIF, VolumeMonitor) dlg, gulong handlerId, ConnectFlags flags) 505 { 506 this.dlg = dlg; 507 this.handlerId = handlerId; 508 this.flags = flags; 509 } 510 } 511 protected OnDriveStopButtonDelegateWrapper[] onDriveStopButtonListeners; 512 513 /** 514 * Emitted when the stop button is pressed on @drive. 515 * 516 * Params: 517 * drive = the drive where the stop button was pressed 518 * 519 * Since: 2.22 520 */ 521 gulong addOnDriveStopButton(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 522 { 523 onDriveStopButtonListeners ~= new OnDriveStopButtonDelegateWrapper(dlg, 0, connectFlags); 524 onDriveStopButtonListeners[onDriveStopButtonListeners.length - 1].handlerId = Signals.connectData( 525 this, 526 "drive-stop-button", 527 cast(GCallback)&callBackDriveStopButton, 528 cast(void*)onDriveStopButtonListeners[onDriveStopButtonListeners.length - 1], 529 cast(GClosureNotify)&callBackDriveStopButtonDestroy, 530 connectFlags); 531 return onDriveStopButtonListeners[onDriveStopButtonListeners.length - 1].handlerId; 532 } 533 534 extern(C) static void callBackDriveStopButton(GVolumeMonitor* volumemonitorStruct, GDrive* drive,OnDriveStopButtonDelegateWrapper wrapper) 535 { 536 wrapper.dlg(ObjectG.getDObject!(Drive, DriveIF)(drive), wrapper.outer); 537 } 538 539 extern(C) static void callBackDriveStopButtonDestroy(OnDriveStopButtonDelegateWrapper wrapper, GClosure* closure) 540 { 541 wrapper.outer.internalRemoveOnDriveStopButton(wrapper); 542 } 543 544 protected void internalRemoveOnDriveStopButton(OnDriveStopButtonDelegateWrapper source) 545 { 546 foreach(index, wrapper; onDriveStopButtonListeners) 547 { 548 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 549 { 550 onDriveStopButtonListeners[index] = null; 551 onDriveStopButtonListeners = std.algorithm.remove(onDriveStopButtonListeners, index); 552 break; 553 } 554 } 555 } 556 557 558 protected class OnMountAddedDelegateWrapper 559 { 560 void delegate(MountIF, VolumeMonitor) dlg; 561 gulong handlerId; 562 ConnectFlags flags; 563 this(void delegate(MountIF, VolumeMonitor) dlg, gulong handlerId, ConnectFlags flags) 564 { 565 this.dlg = dlg; 566 this.handlerId = handlerId; 567 this.flags = flags; 568 } 569 } 570 protected OnMountAddedDelegateWrapper[] onMountAddedListeners; 571 572 /** 573 * Emitted when a mount is added. 574 * 575 * Params: 576 * mount = a #GMount that was added. 577 */ 578 gulong addOnMountAdded(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 579 { 580 onMountAddedListeners ~= new OnMountAddedDelegateWrapper(dlg, 0, connectFlags); 581 onMountAddedListeners[onMountAddedListeners.length - 1].handlerId = Signals.connectData( 582 this, 583 "mount-added", 584 cast(GCallback)&callBackMountAdded, 585 cast(void*)onMountAddedListeners[onMountAddedListeners.length - 1], 586 cast(GClosureNotify)&callBackMountAddedDestroy, 587 connectFlags); 588 return onMountAddedListeners[onMountAddedListeners.length - 1].handlerId; 589 } 590 591 extern(C) static void callBackMountAdded(GVolumeMonitor* volumemonitorStruct, GMount* mount,OnMountAddedDelegateWrapper wrapper) 592 { 593 wrapper.dlg(ObjectG.getDObject!(Mount, MountIF)(mount), wrapper.outer); 594 } 595 596 extern(C) static void callBackMountAddedDestroy(OnMountAddedDelegateWrapper wrapper, GClosure* closure) 597 { 598 wrapper.outer.internalRemoveOnMountAdded(wrapper); 599 } 600 601 protected void internalRemoveOnMountAdded(OnMountAddedDelegateWrapper source) 602 { 603 foreach(index, wrapper; onMountAddedListeners) 604 { 605 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 606 { 607 onMountAddedListeners[index] = null; 608 onMountAddedListeners = std.algorithm.remove(onMountAddedListeners, index); 609 break; 610 } 611 } 612 } 613 614 615 protected class OnMountChangedDelegateWrapper 616 { 617 void delegate(MountIF, VolumeMonitor) dlg; 618 gulong handlerId; 619 ConnectFlags flags; 620 this(void delegate(MountIF, VolumeMonitor) dlg, gulong handlerId, ConnectFlags flags) 621 { 622 this.dlg = dlg; 623 this.handlerId = handlerId; 624 this.flags = flags; 625 } 626 } 627 protected OnMountChangedDelegateWrapper[] onMountChangedListeners; 628 629 /** 630 * Emitted when a mount changes. 631 * 632 * Params: 633 * mount = a #GMount that changed. 634 */ 635 gulong addOnMountChanged(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 636 { 637 onMountChangedListeners ~= new OnMountChangedDelegateWrapper(dlg, 0, connectFlags); 638 onMountChangedListeners[onMountChangedListeners.length - 1].handlerId = Signals.connectData( 639 this, 640 "mount-changed", 641 cast(GCallback)&callBackMountChanged, 642 cast(void*)onMountChangedListeners[onMountChangedListeners.length - 1], 643 cast(GClosureNotify)&callBackMountChangedDestroy, 644 connectFlags); 645 return onMountChangedListeners[onMountChangedListeners.length - 1].handlerId; 646 } 647 648 extern(C) static void callBackMountChanged(GVolumeMonitor* volumemonitorStruct, GMount* mount,OnMountChangedDelegateWrapper wrapper) 649 { 650 wrapper.dlg(ObjectG.getDObject!(Mount, MountIF)(mount), wrapper.outer); 651 } 652 653 extern(C) static void callBackMountChangedDestroy(OnMountChangedDelegateWrapper wrapper, GClosure* closure) 654 { 655 wrapper.outer.internalRemoveOnMountChanged(wrapper); 656 } 657 658 protected void internalRemoveOnMountChanged(OnMountChangedDelegateWrapper source) 659 { 660 foreach(index, wrapper; onMountChangedListeners) 661 { 662 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 663 { 664 onMountChangedListeners[index] = null; 665 onMountChangedListeners = std.algorithm.remove(onMountChangedListeners, index); 666 break; 667 } 668 } 669 } 670 671 672 protected class OnMountPreUnmountDelegateWrapper 673 { 674 void delegate(MountIF, VolumeMonitor) dlg; 675 gulong handlerId; 676 ConnectFlags flags; 677 this(void delegate(MountIF, VolumeMonitor) dlg, gulong handlerId, ConnectFlags flags) 678 { 679 this.dlg = dlg; 680 this.handlerId = handlerId; 681 this.flags = flags; 682 } 683 } 684 protected OnMountPreUnmountDelegateWrapper[] onMountPreUnmountListeners; 685 686 /** 687 * Emitted when a mount is about to be removed. 688 * 689 * Params: 690 * mount = a #GMount that is being unmounted. 691 */ 692 gulong addOnMountPreUnmount(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 693 { 694 onMountPreUnmountListeners ~= new OnMountPreUnmountDelegateWrapper(dlg, 0, connectFlags); 695 onMountPreUnmountListeners[onMountPreUnmountListeners.length - 1].handlerId = Signals.connectData( 696 this, 697 "mount-pre-unmount", 698 cast(GCallback)&callBackMountPreUnmount, 699 cast(void*)onMountPreUnmountListeners[onMountPreUnmountListeners.length - 1], 700 cast(GClosureNotify)&callBackMountPreUnmountDestroy, 701 connectFlags); 702 return onMountPreUnmountListeners[onMountPreUnmountListeners.length - 1].handlerId; 703 } 704 705 extern(C) static void callBackMountPreUnmount(GVolumeMonitor* volumemonitorStruct, GMount* mount,OnMountPreUnmountDelegateWrapper wrapper) 706 { 707 wrapper.dlg(ObjectG.getDObject!(Mount, MountIF)(mount), wrapper.outer); 708 } 709 710 extern(C) static void callBackMountPreUnmountDestroy(OnMountPreUnmountDelegateWrapper wrapper, GClosure* closure) 711 { 712 wrapper.outer.internalRemoveOnMountPreUnmount(wrapper); 713 } 714 715 protected void internalRemoveOnMountPreUnmount(OnMountPreUnmountDelegateWrapper source) 716 { 717 foreach(index, wrapper; onMountPreUnmountListeners) 718 { 719 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 720 { 721 onMountPreUnmountListeners[index] = null; 722 onMountPreUnmountListeners = std.algorithm.remove(onMountPreUnmountListeners, index); 723 break; 724 } 725 } 726 } 727 728 729 protected class OnMountRemovedDelegateWrapper 730 { 731 void delegate(MountIF, VolumeMonitor) dlg; 732 gulong handlerId; 733 ConnectFlags flags; 734 this(void delegate(MountIF, VolumeMonitor) dlg, gulong handlerId, ConnectFlags flags) 735 { 736 this.dlg = dlg; 737 this.handlerId = handlerId; 738 this.flags = flags; 739 } 740 } 741 protected OnMountRemovedDelegateWrapper[] onMountRemovedListeners; 742 743 /** 744 * Emitted when a mount is removed. 745 * 746 * Params: 747 * mount = a #GMount that was removed. 748 */ 749 gulong addOnMountRemoved(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 750 { 751 onMountRemovedListeners ~= new OnMountRemovedDelegateWrapper(dlg, 0, connectFlags); 752 onMountRemovedListeners[onMountRemovedListeners.length - 1].handlerId = Signals.connectData( 753 this, 754 "mount-removed", 755 cast(GCallback)&callBackMountRemoved, 756 cast(void*)onMountRemovedListeners[onMountRemovedListeners.length - 1], 757 cast(GClosureNotify)&callBackMountRemovedDestroy, 758 connectFlags); 759 return onMountRemovedListeners[onMountRemovedListeners.length - 1].handlerId; 760 } 761 762 extern(C) static void callBackMountRemoved(GVolumeMonitor* volumemonitorStruct, GMount* mount,OnMountRemovedDelegateWrapper wrapper) 763 { 764 wrapper.dlg(ObjectG.getDObject!(Mount, MountIF)(mount), wrapper.outer); 765 } 766 767 extern(C) static void callBackMountRemovedDestroy(OnMountRemovedDelegateWrapper wrapper, GClosure* closure) 768 { 769 wrapper.outer.internalRemoveOnMountRemoved(wrapper); 770 } 771 772 protected void internalRemoveOnMountRemoved(OnMountRemovedDelegateWrapper source) 773 { 774 foreach(index, wrapper; onMountRemovedListeners) 775 { 776 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 777 { 778 onMountRemovedListeners[index] = null; 779 onMountRemovedListeners = std.algorithm.remove(onMountRemovedListeners, index); 780 break; 781 } 782 } 783 } 784 785 786 protected class OnVolumeAddedDelegateWrapper 787 { 788 void delegate(VolumeIF, VolumeMonitor) dlg; 789 gulong handlerId; 790 ConnectFlags flags; 791 this(void delegate(VolumeIF, VolumeMonitor) dlg, gulong handlerId, ConnectFlags flags) 792 { 793 this.dlg = dlg; 794 this.handlerId = handlerId; 795 this.flags = flags; 796 } 797 } 798 protected OnVolumeAddedDelegateWrapper[] onVolumeAddedListeners; 799 800 /** 801 * Emitted when a mountable volume is added to the system. 802 * 803 * Params: 804 * volume = a #GVolume that was added. 805 */ 806 gulong addOnVolumeAdded(void delegate(VolumeIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 807 { 808 onVolumeAddedListeners ~= new OnVolumeAddedDelegateWrapper(dlg, 0, connectFlags); 809 onVolumeAddedListeners[onVolumeAddedListeners.length - 1].handlerId = Signals.connectData( 810 this, 811 "volume-added", 812 cast(GCallback)&callBackVolumeAdded, 813 cast(void*)onVolumeAddedListeners[onVolumeAddedListeners.length - 1], 814 cast(GClosureNotify)&callBackVolumeAddedDestroy, 815 connectFlags); 816 return onVolumeAddedListeners[onVolumeAddedListeners.length - 1].handlerId; 817 } 818 819 extern(C) static void callBackVolumeAdded(GVolumeMonitor* volumemonitorStruct, GVolume* volume,OnVolumeAddedDelegateWrapper wrapper) 820 { 821 wrapper.dlg(ObjectG.getDObject!(Volume, VolumeIF)(volume), wrapper.outer); 822 } 823 824 extern(C) static void callBackVolumeAddedDestroy(OnVolumeAddedDelegateWrapper wrapper, GClosure* closure) 825 { 826 wrapper.outer.internalRemoveOnVolumeAdded(wrapper); 827 } 828 829 protected void internalRemoveOnVolumeAdded(OnVolumeAddedDelegateWrapper source) 830 { 831 foreach(index, wrapper; onVolumeAddedListeners) 832 { 833 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 834 { 835 onVolumeAddedListeners[index] = null; 836 onVolumeAddedListeners = std.algorithm.remove(onVolumeAddedListeners, index); 837 break; 838 } 839 } 840 } 841 842 843 protected class OnVolumeChangedDelegateWrapper 844 { 845 void delegate(VolumeIF, VolumeMonitor) dlg; 846 gulong handlerId; 847 ConnectFlags flags; 848 this(void delegate(VolumeIF, VolumeMonitor) dlg, gulong handlerId, ConnectFlags flags) 849 { 850 this.dlg = dlg; 851 this.handlerId = handlerId; 852 this.flags = flags; 853 } 854 } 855 protected OnVolumeChangedDelegateWrapper[] onVolumeChangedListeners; 856 857 /** 858 * Emitted when mountable volume is changed. 859 * 860 * Params: 861 * volume = a #GVolume that changed. 862 */ 863 gulong addOnVolumeChanged(void delegate(VolumeIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 864 { 865 onVolumeChangedListeners ~= new OnVolumeChangedDelegateWrapper(dlg, 0, connectFlags); 866 onVolumeChangedListeners[onVolumeChangedListeners.length - 1].handlerId = Signals.connectData( 867 this, 868 "volume-changed", 869 cast(GCallback)&callBackVolumeChanged, 870 cast(void*)onVolumeChangedListeners[onVolumeChangedListeners.length - 1], 871 cast(GClosureNotify)&callBackVolumeChangedDestroy, 872 connectFlags); 873 return onVolumeChangedListeners[onVolumeChangedListeners.length - 1].handlerId; 874 } 875 876 extern(C) static void callBackVolumeChanged(GVolumeMonitor* volumemonitorStruct, GVolume* volume,OnVolumeChangedDelegateWrapper wrapper) 877 { 878 wrapper.dlg(ObjectG.getDObject!(Volume, VolumeIF)(volume), wrapper.outer); 879 } 880 881 extern(C) static void callBackVolumeChangedDestroy(OnVolumeChangedDelegateWrapper wrapper, GClosure* closure) 882 { 883 wrapper.outer.internalRemoveOnVolumeChanged(wrapper); 884 } 885 886 protected void internalRemoveOnVolumeChanged(OnVolumeChangedDelegateWrapper source) 887 { 888 foreach(index, wrapper; onVolumeChangedListeners) 889 { 890 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 891 { 892 onVolumeChangedListeners[index] = null; 893 onVolumeChangedListeners = std.algorithm.remove(onVolumeChangedListeners, index); 894 break; 895 } 896 } 897 } 898 899 900 protected class OnVolumeRemovedDelegateWrapper 901 { 902 void delegate(VolumeIF, VolumeMonitor) dlg; 903 gulong handlerId; 904 ConnectFlags flags; 905 this(void delegate(VolumeIF, VolumeMonitor) dlg, gulong handlerId, ConnectFlags flags) 906 { 907 this.dlg = dlg; 908 this.handlerId = handlerId; 909 this.flags = flags; 910 } 911 } 912 protected OnVolumeRemovedDelegateWrapper[] onVolumeRemovedListeners; 913 914 /** 915 * Emitted when a mountable volume is removed from the system. 916 * 917 * Params: 918 * volume = a #GVolume that was removed. 919 */ 920 gulong addOnVolumeRemoved(void delegate(VolumeIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 921 { 922 onVolumeRemovedListeners ~= new OnVolumeRemovedDelegateWrapper(dlg, 0, connectFlags); 923 onVolumeRemovedListeners[onVolumeRemovedListeners.length - 1].handlerId = Signals.connectData( 924 this, 925 "volume-removed", 926 cast(GCallback)&callBackVolumeRemoved, 927 cast(void*)onVolumeRemovedListeners[onVolumeRemovedListeners.length - 1], 928 cast(GClosureNotify)&callBackVolumeRemovedDestroy, 929 connectFlags); 930 return onVolumeRemovedListeners[onVolumeRemovedListeners.length - 1].handlerId; 931 } 932 933 extern(C) static void callBackVolumeRemoved(GVolumeMonitor* volumemonitorStruct, GVolume* volume,OnVolumeRemovedDelegateWrapper wrapper) 934 { 935 wrapper.dlg(ObjectG.getDObject!(Volume, VolumeIF)(volume), wrapper.outer); 936 } 937 938 extern(C) static void callBackVolumeRemovedDestroy(OnVolumeRemovedDelegateWrapper wrapper, GClosure* closure) 939 { 940 wrapper.outer.internalRemoveOnVolumeRemoved(wrapper); 941 } 942 943 protected void internalRemoveOnVolumeRemoved(OnVolumeRemovedDelegateWrapper source) 944 { 945 foreach(index, wrapper; onVolumeRemovedListeners) 946 { 947 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 948 { 949 onVolumeRemovedListeners[index] = null; 950 onVolumeRemovedListeners = std.algorithm.remove(onVolumeRemovedListeners, index); 951 break; 952 } 953 } 954 } 955 956 }