2009-02-27 Alberto Garcia <agarcia@igalia.com>
[hildon] / src / hildon-get-password-dialog.c
index c5bcc91..5c03a55 100644 (file)
@@ -3,12 +3,12 @@
  *
  * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
  *
- * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
+ * Contact: Rodrigo Novo <rodrigo.novo@nokia.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; version 2.1 of
- * the License.
+ * the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * </example>
  */
 
+#undef                                          HILDON_DISABLE_DEPRECATED
+
 #ifdef                                          HAVE_CONFIG_H
 #include                                        <config.h>
 #endif
 
-#include                                        "hildon-get-password-dialog.h"
-#include                                        <glib.h>
 #include                                        <errno.h>
 #include                                        <string.h>
 #include                                        <strings.h>
 #include                                        <unistd.h>
 #include                                        <stdio.h>
-#include                                        <gtk/gtk.h>
-#include                                        "hildon-input-mode-hint.h"
+#include                                        <libintl.h>
+
+#include                                        "hildon-get-password-dialog.h"
 #include                                        "hildon-caption.h"
 #include                                        "hildon-banner.h"
-#include                                        <libintl.h>
 #include                                        "hildon-get-password-dialog-private.h"
 
 #define                                         _(String) dgettext("hildon-libs", String)
@@ -91,7 +91,7 @@
 
 #define                                         HILDON_GET_PASSWORD_DIALOG_PASSWORD "ecdg_fi_get_old_pwd_enter_pwd"
 
-#define                                         HILDON_GET_PASSWORD_DIALOG_OK "ecdg_bd_get_old_password_dialog_ok"
+#define                                         HILDON_GET_PASSWORD_DIALOG_OK "wdgt_bd_done"
 
 #define                                         HILDON_GET_PASSWORD_DIALOG_CANCEL "ecdg_bd_get_old_password_dialog_cancel"
 
@@ -99,7 +99,7 @@
 
 #define                                         HILDON_GET_PASSWORD_VERIFY_DIALOG_PASSWORD "ecdg_fi_verify_pwd_enter_pwd"
 
-#define                                         HILDON_GET_PASSWORD_VERIFY_DIALOG_OK "ecdg_bd_verify_password_dialog_ok"
+#define                                         HILDON_GET_PASSWORD_VERIFY_DIALOG_OK "wdgt_bd_done"
 
 #define                                         HILDON_GET_PASSWORD_VERIFY_DIALOG_CANCEL "ecdg_bd_verify_password_dialog_cancel"
 
@@ -128,10 +128,12 @@ hildon_get_password_get_property                (GObject *object,
 static void 
 create_contents                                 (HildonGetPasswordDialog *dialog);
 
+#ifdef MAEMO_GTK 
 static void 
 invalid_input                                   (GtkWidget *widget, 
                                                  GtkInvalidInputType reason, 
                                                  gpointer unused);
+#endif
 
 enum
 {
@@ -170,13 +172,15 @@ hildon_get_password_set_property                (GObject *object,
             break;
 
         case PROP_NUMBERS_ONLY:
+#ifdef MAEMO_GTK 
             /* Set input mode for the password entry */
             g_object_set(G_OBJECT (gtk_bin_get_child GTK_BIN ((priv->password_entry))),
-                    "input-mode",
+                    "hildon-input-mode",
                     (g_value_get_boolean (value)
-                     ? HILDON_INPUT_MODE_HINT_NUMERIC
-                     : HILDON_INPUT_MODE_HINT_ALPHANUMERICSPECIAL),
+                     ? HILDON_GTK_INPUT_MODE_NUMERIC
+                     : HILDON_GTK_INPUT_MODE_FULL),
                     NULL);
+#endif
             break;
 
         case PROP_CAPTION_LABEL:
@@ -208,7 +212,9 @@ hildon_get_password_get_property                (GObject *object,
     HildonGetPasswordDialogPrivate *priv;
     const gchar *string;
     gint max_length;
+#ifdef MAEMO_GTK 
     gint input_mode;
+#endif
 
     priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE (dialog);
     g_assert (priv);
@@ -226,12 +232,16 @@ hildon_get_password_get_property                (GObject *object,
             break;
 
         case PROP_NUMBERS_ONLY:
+#ifdef MAEMO_GTK 
             /* This property is set if and only if the input mode
                of the password entry has been set to numeric only */
             g_object_get (G_OBJECT (gtk_bin_get_child (GTK_BIN (priv->password_entry))),
-                    "input-mode", &input_mode, NULL);
+                    "hildon-input-mode", &input_mode, NULL);
             g_value_set_boolean (value,
-                    (input_mode == HILDON_INPUT_MODE_HINT_NUMERIC));
+                    (input_mode == HILDON_GTK_INPUT_MODE_NUMERIC));
+#else
+            g_value_set_boolean (value, FALSE);
+#endif
             break;
 
         case PROP_CAPTION_LABEL:
@@ -377,6 +387,7 @@ create_contents                                 (HildonGetPasswordDialog *dialog
     HildonGetPasswordDialogPrivate *priv;
     GtkSizeGroup * group;
     GtkWidget *control;
+    AtkObject *atk_aux = NULL;
 
     /* Cache private pointer for faster member access */
     priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE (dialog);
@@ -410,9 +421,16 @@ create_contents                                 (HildonGetPasswordDialog *dialog
 
     /* Create password text entry */
     control = gtk_entry_new ();
+    if ((atk_aux = gtk_widget_get_accessible(control)))
+      {
+       atk_object_set_name(atk_aux, _("Passwd"));
+      }
+
     gtk_entry_set_width_chars (GTK_ENTRY (control), 20);
 
+#ifdef MAEMO_GTK 
     g_object_set (control, "hildon-input-mode", HILDON_GTK_INPUT_MODE_FULL, NULL);
+#endif
 
     gtk_entry_set_visibility (GTK_ENTRY(control), FALSE);
     priv->password_entry = HILDON_CAPTION
@@ -626,6 +644,7 @@ hildon_get_password_dialog_set_max_characters   (HildonGetPasswordDialog *dialog
      * disconnected before connecting the new signal. Besides, this 
      * should go into the constructor */
 
+#ifdef MAEMO_GTK 
     /* Connect callback to show error banner if the limit is exceeded */
     g_signal_connect (GTK_ENTRY
             (gtk_bin_get_child
@@ -634,8 +653,10 @@ hildon_get_password_dialog_set_max_characters   (HildonGetPasswordDialog *dialog
             G_CALLBACK (invalid_input),
             NULL
             );
+#endif
 }
 
+#ifdef MAEMO_GTK 
 /* Callback that gets called when maximum chars is reached in the entry */
 static void 
 invalid_input                                   (GtkWidget *widget, 
@@ -647,3 +668,4 @@ invalid_input                                   (GtkWidget *widget,
         hildon_banner_show_information (widget, NULL, _(HILDON_GET_PASSWORD_DIALOG_MAX_CHARS));
     }
 }
+#endif