Gcr.Prompt¶
- Implementations:
Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
|
|
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/c |
Window ID of application window requesting prompt |
||
r/w/c |
Cancel button label |
||
r/w |
Whether prompt choice is chosen |
||
r/w/c |
Label for prompt choice |
||
r/w/c |
Continue button label |
||
r/w/c |
Prompt description |
||
r/w/c |
Prompt message |
||
r/w |
Whether prompting for a new password |
||
r |
String of new password |
||
r/w/c |
Prompt title |
||
r/w/c |
Prompt warning |
Signals¶
Name |
Short Description |
---|---|
Action signal fired when the prompt is to be closed. |
Fields¶
None
Class Details¶
- class Gcr.Prompt¶
- Bases:
- Structure:
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 theGcr.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
orNone
) – optional cancellation object- Raises:
- Returns:
the reply from the prompt
- Return type:
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 beGcr.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:
cancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
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:
- Returns:
the reply from the prompt
- Return type:
Complete an operation to prompt for confirmation.
Gcr.PromptReply.CONTINUE
will be returned if the user confirms the prompt. The return value will also beGcr.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
orNone
) – optional cancellation object- Raises:
- Returns:
the reply from the prompt
- Return type:
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 beGcr.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:
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:
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:
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]¶
-
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:
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:
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:
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:
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:
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:
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:
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
orNone
) – optional cancellation object- Raises:
- Returns:
the password owned by the prompt, or
None
- Return type:
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:
cancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
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:
- Returns:
the password owned by the prompt, or
None
- Return type:
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
orNone
) – optional cancellation object- Raises:
- Returns:
the password owned by the prompt, or
None
- Return type:
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.
- 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]¶
-
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]¶
-
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:
cancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
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:
Complete an operation to prompt for confirmation.
Gcr.PromptReply.CONTINUE
will be returned if the user confirms the prompt. The return value will also beGcr.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:
cancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
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:
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:
- 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¶
-
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¶
-
The label for the cancel button in the prompt.
- Gcr.Prompt.props.choice_chosen¶
-
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¶
-
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¶
-
The label for the continue button in the prompt.
- Gcr.Prompt.props.description¶
-
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¶
-
The prompt message for the user.
A prompt implementation should always display this message.
- Gcr.Prompt.props.password_new¶
-
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¶
-
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¶
-
The title of the prompt.
A prompt implementation may choose not to display the prompt title. The
Gcr.Prompt
:message
should contain relevant information.