[empathy/gnome-2-34: 52/60] password-dialog: make OK insensitive unless there's a password set



commit 5b105c40c45bcf8be7d1489d224b1e0f4babadf8
Author: Jonny Lamb <jonnylamb gnome org>
Date:   Fri Dec 17 10:05:00 2010 +0000

    password-dialog: make OK insensitive unless there's a password set
    
    Signed-off-by: Jonny Lamb <jonnylamb gnome org>

 libempathy-gtk/empathy-password-dialog.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/libempathy-gtk/empathy-password-dialog.c b/libempathy-gtk/empathy-password-dialog.c
index 442396d..2b1048c 100644
--- a/libempathy-gtk/empathy-password-dialog.c
+++ b/libempathy-gtk/empathy-password-dialog.c
@@ -41,6 +41,7 @@ typedef struct {
 
   GtkWidget *entry;
   GtkWidget *ticky;
+  GtkWidget *ok_button;
 
   gboolean grabbing;
 
@@ -135,12 +136,16 @@ static void
 password_entry_changed_cb (GtkEditable *entry,
     gpointer user_data)
 {
+  EmpathyPasswordDialogPriv *priv = EMPATHY_PASSWORD_DIALOG (user_data)->priv;
   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));
+
+  gtk_widget_set_sensitive (priv->ok_button,
+      !EMP_STR_EMPTY (str));
 }
 
 static gboolean
@@ -233,10 +238,12 @@ empathy_password_dialog_constructed (GObject *object)
       object, 0);
 
   /* dialog */
-  gtk_dialog_add_buttons (GTK_DIALOG (dialog),
-      GTK_STOCK_OK, GTK_RESPONSE_OK,
-      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-      NULL);
+  gtk_dialog_add_button (GTK_DIALOG (dialog),
+      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+  priv->ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+      GTK_STOCK_OK, GTK_RESPONSE_OK);
+  gtk_widget_set_sensitive (priv->ok_button, FALSE);
 
   text = g_strdup_printf (_("Enter your password for account\n<b>%s</b>"),
       tp_account_get_display_name (account));
@@ -267,7 +274,7 @@ empathy_password_dialog_constructed (GObject *object)
   g_signal_connect (priv->entry, "icon-release",
       G_CALLBACK (clear_icon_released_cb), NULL);
   g_signal_connect (priv->entry, "changed",
-      G_CALLBACK (password_entry_changed_cb), NULL);
+      G_CALLBACK (password_entry_changed_cb), dialog);
 
   gtk_box_pack_start (box, priv->entry, FALSE, FALSE, 0);
   gtk_widget_show (priv->entry);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]