Gcr.Prompt

g GObject.GInterface GObject.GInterface Gcr.Prompt Gcr.Prompt GObject.GInterface->Gcr.Prompt

Implementations:

Gcr.SystemPrompt

Methods

close ()

confirm (cancellable)

confirm_async (cancellable, callback, *user_data)

confirm_finish (result)

confirm_run (cancellable)

get_caller_window ()

get_cancel_label ()

get_choice_chosen ()

get_choice_label ()

get_continue_label ()

get_description ()

get_message ()

get_password_new ()

get_password_strength ()

get_title ()

get_warning ()

password (cancellable)

password_async (cancellable, callback, *user_data)

password_finish (result)

password_run (cancellable)

reset ()

set_caller_window (window_id)

set_cancel_label (cancel_label)

set_choice_chosen (chosen)

set_choice_label (choice_label)

set_continue_label (continue_label)

set_description (description)

set_message (message)

set_password_new (new_password)

set_title (title)

set_warning (warning)

Virtual Methods

do_prompt_close ()

do_prompt_confirm_async (cancellable, callback, *user_data)

do_prompt_confirm_finish (result)

do_prompt_password_async (cancellable, callback, *user_data)

do_prompt_password_finish (result)

Properties

Name

Type

Flags

Short Description

caller-window

str

r/w/c

Window ID of application window requesting prompt

cancel-label

str

r/w/c

Cancel button label

choice-chosen

bool

r/w

Whether prompt choice is chosen

choice-label

str

r/w/c

Label for prompt choice

continue-label

str

r/w/c

Continue button label

description

str

r/w/c

Prompt description

message

str

r/w/c

Prompt message

password-new

bool

r/w

Whether prompting for a new password

password-strength

int

r

String of new password

title

str

r/w/c

Prompt title

warning

str

r/w/c

Prompt warning

Signals

Name

Short Description

prompt-close

Action signal fired when the prompt is to be closed.

Fields

None

Class Details

class Gcr.Prompt
Bases:

GObject.GInterface

Structure:

Gcr.PromptInterface

A prompt displayed to the user. It is an interface with various implementations.

Various properties are set on the prompt, and then the prompt is displayed the various prompt methods like [method`Prompt`.password_run].

A GcrPrompt may be used to display multiple related prompts. Most implementions do not hide the window between display of multiple related prompts, and the Gcr.Prompt must be closed or destroyed in order to make it go away. This allows the user to see that the prompts are related.

Use GcrPromptDialog (part of gcr-ui) to create an in-process GTK+ dialog prompt. Use [class`SystemPrompt`] to create a system prompt in a prompter process.

The prompt implementation will always display the [property`Prompt`:py:data::message<Gcr.Prompt.props.message>] property, but may choose not to display the [property`Prompt`:py:data::description<Gcr.Prompt.props.description>] or [property`Prompt`:py:data::title<Gcr.Prompt.props.title>] properties.

close()[source]

Closes the prompt so that in can no longer be used to prompt. The various prompt methods will return results as if the user dismissed the prompt.

The prompt may also be closed by the implementor of the prompt object.

This emits the [signal`Prompt`:py:func:::prompt-close<Gcr.Prompt.signals.prompt_close>] signal on the prompt object.

confirm(cancellable)[source]
Parameters:

cancellable (Gio.Cancellable or None) – optional cancellation object

Raises:

GLib.Error

Returns:

the reply from the prompt

Return type:

Gcr.PromptReply

Prompts for confirmation asking a cancel/continue style question. Set the various properties on the prompt before calling this function to represent the question correctly.

This method will block until the a response is returned from the prompter.

Gcr.PromptReply.CONTINUE will be returned if the user confirms the prompt. The return value will also be Gcr.PromptReply.CANCEL if the user cancels or if an error occurs. Check the error argument to tell the difference.

confirm_async(cancellable, callback, *user_data)[source]
Parameters:

Prompts for confirmation asking a cancel/continue style question. Set the various properties on the prompt before calling this method to represent the question correctly.

