Cleaning up the HildonGetPasswordDialog.
authorMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Sun, 7 Jan 2007 18:23:44 +0000 (18:23 +0000)
committerMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Sun, 7 Jan 2007 18:23:44 +0000 (18:23 +0000)
ChangeLog
src/hildon-get-password-dialog-private.h [new file with mode: 0644]
src/hildon-get-password-dialog.c
src/hildon-get-password-dialog.h

index a2b0349..065c17a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-01-07  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
+
+       * src/hildon-get-password-dialog-private.h:
+       * src/hildon-get-password-dialog.c:
+       * src/hildon-get-password-dialog.h: Cleaning up the
+       HildonGetPasswordDialogi.
+
 2007-01-05  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
 
        * src/hildon-font-selection-dialog.c:
diff --git a/src/hildon-get-password-dialog-private.h b/src/hildon-get-password-dialog-private.h
new file mode 100644 (file)
index 0000000..10f06ef
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * This file is part of hildon-libs
+ *
+ * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
+ *
+ * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@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.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef                                         __HILDON_GET_PASSWORD_DIALOG_PRIVATE_H__
+#define                                         __HILDON_GET_PASSWORD_DIALOG_PRIVATE_H__
+
+G_BEGIN_DECLS
+
+#define                                         HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(obj) \
+                                                (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
+                                                HILDON_TYPE_GET_PASSWORD_DIALOG, HildonGetPasswordDialogPrivate));
+
+typedef struct                                  _HildonGetPasswordDialogPrivate HildonGetPasswordDialogPrivate;
+
+struct                                          _HildonGetPasswordDialogPrivate 
+{
+    GtkLabel *message_label;
+    HildonCaption *password_entry;
+    gboolean get_old;
+};
+
+G_END_DECLS
+
+#endif                                          /* __HILDON_GET_PASSWORD_DIALOG_PRIVATE_H__ */
index cb87d41..f208aaf 100644 (file)
  * 
  * HildonGetPasswordDialog prompts the user for a password.  It allows
  * inputting password, with an optional configurable label eg. for
- * showing the domain. The maximum length of the password can be set.
+ * showing a custom message. The maximum length of the password can be set.
  */
 
-#include <config.h>
-#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 "hildon-caption.h"
-#include "hildon-banner.h"
-#include <libintl.h>
-
-#define _(String) dgettext(PACKAGE, String)
-
-static GtkDialogClass * parent_class;
-
-typedef struct _HildonGetPasswordDialogPrivate 
-  HildonGetPasswordDialogPrivate;
-
-struct _HildonGetPasswordDialogPrivate {
-  GtkButton *okButton;
-  GtkButton *cancelButton;
-  
-  GtkLabel *domainLabel;
-  HildonCaption *passwordEntry;
-  gboolean get_old;
-};
+#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                                        "hildon-caption.h"
+#include                                        "hildon-banner.h"
+#include                                        <libintl.h>
+#include                                        "hildon-get-password-dialog-private.h"
+
+#define                                         _(String) dgettext(PACKAGE, String)
+
+#define                                         HILDON_GET_PASSWORD_DIALOG_TITLE "ecdg_ti_get_old_password"
+
+#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_CANCEL "ecdg_bd_get_old_password_dialog_cancel"
 
+#define                                         HILDON_GET_PASSWORD_VERIFY_DIALOG_TITLE "ecdg_ti_verify_password"
 
-#define HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
-  HILDON_TYPE_GET_PASSWORD_DIALOG, HildonGetPasswordDialogPrivate));
+#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_CANCEL "ecdg_bd_verify_password_dialog_cancel"
+
+#define                                         HILDON_GET_PASSWORD_DIALOG_MAX_CHARS "ckdg_ib_maximum_characters_reached"
+
+static GtkDialogClass*                          parent_class;
+
+static void
+hildon_get_password_dialog_class_init           (HildonGetPasswordDialogClass *class);
 
 static void
