Skip to content

Gio.MountOperation

class — extends GObject.Object

GMountOperation provides a mechanism for interacting with the user. It can be used for authenticating mountable operations, such as loop mounting files, hard drive partitions or server locations. It can also be used to ask the user questions or show a list of applications preventing unmount or eject operations from completing.

Note that GMountOperation is used for more than just Mount objects – for example it is also used in Drive.start and Drive.stop.

Users should instantiate a subclass of this that implements all the various callbacks to show the required dialogs, such as GtkMountOperation. If no user interaction is desired (for example when automounting filesystems at login time), usually NULL can be passed, see each method taking a GMountOperation for details.

Throughout the API, the term ‘TCRYPT’ is used to mean ‘compatible with TrueCrypt and VeraCrypt’. TrueCrypt is a discontinued system for encrypting file containers, partitions or whole disks, typically used with Windows. VeraCrypt is a maintained fork of TrueCrypt with various improvements and auditing fixes.

Constructors

new

@classmethod
def new(cls) -> MountOperation

Creates a new mount operation.

Methods

get_anonymous

def get_anonymous(self) -> bool

Check to see whether the mount operation is being used for an anonymous user.

get_choice

def get_choice(self) -> int

Gets a choice from the mount operation.

get_domain

def get_domain(self) -> str | None

Gets the domain of the mount operation.

get_is_tcrypt_hidden_volume

def get_is_tcrypt_hidden_volume(self) -> bool

Check to see whether the mount operation is being used for a TCRYPT hidden volume.

get_is_tcrypt_system_volume

def get_is_tcrypt_system_volume(self) -> bool

Check to see whether the mount operation is being used for a TCRYPT system volume.

get_password

def get_password(self) -> str | None

Gets a password from the mount operation.

get_password_save

def get_password_save(self) -> PasswordSave

Gets the state of saving passwords for the mount operation.

get_pim

def get_pim(self) -> int

Gets a PIM from the mount operation.

get_username

def get_username(self) -> str | None

Get the user name from the mount operation.

reply

def reply(self, result: MountOperationResult | int) -> None

Emits the MountOperation::reply signal.

Parameters:

set_anonymous

def set_anonymous(self, anonymous: bool) -> None

Sets the mount operation to use an anonymous user if anonymous is True.

Parameters:

  • anonymous — boolean value.

set_choice

def set_choice(self, choice: int) -> None

Sets a default choice for the mount operation.

Parameters:

  • choice — an integer.

set_domain

def set_domain(self, domain: str | None = ...) -> None

Sets the mount operation's domain.

Parameters:

  • domain — the domain to set.

set_is_tcrypt_hidden_volume

def set_is_tcrypt_hidden_volume(self, hidden_volume: bool) -> None

Sets the mount operation to use a hidden volume if hidden_volume is True.

Parameters:

  • hidden_volume — boolean value.

set_is_tcrypt_system_volume

def set_is_tcrypt_system_volume(self, system_volume: bool) -> None

Sets the mount operation to use a system volume if system_volume is True.

Parameters:

  • system_volume — boolean value.

set_password

def set_password(self, password: str | None = ...) -> None

Sets the mount operation's password to password.

Parameters:

  • password — password to set.

set_password_save

def set_password_save(self, save: PasswordSave | int) -> None

Sets the state of saving passwords for the mount operation.

Parameters:

set_pim

def set_pim(self, pim: int) -> None

Sets the mount operation's PIM to pim.

Parameters:

  • pim — an unsigned integer.

set_username

def set_username(self, username: str | None = ...) -> None

Sets the user name within op to username.

Parameters:

  • username — input username.

Virtual methods

do_aborted

def do_aborted(self) -> None

do_ask_password

def do_ask_password(self, message: str, default_user: str, default_domain: str, flags: AskPasswordFlags | int) -> None

do_ask_question

def do_ask_question(self, message: str, choices: list[str]) -> None

Virtual implementation of MountOperation::ask-question.