This method will return immediately and complete asynchronously.

confirm_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – asynchronous result passed to callback

Raises:

GLib.Error

Returns:

the reply from the prompt

Return type:

Gcr.PromptReply

Complete an operation to prompt for confirmation.

Gcr.PromptReply.CONTINUE will be returned if the user confirms the prompt. The return value will also be Gcr.PromptReply.CANCEL if the user cancels or if an error occurs. Check the error argument to tell the difference.

confirm_run(cancellable)[source]
Parameters:

cancellable (Gio.Cancellable or None) – optional cancellation object

Raises:

GLib.Error

Returns:

the reply from the prompt

Return type:

Gcr.PromptReply

Prompts for confirmation asking a cancel/continue style question. Set the various properties on the prompt before calling this function to represent the question correctly.

This method will block until the a response is returned from the prompter and will run a main loop similar to a gtk_dialog_run(). The application will remain responsive but care must be taken to handle reentrancy issues.

Gcr.PromptReply.CONTINUE will be returned if the user confirms the prompt. The return value will also be Gcr.PromptReply.CANCEL if the user cancels or if an error occurs. Check the error argument to tell the difference.

get_caller_window()[source]
Returns:

a newly allocated string containing the string handle of the window.

Return type:

str

Get the string handle of the caller’s window.

The caller window indicates to the prompt which window is prompting the user. The prompt may choose to ignore this information or use it in whatever way it sees fit.

get_cancel_label()[source]
Returns:

a newly allocated string containing the label

Return type:

str

Get the label for the cancel button.

This is the button that results in a Gcr.PromptReply.CANCEL reply from the prompt.

get_choice_chosen()[source]
Returns:

whether chosen

Return type:

bool

Get whether the additional choice was chosen or not.

The additional choice would have been setup using Gcr.Prompt.set_choice_label().

get_choice_label()[source]
Returns:

a newly allocated string containing the additional choice or None

Return type:

str

Get the label for the additional choice.

This will be None if no additional choice is being displayed.

get_continue_label()[source]
Returns:

a newly allocated string containing the label

Return type:

str

Get the label for the continue button.

This is the button that results in a Gcr.PromptReply.CONTINUE reply from the prompt.

get_description()[source]
Returns:

a newly allocated string containing the detailed description of the prompt

Return type:

str

Get the detailed description of the prompt.

A prompt implementation may choose not to display this detailed description. The prompt message should contain relevant information.

get_message()[source]
Returns:

a newly allocated string containing the detailed description of the prompt

Return type:

str

Gets the prompt message for the user.

A prompt implementation should always display this message.

get_password_new()[source]
Returns:

whether in new password mode or not

Return type:

bool

Get whether the prompt will prompt for a new password.

This will cause the prompt implementation to ask the user to confirm the password and/or display other relevant user interface for creating a new password.

get_password_strength()[source]
Returns:

zero if the password is empty, greater than zero if not

Return type:

int

Get indication of the password strength.

Prompts will return a zero value if the password is empty, and a value greater than zero if the password has any characters.

This is only valid after a successful prompt for a password.

get_title()[source]
Returns:

a newly allocated string containing the prompt title.

Return type:

str

Gets the title of the prompt.

A prompt implementation may choose not to display the prompt title. The prompt message should contain relevant information.

get_warning()[source]
Returns:

a newly allocated string containing the prompt warning, or None if no warning

Return type:

str

Get a prompt warning displayed on the prompt.

This is a warning like “The password is incorrect.” usually displayed to the user about a previous ‘unsuccessful’ prompt.

If this string is None then no warning is displayed.

password(cancellable)[source]
Parameters:

cancellable (Gio.Cancellable or None) – optional cancellation object

Raises:

GLib.Error

Returns:

the password owned by the prompt, or None

Return type:

str

Prompts for password. Set the various properties on the prompt before calling this method to explain which password should be entered.

This method will block until the a response is returned from the prompter.