-hildon_get_password_dialog_class_init(HildonGetPasswordDialogClass *
-                                      class);
-static void hildon_get_password_dialog_init(HildonGetPasswordDialog *
-                                            widget);
-static void hildon_get_password_set_property(GObject * object,
-                                             guint prop_id,
-                                             const GValue * value,
-                                             GParamSpec * pspec);
-static void hildon_get_password_get_property(GObject * object,
-                                             guint prop_id, GValue * value,
-                                             GParamSpec * pspec);
-static void create_contents(HildonGetPasswordDialog *dialog);
-static void _invalid_input(GtkWidget *widget, GtkInvalidInputType reason, 
-                          gpointer unused);
-
-enum{
-    PROP_NONE = 0,
-    PROP_DOMAIN,
+hildon_get_password_dialog_init                 (HildonGetPasswordDialog *widget);
+
+static void
+hildon_get_password_set_property                (GObject *object,
+                                                 guint prop_id,
+                                                 const GValue *value,
+                                                 GParamSpec *pspec);
+
+static void
+hildon_get_password_get_property                (GObject *object,
+                                                 guint prop_id, 
+                                                 GValue *value,
+                                                 GParamSpec *pspec);
+
+static void 
+create_contents                                 (HildonGetPasswordDialog *dialog);
+
+static void 
+invalid_input                                   (GtkWidget *widget, 
+                                                 GtkInvalidInputType reason, 
+                                                 gpointer unused);
+
+enum
+{
+    PROP_0,
+    PROP_MESSAGE,
     PROP_PASSWORD,
     PROP_NUMBERS_ONLY,
     PROP_CAPTION_LABEL,
@@ -95,252 +111,264 @@ enum{
 
 /* Private functions */
 static void
-hildon_get_password_set_property(GObject * object,
-                                 guint prop_id,
-                                 const GValue * value, GParamSpec * pspec)
+hildon_get_password_set_property                (GObject *object,
+                                                 guint prop_id,
+                                                 const GValue *value, 
+                                                 GParamSpec *pspec)
 {
-  HildonGetPasswordDialog *dialog = HILDON_GET_PASSWORD_DIALOG(object);
-  HildonGetPasswordDialogPrivate *priv;
-  
-  priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
-  
-  switch (prop_id) {
-  case PROP_DOMAIN:
-    /* Set label text representing password domain */
-    gtk_label_set_text(priv->domainLabel, g_value_get_string(value));
-    break;
-  case PROP_PASSWORD:
-    gtk_entry_set_text(GTK_ENTRY
-                      (gtk_bin_get_child (GTK_BIN (priv->passwordEntry))),
-                      g_value_get_string(value));
-    break;
-  case PROP_NUMBERS_ONLY:
-    /* Set input mode for the password entry */
-    g_object_set(G_OBJECT(gtk_bin_get_child GTK_BIN ((priv->passwordEntry))),
-                "input-mode",
-                (g_value_get_boolean(value)
-                 ? HILDON_INPUT_MODE_HINT_NUMERIC
-                 : HILDON_INPUT_MODE_HINT_ALPHANUMERICSPECIAL),
-                NULL);
-    break;
-  case PROP_CAPTION_LABEL:
-    hildon_get_password_dialog_set_caption(dialog, g_value_get_string(value));
-    break;
-  case PROP_MAX_CHARS:
-    hildon_get_password_dialog_set_max_characters(dialog, 
-                                                 g_value_get_int(value));
-    break;
-  case PROP_GET_OLD:
-    priv->get_old = g_value_get_boolean(value);
-    create_contents(dialog);
-    break;
-  default:
-    G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-    break;
-  }
+    HildonGetPasswordDialog *dialog = HILDON_GET_PASSWORD_DIALOG (object);
+    HildonGetPasswordDialogPrivate *priv;
+
+    priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE (object);
+    g_assert (priv);
+
+    switch (prop_id) {
+
+        case PROP_MESSAGE:
+            /* Set label text representing password domain */
+            gtk_label_set_text (priv->message_label, g_value_get_string (value));
+            break;
+
+        case PROP_PASSWORD:
+            gtk_entry_set_text(GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->password_entry))), 
+                    g_value_get_string(value));
+            break;
+
+        case PROP_NUMBERS_ONLY:
+            /* Set input mode for the password entry */
+            g_object_set(G_OBJECT (gtk_bin_get_child GTK_BIN ((priv->password_entry))),
+                    "input-mode",
+                    (g_value_get_boolean (value)
+                     ? HILDON_INPUT_MODE_HINT_NUMERIC
+                     : HILDON_INPUT_MODE_HINT_ALPHANUMERICSPECIAL),
+                    NULL);
+            break;
+
+        case PROP_CAPTION_LABEL:
+            hildon_get_password_dialog_set_caption (dialog, g_value_get_string (value));
+            break;
+
+        case PROP_MAX_CHARS:
+            hildon_get_password_dialog_set_max_characters (dialog, g_value_get_int (value));
+            break;
+
+        case PROP_GET_OLD:
+            priv->get_old = g_value_get_boolean (value);
+            create_contents (dialog);
+            break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
 }
-  
+
 static void
-hildon_get_password_get_property(GObject * object,
-                                 guint prop_id,
-                                 GValue * value, GParamSpec * pspec)
+hildon_get_password_get_property                (GObject *object,
+                                                 guint prop_id,
+                                                 GValue *value, 
+                                                 GParamSpec *pspec)
 {
-    HildonGetPasswordDialog *dialog = HILDON_GET_PASSWORD_DIALOG(object);
+    HildonGetPasswordDialog *dialog = HILDON_GET_PASSWORD_DIALOG (object);
     HildonGetPasswordDialogPrivate *priv;
     const gchar *string;
     gint max_length;
     gint input_mode;
 
-    priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
-    
+    priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE (dialog);
+    g_assert (priv);
+
     switch (prop_id) {
-    case PROP_DOMAIN:
-      string = gtk_label_get_text(priv->domainLabel);
-      g_value_set_string(value, string);
-      break;
-    case PROP_PASSWORD:
-      string = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(GTK_BIN (priv->passwordEntry))));
-      g_value_set_string(value, string);
-      break;
-    case PROP_NUMBERS_ONLY:
-      /* 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->passwordEntry))),
-                  "input-mode", &input_mode, NULL);
-      g_value_set_boolean(value,
-                         (input_mode == HILDON_INPUT_MODE_HINT_NUMERIC));
-      break;
-    case PROP_CAPTION_LABEL:
-      string = hildon_caption_get_label(priv->passwordEntry);
-      g_value_set_string(value, string);
-      break;
-    case PROP_MAX_CHARS:
-      max_length = gtk_entry_get_max_length(
-             GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->passwordEntry))));
-      g_value_set_int(value, max_length);
-      break;
-    case PROP_GET_OLD:
-      g_value_set_boolean(value, priv->get_old);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-      break;
+
+        case PROP_MESSAGE:
+            string = gtk_label_get_text (priv->message_label);
+            g_value_set_string (value, string);
+            break;
+
+        case PROP_PASSWORD:
+            string = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->password_entry))));
+            g_value_set_string (value, string);
+            break;
+
+        case PROP_NUMBERS_ONLY:
+            /* 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);
+            g_value_set_boolean (value,
+                    (input_mode == HILDON_INPUT_MODE_HINT_NUMERIC));
+            break;
+
+        case PROP_CAPTION_LABEL:
+            string = hildon_caption_get_label (priv->password_entry);
+            g_value_set_string (value, string);
+            break;
+
+        case PROP_MAX_CHARS:
+            max_length = gtk_entry_get_max_length 
+                    (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->password_entry))));
+            g_value_set_int (value, max_length);
+            break;
+
+        case PROP_GET_OLD:
+            g_value_set_boolean (value, priv->get_old);
+            break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
     }
 }
 
 static void
-hildon_get_password_dialog_class_init(HildonGetPasswordDialogClass * class)
+hildon_get_password_dialog_class_init           (HildonGetPasswordDialogClass *class)
 {
-
-  GObjectClass *object_class = G_OBJECT_CLASS(class);
-  
-  parent_class = g_type_class_peek_parent(class);
-  
-  /* Override virtual functions */
-  object_class->set_property = hildon_get_password_set_property;
-  object_class->get_property = hildon_get_password_get_property;
-  
-  /* Install new properties */
-  g_object_class_install_property 
-    (object_class, 
-     PROP_DOMAIN, 
-     g_param_spec_string ("domain",
-                         "Domain",
-                         "Set domain(content) for optional label.",
-                         NULL,
-                         G_PARAM_READWRITE));
-  
-  g_object_class_install_property
-    (object_class, 
-     PROP_PASSWORD,
-     g_param_spec_string ("password",
-                         "Password",
-                         "Set content for password entry",
-                         "DEFAULT",
-                         G_PARAM_READWRITE));
-
-  g_object_class_install_property
-    (object_class, 
-     PROP_NUMBERS_ONLY,
-     g_param_spec_boolean ("numbers_only",
-                         "NumbersOnly",
-                         "Set entry to accept only numeric values",
-                         FALSE,
-                         G_PARAM_READWRITE));
-
-  g_object_class_install_property
-    (object_class, 
-     PROP_CAPTION_LABEL,
-     g_param_spec_string ("caption-label",
-                         "Caption Label",
-                         "The text to be set as the caption label",
-                         NULL,
-                         G_PARAM_READWRITE));
-
-  g_object_class_install_property
-    (object_class, 
-     PROP_MAX_CHARS,
-     g_param_spec_int ("max-characters",
-                      "Maximum Characters",
-                      "The maximum number of characters the password"
-                      " dialog accepts",
-                      G_MININT,
-                      G_MAXINT,
-                      0,
-                      G_PARAM_READWRITE));
-
-  g_object_class_install_property
-    (object_class,
-     PROP_GET_OLD,
-     g_param_spec_boolean ("get-old",
-                          "Get Old Password",
-                          "TRUE if dialog is a get old password dialog, "
-                          "FALSE if dialog is a get password dialog",
-                          FALSE,
-                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+    GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+    parent_class = g_type_class_peek_parent (class);
+
+    /* Override virtual functions */
+    object_class->set_property = hildon_get_password_set_property;
+    object_class->get_property = hildon_get_password_get_property;
+
+    /* Install new properties */
+    g_object_class_install_property 
+        (object_class, 
+         PROP_MESSAGE, 
+         g_param_spec_string ("message",
+             "Message",
+             "Set optional message",
+             NULL,
+             G_PARAM_READWRITE));
+
+    g_object_class_install_property
+        (object_class, 
+         PROP_PASSWORD,
+         g_param_spec_string ("password",
+             "Password",
+             "Password field",
+             "DEFAULT",
+             G_PARAM_READWRITE));
+
+    g_object_class_install_property
+        (object_class, 
+         PROP_NUMBERS_ONLY,
+         g_param_spec_boolean ("numbers_only",
+             "NumbersOnly",
+             "Set entry to accept only numeric values",
+             FALSE,
+             G_PARAM_READWRITE));
+
+    g_object_class_install_property
+        (object_class, 
+         PROP_CAPTION_LABEL,
+         g_param_spec_string ("caption-label",
+             "Caption Label",
+             "The text to be set as the caption label",
+             NULL,
+             G_PARAM_READWRITE));
+
+    g_object_class_install_property
+        (object_class, 
+         PROP_MAX_CHARS,
+         g_param_spec_int ("max-characters",
+             "Maximum Characters",
+             "The maximum number of characters the password"
+             " dialog accepts",
+             G_MININT,
+             G_MAXINT,
+             0,
+             G_PARAM_READWRITE));
+
+    g_object_class_install_property
+        (object_class,
+         PROP_GET_OLD,
+         g_param_spec_boolean ("get-old",
+             "Get Old Password",
+             "TRUE if dialog is a get old password dialog, "
+             "FALSE if dialog is a get password dialog",
+             FALSE,
+             G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 
     /* Install private structure */
-    g_type_class_add_private(class,
-                             sizeof(HildonGetPasswordDialogPrivate));
+    g_type_class_add_private (class, sizeof (HildonGetPasswordDialogPrivate));
 }
 
 static void
-hildon_get_password_dialog_init(HildonGetPasswordDialog * dialog)
+hildon_get_password_dialog_init                 (HildonGetPasswordDialog *dialog)
 {
     /* Set initial properties for the dialog; the actual contents are
        created once the 'get-old' property is set with g_object_new */
-    gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
-    gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+
+    gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+    gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
     gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 }
 
 static void
-create_contents(HildonGetPasswordDialog *dialog)
+create_contents                                 (HildonGetPasswordDialog *dialog)
 {
     HildonGetPasswordDialogPrivate *priv;
     GtkSizeGroup * group;
     GtkWidget *control;
 
     /* Cache private pointer for faster member access */
-    priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+    priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE (dialog);
+    g_assert (priv);
 
     /* Sizegroup for captions */
-    group = GTK_SIZE_GROUP(gtk_size_group_new
-                          (GTK_SIZE_GROUP_HORIZONTAL));
+    group = GTK_SIZE_GROUP (gtk_size_group_new
+            (GTK_SIZE_GROUP_HORIZONTAL));
 
     /* Dialog title */
-    gtk_window_set_title(GTK_WINDOW(dialog),
-                        priv->get_old
-                        ? _(HILDON_GET_PASSWORD_DIALOG_TITLE)
-                        : _(HILDON_GET_PASSWORD_VERIFY_DIALOG_TITLE));
+    gtk_window_set_title (GTK_WINDOW (dialog),
+            priv->get_old
+            ? _(HILDON_GET_PASSWORD_DIALOG_TITLE)
+            : _(HILDON_GET_PASSWORD_VERIFY_DIALOG_TITLE));
 
     /* Optional password domain label */
-    priv->domainLabel = GTK_LABEL(gtk_label_new(NULL));
-    
+    priv->message_label = GTK_LABEL (gtk_label_new (NULL));
+
     /* Create buttons */
-    priv->okButton =
-      GTK_BUTTON(gtk_dialog_add_button(GTK_DIALOG(dialog),
-                                      (priv->get_old
-                                       ? _(HILDON_GET_PASSWORD_DIALOG_OK)
-                                       : _(HILDON_GET_PASSWORD_VERIFY_DIALOG_OK)),
-
-                                       GTK_RESPONSE_OK));
-    priv->cancelButton =
-      GTK_BUTTON(gtk_dialog_add_button(GTK_DIALOG(dialog),
-                                       (priv->get_old
-                                       ? _(HILDON_GET_PASSWORD_DIALOG_CANCEL)
-                                       : _(HILDON_GET_PASSWORD_VERIFY_DIALOG_CANCEL)),
-                                       GTK_RESPONSE_CANCEL));
+    gtk_dialog_add_button (GTK_DIALOG (dialog),
+                    (priv->get_old
+                     ? _(HILDON_GET_PASSWORD_DIALOG_OK)
+                     : _(HILDON_GET_PASSWORD_VERIFY_DIALOG_OK)),
+                    GTK_RESPONSE_OK);
+
+    gtk_dialog_add_button (GTK_DIALOG (dialog),
+                    (priv->get_old
+                     ? _(HILDON_GET_PASSWORD_DIALOG_CANCEL)
+                     : _(HILDON_GET_PASSWORD_VERIFY_DIALOG_CANCEL)),
+                    GTK_RESPONSE_CANCEL);
 
     /* Create password text entry */
-    control = gtk_entry_new();
+    control = gtk_entry_new ();
     gtk_entry_set_width_chars (GTK_ENTRY (control), 20);
 
     g_object_set (control, "hildon-input-mode", HILDON_GTK_INPUT_MODE_FULL, NULL);
-    gtk_entry_set_visibility(GTK_ENTRY(control), FALSE);
-    priv->passwordEntry = HILDON_CAPTION
-      (hildon_caption_new(group,
-                         (priv->get_old
-                          ? _(HILDON_GET_PASSWORD_DIALOG_PASSWORD)
-                          : _(HILDON_GET_PASSWORD_VERIFY_DIALOG_PASSWORD)),
-                         control, NULL,
-                         HILDON_CAPTION_OPTIONAL));
-    hildon_caption_set_separator(HILDON_CAPTION(priv->passwordEntry), "");
+
+    gtk_entry_set_visibility (GTK_ENTRY(control), FALSE);
+    priv->password_entry = HILDON_CAPTION
+        (hildon_caption_new(group,
+                            (priv->get_old
+                             ? _(HILDON_GET_PASSWORD_DIALOG_PASSWORD)
+                             : _(HILDON_GET_PASSWORD_VERIFY_DIALOG_PASSWORD)),
+                            control, NULL,
+                            HILDON_CAPTION_OPTIONAL));
+    hildon_caption_set_separator (HILDON_CAPTION (priv->password_entry), "");
 
     /* Do the basic layout */
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
-                       GTK_WIDGET(priv->domainLabel), FALSE, FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
-                       GTK_WIDGET(priv->passwordEntry), FALSE, FALSE, 0);
-    gtk_widget_show_all(GTK_DIALOG(dialog)->vbox);
-    
+    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
+            GTK_WIDGET (priv->message_label), FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
+            GTK_WIDGET (priv->password_entry), FALSE, FALSE, 0);
+    gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
+
     /* Ensure group is freed when all its contents have been removed */
-    g_object_unref(group);
+    g_object_unref (group);
 }
 
-
-/* Public functions */
-
 /**
  * hildon_get_password_dialog_get_type:
  *
@@ -349,26 +377,27 @@ create_contents(HildonGetPasswordDialog *dialog)
  *
  * Returns: HildonGetPasswordDialog type
  */
-GType hildon_get_password_dialog_get_type(void)
+GType G_GNUC_CONST
+hildon_get_password_dialog_get_type             (void)
 {
     static GType dialog_type = 0;
 
-    if (!dialog_type) {
+    if (! dialog_type) {
         static const GTypeInfo dialog_info = {
-            sizeof(HildonGetPasswordDialogClass),
+            sizeof (HildonGetPasswordDialogClass),
             NULL,       /* base_init */
             NULL,       /* base_finalize */
             (GClassInitFunc) hildon_get_password_dialog_class_init,
             NULL,       /* class_finalize */
             NULL,       /* class_data */
-            sizeof(HildonGetPasswordDialog),
+            sizeof (HildonGetPasswordDialog),
             0,  /* n_preallocs */
             (GInstanceInitFunc) hildon_get_password_dialog_init
         };
 
-        dialog_type = g_type_register_static(GTK_TYPE_DIALOG,
-                                             "HildonGetPasswordDialog",
-                                             &dialog_info, 0);
+        dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
+                "HildonGetPasswordDialog",
+                &dialog_info, 0);
     }
     return dialog_type;
 }
@@ -385,18 +414,19 @@ GType hildon_get_password_dialog_get_type(void)
  *
  * Returns: a new #GtkWidget of type HildonGetPasswordDialog
  */
-GtkWidget *hildon_get_password_dialog_new(GtkWindow * parent,
-                                          gboolean get_old)
+GtkWidget*
+hildon_get_password_dialog_new                  (GtkWindow *parent,
+                                                 gboolean get_old)
 {
     HildonGetPasswordDialog *dialog = g_object_new
         (HILDON_TYPE_GET_PASSWORD_DIALOG,
          "get-old", get_old, NULL);
 
     if (parent != NULL) {
-        gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
+        gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
     }
 
-    return GTK_WIDGET(dialog);
+    return (GtkWidget *) dialog;
 }
 
 /**
@@ -414,65 +444,68 @@ GtkWidget *hildon_get_password_dialog_new(GtkWindow * parent,
  *
  * Returns: a new #GtkWidget of type HildonGetPasswordDialog
  */
-GtkWidget *hildon_get_password_dialog_new_with_default (GtkWindow * parent,
-                                                       const gchar *password,
-                                               gboolean get_old)
+GtkWidget*
+hildon_get_password_dialog_new_with_default     (GtkWindow *parent,
+                                                 const gchar *password,
+                                                 gboolean get_old)
 {
     GtkWidget *dialog;
 
-    dialog = hildon_get_password_dialog_new(parent, get_old);
-    if(password != NULL)
-        g_object_set(G_OBJECT(dialog), "password", password, NULL);
+    dialog = hildon_get_password_dialog_new (parent, get_old);
 
-    return GTK_WIDGET(dialog);
+    if (password != NULL)
+        g_object_set (G_OBJECT (dialog), "password", password, NULL);
+
+    return GTK_WIDGET (dialog);
 }
 
 /**
  * hildon_get_password_dialog_get_password:
  * @dialog: pointer to HildonSetPasswordDialog
  * 
- * Gets the currently inputted password.
+ * Gets the currently entered password.
  *
- * Returns: current password ( if the dialog is successfully 
- * accepted with 'OK'  )
+ * Returns: current password entered by the user.
  */
-const gchar
-    *hildon_get_password_dialog_get_password(HildonGetPasswordDialog *
-                                             dialog)
+const gchar*
+hildon_get_password_dialog_get_password         (HildonGetPasswordDialog *dialog)
 {
     GtkEntry *entry1;
     gchar *text1;
 
     HildonGetPasswordDialogPrivate *priv;
 
-    g_return_val_if_fail (HILDON_IS_GET_PASSWORD_DIALOG(dialog), NULL);
-    priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+    g_return_val_if_fail (HILDON_IS_GET_PASSWORD_DIALOG (dialog), NULL);
+    priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE (dialog);
+    g_assert (priv);
 
     /* Retrieve the password entry widget */
-    entry1 = GTK_ENTRY (gtk_bin_get_child(GTK_BIN (priv->passwordEntry)));
-    text1 = GTK_ENTRY(entry1)->text;
+    entry1 = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->password_entry)));
+    text1 = GTK_ENTRY (entry1)->text;
 
     return text1;
 }
 
 /**
- * hildon_get_password_dialog_set_domain(GtkWidget *dialog, 
+ * hildon_get_password_dialog_set_message
  * @dialog: the dialog
- * @domain: the domain or some other descriptive text to be set
+ * @message: a custom message or some other descriptive text to be set
  * 
  * Sets the optional descriptive text.
  */