Parameters:

  • message — string containing a message to display to the user
  • choices — an array of strings for each possible choice

do_reply

def do_reply(self, result: MountOperationResult | int) -> None

Emits the MountOperation::reply signal.

Parameters:

do_show_processes

def do_show_processes(self, message: str, processes: list[GLib.Pid], choices: list[str]) -> None

Virtual implementation of MountOperation::show-processes.

Parameters:

  • message — string containing a message to display to the user
  • processes — an array of GPid for processes blocking the operation
  • choices — an array of strings for each possible choice

do_show_unmount_progress

def do_show_unmount_progress(self, message: str, time_left: int, bytes_left: int) -> None

Properties

anonymous

anonymous: bool  # read/write

Whether to use an anonymous user when authenticating.

choice

choice: int  # read/write

The index of the user's choice when a question is asked during the mount operation. See the MountOperation::ask-question signal.

domain

domain: str  # read/write

The domain to use for the mount operation.

is_tcrypt_hidden_volume

is_tcrypt_hidden_volume: bool  # read/write

Whether the device to be unlocked is a TCRYPT hidden volume. See the VeraCrypt documentation.

is_tcrypt_system_volume

is_tcrypt_system_volume: bool  # read/write

Whether the device to be unlocked is a TCRYPT system volume. In this context, a system volume is a volume with a bootloader and operating system installed. This is only supported for Windows operating systems. For further documentation, see the VeraCrypt documentation.

password

password: str  # read/write

The password that is used for authentication when carrying out the mount operation.

password_save

password_save: PasswordSave | int  # read/write

Determines if and how the password information should be saved.

pim

pim: int  # read/write

The VeraCrypt PIM value, when unlocking a VeraCrypt volume. See the VeraCrypt documentation.

username

username: str  # read/write

The user name that is used for authentication when carrying out the mount operation.

Signals

aborted

def on_aborted(self) -> None: ...

Emitted by the backend when e.g. a device becomes unavailable while a mount operation is in progress.

Implementations of GMountOperation should handle this signal by dismissing open password dialogs.

ask-password

def on_ask_password(self, message: str, default_user: str, default_domain: str, flags: AskPasswordFlags) -> None: ...

Emitted when a mount operation asks the user for a password.

If the message contains a line break, the first line should be presented as a heading. For example, it may be used as the primary text in a Gtk.MessageDialog.

ask-question

def on_ask_question(self, message: str, choices: list[str]) -> None: ...

Emitted when asking the user a question and gives a list of choices for the user to choose from.

If the message contains a line break, the first line should be presented as a heading. For example, it may be used as the primary text in a Gtk.MessageDialog.

reply

def on_reply(self, result: MountOperationResult) -> None: ...

Emitted when the user has replied to the mount operation.

show-processes

def on_show_processes(self, message: str, processes: list[GLib.Pid], choices: list[str]) -> None: ...

Emitted when one or more processes are blocking an operation e.g. unmounting/ejecting a Mount or stopping a Drive.

Note that this signal may be emitted several times to update the list of blocking processes as processes close files. The application should only respond with MountOperation.reply to the latest signal (setting MountOperation:choice to the choice the user made).

If the message contains a line break, the first line should be presented as a heading. For example, it may be used as the primary text in a Gtk.MessageDialog.

show-unmount-progress

def on_show_unmount_progress(self, message: str, time_left: int, bytes_left: int) -> None: ...

Emitted when an unmount operation has been busy for more than some time (typically 1.5 seconds).

When unmounting or ejecting a volume, the kernel might need to flush pending data in its buffers to the volume stable storage, and this operation can take a considerable amount of time. This signal may be emitted several times as long as the unmount operation is outstanding, and then one last time when the operation is completed, with bytes_left set to zero.

Implementations of GMountOperation should handle this signal by showing an UI notification, and then dismiss it, or show another notification of completion, when bytes_left reaches zero.

If the message contains a line break, the first line should be presented as a heading. For example, it may be used as the primary text in a Gtk.MessageDialog.