/** * g_drive_eject_with_operation: * @drive: a #GDrive. * @flags: flags affecting the unmount if required for eject * @mount_operation: (allow-none): a #GMountOperation or %NULL to avoid * user interaction. * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore. * @callback: (allow-none): a #GAsyncReadyCallback, or %NULL. * @user_data: user data passed to @callback. * * Ejects a drive. This is an asynchronous operation, and is * finished by calling g_drive_eject_with_operation_finish() with the @drive * and #GAsyncResult data returned in the @callback. * * Since: 2.22 **/ void g_drive_eject_with_operation (GDrive *drive, GMountUnmountFlags flags, GMountOperation *mount_operation, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GDriveIface *iface; g_return_if_fail (G_IS_DRIVE (drive)); iface = G_DRIVE_GET_IFACE (drive); if (iface->eject == NULL && iface->eject_with_operation == NULL) { g_task_report_new_error (drive, callback, user_data, g_drive_eject_with_operation, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, /* Translators: This is an error * message for drive objects that * don't implement any of eject or eject_with_operation. */ _("drive doesn't implement eject or eject_with_operation")); return; } if (iface->eject_with_operation != NULL) (* iface->eject_with_operation) (drive, flags, mount_operation, cancellable, callback, user_data); else (* iface->eject) (drive, flags, cancellable, callback, user_data); }
/** * g_drive_stop: * @drive: a #GDrive. * @flags: flags affecting the unmount if required for stopping. * @mount_operation: (allow-none): a #GMountOperation or %NULL to avoid * user interaction. * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore. * @callback: (allow-none): a #GAsyncReadyCallback, or %NULL. * @user_data: user data to pass to @callback * * Asynchronously stops a drive. * * When the operation is finished, @callback will be called. * You can then call g_drive_stop_finish() to obtain the * result of the operation. * * Since: 2.22 */ void g_drive_stop (GDrive *drive, GMountUnmountFlags flags, GMountOperation *mount_operation, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GDriveIface *iface; g_return_if_fail (G_IS_DRIVE (drive)); iface = G_DRIVE_GET_IFACE (drive); if (iface->stop == NULL) { g_task_report_new_error (drive, callback, user_data, g_drive_start, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("drive doesn't implement stop")); return; } (* iface->stop) (drive, flags, mount_operation, cancellable, callback, user_data); }
/** * g_drive_is_media_check_automatic: * @drive: a #GDrive. * * Checks if @drive is capabable of automatically detecting media changes. * * Returns: %TRUE if the @drive is capabable of automatically detecting * media changes, %FALSE otherwise. **/ gboolean g_drive_is_media_check_automatic (GDrive *drive) { GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), FALSE); iface = G_DRIVE_GET_IFACE (drive); return (* iface->is_media_check_automatic) (drive); }
/** * g_drive_get_volumes: * @drive: a #GDrive. * * Get a list of mountable volumes for @drive. * * The returned list should be freed with g_list_free(), after * its elements have been unreffed with g_object_unref(). * * Returns: (element-type GVolume) (transfer full): #GList containing any #GVolume objects on the given @drive. **/ GList * g_drive_get_volumes (GDrive *drive) { GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), NULL); iface = G_DRIVE_GET_IFACE (drive); return (* iface->get_volumes) (drive); }
/** * g_drive_is_media_removable: * @drive: a #GDrive. * * Checks if the @drive supports removable media. * * Returns: %TRUE if @drive supports removable media, %FALSE otherwise. **/ gboolean g_drive_is_media_removable (GDrive *drive) { GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), FALSE); iface = G_DRIVE_GET_IFACE (drive); return (* iface->is_media_removable) (drive); }
/** * g_drive_get_icon: * @drive: a #GDrive. * * Gets the icon for @drive. * * Returns: (transfer full): #GIcon for the @drive. * Free the returned object with g_object_unref(). **/ GIcon * g_drive_get_icon (GDrive *drive) { GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), NULL); iface = G_DRIVE_GET_IFACE (drive); return (* iface->get_icon) (drive); }
/** * g_drive_has_media: * @drive: a #GDrive. * * Checks if the @drive has media. Note that the OS may not be polling * the drive for media changes; see g_drive_is_media_check_automatic() * for more details. * * Returns: %TRUE if @drive has media, %FALSE otherwise. **/ gboolean g_drive_has_media (GDrive *drive) { GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), FALSE); iface = G_DRIVE_GET_IFACE (drive); return (* iface->has_media) (drive); }
/** * g_drive_is_removable: * @drive: a #GDrive. * * Checks if the #GDrive and/or its media is considered removable by the user. * See g_drive_is_media_removable(). * * Returns: %TRUE if @drive and/or its media is considered removable, %FALSE otherwise. * * Since: 2.50 **/ gboolean g_drive_is_removable (GDrive *drive) { GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), FALSE); iface = G_DRIVE_GET_IFACE (drive); if (iface->is_removable != NULL) return iface->is_removable (drive); return FALSE; }
/** * g_drive_get_sort_key: * @drive: A #GDrive. * * Gets the sort key for @drive, if any. * * Returns: Sorting key for @drive or %NULL if no such key is available. * * Since: 2.32 */ const gchar * g_drive_get_sort_key (GDrive *drive) { const gchar *ret = NULL; GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), NULL); iface = G_DRIVE_GET_IFACE (drive); if (iface->get_sort_key != NULL) ret = iface->get_sort_key (drive); return ret; }
/** * g_drive_can_stop: * @drive: a #GDrive. * * Checks if a drive can be stopped. * * Returns: %TRUE if the @drive can be stopped, %FALSE otherwise. * * Since: 2.22 */ gboolean g_drive_can_stop (GDrive *drive) { GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), FALSE); iface = G_DRIVE_GET_IFACE (drive); if (iface->can_stop == NULL) return FALSE; return (* iface->can_stop) (drive); }
/** * g_drive_can_poll_for_media: * @drive: a #GDrive. * * Checks if a drive can be polled for media changes. * * Returns: %TRUE if the @drive can be polled for media changes, * %FALSE otherwise. **/ gboolean g_drive_can_poll_for_media (GDrive *drive) { GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), FALSE); iface = G_DRIVE_GET_IFACE (drive); if (iface->poll_for_media == NULL) return FALSE; return (* iface->can_poll_for_media) (drive); }
/** * g_drive_get_start_stop_type: * @drive: a #GDrive. * * Gets a hint about how a drive can be started/stopped. * * Returns: A value from the #GDriveStartStopType enumeration. * * Since: 2.22 */ GDriveStartStopType g_drive_get_start_stop_type (GDrive *drive) { GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), FALSE); iface = G_DRIVE_GET_IFACE (drive); if (iface->get_start_stop_type == NULL) return G_DRIVE_START_STOP_TYPE_UNKNOWN; return (* iface->get_start_stop_type) (drive); }
/** * g_drive_get_identifier: * @drive: a #GDrive * @kind: the kind of identifier to return * * Gets the identifier of the given kind for @drive. * * Returns: a newly allocated string containing the * requested identfier, or %NULL if the #GDrive * doesn't have this kind of identifier. */ char * g_drive_get_identifier (GDrive *drive, const char *kind) { GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), NULL); g_return_val_if_fail (kind != NULL, NULL); iface = G_DRIVE_GET_IFACE (drive); if (iface->get_identifier == NULL) return NULL; return (* iface->get_identifier) (drive, kind); }
/** * g_drive_get_symbolic_icon: * @drive: a #GDrive. * * Gets the icon for @drive. * * Returns: (transfer full): symbolic #GIcon for the @drive. * Free the returned object with g_object_unref(). * * Since: 2.34 **/ GIcon * g_drive_get_symbolic_icon (GDrive *drive) { GDriveIface *iface; GIcon *ret; g_return_val_if_fail (G_IS_DRIVE (drive), NULL); iface = G_DRIVE_GET_IFACE (drive); if (iface->get_symbolic_icon != NULL) ret = iface->get_symbolic_icon (drive); else ret = g_themed_icon_new_with_default_fallbacks ("drive-removable-media-symbolic"); return ret; }
/** * g_drive_stop_finish: * @drive: a #GDrive. * @result: a #GAsyncResult. * @error: a #GError, or %NULL * * Finishes stopping a drive. * * Returns: %TRUE if the drive has been stopped successfully, * %FALSE otherwise. * * Since: 2.22 */ gboolean g_drive_stop_finish (GDrive *drive, GAsyncResult *result, GError **error) { GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), FALSE); g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE); if (g_async_result_legacy_propagate_error (result, error)) return FALSE; else if (g_async_result_is_tagged (result, g_drive_start)) return g_task_propagate_boolean (G_TASK (result), error); iface = G_DRIVE_GET_IFACE (drive); return (* iface->stop_finish) (drive, result, error); }
/** * g_drive_stop_finish: * @drive: a #GDrive. * @result: a #GAsyncResult. * @error: a #GError, or %NULL * * Finishes stopping a drive. * * Returns: %TRUE if the drive has been stopped successfully, * %FALSE otherwise. * * Since: 2.22 */ gboolean g_drive_stop_finish (GDrive *drive, GAsyncResult *result, GError **error) { GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), FALSE); g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE); if (G_IS_SIMPLE_ASYNC_RESULT (result)) { GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); if (g_simple_async_result_propagate_error (simple, error)) return FALSE; } iface = G_DRIVE_GET_IFACE (drive); return (* iface->stop_finish) (drive, result, error); }
static void brasero_gio_operation_eject_finish (GObject *source, GAsyncResult *result, gpointer user_data) { BraseroGioOperation *operation = user_data; if (G_IS_DRIVE (source)) operation->result = g_drive_eject_with_operation_finish (G_DRIVE (source), result, &operation->error); else operation->result = g_volume_eject_with_operation_finish (G_VOLUME (source), result, &operation->error); if (operation->error) brasero_gio_operation_end (operation); else if (!operation->result) brasero_gio_operation_end (operation); }
static void do_drive_tests (GDrive *drive) { GList *volumes, *l; gchar *name; gboolean has_volumes; g_assert (G_IS_DRIVE (drive)); name = g_drive_get_name (drive); g_assert (name != NULL); g_free (name); has_volumes = g_drive_has_volumes (drive); volumes = g_drive_get_volumes (drive); g_assert (has_volumes == (volumes != NULL)); for (l = volumes; l; l = l->next) { GVolume *volume = l->data; do_volume_tests (drive, volume); } g_list_free_full (volumes, g_object_unref); }
/** * g_drive_poll_for_media: * @drive: a #GDrive. * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore. * @callback: (allow-none): a #GAsyncReadyCallback, or %NULL. * @user_data: user data to pass to @callback * * Asynchronously polls @drive to see if media has been inserted or removed. * * When the operation is finished, @callback will be called. * You can then call g_drive_poll_for_media_finish() to obtain the * result of the operation. **/ void g_drive_poll_for_media (GDrive *drive, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GDriveIface *iface; g_return_if_fail (G_IS_DRIVE (drive)); iface = G_DRIVE_GET_IFACE (drive); if (iface->poll_for_media == NULL) { g_task_report_new_error (drive, callback, user_data, g_drive_poll_for_media, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("drive doesn't implement polling for media")); return; } (* iface->poll_for_media) (drive, cancellable, callback, user_data); }
/** * g_drive_start: * @drive: a #GDrive. * @flags: flags affecting the start operation. * @mount_operation: (allow-none): a #GMountOperation or %NULL to avoid * user interaction. * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore. * @callback: (allow-none): a #GAsyncReadyCallback, or %NULL. * @user_data: user data to pass to @callback * * Asynchronously starts a drive. * * When the operation is finished, @callback will be called. * You can then call g_drive_start_finish() to obtain the * result of the operation. * * Since: 2.22 */ void g_drive_start (GDrive *drive, GDriveStartFlags flags, GMountOperation *mount_operation, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GDriveIface *iface; g_return_if_fail (G_IS_DRIVE (drive)); iface = G_DRIVE_GET_IFACE (drive); if (iface->start == NULL) { g_simple_async_report_error_in_idle (G_OBJECT (drive), callback, user_data, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("drive doesn't implement start")); return; } (* iface->start) (drive, flags, mount_operation, cancellable, callback, user_data); }