-
-void hildon_get_password_dialog_set_domain(HildonGetPasswordDialog *dialog, 
-                                           const gchar *domain)
+void 
+hildon_get_password_dialog_set_message          (HildonGetPasswordDialog *dialog, 
+                                                 const gchar *message)
 {
-  HildonGetPasswordDialogPrivate *priv;
+    HildonGetPasswordDialogPrivate *priv;
 
-  g_return_if_fail (HILDON_IS_GET_PASSWORD_DIALOG(dialog));
+    g_return_if_fail (HILDON_IS_GET_PASSWORD_DIALOG (dialog));
+
+    priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE (dialog);
+    g_assert (priv);
+
+    gtk_label_set_text (priv->message_label, message);
 
-  priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
-  gtk_label_set_text(priv->domainLabel, domain);
-  
 }
 
 /**
@@ -482,20 +515,19 @@ void hildon_get_password_dialog_set_domain(HildonGetPasswordDialog *dialog,
  * 
  * Sets the password entry field's neigbouring label.
  */
-
-void hildon_get_password_dialog_set_caption(HildonGetPasswordDialog *dialog,
-                                           const gchar *new_caption)
+void 
+hildon_get_password_dialog_set_caption          (HildonGetPasswordDialog *dialog,
+                                                 const gchar *new_caption)
 {
-  
-
-  HildonGetPasswordDialogPrivate *priv;
+    HildonGetPasswordDialogPrivate *priv;
 
-  g_return_if_fail (HILDON_IS_GET_PASSWORD_DIALOG(dialog));
-  g_return_if_fail (new_caption != NULL);
+    g_return_if_fail (HILDON_IS_GET_PASSWORD_DIALOG (dialog));
+    g_return_if_fail (new_caption != NULL);
 
-  priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
-  hildon_caption_set_label(priv->passwordEntry, new_caption);
+    priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE (dialog);
+    g_assert (priv);
 
+    hildon_caption_set_label (priv->password_entry, new_caption);
 }
 
 /**
@@ -507,36 +539,46 @@ void hildon_get_password_dialog_set_caption(HildonGetPasswordDialog *dialog,
  * 
  * sets the maximum number of characters allowed as the password
  */
