1 <?xml version="1.0" standalone="no"?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
5 <refentry id="class-giovolume">
7 <refname>gio.Volume</refname>
8 <refpurpose>Volume management.</refpurpose>
12 <title>Synopsis</title>
14 <classsynopsis language="python">
15 <ooclass><classname>gio.Volume</classname></ooclass>
16 <ooclass><classname><link linkend="class-gobjectginterface">gobject.GInterface</link></classname></ooclass>
18 <methodsynopsis language="python">
19 <methodname><link linkend="method-giovolume--can-eject">can_eject</link></methodname>
20 <methodparam></methodparam>
22 <methodsynopsis language="python">
23 <methodname><link linkend="method-giovolume--can-mount">can_mount</link></methodname>
24 <methodparam></methodparam>
26 <methodsynopsis language="python">
27 <methodname><link linkend="method-giovolume--eject">eject</link></methodname>
28 <methodparam><parameter role="keyword">callback</parameter></methodparam>
29 <methodparam><parameter role="keyword">flags</parameter><initializer><literal>gio.MOUNT_UNMOUNT_NONE</literal></initializer></methodparam>
30 <methodparam><parameter role="keyword">cancellable</parameter><initializer><literal>None</literal></initializer></methodparam>
31 <methodparam><parameter role="keyword">user_data</parameter><initializer><literal>None</literal></initializer></methodparam>
33 <methodsynopsis language="python">
34 <methodname><link linkend="method-giovolume--eject-finish">eject_finish</link></methodname>
35 <methodparam><parameter role="keyword">result</parameter></methodparam>
37 <methodsynopsis language="python">
38 <methodname><link linkend="method-giovolume--enumerate-identifiers">enumerate_identifiers</link></methodname>
39 <methodparam></methodparam>
41 <methodsynopsis language="python">
42 <methodname><link linkend="method-giovolume--get-activation-root">get_activation_root</link></methodname>
43 <methodparam></methodparam>
45 <methodsynopsis language="python">
46 <methodname><link linkend="method-giovolume--get-drive">get_drive</link></methodname>
47 <methodparam></methodparam>
49 <methodsynopsis language="python">
50 <methodname><link linkend="method-giovolume--get-icon">get_icon</link></methodname>
51 <methodparam></methodparam>
53 <methodsynopsis language="python">
54 <methodname><link linkend="method-giovolume--get-identifier">get_identifier</link></methodname>
55 <methodparam></methodparam>
57 <methodsynopsis language="python">
58 <methodname><link linkend="method-giovolume--get-mount">get_mount</link></methodname>
59 <methodparam></methodparam>
61 <methodsynopsis language="python">
62 <methodname><link linkend="method-giovolume--get-name">get_name</link></methodname>
63 <methodparam></methodparam>
65 <methodsynopsis language="python">
66 <methodname><link linkend="method-giovolume--get-uuid">get_uuid</link></methodname>
67 <methodparam></methodparam>
69 <methodsynopsis language="python">
70 <methodname><link linkend="method-giovolume--mount">mount</link></methodname>
71 <methodparam><parameter role="keyword">mount_operation</parameter></methodparam>
72 <methodparam><parameter role="keyword">callback</parameter></methodparam>
73 <methodparam><parameter role="keyword">flags</parameter><initializer><literal>gio.MOUNT_MOUNT_NONE</literal></initializer></methodparam>
74 <methodparam><parameter role="keyword">cancellable</parameter><initializer><literal>None</literal></initializer></methodparam>
75 <methodparam><parameter role="keyword">user_data</parameter><initializer><literal>None</literal></initializer></methodparam>
77 <methodsynopsis language="python">
78 <methodname><link linkend="method-giovolume--mount-finish">mount_finish</link></methodname>
79 <methodparam><parameter role="keyword">result</parameter></methodparam>
81 <methodsynopsis language="python">
82 <methodname><link linkend="method-giovolume--should-automount">should_automount</link></methodname>
83 <methodparam></methodparam>
91 <title>Ancestry</title>
93 <synopsis>+-- <link linkend="class-gobjectginterface">gobject.GInterface</link>
94 +-- <link linkend="class-giovolume">gio.Volume</link>
100 <title>Prerequisites</title>
102 <link linkend="class-giovolume"><classname>gio.Volume</classname></link> requires
103 <link linkend="class-gobject"><classname>gobject.GObject</classname></link>
107 <refsect1 id="signal-prototypes-giovolume">
108 <title>gio.Volume Signal Prototypes</title>
110 <para><link linkend="signal-prototypes-gobject">gobject.GObject Signal Prototypes</link></para>
114 <term><link linkend="signal-giovolume--changed">"changed"</link></term>
116 <methodsynopsis language="python"><methodname>callback</methodname>
117 <methodparam><parameter>volume</parameter></methodparam>
118 <methodparam><parameter>user_param1</parameter></methodparam>
119 <methodparam><parameter>...</parameter></methodparam>
124 <term><link linkend="signal-giovolume--removed">"removed"</link></term>
126 <methodsynopsis language="python"><methodname>callback</methodname>
127 <methodparam><parameter>volume</parameter></methodparam>
128 <methodparam><parameter>user_param1</parameter></methodparam>
129 <methodparam><parameter>...</parameter></methodparam>
138 <title>Description</title>
141 The <link linkend="class-giovolume"><classname>gio.Volume</classname></link>
142 interface represents user-visible objects that can be mounted. Note, when porting
143 from GnomeVFS, <link linkend="class-giovolume"><classname>gio.Volume</classname></link>
144 is the moral equivalent of GnomeVFSDrive.
147 Mounting a <link linkend="class-giovolume"><classname>gio.Volume</classname></link>
148 instance is an asynchronous operation. For more information about asynchronous operations.
149 To mount a <link linkend="class-giovolume"><classname>gio.Volume</classname></link>, first call
150 <methodname><link linkend="method-giovolume--mount">gio.Volume.mount</link></methodname>()
151 with (at least) the <link linkend="class-giovolume"><classname>gio.Volume</classname></link>
152 instance, optionally a
153 <link linkend="class-giomountoperation"><classname>gio.MountOperation</classname></link>
154 object and a GAsyncReadyCallback.
157 Typically, one will only want to pass <literal>None</literal> for the GMountOperation
158 if automounting all volumes when a desktop session starts since it's not desirable
159 to put up a lot of dialogs asking for credentials.
162 The callback will be fired when the operation has resolved (either with success or failure),
163 and a GAsyncReady structure will be passed to the callback. That callback should then call
164 <methodname><link linkend="method-giovolume--mount-finish">gio.Volume.mount_finish</link></methodname>()
165 with the GVolume instance and the GAsyncReady data to see if the operation was completed
166 successfully. If an error is present when
167 <methodname><link linkend="method-giovolume--mount-finish">gio.Volume.mount_finish</link></methodname>()
168 is called, then it will be filled with any error information.
171 It is sometimes necessary to directly access the underlying operating system object behind a volume
172 (e.g. for passing a volume to an application via the commandline). For this purpose, GIO allows to obtain
173 an 'identifier' for the volume. There can be different kinds of identifiers, such as Hal UDIs,
174 filesystem labels, traditional Unix devices (e.g. /dev/sda2), uuids. GIO uses predefind strings
175 as names for the different kinds of identifiers:
176 "hal-udi", "label", etc. Use
177 <methodname><link linkend="method-giovolume--get-identifier">gio.Volume.get_identifier</link></methodname>()
178 to obtain an identifier for a volume.
183 <title>Methods</title>
185 <refsect2 id="method-giovolume--can-eject">
186 <title>gio.Volume.can_eject</title>
188 <programlisting><methodsynopsis language="python">
189 <methodname>can_eject</methodname>
190 <methodparam></methodparam>
191 </methodsynopsis></programlisting>
195 <term><emphasis>Returns</emphasis> :</term>
196 <listitem><simpara><literal>True</literal> if the volume can be ejected,
197 <literal>False</literal> otherwise.
198 </simpara></listitem>
203 The <methodname>can_eject</methodname>() method checks if a volume can be ejected.
207 <refsect2 id="method-giovolume--can-mount">
208 <title>gio.Volume.can_mount</title>
210 <programlisting><methodsynopsis language="python">
211 <methodname>can_mount</methodname>
212 <methodparam></methodparam>
213 </methodsynopsis></programlisting>
217 <term><emphasis>Returns</emphasis> :</term>
218 <listitem><simpara><literal>True</literal> if the volume can be mounted
219 for media changes, <literal>False</literal> otherwise.
220 </simpara></listitem>
225 The <methodname>can_mount</methodname>() method checks if a volume
230 <refsect2 id="method-giovolume--eject">
231 <title>gio.Volume.eject</title>
233 <programlisting><methodsynopsis language="python">
234 <methodname>eject</methodname>
236 <parameter role="keyword">callback</parameter>
239 <parameter role="keyword">flags</parameter><initializer><literal>gio.MOUNT_UNMOUNT_NONE</literal></initializer>
242 <parameter role="keyword">cancellable</parameter><initializer><literal>None</literal></initializer>
245 <parameter role="keyword">user_data</parameter><initializer><literal>None</literal></initializer>
247 </methodsynopsis></programlisting>
251 <term><parameter role="keyword">callback</parameter> :</term>
252 <listitem><simpara>A GAsyncReadyCallback to call when the request is satisfied.
253 </simpara></listitem>
256 <term><parameter role="keyword">flags</parameter> :</term>
257 <listitem><simpara>flags affecting the unmount if required for eject.
258 </simpara></listitem>
261 <term><parameter role="keyword">cancellable</parameter> :</term>
262 <listitem><simpara>Optional
263 <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
264 object, <literal>None</literal> to ignore.
265 </simpara></listitem>
268 <term><parameter role="keyword">user_data</parameter> :</term>
269 <listitem><simpara>The data to pass to callback function.
270 </simpara></listitem>
275 The <methodname>eject</methodname>() method asynchronously ejects a volume.
278 When the operation is finished, callback will be called. You can then call
279 <methodname><link linkend="method-giovolume--eject-finish">gio.Volume.eject_finish</link></methodname>()
280 to obtain the result of the operation.
284 <refsect2 id="method-giovolume--eject-finish">
285 <title>gio.Volume.eject_finish</title>
287 <programlisting><methodsynopsis language="python">
288 <methodname>eject_finish</methodname>
289 <methodparam><parameter role="keyword">result</parameter></methodparam>
290 </methodsynopsis></programlisting>
294 <term><parameter role="keyword">result</parameter> :</term>
295 <listitem><simpara>a <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link>.
296 </simpara></listitem>
299 <term><emphasis>Returns</emphasis> :</term>
300 <listitem><simpara><literal>True</literal> if the volume has been ejected
301 successfully, <literal>False</literal> otherwise.
302 </simpara></listitem>
307 The <methodname>eject_finish</methodname>() method finishes ejecting a volume.
308 If any errors occured during the operation, error will be set to contain the
309 errors and <literal>False</literal> will be returned.
313 <refsect2 id="method-giovolume--enumerate-identifiers">
314 <title>gio.Volume.enumerate_identifiers</title>
316 <programlisting><methodsynopsis language="python">
317 <methodname>enumerate_identifiers</methodname>
318 <methodparam></methodparam>
319 </methodsynopsis></programlisting>
323 <term><emphasis>Returns</emphasis> :</term>
324 <listitem><simpara>a list of strings containing kinds of identifiers.
325 </simpara></listitem>
330 The <methodname>enumerate_identifiers</methodname>() method gets the kinds
331 of identifiers that volume has. Use
332 <methodname><link linkend="method-giovolume--get-identifier">gio.Volume.get_identifier</link></methodname>()
333 to obtain the identifiers themselves.
337 <refsect2 id="method-giovolume--get-activation-root">
338 <title>gio.Volume.get_activation_root</title>
340 <programlisting><methodsynopsis language="python">
341 <methodname>get_activation_root</methodname>
342 <methodparam></methodparam>
343 </methodsynopsis></programlisting>
347 <term><emphasis>Returns</emphasis> :</term>
348 <listitem><simpara>the activation root of volume or <literal>None</literal>.
349 </simpara></listitem>
354 The <methodname>get_activation_root</methodname>() method gets the activation
355 root for a <link linkend="class-giovolume"><classname>gio.Volume</classname></link>
356 if it is known ahead of mount time. Returns <literal>None</literal> otherwise.
357 If not <literal>None</literal> and if volume is mounted, then the result of
358 <methodname><link linkend="method-giomount--get-root">gio.Mount.get_root</link></methodname>()
359 on the GMount object obtained from
360 <methodname><link linkend="method-giovolume--get-mount">gio.Volume.get_mount</link></methodname>()
361 will always either be equal or a prefix of what this function returns.
362 In other words, in code:
365 mount = volume.get_mount() # mounted, so never None
366 mount_root = mount.get_root()
367 volume_activation_root = volume.get_activation_root() # assume not None
373 volume_activation_root.has_prefix(mount_root) || volume_activation_root.equal(mount_root)
376 will always be <literal>True</literal>.
379 Activation roots are typically used in
380 <link linkend="class-giovolumemonitor"><classname>gio.VolumeMonitor</classname></link>
381 implementations to find the underlying mount to shadow, see
382 <methodname><link linkend="method-giomount--is-shadowed">gio.Mount.is_shadowed</link></methodname>()
387 <refsect2 id="method-giovolume--get-drive">
388 <title>gio.Volume.get_drive</title>
390 <programlisting><methodsynopsis language="python">
391 <methodname>get_drive</methodname>
392 <methodparam></methodparam>
393 </methodsynopsis></programlisting>
397 <term><emphasis>Returns</emphasis> :</term>
398 <listitem><simpara>A <link linkend="class-giodrive"><classname>gio.Drive</classname></link>
399 or <literal>None</literal> if volume is not associated with a drive.
400 </simpara></listitem>
405 The <methodname>get_drive</methodname>() method gets the drive for the volume.
409 <refsect2 id="method-giovolume--get-icon">
410 <title>gio.Volume.get_icon</title>
412 <programlisting><methodsynopsis language="python">
413 <methodname>get_icon</methodname>
414 <methodparam></methodparam>
415 </methodsynopsis></programlisting>
419 <term><emphasis>Returns</emphasis> :</term>
420 <listitem><simpara><link linkend="class-gioicon"><classname>gio.Icon</classname></link>
422 </simpara></listitem>
427 The <methodname>get_icon</methodname>() method gets the icon for volume.
431 <refsect2 id="method-giovolume--get-identifier">
432 <title>gio.Volume.get_identifier</title>
434 <programlisting><methodsynopsis language="python">
435 <methodname>get_identifier</methodname>
436 <methodparam></methodparam>
437 </methodsynopsis></programlisting>
441 <term><emphasis>Returns</emphasis> :</term>
442 <listitem><simpara>A string containing the requested identfier, or
443 <literal>None</literal> if the
444 <link linkend="class-giovolume"><classname>gio.Volume</classname></link>
445 doesn't have this kind of identifier.
446 </simpara></listitem>
451 The <methodname>get_identifier</methodname>() method gets the identifier of
452 the given kind for volume.
456 <refsect2 id="method-giovolume--get-mount">
457 <title>gio.Volume.get_mount</title>
459 <programlisting><methodsynopsis language="python">
460 <methodname>get_mount</methodname>
461 <methodparam></methodparam>
462 </methodsynopsis></programlisting>
466 <term><emphasis>Returns</emphasis> :</term>
468 <link linkend="class-giomount"><classname>gio.Mount</classname></link>
469 or <literal>None</literal> if volume isn't mounted.
470 </simpara></listitem>
475 The <methodname>get_mount</methodname>() method gets the mount for the volume.
479 <refsect2 id="method-giovolume--get-name">
480 <title>gio.Volume.get_name</title>
482 <programlisting><methodsynopsis language="python">
483 <methodname>get_name</methodname>
484 <methodparam></methodparam>
485 </methodsynopsis></programlisting>
489 <term><emphasis>Returns</emphasis> :</term>
490 <listitem><simpara>A string containing volume's name.
491 </simpara></listitem>
496 The <methodname>get_name</methodname>() method gets the name of volume.
500 <refsect2 id="method-giovolume--get-uuid">
501 <title>gio.Volume.get_uuid</title>
503 <programlisting><methodsynopsis language="python">
504 <methodname>get_uuid</methodname>
505 <methodparam></methodparam>
506 </methodsynopsis></programlisting>
510 <term><emphasis>Returns</emphasis> :</term>
511 <listitem><simpara>the UUID for volume or <literal>None</literal>
512 if no UUID can be computed.
513 </simpara></listitem>
518 The <methodname>get_uuid</methodname>() method gets the UUID for the volume.
519 The reference is typically based on the file system UUID for the volume in
520 question and should be considered an opaque string.
521 Returns <literal>None</literal> if there is no UUID available.
525 <refsect2 id="method-giovolume--mount">
526 <title>gio.Volume.mount</title>
528 <programlisting><methodsynopsis language="python">
529 <methodname>mount</methodname>
531 <parameter role="keyword">mount_operation</parameter>
534 <parameter role="keyword">callback</parameter>
537 <parameter role="keyword">flags</parameter><initializer><literal>gio.MOUNT_MOUNT_NONE</literal></initializer>
540 <parameter role="keyword">cancellable</parameter><initializer><literal>None</literal></initializer>
543 <parameter role="keyword">user_data</parameter><initializer><literal>None</literal></initializer>
545 </methodsynopsis></programlisting>
549 <term><parameter role="keyword">mount_operation</parameter> :</term>
551 <link linkend="class-giomountoperation"><classname>gio.MountOperation</classname></link>
552 or <literal>None</literal> to avoid user interaction.
553 </simpara></listitem>
556 <term><parameter role="keyword">callback</parameter> :</term>
557 <listitem><simpara>A GAsyncReadyCallback to call when the request is satisfied.
558 </simpara></listitem>
561 <term><parameter role="keyword">flags</parameter> :</term>
562 <listitem><simpara>Flags affecting the operation
563 </simpara></listitem>
566 <term><parameter role="keyword">cancellable</parameter> :</term>
567 <listitem><simpara>Optional
568 <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
569 object, <literal>None</literal> to ignore.
570 </simpara></listitem>
573 <term><parameter role="keyword">user_data</parameter> :</term>
574 <listitem><simpara>The data to pass to callback function.
575 </simpara></listitem>
580 The <methodname>mount</methodname>() method mounts a volume. This is an
581 asynchronous operation, and is finished by calling
582 <methodname><link linkend="method-giovolume--mount-finish">gio.Volume.mount_finish</link></methodname>()
583 with the volume and GAsyncResult returned in the callback.
587 <refsect2 id="method-giovolume--mount-finish">
588 <title>gio.Volume.mount_finish</title>
590 <programlisting><methodsynopsis language="python">
591 <methodname>mount_finish</methodname>
592 <methodparam><parameter role="keyword">result</parameter></methodparam>
593 </methodsynopsis></programlisting>
597 <term><parameter role="keyword">result</parameter> :</term>
598 <listitem><simpara>a <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link>.
599 </simpara></listitem>
602 <term><emphasis>Returns</emphasis> :</term>
603 <listitem><simpara><literal>True</literal> if the volume has been mounted
604 successfully, <literal>False</literal> otherwise.
605 </simpara></listitem>
610 The <methodname>mounted</methodname>() method finishes mounting a volume.
611 If any errors occured during the operation, error will be set to contain
612 the errors and <literal>False</literal> will be returned.
615 If the mount operation succeeded,
616 <methodname><link linkend="method-giovolume--get-mount">get_mount</link></methodname>()
617 on volume is guaranteed to return the mount right after calling this function;
618 there's no need to listen for the 'mount-added' signal on
619 <link linkend="class-giovolumemonitor"><classname>gio.VolumeMonitor</classname></link>.
623 <refsect2 id="method-giovolume--should-automount">
624 <title>gio.Volume.should_automount</title>
626 <programlisting><methodsynopsis language="python">
627 <methodname>should_automount</methodname>
628 <methodparam></methodparam>
629 </methodsynopsis></programlisting>
633 <term><emphasis>Returns</emphasis> :</term>
634 <listitem><simpara><literal>True</literal> if the volume should
635 be automatically mounted.
636 </simpara></listitem>
641 The <methodname>should_automount</methodname>() method returns whether
642 the volume should be automatically mounted.
648 <title>Signals</title>
650 <refsect2 id="signal-giovolume--changed">
651 <title>The "changed" gio.Volume Signal</title>
653 <programlisting><methodsynopsis language="python"><methodname>callback</methodname>
654 <methodparam><parameter>volume</parameter></methodparam>
655 <methodparam><parameter>user_param1</parameter></methodparam>
656 <methodparam><parameter>...</parameter></methodparam>
657 </methodsynopsis></programlisting>
661 <term><parameter>volume</parameter> :</term>
662 <listitem><simpara>the volume</simpara></listitem>
665 <term><parameter>user_param1</parameter> :</term>
666 <listitem><simpara>the first user parameter (if any) specified
668 linkend="method-gobject--connect"><methodname>connect</methodname>()</link>
669 method</simpara></listitem>
672 <term><parameter>...</parameter> :</term>
673 <listitem><simpara>additional user parameters (if any)</simpara></listitem>
678 Emitted when the volume has been changed.
682 <refsect2 id="signal-giovolume--removed">
683 <title>The "removed" gio.Volume Signal</title>
685 <programlisting><methodsynopsis language="python"><methodname>callback</methodname>
686 <methodparam><parameter>volume</parameter></methodparam>
687 <methodparam><parameter>user_param1</parameter></methodparam>
688 <methodparam><parameter>...</parameter></methodparam>
689 </methodsynopsis></programlisting>
693 <term><parameter>volume</parameter> :</term>
694 <listitem><simpara>the volume</simpara></listitem>
697 <term><parameter>user_param1</parameter> :</term>
698 <listitem><simpara>the first user parameter (if any) specified
700 linkend="method-gobject--connect"><methodname>connect</methodname>()</link>
701 method</simpara></listitem>
704 <term><parameter>...</parameter> :</term>
705 <listitem><simpara>additional user parameters (if any)</simpara></listitem>
710 This signal is emitted when the
711 <link linkend="class-giovolume"><classname>gio.Volume</classname></link>
712 have been removed. If the recipient is holding references to the object
713 they should release them so the object can be finalized.