X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon-get-password-dialog.c;h=7db3d9b62c06e617054bccfa1653e6505009961e;hb=7d3f0468795e7298a98578fbb054b5cb9908d523;hp=b5254b2d0754ff7495e4092d8acca0ec94b3d16c;hpb=f1d00c898fcadba477887f78a3baeee5f5c489dc;p=hildon diff --git a/src/hildon-get-password-dialog.c b/src/hildon-get-password-dialog.c index b5254b2..7db3d9b 100644 --- a/src/hildon-get-password-dialog.c +++ b/src/hildon-get-password-dialog.c @@ -3,12 +3,12 @@ * * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved. * - * Contact: Michael Dominic Kostrzewa + * Contact: Rodrigo Novo * * 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 @@ -24,30 +24,65 @@ /** * SECTION:hildon-get-password-dialog - * @short_description: A widget used to get a password + * @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 a custom message. The maximum length of the password can be set. + * + * + * HildonGetPassword example + * + * get_dialog = HILDON_GET_PASSWORD_DIALOG (hildon_get_password_dialog_new (parent, FALSE)); + * + * gtk_widget_show (GTK_WIDGET (get_dialog)); + * + * i = gtk_dialog_run (GTK_DIALOG (get_dialog)); + * + * pass = hildon_get_password_dialog_get_password (get_dialog); + * + * if (i == GTK_RESPONSE_OK && (strcmp (pass, dialog.current_password) != 0)) + * { + * gtk_infoprint (GTK_WINDOW (parent), STR_PASSWORD_INCORRECT); + * gtk_widget_set_sensitive (GTK_WIDGET (dialog.button2), FALSE); + * gtk_widget_set_sensitive (GTK_WIDGET (dialog.button3), FALSE); + * gtk_widget_set_sensitive (GTK_WIDGET (dialog.button4), FALSE); + * } + * + * else if (i == GTK_RESPONSE_OK) + * { + * gtk_widget_set_sensitive( GTK_WIDGET( dialog.button2 ), TRUE); + * } + * + * else + * { + * gtk_widget_set_sensitive (GTK_WIDGET (dialog.button2), FALSE); + * gtk_widget_set_sensitive (GTK_WIDGET (dialog.button3), FALSE); + * gtk_widget_set_sensitive (GTK_WIDGET (dialog.button4), FALSE); + * } + * gtk_widget_destroy (GTK_WIDGET (get_dialog)); + * } + * + * */ +#undef HILDON_DISABLE_DEPRECATED + #ifdef HAVE_CONFIG_H #include #endif -#include "hildon-get-password-dialog.h" -#include #include #include #include #include #include -#include -#include "hildon-input-mode-hint.h" +#include + +#include "hildon-get-password-dialog.h" #include "hildon-caption.h" #include "hildon-banner.h" -#include #include "hildon-get-password-dialog-private.h" #define _(String) dgettext("hildon-libs", String) @@ -93,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 { @@ -135,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: @@ -173,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); @@ -191,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: @@ -232,6 +277,12 @@ hildon_get_password_dialog_class_init (HildonGetPasswordDialogClass *c object_class->get_property = hildon_get_password_get_property; /* Install new properties */ + + /** + * HildonGetPasswordDialog:message: + * + * Optional message displayed to the user. + */ g_object_class_install_property (object_class, PROP_MESSAGE, @@ -241,6 +292,11 @@ hildon_get_password_dialog_class_init (HildonGetPasswordDialogClass *c NULL, G_PARAM_READWRITE)); + /** + * HildonGetPasswordDialog:password: + * + * Password field contents. + */ g_object_class_install_property (object_class, PROP_PASSWORD, @@ -250,15 +306,25 @@ hildon_get_password_dialog_class_init (HildonGetPasswordDialogClass *c "DEFAULT", G_PARAM_READWRITE)); + /** + * HildonGetPasswordDialog:numbers-only: + * + * If the password entry field is operating in numbers-only mode. + */ g_object_class_install_property (object_class, PROP_NUMBERS_ONLY, - g_param_spec_boolean ("numbers_only", + g_param_spec_boolean ("numbers-only", "NumbersOnly", "Set entry to accept only numeric values", FALSE, G_PARAM_READWRITE)); + /** + * HildonGetPasswordDialog:caption-label: + * + * Caption label. + */ g_object_class_install_property (object_class, PROP_CAPTION_LABEL, @@ -267,7 +333,12 @@ hildon_get_password_dialog_class_init (HildonGetPasswordDialogClass *c "The text to be set as the caption label", NULL, G_PARAM_READWRITE)); - + + /** + * HildonGetPasswordDialog:max-characters: + * + * Maximum characters than can be entered. + */ g_object_class_install_property (object_class, PROP_MAX_CHARS, @@ -280,6 +351,11 @@ hildon_get_password_dialog_class_init (HildonGetPasswordDialogClass *c 0, G_PARAM_READWRITE)); + /** + * HildonGetPasswordDialog:get-old: + * + * If the dialog is used to retrieve an old password or set a new one. + */ g_object_class_install_property (object_class, PROP_GET_OLD, @@ -311,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); @@ -344,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 @@ -434,7 +518,7 @@ hildon_get_password_dialog_new (GtkWindow *parent, * @parent: parent window; can be NULL * @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, + * 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. * @@ -463,7 +547,7 @@ hildon_get_password_dialog_new_with_default (GtkWindow *parent, * hildon_get_password_dialog_get_password: * @dialog: pointer to HildonSetPasswordDialog * - * Gets the currently entered password. + * Gets the currently entered password. The string should not be freed. * * Returns: current password entered by the user. */ @@ -491,7 +575,7 @@ hildon_get_password_dialog_get_password (HildonGetPasswordDialog *dialog * @dialog: the dialog * @message: a custom message or some other descriptive text to be set * - * Sets the optional descriptive text. + * Sets the optional descriptive text displayed at the top of the dialog. */ void hildon_get_password_dialog_set_message (HildonGetPasswordDialog *dialog, @@ -535,7 +619,6 @@ hildon_get_password_dialog_set_caption (HildonGetPasswordDialog *dialog * @dialog: the dialog * @max_characters: the maximum number of characters the password dialog * accepts - * @new_caption: the text to be set as the caption label * * sets the maximum number of characters allowed as the password */ @@ -561,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 @@ -569,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, @@ -582,3 +668,4 @@ invalid_input (GtkWidget *widget, hildon_banner_show_information (widget, NULL, _(HILDON_GET_PASSWORD_DIALOG_MAX_CHARS)); } } +#endif