-
-void hildon_get_password_dialog_set_max_characters (HildonGetPasswordDialog *dialog, gint max_characters )
+void 
+hildon_get_password_dialog_set_max_characters   (HildonGetPasswordDialog *dialog, 
+                                                 gint max_characters)
 {
-  HildonGetPasswordDialogPrivate *priv;
-
-  g_return_if_fail (max_characters > 0);
-  g_return_if_fail (HILDON_IS_GET_PASSWORD_DIALOG(dialog));
-
-  priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
-
-  /* Apply the given length to password entry */
-  gtk_entry_set_max_length(GTK_ENTRY
-                          (gtk_bin_get_child
-                           GTK_BIN ((priv->passwordEntry))),
-                          max_characters);
-
-  /* Connect callback to show error banner if the limit is exceeded */
-  g_signal_connect(GTK_ENTRY
-                  (gtk_bin_get_child
-                   GTK_BIN ((priv->passwordEntry))),
-                  "invalid_input",
-                  G_CALLBACK(_invalid_input),
-                  NULL
-                  );
+    HildonGetPasswordDialogPrivate *priv;
+
+    g_return_if_fail (max_characters > 0);
+    g_return_if_fail (HILDON_IS_GET_PASSWORD_DIALOG (dialog));
+
+    priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE (dialog);
+    g_assert (priv);
+
+    /* Apply the given length to password entry */
+    gtk_entry_set_max_length (GTK_ENTRY
+            (gtk_bin_get_child
+             GTK_BIN ((priv->password_entry))),
+             max_characters);
+
+    /* FIXME There is a bug here -- the prev. signal needs to be
+     * disconnected before connecting the new signal. Besides, this 
+     * should go into the constructor */
+
+    /* Connect callback to show error banner if the limit is exceeded */
+    g_signal_connect (GTK_ENTRY
+            (gtk_bin_get_child
+             GTK_BIN ((priv->password_entry))),
+            "invalid_input",
+            G_CALLBACK (invalid_input),
+            NULL
+            );
 }
 
