## GcrPrompt

GcrPrompt — a user prompt

## Synopsis

                        GcrPrompt;
    struct              GcrPromptIface;
    enum                GcrPromptReply;
    const gchar *       gcr_prompt_password                 (GcrPrompt *prompt,
                                                             GCancellable *cancellable,
                                                             GError **error);
    void                gcr_prompt_password_async           (GcrPrompt *prompt,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    const gchar *       gcr_prompt_password_finish          (GcrPrompt *prompt,
                                                             GAsyncResult *result,
                                                             GError **error);
    const gchar *       gcr_prompt_password_run             (GcrPrompt *prompt,
                                                             GCancellable *cancellable,
                                                             GError **error);
    GcrPromptReply      gcr_prompt_confirm                  (GcrPrompt *prompt,
                                                             GCancellable *cancellable,
                                                             GError **error);
    void                gcr_prompt_confirm_async            (GcrPrompt *prompt,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    GcrPromptReply      gcr_prompt_confirm_finish           (GcrPrompt *prompt,
                                                             GAsyncResult *result,
                                                             GError **error);
    GcrPromptReply      gcr_prompt_confirm_run              (GcrPrompt *prompt,
                                                             GCancellable *cancellable,
                                                             GError **error);
    void                gcr_prompt_reset                    (GcrPrompt *prompt);
    gchar *             gcr_prompt_get_title                (GcrPrompt *prompt);
    void                gcr_prompt_set_title                (GcrPrompt *prompt,
                                                             const gchar *title);
    gchar *             gcr_prompt_get_message              (GcrPrompt *prompt);
    void                gcr_prompt_set_message              (GcrPrompt *prompt,
                                                             const gchar *message);
    gchar *             gcr_prompt_get_description          (GcrPrompt *prompt);
    void                gcr_prompt_set_description          (GcrPrompt *prompt,
                                                             const gchar *description);
    gchar *             gcr_prompt_get_warning              (GcrPrompt *prompt);
    void                gcr_prompt_set_warning              (GcrPrompt *prompt,
                                                             const gchar *warning);
    gchar *             gcr_prompt_get_continue_label       (GcrPrompt *prompt);
    void                gcr_prompt_set_continue_label       (GcrPrompt *prompt,
                                                             const gchar *continue_label);
    gchar *             gcr_prompt_get_cancel_label         (GcrPrompt *prompt);
    void                gcr_prompt_set_cancel_label         (GcrPrompt *prompt,
                                                             const gchar *cancel_label);
    gchar *             gcr_prompt_get_choice_label         (GcrPrompt *prompt);
    void                gcr_prompt_set_choice_label         (GcrPrompt *prompt,
                                                             const gchar *choice_label);
    gboolean            gcr_prompt_get_choice_chosen        (GcrPrompt *prompt);
    void                gcr_prompt_set_choice_chosen        (GcrPrompt *prompt,
                                                             gboolean chosen);
    gboolean            gcr_prompt_get_password_new         (GcrPrompt *prompt);
    void                gcr_prompt_set_password_new         (GcrPrompt *prompt,
                                                             gboolean new_password);
    gint                gcr_prompt_get_password_strength    (GcrPrompt *prompt);
    gchar *             gcr_prompt_get_caller_window        (GcrPrompt *prompt);
    void                gcr_prompt_set_caller_window        (GcrPrompt *prompt,
                                                             const gchar *window_id);

## Object Hierarchy

      GInterface
       +----GcrPrompt

## Prerequisites

GcrPrompt requires GObject.

## Known Implementations

GcrPrompt is implemented by GcrPromptDialog and GcrSystemPrompt.

## Properties

      "caller-window"            gchar*                : Read / Write / Construct
      "cancel-label"             gchar*                : Read / Write / Construct
      "choice-chosen"            gboolean              : Read / Write
      "choice-label"             gchar*                : Read / Write / Construct
      "continue-label"           gchar*                : Read / Write / Construct
      "description"              gchar*                : Read / Write / Construct
      "message"                  gchar*                : Read / Write / Construct
      "password-new"             gboolean              : Read / Write
      "password-strength"        gint                  : Read
      "title"                    gchar*                : Read / Write / Construct
      "warning"                  gchar*                : Read / Write / Construct

## Description

A GcrPrompt represents 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 `gcr_prompt_password_run()`.

A GcrPrompt may be used to display multiple related prompts. Most implemantions do not hide the window between display of multiple related prompts, and the GcrPrompt 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 to create an in-process GTK+ dialog prompt. Use GcrSystemPrompt to create a system prompt in a prompter process.

The prompt implementation will always display the GcrPrompt:message property, but may choose not to display the GcrPrompt:description or GcrPrompt:title properties.

## Details

### GcrPrompt

    typedef struct _GcrPrompt GcrPrompt;

Represents a GcrPrompt displayed to the user.

### struct GcrPromptIface

    struct GcrPromptIface {
    	GTypeInterface parent_iface;

    	void               (* prompt_password_async)    (GcrPrompt *prompt,
    	                                                 GCancellable *cancellable,
    	                                                 GAsyncReadyCallback callback,
    	                                                 gpointer user_data);

    	const gchar *      (* prompt_password_finish)   (GcrPrompt *prompt,
    	                                                 GAsyncResult *result,
    	                                                 GError **error);

    	void               (* prompt_confirm_async)     (GcrPrompt *prompt,
    	                                                 GCancellable *cancellable,
    	                                                 GAsyncReadyCallback callback,
    	                                                 gpointer user_data);

    	GcrPromptReply     (* prompt_confirm_finish)    (GcrPrompt *prompt,
    	                                                 GAsyncResult *result,
    	                                                 GError **error);
    };

The interface for implementing GcrPrompt.

GTypeInterface `parent_iface`; | parent interface
`prompt_password_async` () | begin a password prompt
`prompt_password_finish` () | complete a password prompt
`prompt_confirm_async` () | begin a confirm prompt
`prompt_confirm_finish` () | complete a confirm prompt

### enum GcrPromptReply

    typedef enum {
    	GCR_PROMPT_REPLY_CANCEL = 0,
    	GCR_PROMPT_REPLY_CONTINUE = 1,
    } GcrPromptReply;

Various replies returned by `gcr_prompt_confirm()` and friends.

`GCR_PROMPT_REPLY_CANCEL` | the prompt was cancelled
`GCR_PROMPT_REPLY_CONTINUE` | the user replied with 'ok'

### gcr_prompt_password ()

    const gchar *       gcr_prompt_password                 (GcrPrompt *prompt,
                                                             GCancellable *cancellable,
                                                             GError **error);

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.

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

`prompt` : | a prompt
`cancellable` : | optional cancellation object
`error` : | location to place error on failure
Returns : | the password owned by the prompt, or `NULL`

### gcr_prompt_password_async ()

    void                gcr_prompt_password_async           (GcrPrompt *prompt,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

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.

`prompt` : | a prompt
`cancellable` : | optional cancellation object
`callback` : | called when the operation completes
`user_data` : | data to pass to the callback

### gcr_prompt_password_finish ()

    const gchar *       gcr_prompt_password_finish          (GcrPrompt *prompt,
                                                             GAsyncResult *result,
                                                             GError **error);

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.

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

`prompt` : | a prompt
`result` : | asynchronous result passed to callback
`error` : | location to place error on failure
Returns : | the password owned by the prompt, or `NULL`

### gcr_prompt_password_run ()

    const gchar *       gcr_prompt_password_run             (GcrPrompt *prompt,
                                                             GCancellable *cancellable,
                                                             GError **error);

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.

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

`prompt` : | a prompt
`cancellable` : | optional cancellation object
`error` : | location to place error on failure
Returns : | the password owned by the prompt, or `NULL`

### gcr_prompt_confirm ()

    GcrPromptReply      gcr_prompt_confirm                  (GcrPrompt *prompt,
                                                             GCancellable *cancellable,
                                                             GError **error);

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_PROMPT_REPLY_OK` will be returned if the user confirms the prompt. The return value will also be `GCR_PROMPT_REPLY_CANCEL` if the user cancels or if an error occurs. Check the `error` argument to tell the difference.

`prompt` : | a prompt
`cancellable` : | optional cancellation object
`error` : | location to place error on failure
Returns : | the reply from the prompt

### gcr_prompt_confirm_async ()

    void                gcr_prompt_confirm_async            (GcrPrompt *prompt,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

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.

`prompt` : | a prompt
`cancellable` : | optional cancellation object
`callback` : | called when the operation completes
`user_data` : | data to pass to the callback

### gcr_prompt_confirm_finish ()

    GcrPromptReply      gcr_prompt_confirm_finish           (GcrPrompt *prompt,
                                                             GAsyncResult *result,
                                                             GError **error);

Complete an operation to prompt for confirmation.

`GCR_PROMPT_REPLY_OK` will be returned if the user confirms the prompt. The return value will also be `GCR_PROMPT_REPLY_CANCEL` if the user cancels or if an error occurs. Check the `error` argument to tell the difference.

`prompt` : | a prompt
`result` : | asynchronous result passed to callback
`error` : | location to place error on failure
Returns : | the reply from the prompt

### gcr_prompt_confirm_run ()

    GcrPromptReply      gcr_prompt_confirm_run              (GcrPrompt *prompt,
                                                             GCancellable *cancellable,
                                                             GError **error);

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_PROMPT_REPLY_OK` will be returned if the user confirms the prompt. The return value will also be `GCR_PROMPT_REPLY_CANCEL` if the user cancels or if an error occurs. Check the `error` argument to tell the difference.

`prompt` : | a prompt
`cancellable` : | optional cancellation object
`error` : | location to place error on failure
Returns : | the reply from the prompt

### gcr_prompt_reset ()

    void                gcr_prompt_reset                    (GcrPrompt *prompt);

### gcr_prompt_get_title ()

    gchar *             gcr_prompt_get_title                (GcrPrompt *prompt);

Gets the title of the prompt.

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

`prompt` : | the prompt
Returns : | a newly allocated string containing the prompt title. [transfer full]

### gcr_prompt_set_title ()

    void                gcr_prompt_set_title                (GcrPrompt *prompt,
                                                             const gchar *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.

`prompt` : | the prompt
`title` : | the prompt title

### gcr_prompt_get_message ()

    gchar *             gcr_prompt_get_message              (GcrPrompt *prompt);

Gets the prompt message for the user.

A prompt implementation should always display this message.

`prompt` : | the prompt
Returns : | a newly allocated string containing the detailed description of the prompt. [transfer full]

### gcr_prompt_set_message ()

    void                gcr_prompt_set_message              (GcrPrompt *prompt,
                                                             const gchar *message);

Sets the prompt message for the user.

A prompt implementation should always display this message.

`prompt` : | the prompt
`message` : | the prompt message

### gcr_prompt_get_description ()

    gchar *             gcr_prompt_get_description          (GcrPrompt *prompt);

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.

`prompt` : | the prompt
Returns : | a newly allocated string containing the detailed description of the prompt. [transfer full]

### gcr_prompt_set_description ()

    void                gcr_prompt_set_description          (GcrPrompt *prompt,
                                                             const gchar *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.

`prompt` : | the prompt
`description` : | the detailed description

### gcr_prompt_get_warning ()

    gchar *             gcr_prompt_get_warning              (GcrPrompt *prompt);

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 `NULL` then no warning is displayed.

`prompt` : | the prompt
Returns : | a newly allocated string containing the prompt warning, or `NULL` if no warning. [transfer full]

### gcr_prompt_set_warning ()

    void                gcr_prompt_set_warning              (GcrPrompt *prompt,
                                                             const gchar *warning);

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 `NULL` then no warning is displayed.

`prompt` : | the prompt
`warning` : | the warning or `NULL`. [allow-none]

### gcr_prompt_get_continue_label ()

    gchar *             gcr_prompt_get_continue_label       (GcrPrompt *prompt);

Get the label for the continue button.

This is the button that results in a `GCR_PROMPT_REPLY_CONTINUE` reply from the prompt.

`prompt` : | the prompt
Returns : | a newly allocated string containing the label. [transfer full]

### gcr_prompt_set_continue_label ()

    void                gcr_prompt_set_continue_label       (GcrPrompt *prompt,
                                                             const gchar *continue_label);

Set the label for the continue button.

This is the button that results in a `GCR_PROMPT_REPLY_CONTINUE` reply from the prompt.

`prompt` : | the prompt
`continue_label` : | the label

### gcr_prompt_get_cancel_label ()

    gchar *             gcr_prompt_get_cancel_label         (GcrPrompt *prompt);

Get the label for the cancel button.

This is the button that results in a `GCR_PROMPT_REPLY_CANCEL` reply from the prompt.

`prompt` : | the prompt
Returns : | a newly allocated string containing the label. [transfer full]

### gcr_prompt_set_cancel_label ()

    void                gcr_prompt_set_cancel_label         (GcrPrompt *prompt,
                                                             const gchar *cancel_label);

Set the label for the continue button.

This is the button that results in a `GCR_PROMPT_REPLY_CANCEL` reply from the prompt.

`prompt` : | the prompt
`cancel_label` : | the label

### gcr_prompt_get_choice_label ()

    gchar *             gcr_prompt_get_choice_label         (GcrPrompt *prompt);

Get the label for the additional choice.

This will be `NULL` if no additional choice is being displayed.

`prompt` : | the prompt
Returns : | a newly allocated string containing the additional choice or `NULL`. [transfer full]

### gcr_prompt_set_choice_label ()

    void                gcr_prompt_set_choice_label         (GcrPrompt *prompt,
                                                             const gchar *choice_label);

Set the label for the additional choice.

If this is a non-`NULL` 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 `NULL`, then no additional choice is being displayed.

`prompt` : | the prompt
`choice_label` : | the additional choice or `NULL`. [allow-none]

### gcr_prompt_get_choice_chosen ()

    gboolean            gcr_prompt_get_choice_chosen        (GcrPrompt *prompt);

Get whether the additional choice was chosen or not.

The additional choice would have been setup using `gcr_prompt_set_choice_label()`.

`prompt` : | the prompt
Returns : | whether chosen

### gcr_prompt_set_choice_chosen ()

    void                gcr_prompt_set_choice_chosen        (GcrPrompt *prompt,
                                                             gboolean chosen);

Set whether the additional choice is chosen or not.

The additional choice should be set up using `gcr_prompt_set_choice_label()`.

`prompt` : | the prompt
`chosen` : | whether chosen

### gcr_prompt_get_password_new ()

    gboolean            gcr_prompt_get_password_new         (GcrPrompt *prompt);

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.

`prompt` : | the prompt
Returns : | whether in new password mode or not

### gcr_prompt_set_password_new ()

    void                gcr_prompt_set_password_new         (GcrPrompt *prompt,
                                                             gboolean new_password);

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.

`prompt` : | the prompt
`new_password` : | whether in new password mode or not

### gcr_prompt_get_password_strength ()

    gint                gcr_prompt_get_password_strength    (GcrPrompt *prompt);

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.

`prompt` : | the prompt
Returns : | zero if the password is empty, greater than zero if not

### gcr_prompt_get_caller_window ()

    gchar *             gcr_prompt_get_caller_window        (GcrPrompt *prompt);

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.

`prompt` : | the prompt
Returns : | a newly allocated string containing the string handle of the window. [transfer full]

### gcr_prompt_set_caller_window ()

    void                gcr_prompt_set_caller_window        (GcrPrompt *prompt,
                                                             const gchar *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.

`prompt` : | the prompt
`window_id` : | the window id

## Property Details

### The `"caller-window"` property

      "caller-window"            gchar*                : Read / Write / 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.

Default value: NULL

### The `"cancel-label"` property

      "cancel-label"             gchar*                : Read / Write / Construct

The label for the cancel button in the prompt.

Default value: "Cancel"

### The `"choice-chosen"` property

      "choice-chosen"            gboolean              : Read / Write

Whether the additional choice is chosen or not.

The additional choice would have been setup using "choice-label".

Default value: FALSE

### The `"choice-label"` property

      "choice-label"             gchar*                : Read / Write / Construct

The label for the additional choice.

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

If `NULL`, then no additional choice is displayed.

The initial value of the choice can be set with "choice-chosen".

Default value: NULL

### The `"continue-label"` property

      "continue-label"           gchar*                : Read / Write / Construct

The label for the continue button in the prompt.

Default value: "Continue"

### The `"description"` property

      "description"              gchar*                : Read / Write / 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.

Default value: NULL

### The `"message"` property

      "message"                  gchar*                : Read / Write / Construct

The prompt message for the user.

A prompt implementation should always display this message.

Default value: NULL

### The `"password-new"` property

      "password-new"             gboolean              : Read / Write

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.

Default value: FALSE

### The `"password-strength"` property

      "password-strength"        gint                  : Read

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.

Allowed values: >= 0

Default value: 0

### The `"title"` property

      "title"                    gchar*                : Read / Write / Construct

The title of the prompt.

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

Default value: NULL

### The `"warning"` property

      "warning"                  gchar*                : Read / Write / Construct

A prompt warning displayed on the prompt, or `NULL` for no warning.

This is a warning like "The password is incorrect." usually displayed to the user about a previous 'unsuccessful' prompt.

Default value: NULL