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 = GVolumeMonitor.html 27 * outPack = gio 28 * outFile = VolumeMonitor 29 * strct = GVolumeMonitor 30 * realStrct= 31 * ctorStrct= 32 * clss = VolumeMonitor 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_volume_monitor_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * - g_volume_monitor_get 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - glib.ListG 49 * - gio.Drive 50 * - gio.DriveIF 51 * - gio.Mount 52 * - gio.MountIF 53 * - gio.Volume 54 * - gio.VolumeIF 55 * structWrap: 56 * - GDrive* -> DriveIF 57 * - GList* -> ListG 58 * - GMount* -> MountIF 59 * - GVolume* -> VolumeIF 60 * - GVolumeMonitor* -> 61 * module aliases: 62 * local aliases: 63 * overrides: 64 */ 65 66 module gio.VolumeMonitor; 67 68 public import gtkc.giotypes; 69 70 private import gtkc.gio; 71 private import glib.ConstructionException; 72 private import gobject.ObjectG; 73 74 private import gobject.Signals; 75 public import gtkc.gdktypes; 76 77 private import glib.Str; 78 private import glib.ListG; 79 private import gio.Drive; 80 private import gio.DriveIF; 81 private import gio.Mount; 82 private import gio.MountIF; 83 private import gio.Volume; 84 private import gio.VolumeIF; 85 86 87 88 private import gobject.ObjectG; 89 90 /** 91 * GVolumeMonitor is for listing the user interesting devices and volumes 92 * on the computer. In other words, what a file selector or file manager 93 * would show in a sidebar. 94 * 95 * GVolumeMonitor is not thread-default-context 96 * aware, and so should not be used other than from the main 97 * thread, with no thread-default-context active. 98 */ 99 public class VolumeMonitor : ObjectG 100 { 101 102 /** the main Gtk struct */ 103 protected GVolumeMonitor* gVolumeMonitor; 104 105 106 public GVolumeMonitor* getVolumeMonitorStruct() 107 { 108 return gVolumeMonitor; 109 } 110 111 112 /** the main Gtk struct as a void* */ 113 protected override void* getStruct() 114 { 115 return cast(void*)gVolumeMonitor; 116 } 117 118 /** 119 * Sets our main struct and passes it to the parent class 120 */ 121 public this (GVolumeMonitor* gVolumeMonitor) 122 { 123 super(cast(GObject*)gVolumeMonitor); 124 this.gVolumeMonitor = gVolumeMonitor; 125 } 126 127 protected override void setStruct(GObject* obj) 128 { 129 super.setStruct(obj); 130 gVolumeMonitor = cast(GVolumeMonitor*)obj; 131 } 132 133 /** 134 * Gets the volume monitor used by gio. 135 * Throws: ConstructionException GTK+ fails to create the object. 136 */ 137 public this() 138 { 139 // GVolumeMonitor* g_volume_monitor_get (void); 140 auto p = g_volume_monitor_get(); 141 if(p is null) 142 { 143 throw new ConstructionException("g_volume_monitor_get()"); 144 } 145 this(cast(GVolumeMonitor*) p); 146 } 147 148 /** 149 */ 150 int[string] connectedSignals; 151 152 void delegate(DriveIF, VolumeMonitor)[] onDriveChangedListeners; 153 /** 154 * Emitted when a drive changes. 155 */ 156 void addOnDriveChanged(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 157 { 158 if ( !("drive-changed" in connectedSignals) ) 159 { 160 Signals.connectData( 161 getStruct(), 162 "drive-changed", 163 cast(GCallback)&callBackDriveChanged, 164 cast(void*)this, 165 null, 166 connectFlags); 167 connectedSignals["drive-changed"] = 1; 168 } 169 onDriveChangedListeners ~= dlg; 170 } 171 extern(C) static void callBackDriveChanged(GVolumeMonitor* volumeMonitorStruct, GDrive* drive, VolumeMonitor _volumeMonitor) 172 { 173 foreach ( void delegate(DriveIF, VolumeMonitor) dlg ; _volumeMonitor.onDriveChangedListeners ) 174 { 175 dlg(ObjectG.getDObject!(Drive, DriveIF)(drive), _volumeMonitor); 176 } 177 } 178 179 void delegate(DriveIF, VolumeMonitor)[] onDriveConnectedListeners; 180 /** 181 * Emitted when a drive is connected to the system. 182 */ 183 void addOnDriveConnected(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 184 { 185 if ( !("drive-connected" in connectedSignals) ) 186 { 187 Signals.connectData( 188 getStruct(), 189 "drive-connected", 190 cast(GCallback)&callBackDriveConnected, 191 cast(void*)this, 192 null, 193 connectFlags); 194 connectedSignals["drive-connected"] = 1; 195 } 196 onDriveConnectedListeners ~= dlg; 197 } 198 extern(C) static void callBackDriveConnected(GVolumeMonitor* volumeMonitorStruct, GDrive* drive, VolumeMonitor _volumeMonitor) 199 { 200 foreach ( void delegate(DriveIF, VolumeMonitor) dlg ; _volumeMonitor.onDriveConnectedListeners ) 201 { 202 dlg(ObjectG.getDObject!(Drive, DriveIF)(drive), _volumeMonitor); 203 } 204 } 205 206 void delegate(DriveIF, VolumeMonitor)[] onDriveDisconnectedListeners; 207 /** 208 * Emitted when a drive is disconnected from the system. 209 */ 210 void addOnDriveDisconnected(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 211 { 212 if ( !("drive-disconnected" in connectedSignals) ) 213 { 214 Signals.connectData( 215 getStruct(), 216 "drive-disconnected", 217 cast(GCallback)&callBackDriveDisconnected, 218 cast(void*)this, 219 null, 220 connectFlags); 221 connectedSignals["drive-disconnected"] = 1; 222 } 223 onDriveDisconnectedListeners ~= dlg; 224 } 225 extern(C) static void callBackDriveDisconnected(GVolumeMonitor* volumeMonitorStruct, GDrive* drive, VolumeMonitor _volumeMonitor) 226 { 227 foreach ( void delegate(DriveIF, VolumeMonitor) dlg ; _volumeMonitor.onDriveDisconnectedListeners ) 228 { 229 dlg(ObjectG.getDObject!(Drive, DriveIF)(drive), _volumeMonitor); 230 } 231 } 232 233 void delegate(DriveIF, VolumeMonitor)[] onDriveEjectButtonListeners; 234 /** 235 * Emitted when the eject button is pressed on drive. 236 * Since 2.18 237 */ 238 void addOnDriveEjectButton(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 239 { 240 if ( !("drive-eject-button" in connectedSignals) ) 241 { 242 Signals.connectData( 243 getStruct(), 244 "drive-eject-button", 245 cast(GCallback)&callBackDriveEjectButton, 246 cast(void*)this, 247 null, 248 connectFlags); 249 connectedSignals["drive-eject-button"] = 1; 250 } 251 onDriveEjectButtonListeners ~= dlg; 252 } 253 extern(C) static void callBackDriveEjectButton(GVolumeMonitor* volumeMonitorStruct, GDrive* drive, VolumeMonitor _volumeMonitor) 254 { 255 foreach ( void delegate(DriveIF, VolumeMonitor) dlg ; _volumeMonitor.onDriveEjectButtonListeners ) 256 { 257 dlg(ObjectG.getDObject!(Drive, DriveIF)(drive), _volumeMonitor); 258 } 259 } 260 261 void delegate(DriveIF, VolumeMonitor)[] onDriveStopButtonListeners; 262 /** 263 * Emitted when the stop button is pressed on drive. 264 * Since 2.22 265 */ 266 void addOnDriveStopButton(void delegate(DriveIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 267 { 268 if ( !("drive-stop-button" in connectedSignals) ) 269 { 270 Signals.connectData( 271 getStruct(), 272 "drive-stop-button", 273 cast(GCallback)&callBackDriveStopButton, 274 cast(void*)this, 275 null, 276 connectFlags); 277 connectedSignals["drive-stop-button"] = 1; 278 } 279 onDriveStopButtonListeners ~= dlg; 280 } 281 extern(C) static void callBackDriveStopButton(GVolumeMonitor* volumeMonitorStruct, GDrive* drive, VolumeMonitor _volumeMonitor) 282 { 283 foreach ( void delegate(DriveIF, VolumeMonitor) dlg ; _volumeMonitor.onDriveStopButtonListeners ) 284 { 285 dlg(ObjectG.getDObject!(Drive, DriveIF)(drive), _volumeMonitor); 286 } 287 } 288 289 void delegate(MountIF, VolumeMonitor)[] onMountAddedListeners; 290 /** 291 * Emitted when a mount is added. 292 */ 293 void addOnMountAdded(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 294 { 295 if ( !("mount-added" in connectedSignals) ) 296 { 297 Signals.connectData( 298 getStruct(), 299 "mount-added", 300 cast(GCallback)&callBackMountAdded, 301 cast(void*)this, 302 null, 303 connectFlags); 304 connectedSignals["mount-added"] = 1; 305 } 306 onMountAddedListeners ~= dlg; 307 } 308 extern(C) static void callBackMountAdded(GVolumeMonitor* volumeMonitorStruct, GMount* mount, VolumeMonitor _volumeMonitor) 309 { 310 foreach ( void delegate(MountIF, VolumeMonitor) dlg ; _volumeMonitor.onMountAddedListeners ) 311 { 312 dlg(ObjectG.getDObject!(Mount, MountIF)(mount), _volumeMonitor); 313 } 314 } 315 316 void delegate(MountIF, VolumeMonitor)[] onMountChangedListeners; 317 /** 318 * Emitted when a mount changes. 319 */ 320 void addOnMountChanged(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 321 { 322 if ( !("mount-changed" in connectedSignals) ) 323 { 324 Signals.connectData( 325 getStruct(), 326 "mount-changed", 327 cast(GCallback)&callBackMountChanged, 328 cast(void*)this, 329 null, 330 connectFlags); 331 connectedSignals["mount-changed"] = 1; 332 } 333 onMountChangedListeners ~= dlg; 334 } 335 extern(C) static void callBackMountChanged(GVolumeMonitor* volumeMonitorStruct, GMount* mount, VolumeMonitor _volumeMonitor) 336 { 337 foreach ( void delegate(MountIF, VolumeMonitor) dlg ; _volumeMonitor.onMountChangedListeners ) 338 { 339 dlg(ObjectG.getDObject!(Mount, MountIF)(mount), _volumeMonitor); 340 } 341 } 342 343 void delegate(MountIF, VolumeMonitor)[] onMountPreUnmountListeners; 344 /** 345 * Emitted when a mount is about to be removed. 346 */ 347 void addOnMountPreUnmount(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 348 { 349 if ( !("mount-pre-unmount" in connectedSignals) ) 350 { 351 Signals.connectData( 352 getStruct(), 353 "mount-pre-unmount", 354 cast(GCallback)&callBackMountPreUnmount, 355 cast(void*)this, 356 null, 357 connectFlags); 358 connectedSignals["mount-pre-unmount"] = 1; 359 } 360 onMountPreUnmountListeners ~= dlg; 361 } 362 extern(C) static void callBackMountPreUnmount(GVolumeMonitor* volumeMonitorStruct, GMount* mount, VolumeMonitor _volumeMonitor) 363 { 364 foreach ( void delegate(MountIF, VolumeMonitor) dlg ; _volumeMonitor.onMountPreUnmountListeners ) 365 { 366 dlg(ObjectG.getDObject!(Mount, MountIF)(mount), _volumeMonitor); 367 } 368 } 369 370 void delegate(MountIF, VolumeMonitor)[] onMountRemovedListeners; 371 /** 372 * Emitted when a mount is removed. 373 */ 374 void addOnMountRemoved(void delegate(MountIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 375 { 376 if ( !("mount-removed" in connectedSignals) ) 377 { 378 Signals.connectData( 379 getStruct(), 380 "mount-removed", 381 cast(GCallback)&callBackMountRemoved, 382 cast(void*)this, 383 null, 384 connectFlags); 385 connectedSignals["mount-removed"] = 1; 386 } 387 onMountRemovedListeners ~= dlg; 388 } 389 extern(C) static void callBackMountRemoved(GVolumeMonitor* volumeMonitorStruct, GMount* mount, VolumeMonitor _volumeMonitor) 390 { 391 foreach ( void delegate(MountIF, VolumeMonitor) dlg ; _volumeMonitor.onMountRemovedListeners ) 392 { 393 dlg(ObjectG.getDObject!(Mount, MountIF)(mount), _volumeMonitor); 394 } 395 } 396 397 void delegate(VolumeIF, VolumeMonitor)[] onVolumeAddedListeners; 398 /** 399 * Emitted when a mountable volume is added to the system. 400 */ 401 void addOnVolumeAdded(void delegate(VolumeIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 402 { 403 if ( !("volume-added" in connectedSignals) ) 404 { 405 Signals.connectData( 406 getStruct(), 407 "volume-added", 408 cast(GCallback)&callBackVolumeAdded, 409 cast(void*)this, 410 null, 411 connectFlags); 412 connectedSignals["volume-added"] = 1; 413 } 414 onVolumeAddedListeners ~= dlg; 415 } 416 extern(C) static void callBackVolumeAdded(GVolumeMonitor* volumeMonitorStruct, GVolume* volume, VolumeMonitor _volumeMonitor) 417 { 418 foreach ( void delegate(VolumeIF, VolumeMonitor) dlg ; _volumeMonitor.onVolumeAddedListeners ) 419 { 420 dlg(ObjectG.getDObject!(Volume, VolumeIF)(volume), _volumeMonitor); 421 } 422 } 423 424 void delegate(VolumeIF, VolumeMonitor)[] onVolumeChangedListeners; 425 /** 426 * Emitted when mountable volume is changed. 427 */ 428 void addOnVolumeChanged(void delegate(VolumeIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 429 { 430 if ( !("volume-changed" in connectedSignals) ) 431 { 432 Signals.connectData( 433 getStruct(), 434 "volume-changed", 435 cast(GCallback)&callBackVolumeChanged, 436 cast(void*)this, 437 null, 438 connectFlags); 439 connectedSignals["volume-changed"] = 1; 440 } 441 onVolumeChangedListeners ~= dlg; 442 } 443 extern(C) static void callBackVolumeChanged(GVolumeMonitor* volumeMonitorStruct, GVolume* volume, VolumeMonitor _volumeMonitor) 444 { 445 foreach ( void delegate(VolumeIF, VolumeMonitor) dlg ; _volumeMonitor.onVolumeChangedListeners ) 446 { 447 dlg(ObjectG.getDObject!(Volume, VolumeIF)(volume), _volumeMonitor); 448 } 449 } 450 451 void delegate(VolumeIF, VolumeMonitor)[] onVolumeRemovedListeners; 452 /** 453 * Emitted when a mountable volume is removed from the system. 454 * See Also 455 * GFileMonitor 456 */ 457 void addOnVolumeRemoved(void delegate(VolumeIF, VolumeMonitor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 458 { 459 if ( !("volume-removed" in connectedSignals) ) 460 { 461 Signals.connectData( 462 getStruct(), 463 "volume-removed", 464 cast(GCallback)&callBackVolumeRemoved, 465 cast(void*)this, 466 null, 467 connectFlags); 468 connectedSignals["volume-removed"] = 1; 469 } 470 onVolumeRemovedListeners ~= dlg; 471 } 472 extern(C) static void callBackVolumeRemoved(GVolumeMonitor* volumeMonitorStruct, GVolume* volume, VolumeMonitor _volumeMonitor) 473 { 474 foreach ( void delegate(VolumeIF, VolumeMonitor) dlg ; _volumeMonitor.onVolumeRemovedListeners ) 475 { 476 dlg(ObjectG.getDObject!(Volume, VolumeIF)(volume), _volumeMonitor); 477 } 478 } 479 480 481 /** 482 * Gets a list of drives connected to the system. 483 * The returned list should be freed with g_list_free(), after 484 * its elements have been unreffed with g_object_unref(). 485 * Returns: a GList of connected GDrive objects. [element-type GDrive][transfer full] 486 */ 487 public ListG getConnectedDrives() 488 { 489 // GList * g_volume_monitor_get_connected_drives (GVolumeMonitor *volume_monitor); 490 auto p = g_volume_monitor_get_connected_drives(gVolumeMonitor); 491 492 if(p is null) 493 { 494 return null; 495 } 496 497 return ObjectG.getDObject!(ListG)(cast(GList*) p); 498 } 499 500 /** 501 * Gets a list of the volumes on the system. 502 * The returned list should be freed with g_list_free(), after 503 * its elements have been unreffed with g_object_unref(). 504 * Returns: a GList of GVolume objects. [element-type GVolume][transfer full] 505 */ 506 public ListG getVolumes() 507 { 508 // GList * g_volume_monitor_get_volumes (GVolumeMonitor *volume_monitor); 509 auto p = g_volume_monitor_get_volumes(gVolumeMonitor); 510 511 if(p is null) 512 { 513 return null; 514 } 515 516 return ObjectG.getDObject!(ListG)(cast(GList*) p); 517 } 518 519 /** 520 * Gets a list of the mounts on the system. 521 * The returned list should be freed with g_list_free(), after 522 * its elements have been unreffed with g_object_unref(). 523 * Returns: a GList of GMount objects. [element-type GMount][transfer full] 524 */ 525 public ListG getMounts() 526 { 527 // GList * g_volume_monitor_get_mounts (GVolumeMonitor *volume_monitor); 528 auto p = g_volume_monitor_get_mounts(gVolumeMonitor); 529 530 if(p is null) 531 { 532 return null; 533 } 534 535 return ObjectG.getDObject!(ListG)(cast(GList*) p); 536 } 537 538 /** 539 * Warning 540 * g_volume_monitor_adopt_orphan_mount has been deprecated since version 2.20 and should not be used in newly-written code. Instead of using this function, GVolumeMonitor 541 * implementations should instead create shadow mounts with the URI of 542 * the mount they intend to adopt. See the proxy volume monitor in 543 * gvfs for an example of this. Also see g_mount_is_shadowed(), 544 * g_mount_shadow() and g_mount_unshadow() functions. 545 * This function should be called by any GVolumeMonitor 546 * implementation when a new GMount object is created that is not 547 * associated with a GVolume object. It must be called just before 548 * emitting the mount_added signal. 549 * If the return value is not NULL, the caller must associate the 550 * returned GVolume object with the GMount. This involves returning 551 * it in its g_mount_get_volume() implementation. The caller must 552 * also listen for the "removed" signal on the returned object 553 * and give up its reference when handling that signal 554 * Similary, if implementing g_volume_monitor_adopt_orphan_mount(), 555 * the implementor must take a reference to mount and return it in 556 * its g_volume_get_mount() implemented. Also, the implementor must 557 * listen for the "unmounted" signal on mount and give up its 558 * reference upon handling that signal. 559 * There are two main use cases for this function. 560 * One is when implementing a user space file system driver that reads 561 * blocks of a block device that is already represented by the native 562 * volume monitor (for example a CD Audio file system driver). Such 563 * a driver will generate its own GMount object that needs to be 564 * associated with the GVolume object that represents the volume. 565 * The other is for implementing a GVolumeMonitor whose sole purpose 566 * is to return GVolume objects representing entries in the users 567 * "favorite servers" list or similar. 568 * Params: 569 * mount = a GMount object to find a parent for 570 * Returns: the GVolume object that is the parent for mount or NULL if no wants to adopt the GMount. [transfer full] 571 */ 572 public static VolumeIF adoptOrphanMount(MountIF mount) 573 { 574 // GVolume * g_volume_monitor_adopt_orphan_mount (GMount *mount); 575 auto p = g_volume_monitor_adopt_orphan_mount((mount is null) ? null : mount.getMountTStruct()); 576 577 if(p is null) 578 { 579 return null; 580 } 581 582 return ObjectG.getDObject!(Volume, VolumeIF)(cast(GVolume*) p); 583 } 584 585 /** 586 * Finds a GMount object by its UUID (see g_mount_get_uuid()) 587 * Params: 588 * uuid = the UUID to look for 589 * Returns: a GMount or NULL if no such mount is available. Free the returned object with g_object_unref(). [transfer full] 590 */ 591 public MountIF getMountForUuid(string uuid) 592 { 593 // GMount * g_volume_monitor_get_mount_for_uuid (GVolumeMonitor *volume_monitor, const char *uuid); 594 auto p = g_volume_monitor_get_mount_for_uuid(gVolumeMonitor, Str.toStringz(uuid)); 595 596 if(p is null) 597 { 598 return null; 599 } 600 601 return ObjectG.getDObject!(Mount, MountIF)(cast(GMount*) p); 602 } 603 604 /** 605 * Finds a GVolume object by its UUID (see g_volume_get_uuid()) 606 * Params: 607 * uuid = the UUID to look for 608 * Returns: a GVolume or NULL if no such volume is available. Free the returned object with g_object_unref(). [transfer full] Signal Details The "drive-changed" signal void user_function (GVolumeMonitor *volume_monitor, GDrive *drive, gpointer user_data) : Run Last Emitted when a drive changes. 609 */ 610 public VolumeIF getVolumeForUuid(string uuid) 611 { 612 // GVolume * g_volume_monitor_get_volume_for_uuid (GVolumeMonitor *volume_monitor, const char *uuid); 613 auto p = g_volume_monitor_get_volume_for_uuid(gVolumeMonitor, Str.toStringz(uuid)); 614 615 if(p is null) 616 { 617 return null; 618 } 619 620 return ObjectG.getDObject!(Volume, VolumeIF)(cast(GVolume*) p); 621 } 622 }