-static void _invalid_input(GtkWidget *widget, GtkInvalidInputType reason, 
-                          gpointer unused) 
+/* Callback that gets called when maximum chars is reached in the entry */
+static void 
+invalid_input                                   (GtkWidget *widget, 
+                                                 GtkInvalidInputType reason, 
+                                                 gpointer unused) 
 {
-  if (reason==GTK_INVALID_INPUT_MAX_CHARS_REACHED) {
-    hildon_banner_show_information (widget, NULL, _(HILDON_GET_PASSWORD_DIALOG_MAX_CHARS));
-  }
+    if (reason == GTK_INVALID_INPUT_MAX_CHARS_REACHED) 
+    {
+        hildon_banner_show_information (widget, NULL, _(HILDON_GET_PASSWORD_DIALOG_MAX_CHARS));
+    }
 }
index 5cf005b..841acc3 100644 (file)
  *
  */
 
-#ifndef __HILDON_GET_PASSWORD_DIALOG_H__
-#define __HILDON_GET_PASSWORD_DIALOG_H__
+#ifndef                                         __HILDON_GET_PASSWORD_DIALOG_H__
+#define                                         __HILDON_GET_PASSWORD_DIALOG_H__
 
-#include <gtk/gtkdialog.h>
+#include                                        <gtk/gtkdialog.h>
 
 G_BEGIN_DECLS
 
