gdrive.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /* GIO - GLib Input, Output and Streaming Library
  2. *
  3. * Copyright (C) 2006-2007 Red Hat, Inc.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library 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 GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General
  16. * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * Author: Alexander Larsson <alexl@redhat.com>
  19. * David Zeuthen <davidz@redhat.com>
  20. */
  21. #ifndef __G_DRIVE_H__
  22. #define __G_DRIVE_H__
  23. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  24. #error "Only <gio/gio.h> can be included directly."
  25. #endif
  26. #include <gio/giotypes.h>
  27. G_BEGIN_DECLS
  28. /**
  29. * G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE:
  30. *
  31. * The string used to obtain a Unix device path with g_drive_get_identifier().
  32. *
  33. * Since: 2.58
  34. */
  35. #define G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE "unix-device"
  36. #define G_TYPE_DRIVE (g_drive_get_type ())
  37. #define G_DRIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_DRIVE, GDrive))
  38. #define G_IS_DRIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_DRIVE))
  39. #define G_DRIVE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_DRIVE, GDriveIface))
  40. /**
  41. * GDriveIface:
  42. * @g_iface: The parent interface.
  43. * @changed: Signal emitted when the drive is changed.
  44. * @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.
  45. * @eject_button: Signal emitted when the physical eject button (if any) of a drive have been pressed.
  46. * @get_name: Returns the name for the given #GDrive.
  47. * @get_icon: Returns a #GIcon for the given #GDrive.
  48. * @has_volumes: Returns %TRUE if the #GDrive has mountable volumes.
  49. * @get_volumes: Returns a list #GList of #GVolume for the #GDrive.
  50. * @is_removable: Returns %TRUE if the #GDrive and/or its media is considered removable by the user. Since 2.50.
  51. * @is_media_removable: Returns %TRUE if the #GDrive supports removal and insertion of media.
  52. * @has_media: Returns %TRUE if the #GDrive has media inserted.
  53. * @is_media_check_automatic: Returns %TRUE if the #GDrive is capabable of automatically detecting media changes.
  54. * @can_poll_for_media: Returns %TRUE if the #GDrive is capable of manually polling for media change.
  55. * @can_eject: Returns %TRUE if the #GDrive can eject media.
  56. * @eject: Ejects a #GDrive.
  57. * @eject_finish: Finishes an eject operation.
  58. * @poll_for_media: Poll for media insertion/removal on a #GDrive.
  59. * @poll_for_media_finish: Finishes a media poll operation.
  60. * @get_identifier: Returns the identifier of the given kind, or %NULL if
  61. * the #GDrive doesn't have one.
  62. * @enumerate_identifiers: Returns an array strings listing the kinds
  63. * of identifiers which the #GDrive has.
  64. * @get_start_stop_type: Gets a #GDriveStartStopType with details about starting/stopping the drive. Since 2.22.
  65. * @can_stop: Returns %TRUE if a #GDrive can be stopped. Since 2.22.
  66. * @stop: Stops a #GDrive. Since 2.22.
  67. * @stop_finish: Finishes a stop operation. Since 2.22.
  68. * @can_start: Returns %TRUE if a #GDrive can be started. Since 2.22.
  69. * @can_start_degraded: Returns %TRUE if a #GDrive can be started degraded. Since 2.22.
  70. * @start: Starts a #GDrive. Since 2.22.
  71. * @start_finish: Finishes a start operation. Since 2.22.
  72. * @stop_button: Signal emitted when the physical stop button (if any) of a drive have been pressed. Since 2.22.
  73. * @eject_with_operation: Starts ejecting a #GDrive using a #GMountOperation. Since 2.22.
  74. * @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22.
  75. * @get_sort_key: Gets a key used for sorting #GDrive instances or %NULL if no such key exists. Since 2.32.
  76. * @get_symbolic_icon: Returns a symbolic #GIcon for the given #GDrive. Since 2.34.
  77. *
  78. * Interface for creating #GDrive implementations.
  79. */
  80. typedef struct _GDriveIface GDriveIface;
  81. struct _GDriveIface
  82. {
  83. GTypeInterface g_iface;
  84. /* signals */
  85. void (* changed) (GDrive *drive);
  86. void (* disconnected) (GDrive *drive);
  87. void (* eject_button) (GDrive *drive);
  88. /* Virtual Table */
  89. char * (* get_name) (GDrive *drive);
  90. GIcon * (* get_icon) (GDrive *drive);
  91. gboolean (* has_volumes) (GDrive *drive);
  92. GList * (* get_volumes) (GDrive *drive);
  93. gboolean (* is_media_removable) (GDrive *drive);
  94. gboolean (* has_media) (GDrive *drive);
  95. gboolean (* is_media_check_automatic) (GDrive *drive);
  96. gboolean (* can_eject) (GDrive *drive);
  97. gboolean (* can_poll_for_media) (GDrive *drive);
  98. void (* eject) (GDrive *drive,
  99. GMountUnmountFlags flags,
  100. GCancellable *cancellable,
  101. GAsyncReadyCallback callback,
  102. gpointer user_data);
  103. gboolean (* eject_finish) (GDrive *drive,
  104. GAsyncResult *result,
  105. GError **error);
  106. void (* poll_for_media) (GDrive *drive,
  107. GCancellable *cancellable,
  108. GAsyncReadyCallback callback,
  109. gpointer user_data);
  110. gboolean (* poll_for_media_finish) (GDrive *drive,
  111. GAsyncResult *result,
  112. GError **error);
  113. char * (* get_identifier) (GDrive *drive,
  114. const char *kind);
  115. char ** (* enumerate_identifiers) (GDrive *drive);
  116. GDriveStartStopType (* get_start_stop_type) (GDrive *drive);
  117. gboolean (* can_start) (GDrive *drive);
  118. gboolean (* can_start_degraded) (GDrive *drive);
  119. void (* start) (GDrive *drive,
  120. GDriveStartFlags flags,
  121. GMountOperation *mount_operation,
  122. GCancellable *cancellable,
  123. GAsyncReadyCallback callback,
  124. gpointer user_data);
  125. gboolean (* start_finish) (GDrive *drive,
  126. GAsyncResult *result,
  127. GError **error);
  128. gboolean (* can_stop) (GDrive *drive);
  129. void (* stop) (GDrive *drive,
  130. GMountUnmountFlags flags,
  131. GMountOperation *mount_operation,
  132. GCancellable *cancellable,
  133. GAsyncReadyCallback callback,
  134. gpointer user_data);
  135. gboolean (* stop_finish) (GDrive *drive,
  136. GAsyncResult *result,
  137. GError **error);
  138. /* signal, not VFunc */
  139. void (* stop_button) (GDrive *drive);
  140. void (* eject_with_operation) (GDrive *drive,
  141. GMountUnmountFlags flags,
  142. GMountOperation *mount_operation,
  143. GCancellable *cancellable,
  144. GAsyncReadyCallback callback,
  145. gpointer user_data);
  146. gboolean (* eject_with_operation_finish) (GDrive *drive,
  147. GAsyncResult *result,
  148. GError **error);
  149. const gchar * (* get_sort_key) (GDrive *drive);
  150. GIcon * (* get_symbolic_icon) (GDrive *drive);
  151. gboolean (* is_removable) (GDrive *drive);
  152. };
  153. GLIB_AVAILABLE_IN_ALL
  154. GType g_drive_get_type (void) G_GNUC_CONST;
  155. GLIB_AVAILABLE_IN_ALL
  156. char * g_drive_get_name (GDrive *drive);
  157. GLIB_AVAILABLE_IN_ALL
  158. GIcon * g_drive_get_icon (GDrive *drive);
  159. GLIB_AVAILABLE_IN_ALL
  160. GIcon * g_drive_get_symbolic_icon (GDrive *drive);
  161. GLIB_AVAILABLE_IN_ALL
  162. gboolean g_drive_has_volumes (GDrive *drive);
  163. GLIB_AVAILABLE_IN_ALL
  164. GList * g_drive_get_volumes (GDrive *drive);
  165. GLIB_AVAILABLE_IN_2_50
  166. gboolean g_drive_is_removable (GDrive *drive);
  167. GLIB_AVAILABLE_IN_ALL
  168. gboolean g_drive_is_media_removable (GDrive *drive);
  169. GLIB_AVAILABLE_IN_ALL
  170. gboolean g_drive_has_media (GDrive *drive);
  171. GLIB_AVAILABLE_IN_ALL
  172. gboolean g_drive_is_media_check_automatic (GDrive *drive);
  173. GLIB_AVAILABLE_IN_ALL
  174. gboolean g_drive_can_poll_for_media (GDrive *drive);
  175. GLIB_AVAILABLE_IN_ALL
  176. gboolean g_drive_can_eject (GDrive *drive);
  177. GLIB_DEPRECATED_FOR(g_drive_eject_with_operation)
  178. void g_drive_eject (GDrive *drive,
  179. GMountUnmountFlags flags,
  180. GCancellable *cancellable,
  181. GAsyncReadyCallback callback,
  182. gpointer user_data);
  183. GLIB_DEPRECATED_FOR(g_drive_eject_with_operation_finish)
  184. gboolean g_drive_eject_finish (GDrive *drive,
  185. GAsyncResult *result,
  186. GError **error);
  187. GLIB_AVAILABLE_IN_ALL
  188. void g_drive_poll_for_media (GDrive *drive,
  189. GCancellable *cancellable,
  190. GAsyncReadyCallback callback,
  191. gpointer user_data);
  192. GLIB_AVAILABLE_IN_ALL
  193. gboolean g_drive_poll_for_media_finish (GDrive *drive,
  194. GAsyncResult *result,
  195. GError **error);
  196. GLIB_AVAILABLE_IN_ALL
  197. char * g_drive_get_identifier (GDrive *drive,
  198. const char *kind);
  199. GLIB_AVAILABLE_IN_ALL
  200. char ** g_drive_enumerate_identifiers (GDrive *drive);
  201. GLIB_AVAILABLE_IN_ALL
  202. GDriveStartStopType g_drive_get_start_stop_type (GDrive *drive);
  203. GLIB_AVAILABLE_IN_ALL
  204. gboolean g_drive_can_start (GDrive *drive);
  205. GLIB_AVAILABLE_IN_ALL
  206. gboolean g_drive_can_start_degraded (GDrive *drive);
  207. GLIB_AVAILABLE_IN_ALL
  208. void g_drive_start (GDrive *drive,
  209. GDriveStartFlags flags,
  210. GMountOperation *mount_operation,
  211. GCancellable *cancellable,
  212. GAsyncReadyCallback callback,
  213. gpointer user_data);
  214. GLIB_AVAILABLE_IN_ALL
  215. gboolean g_drive_start_finish (GDrive *drive,
  216. GAsyncResult *result,
  217. GError **error);
  218. GLIB_AVAILABLE_IN_ALL
  219. gboolean g_drive_can_stop (GDrive *drive);
  220. GLIB_AVAILABLE_IN_ALL
  221. void g_drive_stop (GDrive *drive,
  222. GMountUnmountFlags flags,
  223. GMountOperation *mount_operation,
  224. GCancellable *cancellable,
  225. GAsyncReadyCallback callback,
  226. gpointer user_data);
  227. GLIB_AVAILABLE_IN_ALL
  228. gboolean g_drive_stop_finish (GDrive *drive,
  229. GAsyncResult *result,
  230. GError **error);
  231. GLIB_AVAILABLE_IN_ALL
  232. void g_drive_eject_with_operation (GDrive *drive,
  233. GMountUnmountFlags flags,
  234. GMountOperation *mount_operation,
  235. GCancellable *cancellable,
  236. GAsyncReadyCallback callback,
  237. gpointer user_data);
  238. GLIB_AVAILABLE_IN_ALL
  239. gboolean g_drive_eject_with_operation_finish (GDrive *drive,
  240. GAsyncResult *result,
  241. GError **error);
  242. GLIB_AVAILABLE_IN_2_32
  243. const gchar *g_drive_get_sort_key (GDrive *drive);
  244. G_END_DECLS
  245. #endif /* __G_DRIVE_H__ */