1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
5 * SPDX-License-Identifier: LGPL-2.1-or-later
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 * Author: Alexander Larsson <alexl@redhat.com>
21 * David Zeuthen <davidz@redhat.com>
27 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
28 #error "Only <gio/gio.h> can be included directly."
31 #include <gio/giotypes.h>
36 * G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE:
38 * The string used to obtain a Unix device path with g_drive_get_identifier().
42 #define G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE "unix-device"
44 #define G_TYPE_DRIVE (g_drive_get_type ())
45 #define G_DRIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_DRIVE, GDrive))
46 #define G_IS_DRIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_DRIVE))
47 #define G_DRIVE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_DRIVE, GDriveIface))
51 * @g_iface: The parent interface.
52 * @changed: Signal emitted when the drive is changed.
53 * @disconnected: The removed signal that is emitted when the #GDrive have been disconnected. If the recipient is holding references to the object they should release them so the object can be finalized.
54 * @eject_button: Signal emitted when the physical eject button (if any) of a drive have been pressed.
55 * @get_name: Returns the name for the given #GDrive.
56 * @get_icon: Returns a #GIcon for the given #GDrive.
57 * @has_volumes: Returns %TRUE if the #GDrive has mountable volumes.
58 * @get_volumes: Returns a list #GList of #GVolume for the #GDrive.
59 * @is_removable: Returns %TRUE if the #GDrive and/or its media is considered removable by the user. Since 2.50.
60 * @is_media_removable: Returns %TRUE if the #GDrive supports removal and insertion of media.
61 * @has_media: Returns %TRUE if the #GDrive has media inserted.
62 * @is_media_check_automatic: Returns %TRUE if the #GDrive is capable of automatically detecting media changes.
63 * @can_poll_for_media: Returns %TRUE if the #GDrive is capable of manually polling for media change.
64 * @can_eject: Returns %TRUE if the #GDrive can eject media.
65 * @eject: Ejects a #GDrive.
66 * @eject_finish: Finishes an eject operation.
67 * @poll_for_media: Poll for media insertion/removal on a #GDrive.
68 * @poll_for_media_finish: Finishes a media poll operation.
69 * @get_identifier: Returns the identifier of the given kind, or %NULL if
70 * the #GDrive doesn't have one.
71 * @enumerate_identifiers: Returns an array strings listing the kinds
72 * of identifiers which the #GDrive has.
73 * @get_start_stop_type: Gets a #GDriveStartStopType with details about starting/stopping the drive. Since 2.22.
74 * @can_stop: Returns %TRUE if a #GDrive can be stopped. Since 2.22.
75 * @stop: Stops a #GDrive. Since 2.22.
76 * @stop_finish: Finishes a stop operation. Since 2.22.
77 * @can_start: Returns %TRUE if a #GDrive can be started. Since 2.22.
78 * @can_start_degraded: Returns %TRUE if a #GDrive can be started degraded. Since 2.22.
79 * @start: Starts a #GDrive. Since 2.22.
80 * @start_finish: Finishes a start operation. Since 2.22.
81 * @stop_button: Signal emitted when the physical stop button (if any) of a drive have been pressed. Since 2.22.
82 * @eject_with_operation: Starts ejecting a #GDrive using a #GMountOperation. Since 2.22.
83 * @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22.
84 * @get_sort_key: Gets a key used for sorting #GDrive instances or %NULL if no such key exists. Since 2.32.
85 * @get_symbolic_icon: Returns a symbolic #GIcon for the given #GDrive. Since 2.34.
87 * Interface for creating #GDrive implementations.
89 typedef struct _GDriveIface GDriveIface;
93 GTypeInterface g_iface;
96 void (* changed) (GDrive *drive);
97 void (* disconnected) (GDrive *drive);
98 void (* eject_button) (GDrive *drive);
101 char * (* get_name) (GDrive *drive);
102 GIcon * (* get_icon) (GDrive *drive);
103 gboolean (* has_volumes) (GDrive *drive);
104 GList * (* get_volumes) (GDrive *drive);
105 gboolean (* is_media_removable) (GDrive *drive);
106 gboolean (* has_media) (GDrive *drive);
107 gboolean (* is_media_check_automatic) (GDrive *drive);
108 gboolean (* can_eject) (GDrive *drive);
109 gboolean (* can_poll_for_media) (GDrive *drive);
110 void (* eject) (GDrive *drive,
111 GMountUnmountFlags flags,
112 GCancellable *cancellable,
113 GAsyncReadyCallback callback,
115 gboolean (* eject_finish) (GDrive *drive,
116 GAsyncResult *result,
118 void (* poll_for_media) (GDrive *drive,
119 GCancellable *cancellable,
120 GAsyncReadyCallback callback,
122 gboolean (* poll_for_media_finish) (GDrive *drive,
123 GAsyncResult *result,
126 char * (* get_identifier) (GDrive *drive,
128 char ** (* enumerate_identifiers) (GDrive *drive);
130 GDriveStartStopType (* get_start_stop_type) (GDrive *drive);
132 gboolean (* can_start) (GDrive *drive);
133 gboolean (* can_start_degraded) (GDrive *drive);
134 void (* start) (GDrive *drive,
135 GDriveStartFlags flags,
136 GMountOperation *mount_operation,
137 GCancellable *cancellable,
138 GAsyncReadyCallback callback,
140 gboolean (* start_finish) (GDrive *drive,
141 GAsyncResult *result,
144 gboolean (* can_stop) (GDrive *drive);
145 void (* stop) (GDrive *drive,
146 GMountUnmountFlags flags,
147 GMountOperation *mount_operation,
148 GCancellable *cancellable,
149 GAsyncReadyCallback callback,
151 gboolean (* stop_finish) (GDrive *drive,
152 GAsyncResult *result,
154 /* signal, not VFunc */
155 void (* stop_button) (GDrive *drive);
157 void (* eject_with_operation) (GDrive *drive,
158 GMountUnmountFlags flags,
159 GMountOperation *mount_operation,
160 GCancellable *cancellable,
161 GAsyncReadyCallback callback,
163 gboolean (* eject_with_operation_finish) (GDrive *drive,
164 GAsyncResult *result,
167 const gchar * (* get_sort_key) (GDrive *drive);
168 GIcon * (* get_symbolic_icon) (GDrive *drive);
169 gboolean (* is_removable) (GDrive *drive);
174 GType g_drive_get_type (void) G_GNUC_CONST;
177 char * g_drive_get_name (GDrive *drive);
179 GIcon * g_drive_get_icon (GDrive *drive);
181 GIcon * g_drive_get_symbolic_icon (GDrive *drive);
183 gboolean g_drive_has_volumes (GDrive *drive);
185 GList * g_drive_get_volumes (GDrive *drive);
186 GIO_AVAILABLE_IN_2_50
187 gboolean g_drive_is_removable (GDrive *drive);
189 gboolean g_drive_is_media_removable (GDrive *drive);
191 gboolean g_drive_has_media (GDrive *drive);
193 gboolean g_drive_is_media_check_automatic (GDrive *drive);
195 gboolean g_drive_can_poll_for_media (GDrive *drive);
197 gboolean g_drive_can_eject (GDrive *drive);
198 GIO_DEPRECATED_FOR(g_drive_eject_with_operation)
199 void g_drive_eject (GDrive *drive,
200 GMountUnmountFlags flags,
201 GCancellable *cancellable,
202 GAsyncReadyCallback callback,
205 GIO_DEPRECATED_FOR(g_drive_eject_with_operation_finish)
206 gboolean g_drive_eject_finish (GDrive *drive,
207 GAsyncResult *result,
210 void g_drive_poll_for_media (GDrive *drive,
211 GCancellable *cancellable,
212 GAsyncReadyCallback callback,
215 gboolean g_drive_poll_for_media_finish (GDrive *drive,
216 GAsyncResult *result,
219 char * g_drive_get_identifier (GDrive *drive,
222 char ** g_drive_enumerate_identifiers (GDrive *drive);
225 GDriveStartStopType g_drive_get_start_stop_type (GDrive *drive);
228 gboolean g_drive_can_start (GDrive *drive);
230 gboolean g_drive_can_start_degraded (GDrive *drive);
232 void g_drive_start (GDrive *drive,
233 GDriveStartFlags flags,
234 GMountOperation *mount_operation,
235 GCancellable *cancellable,
236 GAsyncReadyCallback callback,
239 gboolean g_drive_start_finish (GDrive *drive,
240 GAsyncResult *result,
244 gboolean g_drive_can_stop (GDrive *drive);
246 void g_drive_stop (GDrive *drive,
247 GMountUnmountFlags flags,
248 GMountOperation *mount_operation,
249 GCancellable *cancellable,
250 GAsyncReadyCallback callback,
253 gboolean g_drive_stop_finish (GDrive *drive,
254 GAsyncResult *result,
258 void g_drive_eject_with_operation (GDrive *drive,
259 GMountUnmountFlags flags,
260 GMountOperation *mount_operation,
261 GCancellable *cancellable,
262 GAsyncReadyCallback callback,
265 gboolean g_drive_eject_with_operation_finish (GDrive *drive,
266 GAsyncResult *result,
269 GIO_AVAILABLE_IN_2_32
270 const gchar *g_drive_get_sort_key (GDrive *drive);
274 #endif /* __G_DRIVE_H__ */