-#define HILDON_TYPE_GET_PASSWORD_DIALOG ( hildon_get_password_dialog_get_type() )
+#define                                         HILDON_TYPE_GET_PASSWORD_DIALOG \
+                                                (hildon_get_password_dialog_get_type())
 
-#define HILDON_GET_PASSWORD_DIALOG(obj) \
-  (GTK_CHECK_CAST (obj, HILDON_TYPE_GET_PASSWORD_DIALOG,\
-   HildonGetPasswordDialog))
+#define                                         HILDON_GET_PASSWORD_DIALOG(obj) \
+                                                (GTK_CHECK_CAST (obj, HILDON_TYPE_GET_PASSWORD_DIALOG,\
+                                                HildonGetPasswordDialog))
 
-#define HILDON_GET_PASSWORD_DIALOG_CLASS(klass) \
-  (GTK_CHECK_CLASS_CAST ((klass), HILDON_TYPE_GET_PASSWORD_DIALOG, \
-  HildonGetPasswordDialogClass))
+#define                                         HILDON_GET_PASSWORD_DIALOG_CLASS(klass) \
+                                                (GTK_CHECK_CLASS_CAST ((klass), HILDON_TYPE_GET_PASSWORD_DIALOG, \
+                                                HildonGetPasswordDialogClass))
 
