summaryrefslogtreecommitdiff
path: root/gtk/gtkprintbackend.c
diff options
context:
space:
mode:
authorAndre Heinecke <aheinecke@intevation.de>2014-08-19 17:55:47 +0200
committerMarek Kasik <mkasik@redhat.com>2014-09-01 22:39:51 +0200
commit382d68ff8e5701a10aa8d4f879c46c63c21e075f (patch)
treecbb059d3c0cdf71d090197170461880ce645c6d7 /gtk/gtkprintbackend.c
parentd5dae5b5dfef5d49cc8dd4e79afce31d832c7991 (diff)
downloadgtk+-382d68ff8e5701a10aa8d4f879c46c63c21e075f.tar.gz
Use secrets service for cups auth_info
When a printer requires auth_info (e.g. a printer connected over the samba protocol) it is now possible to save the credentials necessary for printing if a secrets service is available over dbus. The auth_info is then stored / loaded from the default collection of that secrets service. If no such service is available the user is not shown the option to remember the password and the behavior remains the same as before. https://bugzilla.gnome.org/show_bug.cgi?id=674264
Diffstat (limited to 'gtk/gtkprintbackend.c')
-rw-r--r--gtk/gtkprintbackend.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/gtk/gtkprintbackend.c b/gtk/gtkprintbackend.c
index 3de625f304..31a181bddc 100644
--- a/gtk/gtkprintbackend.c
+++ b/gtk/gtkprintbackend.c
@@ -47,6 +47,7 @@ struct _GtkPrintBackendPrivate
GtkPrintBackendStatus status;
char **auth_info_required;
char **auth_info;
+ gboolean store_auth_info;
};
enum {
@@ -360,7 +361,8 @@ static void request_password (GtkPrintBack
gpointer auth_info_default,
gpointer auth_info_display,
gpointer auth_info_visible,
- const gchar *prompt);
+ const gchar *prompt,
+ gboolean can_store_auth_info);
static void
gtk_print_backend_class_init (GtkPrintBackendClass *class)
@@ -437,9 +439,9 @@ gtk_print_backend_class_init (GtkPrintBackendClass *class)
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkPrintBackendClass, request_password),
- NULL, NULL,
- _gtk_marshal_VOID__POINTER_POINTER_POINTER_POINTER_STRING,
- G_TYPE_NONE, 5, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING);
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 6, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER,
+ G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN);
}
static void
@@ -666,12 +668,24 @@ gtk_print_backend_print_stream (GtkPrintBackend *backend,
void
gtk_print_backend_set_password (GtkPrintBackend *backend,
gchar **auth_info_required,
- gchar **auth_info)
+ gchar **auth_info,
+ gboolean store_auth_info)
{
g_return_if_fail (GTK_IS_PRINT_BACKEND (backend));
if (GTK_PRINT_BACKEND_GET_CLASS (backend)->set_password)
- GTK_PRINT_BACKEND_GET_CLASS (backend)->set_password (backend, auth_info_required, auth_info);
+ GTK_PRINT_BACKEND_GET_CLASS (backend)->set_password (backend,
+ auth_info_required,
+ auth_info,
+ store_auth_info);
+}
+
+static void
+store_auth_info_toggled (GtkCheckButton *chkbtn,
+ gpointer user_data)
+{
+ gboolean *data = (gboolean *) user_data;
+ *data = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chkbtn));
}
static void
@@ -698,9 +712,9 @@ password_dialog_response (GtkWidget *dialog,
gint i;
if (response_id == GTK_RESPONSE_OK)
- gtk_print_backend_set_password (backend, priv->auth_info_required, priv->auth_info);
+ gtk_print_backend_set_password (backend, priv->auth_info_required, priv->auth_info, priv->store_auth_info);
else
- gtk_print_backend_set_password (backend, priv->auth_info_required, NULL);
+ gtk_print_backend_set_password (backend, priv->auth_info_required, NULL, FALSE);
for (i = 0; i < g_strv_length (priv->auth_info_required); i++)
if (priv->auth_info[i] != NULL)
@@ -725,10 +739,11 @@ request_password (GtkPrintBackend *backend,
gpointer auth_info_default,
gpointer auth_info_display,
gpointer auth_info_visible,
- const gchar *prompt)
+ const gchar *prompt,
+ gboolean can_store_auth_info)
{
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;
GtkWidget *content_area;
gchar *markup;
@@ -742,6 +757,7 @@ request_password (GtkPrintBackend *backend,
priv->auth_info_required = g_strdupv (ai_required);
length = g_strv_length (ai_required);
priv->auth_info = g_new0 (gchar *, length);
+ priv->store_auth_info = FALSE;
dialog = gtk_dialog_new_with_buttons ( _("Authentication"), NULL, GTK_DIALOG_MODAL,
_("_Cancel"), GTK_RESPONSE_CANCEL,
@@ -812,6 +828,16 @@ request_password (GtkPrintBackend *backend,
}
}
+ if (can_store_auth_info)
+ {
+ 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),
+ &(priv->store_auth_info));
+ }
+
if (focus != NULL)
{
gtk_widget_grab_focus (focus);