aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonny Lamb <jonnylamb@gnome.org>2010-12-03 21:04:04 +0800
committerJonny Lamb <jonnylamb@gnome.org>2010-12-03 21:04:04 +0800
commitfd337e4163b26ea7e284473817a1d17946ab12d4 (patch)
tree108f20b15091187888f2e70da3d4b8ca34ef321e
parent2b5028d1ec652a136f30d7b3955562a6a07f9f42 (diff)
downloadgsoc2013-empathy-fd337e4163b26ea7e284473817a1d17946ab12d4.tar
gsoc2013-empathy-fd337e4163b26ea7e284473817a1d17946ab12d4.tar.gz
gsoc2013-empathy-fd337e4163b26ea7e284473817a1d17946ab12d4.tar.bz2
gsoc2013-empathy-fd337e4163b26ea7e284473817a1d17946ab12d4.tar.lz
gsoc2013-empathy-fd337e4163b26ea7e284473817a1d17946ab12d4.tar.xz
gsoc2013-empathy-fd337e4163b26ea7e284473817a1d17946ab12d4.tar.zst
gsoc2013-empathy-fd337e4163b26ea7e284473817a1d17946ab12d4.zip
auth-client: improve the password request dialog
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
-rw-r--r--libempathy/empathy-server-sasl-handler.c10
-rw-r--r--libempathy/empathy-server-sasl-handler.h3
-rw-r--r--src/empathy-auth-client.c74
3 files changed, 74 insertions, 13 deletions
diff --git a/libempathy/empathy-server-sasl-handler.c b/libempathy/empathy-server-sasl-handler.c
index 5c78591ed..9f10a7921 100644
--- a/libempathy/empathy-server-sasl-handler.c
+++ b/libempathy/empathy-server-sasl-handler.c
@@ -241,7 +241,8 @@ start_mechanism_with_data_cb (TpChannel *proxy,
void
empathy_server_sasl_handler_provide_password (
EmpathyServerSASLHandler *handler,
- const gchar *password)
+ const gchar *password,
+ gboolean remember)
{
EmpathyServerSASLHandlerPriv *priv;
GArray *array;
@@ -262,6 +263,13 @@ empathy_server_sasl_handler_provide_password (
NULL, NULL, G_OBJECT (handler));
g_array_unref (array);
+
+ DEBUG ("%sremembering the password", remember ? "" : "not ");
+
+ if (remember)
+ {
+ /* TODO */
+ }
}
void
diff --git a/libempathy/empathy-server-sasl-handler.h b/libempathy/empathy-server-sasl-handler.h
index 47f49e2a4..cdedef90c 100644
--- a/libempathy/empathy-server-sasl-handler.h
+++ b/libempathy/empathy-server-sasl-handler.h
@@ -62,7 +62,8 @@ EmpathyServerSASLHandler * empathy_server_sasl_handler_new (
TpAccount *account, TpChannel *channel);
void empathy_server_sasl_handler_provide_password (
- EmpathyServerSASLHandler *handler, const gchar *password);
+ EmpathyServerSASLHandler *handler, const gchar *password,
+ gboolean remember);
void empathy_server_sasl_handler_cancel (EmpathyServerSASLHandler *handler);
diff --git a/src/empathy-auth-client.c b/src/empathy-auth-client.c
index 864253bbf..6b03a03d1 100644
--- a/src/empathy-auth-client.c
+++ b/src/empathy-auth-client.c
@@ -32,6 +32,7 @@
#include <libempathy/empathy-server-sasl-handler.h>
#include <libempathy/empathy-server-tls-handler.h>
#include <libempathy/empathy-tls-verifier.h>
+#include <libempathy/empathy-utils.h>
#include <libempathy-gtk/empathy-tls-dialog.h>
#include <libempathy-gtk/empathy-ui-utils.h>
@@ -209,6 +210,7 @@ typedef struct
{
EmpathyServerSASLHandler *handler;
GtkWidget *entry;
+ GtkWidget *ticky;
} PasswordDialogData;
static void
@@ -218,10 +220,11 @@ password_dialog_response_cb (GtkDialog *dialog,
{
PasswordDialogData *data = user_data;
- if (response == GTK_RESPONSE_ACCEPT)
+ if (response == GTK_RESPONSE_OK)
{
empathy_server_sasl_handler_provide_password (data->handler,
- gtk_entry_get_text (GTK_ENTRY (data->entry)));
+ gtk_entry_get_text (GTK_ENTRY (data->entry)),
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->ticky)));
}
else
{
@@ -235,32 +238,81 @@ password_dialog_response_cb (GtkDialog *dialog,
}
static void
+clear_icon_released_cb (GtkEntry *entry,
+ GtkEntryIconPosition icon_pos,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ gtk_entry_set_text (entry, "");
+}
+
+static void
+password_entry_changed_cb (GtkEditable *entry,
+ gpointer user_data)
+{
+ const gchar *str;
+
+ str = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY, !EMP_STR_EMPTY (str));
+}
+
+static void
auth_factory_new_sasl_handler_cb (EmpathyAuthFactory *factory,
EmpathyServerSASLHandler *handler,
gpointer user_data)
{
- GtkWidget *dialog, *entry;
+ GtkWidget *dialog, *entry, *icon, *ticky;
+ GtkBox *box;
+ TpAccount *account;
PasswordDialogData *data;
DEBUG ("New SASL server handler received from the factory");
- dialog = gtk_dialog_new_with_buttons (_("Enter password"), NULL,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
- NULL);
+ account = empathy_server_sasl_handler_get_account (handler);
+
+ dialog = gtk_message_dialog_new_with_markup (NULL, 0,
+ GTK_MESSAGE_OTHER, GTK_BUTTONS_OK_CANCEL,
+ _("Enter your password for account\n<b>%s</b>"),
+ tp_account_get_display_name (account));
+
+ box = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog)));
+ /* dialog icon */
+ icon = gtk_image_new_from_icon_name (tp_account_get_icon_name (account),
+ GTK_ICON_SIZE_DIALOG);
+ gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), icon);
+ gtk_widget_show (icon);
+
+ /* entry */
entry = gtk_entry_new ();
gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
- gtk_box_pack_start (GTK_BOX (
- gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
- entry, FALSE, FALSE, 10);
+ /* entry clear icon */
+ gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
+ gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY, FALSE);
+
+ g_signal_connect (entry, "icon-release",
+ G_CALLBACK (clear_icon_released_cb), NULL);
+ g_signal_connect (entry, "changed",
+ G_CALLBACK (password_entry_changed_cb), NULL);
+
+ gtk_box_pack_start (box, entry, FALSE, FALSE, 0);
gtk_widget_show (entry);
+ /* remember password ticky */
+ ticky = gtk_check_button_new_with_label (_("Remember password"));
+
+ gtk_box_pack_start (box, ticky, FALSE, FALSE, 0);
+ gtk_widget_show (ticky);
+
data = g_slice_new0 (PasswordDialogData);
data->handler = g_object_ref (handler);
data->entry = entry;
+ data->ticky = ticky;
g_signal_connect (dialog, "response",
G_CALLBACK (password_dialog_response_cb), data);