print: add optional remember-password UI state
Prepare the print authentication dialog for backends that can store credentials without changing the request-password signal or gtk_print_backend_set_password() ABI. This keeps the openSUSE CUPS Secret Service feature ABI-conservative for gtk2-ng.
This commit is contained in:
parent
0d089cd6de
commit
dab59b874b
1 changed files with 30 additions and 1 deletions
|
|
@ -349,6 +349,9 @@ gtk_print_backend_load_modules (void)
|
|||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkPrintBackend, gtk_print_backend, G_TYPE_OBJECT)
|
||||
|
||||
#define GTK_PRINT_BACKEND_CAN_STORE_AUTH_INFO_KEY "gtk-print-backend-can-store-auth-info"
|
||||
#define GTK_PRINT_BACKEND_STORE_AUTH_INFO_KEY "gtk-print-backend-store-auth-info"
|
||||
|
||||
static void fallback_printer_request_details (GtkPrinter *printer);
|
||||
static gboolean fallback_printer_mark_conflicts (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options);
|
||||
|
|
@ -690,6 +693,17 @@ store_entry (GtkEntry *entry,
|
|||
*data = g_strdup (gtk_entry_get_text (entry));
|
||||
}
|
||||
|
||||
static void
|
||||
store_auth_info_toggled (GtkToggleButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkPrintBackend *backend = GTK_PRINT_BACKEND (user_data);
|
||||
|
||||
g_object_set_data (G_OBJECT (backend),
|
||||
GTK_PRINT_BACKEND_STORE_AUTH_INFO_KEY,
|
||||
GINT_TO_POINTER (gtk_toggle_button_get_active (button)));
|
||||
}
|
||||
|
||||
static void
|
||||
password_dialog_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
|
|
@ -729,7 +743,7 @@ request_password (GtkPrintBackend *backend,
|
|||
const gchar *prompt)
|
||||
{
|
||||
GtkPrintBackendPrivate *priv = backend->priv;
|
||||
GtkWidget *dialog, *box, *main_box, *label, *icon, *vbox, *entry;
|
||||
GtkWidget *dialog, *box, *main_box, *label, *icon, *vbox, *entry, *chkbtn;
|
||||
GtkWidget *focus = NULL;
|
||||
gchar *markup;
|
||||
gint length;
|
||||
|
|
@ -743,6 +757,10 @@ request_password (GtkPrintBackend *backend,
|
|||
length = g_strv_length (ai_required);
|
||||
priv->auth_info = g_new0 (gchar *, length + 1);
|
||||
|
||||
g_object_set_data (G_OBJECT (backend),
|
||||
GTK_PRINT_BACKEND_STORE_AUTH_INFO_KEY,
|
||||
GINT_TO_POINTER (FALSE));
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons ( _("Authentication"), NULL, GTK_DIALOG_MODAL,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
||||
|
|
@ -810,6 +828,17 @@ request_password (GtkPrintBackend *backend,
|
|||
}
|
||||
}
|
||||
|
||||
if (g_object_get_data (G_OBJECT (backend),
|
||||
GTK_PRINT_BACKEND_CAN_STORE_AUTH_INFO_KEY))
|
||||
{
|
||||
chkbtn = gtk_check_button_new_with_mnemonic (_("_Remember password"));
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbtn), FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), chkbtn, FALSE, FALSE, 6);
|
||||
g_signal_connect (chkbtn, "toggled",
|
||||
G_CALLBACK (store_auth_info_toggled),
|
||||
backend);
|
||||
}
|
||||
|
||||
if (focus != NULL)
|
||||
{
|
||||
gtk_widget_grab_focus (focus);
|
||||
|
|
|
|||
Loading…
Reference in a new issue