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