-#define HILDON_IS_GET_PASSWORD_DIALOG(obj) \
-  (GTK_CHECK_TYPE (obj, HILDON_TYPE_GET_PASSWORD_DIALOG))
+#define                                         HILDON_IS_GET_PASSWORD_DIALOG(obj) \
+                                                (GTK_CHECK_TYPE (obj, HILDON_TYPE_GET_PASSWORD_DIALOG))
 
-#define HILDON_IS_GET_PASSWORD_DIALOG_CLASS(klass) \
-  (GTK_CHECK_CLASS_TYPE ((klass), HILDON_TYPE_GET_PASSWORD_DIALOG))
+#define                                         HILDON_IS_GET_PASSWORD_DIALOG_CLASS(klass) \
+                                                (GTK_CHECK_CLASS_TYPE ((klass), HILDON_TYPE_GET_PASSWORD_DIALOG))
 
+typedef struct                                  _HildonGetPasswordDialog HildonGetPasswordDialog;
 
-#define HILDON_GET_PASSWORD_DIALOG_TITLE           "ecdg_ti_get_old_password"
-#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_CANCEL          "ecdg_bd_get_old_password_dialog_cancel"
+typedef struct                                  _HildonGetPasswordDialogClass HildonGetPasswordDialogClass;
 
-#define HILDON_GET_PASSWORD_VERIFY_DIALOG_TITLE    "ecdg_ti_verify_password"
-#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_CANCEL   "ecdg_bd_verify_password_dialog_cancel"
-
-#define HILDON_GET_PASSWORD_DIALOG_MAX_CHARS       "ckdg_ib_maximum_characters_reached"
-
-typedef struct _HildonGetPasswordDialog      HildonGetPasswordDialog;
-typedef struct _HildonGetPasswordDialogClass HildonGetPasswordDialogClass;
-
-struct _HildonGetPasswordDialog {
+struct                                          _HildonGetPasswordDialog 
+{
     GtkDialog parent;
 };
 
-struct _HildonGetPasswordDialogClass {
+struct                                          _HildonGetPasswordDialogClass 
+{
     GtkDialogClass parent_class;
 };
 
-GType      hildon_get_password_dialog_get_type(void) G_GNUC_CONST;
+GType G_GNUC_CONST
+hildon_get_password_dialog_get_type             (void);
 
-GtkWidget *hildon_get_password_dialog_new              (GtkWindow   *parent,
-                                                        gboolean     get_old);
+GtkWidget*
+hildon_get_password_dialog_new                  (GtkWindow *parent,
+                                                 gboolean get_old);
 
-GtkWidget *hildon_get_password_dialog_new_with_default (GtkWindow   *parent,
-                                                       const gchar *password,
-                                                       gboolean     get_old);
+GtkWidget*
+hildon_get_password_dialog_new_with_default     (GtkWindow *parent,
+                                                 const gchar *password,
+                                                 gboolean get_old);
 
-void       hildon_get_password_dialog_set_domain       (HildonGetPasswordDialog *dialog, 
-                                                       const gchar             *domain);
+void       
+hildon_get_password_dialog_set_message          (HildonGetPasswordDialog *dialog, 
+                                                 const gchar *message);
 
-void       hildon_get_password_dialog_set_caption      (HildonGetPasswordDialog *dialog,
-                                                       const gchar             *new_caption);
+void       
+hildon_get_password_dialog_set_caption          (HildonGetPasswordDialog *dialog,
+                                                 const gchar *new_caption);
 
-void       hildon_get_password_dialog_set_max_characters(HildonGetPasswordDialog *dialog,
-                                                        gint                     max_characters);
+void       
+hildon_get_password_dialog_set_max_characters   (HildonGetPasswordDialog *dialog,
+                                                 gint max_characters);
 
-const gchar * hildon_get_password_dialog_get_password(HildonGetPasswordDialog * dialog);
+const gchar* 
+hildon_get_password_dialog_get_password         (HildonGetPasswordDialog *dialog);
 
 G_END_DECLS
-#endif /* __HILDON_GET_PASSWORD_DIALOG_H__ */
+
+#endif                                          /* __HILDON_GET_PASSWORD_DIALOG_H__ */