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 = GVolume.html 27 * outPack = gio 28 * outFile = VolumeT 29 * strct = GVolume 30 * realStrct= 31 * ctorStrct= 32 * clss = VolumeT 33 * interf = VolumeIF 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * - TStruct 38 * extend = 39 * implements: 40 * prefixes: 41 * - g_volume_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - glib.ErrorG 49 * - glib.GException 50 * - gobject.Signals 51 * - gio.AsyncResultIF 52 * - gio.Cancellable 53 * - gio.Drive 54 * - gio.DriveIF 55 * - gio.File 56 * - gio.Icon 57 * - gio.IconIF 58 * - gio.Mount 59 * - gio.MountIF 60 * - gio.MountOperation 61 * structWrap: 62 * - GAsyncResult* -> AsyncResultIF 63 * - GCancellable* -> Cancellable 64 * - GDrive* -> DriveIF 65 * - GFile* -> File 66 * - GIcon* -> IconIF 67 * - GMount* -> MountIF 68 * - GMountOperation* -> MountOperation 69 * module aliases: 70 * local aliases: 71 * overrides: 72 */ 73 74 module gio.VolumeT; 75 76 public import gtkc.giotypes; 77 78 public import gtkc.gio; 79 public import glib.ConstructionException; 80 public import gobject.ObjectG; 81 82 public import gobject.Signals; 83 public import gtkc.gdktypes; 84 85 public import glib.Str; 86 public import glib.ErrorG; 87 public import glib.GException; 88 public import gobject.Signals; 89 public import gio.AsyncResultIF; 90 public import gio.Cancellable; 91 public import gio.Drive; 92 public import gio.DriveIF; 93 public import gio.File; 94 public import gio.Icon; 95 public import gio.IconIF; 96 public import gio.Mount; 97 public import gio.MountIF; 98 public import gio.MountOperation; 99 100 101 102 103 /** 104 * The GVolume interface represents user-visible objects that can be 105 * mounted. Note, when porting from GnomeVFS, GVolume is the moral 106 * equivalent of GnomeVFSDrive. 107 * 108 * Mounting a GVolume instance is an asynchronous operation. For more 109 * information about asynchronous operations, see GAsyncResult and 110 * GTask. To mount a GVolume, first call g_volume_mount() with (at 111 * least) the GVolume instance, optionally a GMountOperation object 112 * and a GAsyncReadyCallback. 113 * 114 * Typically, one will only want to pass NULL for the 115 * GMountOperation if automounting all volumes when a desktop session 116 * starts since it's not desirable to put up a lot of dialogs asking 117 * for credentials. 118 * 119 * The callback will be fired when the operation has resolved (either 120 * with success or failure), and a GAsyncReady structure will be 121 * passed to the callback. That callback should then call 122 * g_volume_mount_finish() with the GVolume instance and the 123 * GAsyncReady data to see if the operation was completed 124 * successfully. If an error is present when g_volume_mount_finish() 125 * is called, then it will be filled with any error information. 126 * 127 * It is sometimes necessary to directly access the underlying 128 * operating system object behind a volume (e.g. for passing a volume 129 * to an application via the commandline). For this purpose, GIO 130 * allows to obtain an 'identifier' for the volume. There can be 131 * different kinds of identifiers, such as Hal UDIs, filesystem labels, 132 * traditional Unix devices (e.g. /dev/sda2), 133 * uuids. GIO uses predefind strings as names for the different kinds 134 * of identifiers: G_VOLUME_IDENTIFIER_KIND_HAL_UDI, 135 * G_VOLUME_IDENTIFIER_KIND_LABEL, etc. Use g_volume_get_identifier() 136 * to obtain an identifier for a volume. 137 * 138 * Note that G_VOLUME_IDENTIFIER_KIND_HAL_UDI will only be available 139 * when the gvfs hal volume monitor is in use. Other volume monitors 140 * will generally be able to provide the G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE 141 * identifier, which can be used to obtain a hal device by means of 142 * libhal_manager_find_device_string_match(). 143 */ 144 public template VolumeT(TStruct) 145 { 146 147 /** the main Gtk struct */ 148 protected GVolume* gVolume; 149 150 151 public GVolume* getVolumeTStruct() 152 { 153 return cast(GVolume*)getStruct(); 154 } 155 156 157 /** 158 */ 159 int[string] connectedSignals; 160 161 void delegate(VolumeIF)[] _onChangedListeners; 162 @property void delegate(VolumeIF)[] onChangedListeners() 163 { 164 return _onChangedListeners; 165 } 166 /** 167 * Emitted when the volume has been changed. 168 */ 169 void addOnChanged(void delegate(VolumeIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 170 { 171 if ( !("changed" in connectedSignals) ) 172 { 173 Signals.connectData( 174 getStruct(), 175 "changed", 176 cast(GCallback)&callBackChanged, 177 cast(void*)cast(VolumeIF)this, 178 null, 179 connectFlags); 180 connectedSignals["changed"] = 1; 181 } 182 _onChangedListeners ~= dlg; 183 } 184 extern(C) static void callBackChanged(GVolume* arg0Struct, VolumeIF _volumeIF) 185 { 186 foreach ( void delegate(VolumeIF) dlg ; _volumeIF.onChangedListeners ) 187 { 188 dlg(_volumeIF); 189 } 190 } 191 192 void delegate(VolumeIF)[] _onRemovedListeners; 193 @property void delegate(VolumeIF)[] onRemovedListeners() 194 { 195 return _onRemovedListeners; 196 } 197 /** 198 * This signal is emitted when the GVolume have been removed. If 199 * the recipient is holding references to the object they should 200 * release them so the object can be finalized. 201 */ 202 void addOnRemoved(void delegate(VolumeIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 203 { 204 if ( !("removed" in connectedSignals) ) 205 { 206 Signals.connectData( 207 getStruct(), 208 "removed", 209 cast(GCallback)&callBackRemoved, 210 cast(void*)cast(VolumeIF)this, 211 null, 212 connectFlags); 213 connectedSignals["removed"] = 1; 214 } 215 _onRemovedListeners ~= dlg; 216 } 217 extern(C) static void callBackRemoved(GVolume* arg0Struct, VolumeIF _volumeIF) 218 { 219 foreach ( void delegate(VolumeIF) dlg ; _volumeIF.onRemovedListeners ) 220 { 221 dlg(_volumeIF); 222 } 223 } 224 225 226 /** 227 * Gets the name of volume. 228 * Returns: the name for the given volume. The returned string should be freed with g_free() when no longer needed. 229 */ 230 public string getName() 231 { 232 // char * g_volume_get_name (GVolume *volume); 233 return Str.toString(g_volume_get_name(getVolumeTStruct())); 234 } 235 236 /** 237 * Gets the UUID for the volume. The reference is typically based on 238 * the file system UUID for the volume in question and should be 239 * considered an opaque string. Returns NULL if there is no UUID 240 * available. 241 * Returns: the UUID for volume or NULL if no UUID can be computed. The returned string should be freed with g_free() when no longer needed. 242 */ 243 public string getUuid() 244 { 245 // char * g_volume_get_uuid (GVolume *volume); 246 return Str.toString(g_volume_get_uuid(getVolumeTStruct())); 247 } 248 249 /** 250 * Gets the icon for volume. 251 * Returns: a GIcon. The returned object should be unreffed with g_object_unref() when no longer needed. [transfer full] 252 */ 253 public IconIF getIcon() 254 { 255 // GIcon * g_volume_get_icon (GVolume *volume); 256 auto p = g_volume_get_icon(getVolumeTStruct()); 257 258 if(p is null) 259 { 260 return null; 261 } 262 263 return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p); 264 } 265 266 /** 267 * Gets the symbolic icon for volume. 268 * Since 2.34 269 * Returns: a GIcon. The returned object should be unreffed with g_object_unref() when no longer needed. [transfer full] 270 */ 271 public IconIF getSymbolicIcon() 272 { 273 // GIcon * g_volume_get_symbolic_icon (GVolume *volume); 274 auto p = g_volume_get_symbolic_icon(getVolumeTStruct()); 275 276 if(p is null) 277 { 278 return null; 279 } 280 281 return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p); 282 } 283 284 /** 285 * Gets the drive for the volume. 286 * Returns: a GDrive or NULL if volume is not associated with a drive. The returned object should be unreffed with g_object_unref() when no longer needed. [transfer full] 287 */ 288 public DriveIF getDrive() 289 { 290 // GDrive * g_volume_get_drive (GVolume *volume); 291 auto p = g_volume_get_drive(getVolumeTStruct()); 292 293 if(p is null) 294 { 295 return null; 296 } 297 298 return ObjectG.getDObject!(Drive, DriveIF)(cast(GDrive*) p); 299 } 300 301 /** 302 * Gets the mount for the volume. 303 * Returns: a GMount or NULL if volume isn't mounted. The returned object should be unreffed with g_object_unref() when no longer needed. [transfer full] 304 */ 305 public MountIF getMount() 306 { 307 // GMount * g_volume_get_mount (GVolume *volume); 308 auto p = g_volume_get_mount(getVolumeTStruct()); 309 310 if(p is null) 311 { 312 return null; 313 } 314 315 return ObjectG.getDObject!(Mount, MountIF)(cast(GMount*) p); 316 } 317 318 /** 319 * Checks if a volume can be mounted. 320 * Returns: TRUE if the volume can be mounted. FALSE otherwise. 321 */ 322 public int canMount() 323 { 324 // gboolean g_volume_can_mount (GVolume *volume); 325 return g_volume_can_mount(getVolumeTStruct()); 326 } 327 328 /** 329 * Returns whether the volume should be automatically mounted. 330 * Returns: TRUE if the volume should be automatically mounted. 331 */ 332 public int shouldAutomount() 333 { 334 // gboolean g_volume_should_automount (GVolume *volume); 335 return g_volume_should_automount(getVolumeTStruct()); 336 } 337 338 /** 339 * Gets the activation root for a GVolume if it is known ahead of 340 * mount time. Returns NULL otherwise. If not NULL and if volume 341 * is mounted, then the result of g_mount_get_root() on the 342 * GMount object obtained from g_volume_get_mount() will always 343 * either be equal or a prefix of what this function returns. In 344 * other words, in code 345 * GMount *mount; 346 * GFile *mount_root 347 * GFile *volume_activation_root; 348 * mount = g_volume_get_mount (volume); /+* mounted, so never NULL +/ 349 * mount_root = g_mount_get_root (mount); 350 * volume_activation_root = g_volume_get_activation_root(volume); /+* assume not NULL +/ 351 * then the expression 352 * (g_file_has_prefix (volume_activation_root, mount_root) || 353 * g_file_equal (volume_activation_root, mount_root)) 354 * will always be TRUE. 355 * Activation roots are typically used in GVolumeMonitor 356 * implementations to find the underlying mount to shadow, see 357 * g_mount_is_shadowed() for more details. 358 * Since 2.18 359 * Returns: the activation root of volume or NULL. Use g_object_unref() to free. [transfer full] 360 */ 361 public File getActivationRoot() 362 { 363 // GFile * g_volume_get_activation_root (GVolume *volume); 364 auto p = g_volume_get_activation_root(getVolumeTStruct()); 365 366 if(p is null) 367 { 368 return null; 369 } 370 371 return ObjectG.getDObject!(File)(cast(GFile*) p); 372 } 373 374 /** 375 * Mounts a volume. This is an asynchronous operation, and is 376 * finished by calling g_volume_mount_finish() with the volume 377 * and GAsyncResult returned in the callback. 378 * Virtual: mount_fn 379 * Params: 380 * flags = flags affecting the operation 381 * mountOperation = a GMountOperation or NULL to avoid user interaction. [allow-none] 382 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 383 * callback = a GAsyncReadyCallback, or NULL. [allow-none] 384 * userData = user data that gets passed to callback 385 */ 386 public void mount(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 387 { 388 // void g_volume_mount (GVolume *volume, GMountMountFlags flags, GMountOperation *mount_operation, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 389 g_volume_mount(getVolumeTStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 390 } 391 392 /** 393 * Finishes mounting a volume. If any errors occurred during the operation, 394 * error will be set to contain the errors and FALSE will be returned. 395 * If the mount operation succeeded, g_volume_get_mount() on volume 396 * is guaranteed to return the mount right after calling this 397 * function; there's no need to listen for the 'mount-added' signal on 398 * GVolumeMonitor. 399 * Params: 400 * result = a GAsyncResult 401 * Returns: TRUE, FALSE if operation failed. 402 * Throws: GException on failure. 403 */ 404 public int mountFinish(AsyncResultIF result) 405 { 406 // gboolean g_volume_mount_finish (GVolume *volume, GAsyncResult *result, GError **error); 407 GError* err = null; 408 409 auto p = g_volume_mount_finish(getVolumeTStruct(), (result is null) ? null : result.getAsyncResultTStruct(), &err); 410 411 if (err !is null) 412 { 413 throw new GException( new ErrorG(err) ); 414 } 415 416 return p; 417 } 418 419 /** 420 * Checks if a volume can be ejected. 421 * Returns: TRUE if the volume can be ejected. FALSE otherwise. 422 */ 423 public int canEject() 424 { 425 // gboolean g_volume_can_eject (GVolume *volume); 426 return g_volume_can_eject(getVolumeTStruct()); 427 } 428 429 /** 430 * Warning 431 * g_volume_eject has been deprecated since version 2.22 and should not be used in newly-written code. Use g_volume_eject_with_operation() instead. 432 * Ejects a volume. This is an asynchronous operation, and is 433 * finished by calling g_volume_eject_finish() with the volume 434 * and GAsyncResult returned in the callback. 435 * Params: 436 * flags = flags affecting the unmount if required for eject 437 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 438 * callback = a GAsyncReadyCallback, or NULL. [allow-none] 439 * userData = user data that gets passed to callback 440 */ 441 public void eject(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 442 { 443 // void g_volume_eject (GVolume *volume, GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 444 g_volume_eject(getVolumeTStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 445 } 446 447 /** 448 * Warning 449 * g_volume_eject_finish has been deprecated since version 2.22 and should not be used in newly-written code. Use g_volume_eject_with_operation_finish() instead. 450 * Finishes ejecting a volume. If any errors occurred during the operation, 451 * error will be set to contain the errors and FALSE will be returned. 452 * Params: 453 * result = a GAsyncResult. 454 * Returns: TRUE, FALSE if operation failed. 455 * Throws: GException on failure. 456 */ 457 public int ejectFinish(AsyncResultIF result) 458 { 459 // gboolean g_volume_eject_finish (GVolume *volume, GAsyncResult *result, GError **error); 460 GError* err = null; 461 462 auto p = g_volume_eject_finish(getVolumeTStruct(), (result is null) ? null : result.getAsyncResultTStruct(), &err); 463 464 if (err !is null) 465 { 466 throw new GException( new ErrorG(err) ); 467 } 468 469 return p; 470 } 471 472 /** 473 * Ejects a volume. This is an asynchronous operation, and is 474 * finished by calling g_volume_eject_with_operation_finish() with the volume 475 * and GAsyncResult data returned in the callback. 476 * Since 2.22 477 * Params: 478 * flags = flags affecting the unmount if required for eject 479 * mountOperation = a GMountOperation or NULL to 480 * avoid user interaction. [allow-none] 481 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 482 * callback = a GAsyncReadyCallback, or NULL. [allow-none] 483 * userData = user data passed to callback. 484 */ 485 public void ejectWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 486 { 487 // void g_volume_eject_with_operation (GVolume *volume, GMountUnmountFlags flags, GMountOperation *mount_operation, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 488 g_volume_eject_with_operation(getVolumeTStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 489 } 490 491 /** 492 * Finishes ejecting a volume. If any errors occurred during the operation, 493 * error will be set to contain the errors and FALSE will be returned. 494 * Since 2.22 495 * Params: 496 * result = a GAsyncResult. 497 * Returns: TRUE if the volume was successfully ejected. FALSE otherwise. 498 * Throws: GException on failure. 499 */ 500 public int ejectWithOperationFinish(AsyncResultIF result) 501 { 502 // gboolean g_volume_eject_with_operation_finish (GVolume *volume, GAsyncResult *result, GError **error); 503 GError* err = null; 504 505 auto p = g_volume_eject_with_operation_finish(getVolumeTStruct(), (result is null) ? null : result.getAsyncResultTStruct(), &err); 506 507 if (err !is null) 508 { 509 throw new GException( new ErrorG(err) ); 510 } 511 512 return p; 513 } 514 515 /** 516 * Gets the kinds of identifiers 517 * that volume has. Use g_volume_get_identifier() to obtain 518 * the identifiers themselves. 519 * Returns: a NULL-terminated array of strings containing kinds of identifiers. Use g_strfreev() to free. [array zero-terminated=1][transfer full] 520 */ 521 public string[] enumerateIdentifiers() 522 { 523 // char ** g_volume_enumerate_identifiers (GVolume *volume); 524 return Str.toStringArray(g_volume_enumerate_identifiers(getVolumeTStruct())); 525 } 526 527 /** 528 * Gets the identifier of the given kind for volume. 529 * See the introduction 530 * for more information about volume identifiers. 531 * Params: 532 * kind = the kind of identifier to return 533 * Returns: a newly allocated string containing the requested identfier, or NULL if the GVolume doesn't have this kind of identifier 534 */ 535 public string getIdentifier(string kind) 536 { 537 // char * g_volume_get_identifier (GVolume *volume, const char *kind); 538 return Str.toString(g_volume_get_identifier(getVolumeTStruct(), Str.toStringz(kind))); 539 } 540 541 /** 542 * Gets the sort key for volume, if any. 543 * Since 2.32 544 * Signal Details 545 * The "changed" signal 546 * void user_function (GVolume *arg0, 547 * gpointer user_data) : Run Last 548 * Emitted when the volume has been changed. 549 * Returns: Sorting key for volume or NULL if no such key is available. 550 */ 551 public string getSortKey() 552 { 553 // const gchar * g_volume_get_sort_key (GVolume *volume); 554 return Str.toString(g_volume_get_sort_key(getVolumeTStruct())); 555 } 556 }