2006-10-16 Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
[hildon] / hildon-widgets / hildon-get-password-dialog.c
index 6396f3b..45bd412 100644 (file)
@@ -1,14 +1,14 @@
 /*
  * This file is part of hildon-libs
  *
- * Copyright (C) 2005 Nokia Corporation.
+ * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
  *
- * Contact: Luc Pionchon <luc.pionchon@nokia.com>
+ * 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; either version 2.1 of
- * the License, or (at your option) any later version.
+ * 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
  *
  */
 
+/**
+ * SECTION:hildon-get-password-dialog
+ * @short_description: A widget used to get a password
+ * @see_also: #HildonSetPasswordDialog
+ * 
+ * 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.
+ */
+
 #include <glib.h>
 
 #include <errno.h>
@@ -108,12 +118,12 @@ hildon_get_password_set_property(GObject * object,
     break;
   case PROP_PASSWORD:
     gtk_entry_set_text(GTK_ENTRY
-                      (gtk_bin_get_child(GTK_BIN(priv->passwordEntry))),
+                      (hildon_caption_get_control (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))),
+    g_object_set(G_OBJECT(hildon_caption_get_control(priv->passwordEntry)),
                 "input-mode",
                 (g_value_get_boolean(value)
                  ? HILDON_INPUT_MODE_HINT_NUMERIC
@@ -156,14 +166,14 @@ hildon_get_password_get_property(GObject * object,
       g_value_set_string(value, string);
       break;
     case PROP_PASSWORD:
-      string = gtk_entry_get_text(GTK_ENTRY(priv->passwordEntry));
+      string = gtk_entry_get_text(GTK_ENTRY (hildon_caption_get_control(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);
+      g_object_get(G_OBJECT(hildon_caption_get_control(priv->passwordEntry)),
+                  "input-mode", &input_mode, NULL);
       g_value_set_boolean(value,
                          (input_mode == HILDON_INPUT_MODE_HINT_NUMERIC));
       break;
@@ -311,6 +321,9 @@ create_contents(HildonGetPasswordDialog *dialog)
 
     /* Create password text entry */
     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,
@@ -341,8 +354,8 @@ create_contents(HildonGetPasswordDialog *dialog)
  * Returns GType for HildonGetPasswordDialog as produced by
  * g_type_register_static().
  *
- * Return value: HildonGetPasswordDialog type
- **/
+ * Returns: HildonGetPasswordDialog type
+ */
 GType hildon_get_password_dialog_get_type(void)
 {
     static GType dialog_type = 0;
@@ -370,19 +383,21 @@ GType hildon_get_password_dialog_get_type(void)
 /**
  * hildon_get_password_dialog_new:
  * @parent: parent window; can be NULL
- * @get_old_password_title: FALSE creates a new get password dialog and
- *                     TRUE creates a new get old password dialog 
+ * @get_old: FALSE creates a new get password dialog and
+ *           TRUE creates a new get old password dialog. That is,
+ *           if the password to be obtained is the old password, 
+ *           this parameter is specified TRUE.  
  * 
  * Construct a new HildonGetPasswordDialog.
  *
- * Return value: a new #GtkWidget of type HildonGetPasswordDialog
- **/
+ * Returns: a new #GtkWidget of type HildonGetPasswordDialog
+ */
 GtkWidget *hildon_get_password_dialog_new(GtkWindow * parent,
-                                          gboolean get_old_password_title)
+                                          gboolean get_old)
 {
     HildonGetPasswordDialog *dialog = g_object_new
         (HILDON_TYPE_GET_PASSWORD_DIALOG,
-         "get-old", get_old_password_title, NULL);
+         "get-old", get_old, NULL);
 
     if (parent != NULL) {
         gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
@@ -392,24 +407,27 @@ GtkWidget *hildon_get_password_dialog_new(GtkWindow * parent,
 }
 
 /**
- * hildon_get_password_dialog_new:
+ * hildon_get_password_dialog_new_with_default:
  * @parent: parent window; can be NULL
- * @password: a default password to be shown in password field.
- * @get_old_password_title: FALSE creates a new get password dialog and
- *                     TRUE creates a new get old password dialog 
+ * @password: a default password to be shown in password field
+ * @get_old: FALSE creates a new get password dialog and
+ *           TRUE creates a new get old password dialog.That is,
+ *           if the password to be obtained is the old password,
+ *           this parameter is specified TRUE.
+ *                        
  * 
  * Same as #hildon_get_password_dialog_new but with a default password
  * in password field.
  *
- * Return value: a new #GtkWidget of type HildonGetPasswordDialog
- **/
+ * Returns: a new #GtkWidget of type HildonGetPasswordDialog
+ */
 GtkWidget *hildon_get_password_dialog_new_with_default (GtkWindow * parent,
                                                        const gchar *password,
-                                               gboolean get_old_password_title)
+                                               gboolean get_old)
 {
     GtkWidget *dialog;
 
-    dialog = hildon_get_password_dialog_new(parent, get_old_password_title);
+    dialog = hildon_get_password_dialog_new(parent, get_old);
     if(password != NULL)
         g_object_set(G_OBJECT(dialog), "password", password, NULL);
 
@@ -422,9 +440,9 @@ GtkWidget *hildon_get_password_dialog_new_with_default (GtkWindow * parent,
  * 
  * Gets the currently inputted password.
  *
- * Return value: current password ( if the dialog is successfully 
+ * Returns: current password ( if the dialog is successfully 
  * accepted with 'OK'  )
- **/
+ */
 const gchar
     *hildon_get_password_dialog_get_password(HildonGetPasswordDialog *
                                              dialog)
@@ -438,9 +456,7 @@ const gchar
     priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
 
     /* Retrieve the password entry widget */
-    entry1 = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(
-                       priv->passwordEntry)));
-
+    entry1 = GTK_ENTRY (hildon_caption_get_control(priv->passwordEntry));
     text1 = GTK_ENTRY(entry1)->text;
 
     return text1;
@@ -449,9 +465,9 @@ const gchar
 /**
  * hildon_get_password_dialog_set_domain(GtkWidget *dialog, 
  * @dialog: the dialog
- * @domain: the domain or some other descriptive text to be set.
+ * @domain: the domain or some other descriptive text to be set
  * 
- * sets the optional descriptive text
+ * Sets the optional descriptive text.
  */
 
 void hildon_get_password_dialog_set_domain(HildonGetPasswordDialog *dialog, 
@@ -469,9 +485,11 @@ void hildon_get_password_dialog_set_domain(HildonGetPasswordDialog *dialog,
 /**
  * hildon_get_password_dialog_set_title:
  * @dialog: the dialog
- * @new_title: the text to be set as the dialog title.
+ * @new_title: the text to be set as the dialog title
  * 
- * sets the dialog title
+ * Sets the dialog title.
+ *
+ * DEPRECATED! use gtk_window_set_title instead.
  */
 void hildon_get_password_dialog_set_title(HildonGetPasswordDialog *dialog,
                                          const gchar *new_title)
@@ -487,9 +505,9 @@ void hildon_get_password_dialog_set_title(HildonGetPasswordDialog *dialog,
 /**
  * hildon_get_password_dialog_set_caption:
  * @dialog: the dialog
- * @new_caption: the text to be set as the caption label.
+ * @new_caption: the text to be set as the caption label
  * 
- * sets the password entry field's neigbouring label.
+ * Sets the password entry field's neigbouring label.
  */
 
 void hildon_get_password_dialog_set_caption(HildonGetPasswordDialog *dialog,
@@ -511,7 +529,8 @@ void hildon_get_password_dialog_set_caption(HildonGetPasswordDialog *dialog,
  * hildon_get_password_dialog_set_max_characters:
  * @dialog: the dialog
  * @max_characters: the maximum number of characters the password dialog
- * accepts.
+ * accepts
+ * @new_caption: the text to be set as the caption label
  * 
  * sets the maximum number of characters allowed as the password
  */