Lines Matching +full:- +full:- +full:volume
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
3 /* GIO - GLib Input, Output and Streaming Library
5 * Copyright (C) 2006-2007 Red Hat, Inc.
48 GUnixMount *mount; /* owned by volume monitor */
72 GUnixVolume *volume; in G_DEFINE_TYPE_WITH_CODE() local
74 volume = G_UNIX_VOLUME (object); in G_DEFINE_TYPE_WITH_CODE()
76 if (volume->volume_monitor != NULL) in G_DEFINE_TYPE_WITH_CODE()
77 g_object_unref (volume->volume_monitor); in G_DEFINE_TYPE_WITH_CODE()
79 if (volume->mount) in G_DEFINE_TYPE_WITH_CODE()
80 _g_unix_mount_unset_volume (volume->mount, volume); in G_DEFINE_TYPE_WITH_CODE()
82 g_object_unref (volume->icon); in G_DEFINE_TYPE_WITH_CODE()
83 g_object_unref (volume->symbolic_icon); in G_DEFINE_TYPE_WITH_CODE()
84 g_free (volume->name); in G_DEFINE_TYPE_WITH_CODE()
85 g_free (volume->mount_path); in G_DEFINE_TYPE_WITH_CODE()
86 g_free (volume->device_path); in G_DEFINE_TYPE_WITH_CODE()
87 g_free (volume->identifier); in G_DEFINE_TYPE_WITH_CODE()
88 g_free (volume->identifier_type); in G_DEFINE_TYPE_WITH_CODE()
90 G_OBJECT_CLASS (g_unix_volume_parent_class)->finalize (object); in G_DEFINE_TYPE_WITH_CODE()
98 gobject_class->finalize = g_unix_volume_finalize; in g_unix_volume_class_init()
110 GUnixVolume *volume; in _g_unix_volume_new() local
117 volume = g_object_new (G_TYPE_UNIX_VOLUME, NULL); in _g_unix_volume_new()
118 volume->volume_monitor = volume_monitor != NULL ? g_object_ref (volume_monitor) : NULL; in _g_unix_volume_new()
119 volume->mount_path = g_strdup (g_unix_mount_point_get_mount_path (mountpoint)); in _g_unix_volume_new()
120 volume->device_path = g_strdup (g_unix_mount_point_get_device_path (mountpoint)); in _g_unix_volume_new()
121 volume->can_eject = g_unix_mount_point_guess_can_eject (mountpoint); in _g_unix_volume_new()
123 volume->name = g_unix_mount_point_guess_name (mountpoint); in _g_unix_volume_new()
124 volume->icon = g_unix_mount_point_guess_icon (mountpoint); in _g_unix_volume_new()
125 volume->symbolic_icon = g_unix_mount_point_guess_symbolic_icon (mountpoint); in _g_unix_volume_new()
130 volume->identifier_type = g_strdup (G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT); in _g_unix_volume_new()
131 volume->identifier = g_strdup (volume->device_path); in _g_unix_volume_new()
133 else if (g_str_has_prefix (volume->device_path, "LABEL=")) in _g_unix_volume_new()
135 volume->identifier_type = g_strdup (G_VOLUME_IDENTIFIER_KIND_LABEL); in _g_unix_volume_new()
136 volume->identifier = g_strdup (volume->device_path + 6); in _g_unix_volume_new()
138 else if (g_str_has_prefix (volume->device_path, "UUID=")) in _g_unix_volume_new()
140 volume->identifier_type = g_strdup (G_VOLUME_IDENTIFIER_KIND_UUID); in _g_unix_volume_new()
141 volume->identifier = g_strdup (volume->device_path + 5); in _g_unix_volume_new()
143 else if (g_path_is_absolute (volume->device_path)) in _g_unix_volume_new()
145 volume->identifier_type = g_strdup (G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); in _g_unix_volume_new()
146 volume->identifier = g_strdup (volume->device_path); in _g_unix_volume_new()
149 return volume; in _g_unix_volume_new()
153 _g_unix_volume_disconnected (GUnixVolume *volume) in _g_unix_volume_disconnected() argument
155 if (volume->mount) in _g_unix_volume_disconnected()
157 _g_unix_mount_unset_volume (volume->mount, volume); in _g_unix_volume_disconnected()
158 volume->mount = NULL; in _g_unix_volume_disconnected()
163 _g_unix_volume_set_mount (GUnixVolume *volume, in _g_unix_volume_set_mount() argument
166 if (volume->mount == mount) in _g_unix_volume_set_mount()
169 if (volume->mount) in _g_unix_volume_set_mount()
170 _g_unix_mount_unset_volume (volume->mount, volume); in _g_unix_volume_set_mount()
172 volume->mount = mount; in _g_unix_volume_set_mount()
175 g_signal_emit_by_name (volume, "changed"); in _g_unix_volume_set_mount()
176 if (volume->volume_monitor != NULL) in _g_unix_volume_set_mount()
177 g_signal_emit_by_name (volume->volume_monitor, "volume-changed", volume); in _g_unix_volume_set_mount()
181 _g_unix_volume_unset_mount (GUnixVolume *volume, in _g_unix_volume_unset_mount() argument
184 if (volume->mount == mount) in _g_unix_volume_unset_mount()
186 volume->mount = NULL; in _g_unix_volume_unset_mount()
188 g_signal_emit_by_name (volume, "changed"); in _g_unix_volume_unset_mount()
189 if (volume->volume_monitor != NULL) in _g_unix_volume_unset_mount()
190 g_signal_emit_by_name (volume->volume_monitor, "volume-changed", volume); in _g_unix_volume_unset_mount()
195 g_unix_volume_get_icon (GVolume *volume) in g_unix_volume_get_icon() argument
197 GUnixVolume *unix_volume = G_UNIX_VOLUME (volume); in g_unix_volume_get_icon()
198 return g_object_ref (unix_volume->icon); in g_unix_volume_get_icon()
202 g_unix_volume_get_symbolic_icon (GVolume *volume) in g_unix_volume_get_symbolic_icon() argument
204 GUnixVolume *unix_volume = G_UNIX_VOLUME (volume); in g_unix_volume_get_symbolic_icon()
205 return g_object_ref (unix_volume->symbolic_icon); in g_unix_volume_get_symbolic_icon()
209 g_unix_volume_get_name (GVolume *volume) in g_unix_volume_get_name() argument
211 GUnixVolume *unix_volume = G_UNIX_VOLUME (volume); in g_unix_volume_get_name()
212 return g_strdup (unix_volume->name); in g_unix_volume_get_name()
216 g_unix_volume_get_uuid (GVolume *volume) in g_unix_volume_get_uuid() argument
222 g_unix_volume_can_mount (GVolume *volume) in g_unix_volume_can_mount() argument
228 g_unix_volume_can_eject (GVolume *volume) in g_unix_volume_can_eject() argument
230 GUnixVolume *unix_volume = G_UNIX_VOLUME (volume); in g_unix_volume_can_eject()
231 return unix_volume->can_eject; in g_unix_volume_can_eject()
235 g_unix_volume_should_automount (GVolume *volume) in g_unix_volume_should_automount() argument
244 g_unix_volume_get_drive (GVolume *volume) in g_unix_volume_get_drive() argument
250 g_unix_volume_get_mount (GVolume *volume) in g_unix_volume_get_mount() argument
252 GUnixVolume *unix_volume = G_UNIX_VOLUME (volume); in g_unix_volume_get_mount()
254 if (unix_volume->mount != NULL) in g_unix_volume_get_mount()
255 return g_object_ref (G_MOUNT (unix_volume->mount)); in g_unix_volume_get_mount()
262 _g_unix_volume_has_mount_path (GUnixVolume *volume, in _g_unix_volume_has_mount_path() argument
265 return strcmp (volume->mount_path, mount_path) == 0; in _g_unix_volume_has_mount_path()
293 _g_unix_volume_monitor_update (G_UNIX_VOLUME_MONITOR (unix_volume->volume_monitor)); in eject_mount_done()
304 eject_mount_do (GVolume *volume, in eject_mount_do() argument
315 task = g_task_new (volume, cancellable, callback, user_data); in eject_mount_do()
334 g_unix_volume_mount (GVolume *volume, in g_unix_volume_mount() argument
341 GUnixVolume *unix_volume = G_UNIX_VOLUME (volume); in g_unix_volume_mount()
344 if (unix_volume->mount_path != NULL) in g_unix_volume_mount()
345 argv[1] = unix_volume->mount_path; in g_unix_volume_mount()
347 argv[1] = unix_volume->device_path; in g_unix_volume_mount()
349 eject_mount_do (volume, cancellable, callback, user_data, argv, "[gio] mount volume"); in g_unix_volume_mount()
353 g_unix_volume_mount_finish (GVolume *volume, in g_unix_volume_mount_finish() argument
357 g_return_val_if_fail (g_task_is_valid (result, volume), FALSE); in g_unix_volume_mount_finish()
363 g_unix_volume_eject (GVolume *volume, in g_unix_volume_eject() argument
369 GUnixVolume *unix_volume = G_UNIX_VOLUME (volume); in g_unix_volume_eject()
372 argv[1] = unix_volume->device_path; in g_unix_volume_eject()
374 eject_mount_do (volume, cancellable, callback, user_data, argv, "[gio] eject volume"); in g_unix_volume_eject()
378 g_unix_volume_eject_finish (GVolume *volume, in g_unix_volume_eject_finish() argument
382 g_return_val_if_fail (g_task_is_valid (result, volume), FALSE); in g_unix_volume_eject_finish()
388 g_unix_volume_get_identifier (GVolume *volume, in g_unix_volume_get_identifier() argument
391 GUnixVolume *unix_volume = G_UNIX_VOLUME (volume); in g_unix_volume_get_identifier()
393 if (unix_volume->identifier_type != NULL && in g_unix_volume_get_identifier()
394 strcmp (kind, unix_volume->identifier_type) == 0) in g_unix_volume_get_identifier()
395 return g_strdup (unix_volume->identifier); in g_unix_volume_get_identifier()
401 g_unix_volume_enumerate_identifiers (GVolume *volume) in g_unix_volume_enumerate_identifiers() argument
403 GUnixVolume *unix_volume = G_UNIX_VOLUME (volume); in g_unix_volume_enumerate_identifiers()
406 if (unix_volume->identifier_type) in g_unix_volume_enumerate_identifiers()
409 res[0] = g_strdup (unix_volume->identifier_type); in g_unix_volume_enumerate_identifiers()
424 iface->get_name = g_unix_volume_get_name; in g_unix_volume_volume_iface_init()
425 iface->get_icon = g_unix_volume_get_icon; in g_unix_volume_volume_iface_init()
426 iface->get_symbolic_icon = g_unix_volume_get_symbolic_icon; in g_unix_volume_volume_iface_init()
427 iface->get_uuid = g_unix_volume_get_uuid; in g_unix_volume_volume_iface_init()
428 iface->get_drive = g_unix_volume_get_drive; in g_unix_volume_volume_iface_init()
429 iface->get_mount = g_unix_volume_get_mount; in g_unix_volume_volume_iface_init()
430 iface->can_mount = g_unix_volume_can_mount; in g_unix_volume_volume_iface_init()
431 iface->can_eject = g_unix_volume_can_eject; in g_unix_volume_volume_iface_init()
432 iface->should_automount = g_unix_volume_should_automount; in g_unix_volume_volume_iface_init()
433 iface->mount_fn = g_unix_volume_mount; in g_unix_volume_volume_iface_init()
434 iface->mount_finish = g_unix_volume_mount_finish; in g_unix_volume_volume_iface_init()
435 iface->eject = g_unix_volume_eject; in g_unix_volume_volume_iface_init()
436 iface->eject_finish = g_unix_volume_eject_finish; in g_unix_volume_volume_iface_init()
437 iface->get_identifier = g_unix_volume_get_identifier; in g_unix_volume_volume_iface_init()
438 iface->enumerate_identifiers = g_unix_volume_enumerate_identifiers; in g_unix_volume_volume_iface_init()