A password will be returned if the user enters a password successfully. The returned password is valid until the next time a method is called to display another prompt.

None will be returned if the user cancels or if an error occurs. Check the error argument to tell the difference.

password_async(cancellable, callback, *user_data)[source]
Parameters:

Prompts for password. Set the various properties on the prompt before calling this method to explain which password should be entered.

This method will return immediately and complete asynchronously.

password_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – asynchronous result passed to callback

Raises:

GLib.Error

Returns:

the password owned by the prompt, or None

Return type:

str

Complete an operation to prompt for a password.

A password will be returned if the user enters a password successfully. The returned password is valid until the next time a method is called to display another prompt.

None will be returned if the user cancels or if an error occurs. Check the error argument to tell the difference.

password_run(cancellable)[source]
Parameters:

cancellable (Gio.Cancellable or None) – optional cancellation object

Raises:

GLib.Error

Returns:

the password owned by the prompt, or None

Return type:

str

Prompts for password. Set the various properties on the prompt before calling this method to explain which password should be entered.

This method will block until the a response is returned from the prompter and will run a main loop similar to a gtk_dialog_run(). The application will remain responsive but care must be taken to handle reentrancy issues.

A password will be returned if the user enters a password successfully. The returned password is valid until the next time a method is called to display another prompt.

None will be returned if the user cancels or if an error occurs. Check the error argument to tell the difference.

reset()[source]

Reset the contents and properties of the prompt.

set_caller_window(window_id)[source]
Parameters:

window_id (str) – the window id

Set the string handle of the caller’s window.

The caller window indicates to the prompt which window is prompting the user. The prompt may choose to ignore this information or use it in whatever way it sees fit.

set_cancel_label(cancel_label)[source]
Parameters:

cancel_label (str) – the label

Set the label for the continue button.

This is the button that results in a Gcr.PromptReply.CANCEL reply from the prompt.

set_choice_chosen(chosen)[source]
Parameters:

chosen (bool) – whether chosen

Set whether the additional choice is chosen or not.

The additional choice should be set up using Gcr.Prompt.set_choice_label().

set_choice_label(choice_label)[source]
Parameters:

choice_label (str or None) – the additional choice or None

Set the label for the additional choice.

If this is a non-None value then an additional boolean choice will be displayed by the prompt allowing the user to select or deselect it.

The initial value of the choice can be set with the Gcr.Prompt.set_choice_label() method.

If this is None, then no additional choice is being displayed.

set_continue_label(continue_label)[source]
Parameters:

continue_label (str) – the label

Set the label for the continue button.

This is the button that results in a Gcr.PromptReply.CONTINUE reply from the prompt.

set_description(description)[source]
Parameters:

description (str) – the detailed description

Set the detailed description of the prompt.

A prompt implementation may choose not to display this detailed description. Use Gcr.Prompt.set_message() to set a general message containing relevant information.

set_message(message)[source]
Parameters:

message (str) – the prompt message

Sets the prompt message for the user.

A prompt implementation should always display this message.

set_password_new(new_password)[source]
Parameters:

new_password (bool) – whether in new password mode or not

Set whether the prompt will prompt for a new password.

This will cause the prompt implementation to ask the user to confirm the password and/or display other relevant user interface for creating a new password.

set_title(title)[source]
Parameters:

title (str) – the prompt title

Sets the title of the prompt.

A prompt implementation may choose not to display the prompt title. The prompt message should contain relevant information.

set_warning(warning)[source]
Parameters:

warning (str or None) – the warning or None

Set a prompt warning displayed on the prompt.

This is a warning like “The password is incorrect.” usually displayed to the user about a previous ‘unsuccessful’ prompt.

If this string is None then no warning is displayed.

do_prompt_close() virtual
do_prompt_confirm_async(cancellable, callback, *user_data) virtual
Parameters:

Prompts for confirmation asking a cancel/continue style question. Set the various properties on the prompt before calling this method to represent the question correctly.

This method will return immediately and complete asynchronously.

do_prompt_confirm_finish(result) virtual
Parameters:

result (Gio.AsyncResult) – asynchronous result passed to callback

Returns:

the reply from the prompt

Return type:

Gcr.PromptReply

Complete an operation to prompt for confirmation.

Gcr.PromptReply.CONTINUE will be returned if the user confirms the prompt. The return value will also be Gcr.PromptReply.CANCEL if the user cancels or if an error occurs. Check the error argument to tell the difference.

do_prompt_password_async(cancellable, callback, *user_data) virtual
Parameters:

Prompts for password. Set the various properties on the prompt before calling this method to explain which password should be entered.

This method will return immediately and complete asynchronously.

do_prompt_password_finish(result) virtual
Parameters:

result (Gio.AsyncResult) – asynchronous result passed to callback

Returns:

the password owned by the prompt, or None

Return type:

str

Complete an operation to prompt for a password.

A password will be returned if the user enters a password successfully. The returned password is valid until the next time a method is called to display another prompt.

None will be returned if the user cancels or if an error occurs. Check the error argument to tell the difference.

Signal Details

Gcr.Prompt.signals.prompt_close(prompt)
Signal Name:

prompt-close

Flags:

RUN_FIRST

Parameters:

prompt (Gcr.Prompt) – The object which received the signal

Action signal fired when the prompt is to be closed. After the default handler has run, the prompt is closed. The various prompting methods will return results as if the user dismissed the prompt.

You can use the [method`Prompt`.close] method to emit this signal.

Property Details

Gcr.Prompt.props.caller_window
Name:

caller-window

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The string handle of the caller’s window.

The caller window indicates to the prompt which window is prompting the user. The prompt may choose to ignore this information or use it in whatever way it sees fit.

In X11, this will be a stringified version of the XWindow handle; in Wayland this is the result of an export using the XDG foreign protocol.

Gcr.Prompt.props.cancel_label
Name:

cancel-label

Type:

str

Default Value:

'Cancel'

Flags:

READABLE, WRITABLE, CONSTRUCT

The label for the cancel button in the prompt.

Gcr.Prompt.props.choice_chosen
Name:

choice-chosen

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the additional choice is chosen or not.

The additional choice would have been setup using Gcr.Prompt :choice-label.

Gcr.Prompt.props.choice_label
Name:

choice-label

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The label for the additional choice.

If this is a non-None value then an additional boolean choice will be displayed by the prompt allowing the user to select or deselect it.

If None, then no additional choice is displayed.

The initial value of the choice can be set with Gcr.Prompt :choice-chosen.

Gcr.Prompt.props.continue_label
Name:

continue-label

Type:

str

Default Value:

'Continue'

Flags:

READABLE, WRITABLE, CONSTRUCT

The label for the continue button in the prompt.

Gcr.Prompt.props.description
Name:

description

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The detailed description of the prompt.

A prompt implementation may choose not to display this detailed description. The prompt message should contain relevant information.

Gcr.Prompt.props.message
Name:

message

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The prompt message for the user.

A prompt implementation should always display this message.

Gcr.Prompt.props.password_new
Name:

password-new

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the prompt will prompt for a new password.

This will cause the prompt implementation to ask the user to confirm the password and/or display other relevant user interface for creating a new password.

Gcr.Prompt.props.password_strength
Name:

password-strength

Type:

int

Default Value:

0

Flags:

READABLE

Indication of the password strength.

Prompts will return a zero value if the password is empty, and a value greater than zero if the password has any characters.

This is only valid after a successful prompt for a password.

Gcr.Prompt.props.title
Name:

title

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The title of the prompt.

A prompt implementation may choose not to display the prompt title. The Gcr.Prompt :message should contain relevant information.

Gcr.Prompt.props.warning
Name:

warning

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

A prompt warning displayed on the prompt, or None for no warning.

This is a warning like “The password is incorrect.” usually displayed to the user about a previous ‘unsuccessful’ prompt.