gossip r2787 - in trunk: . data/glade src
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: gossip r2787 - in trunk: . data/glade src
- Date: Tue, 15 Apr 2008 20:28:11 +0100 (BST)
Author: mr
Date: Tue Apr 15 20:28:11 2008
New Revision: 2787
URL: http://svn.gnome.org/viewvc/gossip?rev=2787&view=rev
Log:
Use a confirm entry when changing password, fixes bug 524903
Added:
trunk/src/gossip-change-password-dialog.c
trunk/src/gossip-change-password-dialog.h
Modified:
trunk/ChangeLog
trunk/data/glade/main.glade
trunk/src/Makefile.am
trunk/src/gossip-account-widget-jabber.c
Modified: trunk/data/glade/main.glade
==============================================================================
--- trunk/data/glade/main.glade (original)
+++ trunk/data/glade/main.glade Tue Apr 15 20:28:11 2008
@@ -8646,4 +8646,299 @@
</child>
</widget>
+<widget class="GtkDialog" id="change_password_dialog">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Change Password</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">False</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+ <property name="has_separator">False</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="vbox222">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="hbuttonbox7">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="button_cancel">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="button_ok">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-5</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox223">
+ <property name="border_width">5</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">18</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox197">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">12</property>
+
+ <child>
+ <widget class="GtkImage" id="image905">
+ <property name="visible">True</property>
+ <property name="icon_size">6</property>
+ <property name="icon_name">gtk-dialog-authentication</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label653">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">To make sure your password is set correctly, enter your password and then confirm it below.</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">True</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkTable" id="table">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+
+ <child>
+ <widget class="GtkLabel" id="label654">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Password:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">entry_password</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label655">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Con_firm:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">entry_confirm</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="entry_password">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">False</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">â</property>
+ <property name="activates_default">False</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="entry_confirm">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">False</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">â</property>
+ <property name="activates_default">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox_progress">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">12</property>
+
+ <child>
+ <widget class="GtkLabel" id="label_match">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Passwords do not match!</b></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
</glade-interface>
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Tue Apr 15 20:28:11 2008
@@ -46,6 +46,7 @@
gossip-avatar-image.c gossip-avatar-image.h \
gossip-cell-renderer-expander.c gossip-cell-renderer-expander.h \
gossip-cell-renderer-text.c gossip-cell-renderer-text.h \
+ gossip-change-password-dialog.c gossip-change-password-dialog.h \
gossip-chat.c gossip-chat.h \
gossip-chat-invite.c gossip-chat-invite.h \
gossip-chat-manager.c gossip-chat-manager.h \
Modified: trunk/src/gossip-account-widget-jabber.c
==============================================================================
--- trunk/src/gossip-account-widget-jabber.c (original)
+++ trunk/src/gossip-account-widget-jabber.c Tue Apr 15 20:28:11 2008
@@ -41,6 +41,7 @@
#endif
#include "gossip-account-widget-jabber.h"
+#include "gossip-change-password-dialog.h"
#include "gossip-app.h"
#include "gossip-glade.h"
#include "gossip-marshal.h"
@@ -114,7 +115,6 @@
gint *position,
GossipAccountWidgetJabber *settings);
static void account_widget_jabber_register_cancel (GossipAccountWidgetJabber *settings);
-static void account_widget_jabber_change_password_cancel (GossipAccountWidgetJabber *settings);
static void account_widget_jabber_register_cb (GossipResult result,
GError *error,
GossipAccountWidgetJabber *settings);
@@ -124,11 +124,6 @@
GossipAccountWidgetJabber *settings);
static void account_widget_jabber_button_forget_clicked_cb (GtkWidget *button,
GossipAccountWidgetJabber *settings);
-static void account_widget_jabber_cp_entry_activate_cb (GtkWidget *entry,
- GtkDialog *dialog);
-static void account_widget_jabber_cp_response_cb (GtkWidget *dialog,
- gint response,
- GossipAccountWidgetJabber *settings);
static void account_widget_jabber_button_change_password_clicked_cb (GtkWidget *button,
GossipAccountWidgetJabber *settings);
static void account_widget_jabber_setup (GossipAccountWidgetJabber *settings,
@@ -255,7 +250,6 @@
priv->disposed = TRUE;
account_widget_jabber_register_cancel (settings);
- account_widget_jabber_change_password_cancel (settings);
if (priv->account_changed) {
gossip_debug (DEBUG_DOMAIN, "Disposing of this widget and accounts changed, saving accounts...");
@@ -808,173 +802,14 @@
}
static void
-account_widget_jabber_change_password_cancel (GossipAccountWidgetJabber *settings)
-{
- GossipAccountWidgetJabberPriv *priv;
- GossipSession *session;
-
- priv = GET_PRIV (settings);
-
- if (!priv->changing_password) {
- return;
- }
-
- session = gossip_app_get_session ();
- gossip_session_change_password_cancel (session, priv->account);
-
- priv->changing_password = FALSE;
- gtk_widget_set_sensitive (priv->button_change_password, TRUE);
- gtk_widget_set_sensitive (priv->vbox_settings, TRUE);
-}
-
-static void
-account_widget_jabber_change_password_cb (GossipResult result,
- GError *error,
- GossipAccountWidgetJabber *settings)
-{
- GossipAccountWidgetJabberPriv *priv;
- GtkWidget *toplevel;
- GtkWidget *md;
- const gchar *str;
-
- priv = GET_PRIV (settings);
-
- priv->changing_password = FALSE;
-
- /* FIXME: Not sure how to do this right, but really we
- * shouldn't show the register button as sensitive if we have
- * just registered.
- */
- gtk_widget_set_sensitive (priv->button_change_password, TRUE);
- gtk_widget_set_sensitive (priv->vbox_settings, TRUE);
-
- toplevel = gtk_widget_get_toplevel (priv->vbox_settings);
- if (GTK_WIDGET_TOPLEVEL (toplevel) != TRUE ||
- GTK_WIDGET_TYPE (toplevel) != GTK_TYPE_WINDOW) {
- toplevel = NULL;
- }
-
- if (result == GOSSIP_RESULT_OK) {
- str = _("Successfully changed your account password.");
- md = gtk_message_dialog_new (GTK_WINDOW (toplevel),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE,
- str);
-
- str = _("You should now be able to connect with your new password.");
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (md), str);
- } else {
- str = _("Failed to change your account password.");
- md = gtk_message_dialog_new (GTK_WINDOW (toplevel),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- str);
-
- if (error && error->message) {
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (md),
- error->message);
- }
- }
-
- g_signal_connect_swapped (md, "response",
- G_CALLBACK (gtk_widget_destroy),
- md);
-
- gtk_widget_show_all (md);
-}
-
-static void
-account_widget_jabber_cp_entry_activate_cb (GtkWidget *entry,
- GtkDialog *dialog)
-{
- gtk_dialog_response (dialog, GTK_RESPONSE_OK);
-}
-
-static void
-account_widget_jabber_cp_response_cb (GtkWidget *dialog,
- gint response,
- GossipAccountWidgetJabber *settings)
-{
- if (response == GTK_RESPONSE_OK) {
- GossipAccountWidgetJabberPriv *priv;
- GossipSession *session;
- GtkWidget *entry;
- const gchar *new_password;
-
- priv = GET_PRIV (settings);
-
- entry = g_object_get_data (G_OBJECT (dialog), "entry");
- new_password = gtk_entry_get_text (GTK_ENTRY (entry));
-
- priv->changing_password = TRUE;
- gtk_widget_set_sensitive (priv->button_change_password, FALSE);
- gtk_widget_set_sensitive (priv->vbox_settings, FALSE);
-
- session = gossip_app_get_session ();
- gossip_session_change_password (session,
- priv->account,
- new_password,
- (GossipErrorCallback)
- account_widget_jabber_change_password_cb,
- settings);
- }
-
- gtk_widget_destroy (dialog);
-}
-
-static void
account_widget_jabber_button_change_password_clicked_cb (GtkWidget *button,
GossipAccountWidgetJabber *settings)
{
GossipAccountWidgetJabberPriv *priv;
- GtkWidget *toplevel;
- GtkWidget *dialog;
- GtkWidget *entry;
- GtkWidget *hbox;
- gchar *str;
- const gchar *id;
-
- priv = GET_PRIV (settings);
- toplevel = gtk_widget_get_toplevel (priv->vbox_settings);
- if (GTK_WIDGET_TOPLEVEL (toplevel) != TRUE ||
- GTK_WIDGET_TYPE (toplevel) != GTK_TYPE_WINDOW) {
- toplevel = NULL;
- }
-
- /* Dialog here to get new password from user */
- id = gossip_account_get_id (priv->account);
- str = g_strdup_printf ("<b>%s</b>", id);
- dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
- 0,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_OK_CANCEL,
- _("Please enter a new password for this account:\n%s"),
- str);
-
- g_free (str);
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
- hbox, FALSE, TRUE, 4);
-
- entry = gtk_entry_new ();
- gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 4);
-
- g_object_set (GTK_MESSAGE_DIALOG (dialog)->label, "use-markup", TRUE, NULL);
- g_object_set_data (G_OBJECT (dialog), "entry", entry);
-
- g_signal_connect (entry, "activate",
- G_CALLBACK (account_widget_jabber_cp_entry_activate_cb),
- dialog);
- g_signal_connect (dialog, "response",
- G_CALLBACK (account_widget_jabber_cp_response_cb),
- settings);
+ priv = GET_PRIV (settings);
- gtk_widget_show_all (dialog);
+ gossip_change_password_dialog_show (priv->account);
}
static void
Added: trunk/src/gossip-change-password-dialog.c
==============================================================================
--- (empty file)
+++ trunk/src/gossip-change-password-dialog.c Tue Apr 15 20:28:11 2008
@@ -0,0 +1,271 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Martyn Russell <martyn imendio com>
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+#include <glib/gi18n.h>
+
+#include <libgossip/gossip-debug.h>
+#include <libgossip/gossip-session.h>
+#include <libgossip/gossip-utils.h>
+#include <libgossip/gossip-account-manager.h>
+
+#include "gossip-change-password-dialog.h"
+#include "gossip-app.h"
+#include "gossip-glade.h"
+#include "ephy-spinner.h"
+
+#define DEBUG_DOMAIN "ChangePasswordDialog"
+
+typedef struct {
+ GtkWidget *window;
+
+ GtkWidget *table;
+
+ GtkWidget *entry_password;
+ GtkWidget *entry_confirm;
+
+ GtkWidget *label_match;
+ GtkWidget *throbber;
+
+ GtkWidget *button_ok;
+
+ GossipAccount *account;
+ gboolean changing_password;
+} GossipChangePasswordDialog;
+
+static void
+change_password_dialog_changed_cb (GossipResult result,
+ GError *error,
+ GossipChangePasswordDialog *dialog)
+{
+ GtkWidget *md;
+ const gchar *str;
+
+ dialog->changing_password = FALSE;
+
+ if (result == GOSSIP_RESULT_OK) {
+ GossipSession *session;
+ GossipAccountManager *manager;
+ const gchar *password;
+
+ /* Remember password */
+ password = gtk_entry_get_text (GTK_ENTRY (dialog->entry_password));
+ gossip_account_set_password (dialog->account, password);
+
+ session = gossip_app_get_session ();
+ manager = gossip_session_get_account_manager (session);
+ gossip_account_manager_store (manager);
+
+ /* Show success dialog */
+ str = _("Successfully changed your account password.");
+ md = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_CLOSE,
+ str);
+
+ str = _("You should now be able to connect with your new password.");
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (md), str);
+ } else {
+ str = _("Failed to change your account password.");
+ md = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ str);
+
+ if (error && error->message) {
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (md),
+ error->message);
+ }
+ }
+
+ g_signal_connect_swapped (md, "response",
+ G_CALLBACK (gtk_widget_destroy),
+ md);
+
+ gtk_widget_show_all (md);
+
+ /* Now clean up dialog */
+ gtk_widget_destroy (dialog->window);
+}
+
+static void
+change_password_dialog_start (GossipChangePasswordDialog *dialog)
+{
+ GossipSession *session;
+ const gchar *password;
+
+ if (dialog->changing_password) {
+ return;
+ }
+
+ dialog->changing_password = TRUE;
+
+ /* Disable widgets */
+ gtk_widget_set_sensitive (dialog->table, FALSE);
+ gtk_widget_set_sensitive (dialog->button_ok, FALSE);
+
+ /* Show progress widget */
+ gtk_widget_show (dialog->throbber);
+ ephy_spinner_start (EPHY_SPINNER (dialog->throbber));
+
+ /* Actually set the password */
+ password = gtk_entry_get_text (GTK_ENTRY (dialog->entry_password));
+
+ session = gossip_app_get_session ();
+ gossip_session_change_password (session,
+ dialog->account,
+ password,
+ (GossipErrorCallback)
+ change_password_dialog_changed_cb,
+ dialog);
+}
+
+static void
+change_password_dialog_stop (GossipChangePasswordDialog *dialog)
+{
+ GossipSession *session;
+
+ if (!dialog->changing_password) {
+ return;
+ }
+
+ /* Cancel operation */
+ session = gossip_app_get_session ();
+ gossip_session_change_password_cancel (session,
+ dialog->account);
+ dialog->changing_password = FALSE;
+
+ /* Stop progress widget */
+ ephy_spinner_stop (EPHY_SPINNER (dialog->throbber));
+ gtk_widget_hide (dialog->throbber);
+
+ /* Enable widgets */
+ gtk_widget_set_sensitive (dialog->table, TRUE);
+ gtk_widget_set_sensitive (dialog->button_ok, TRUE);
+}
+
+static void
+change_password_dialog_entry_changed_cb (GtkWidget *widget,
+ GossipChangePasswordDialog *dialog)
+{
+ const gchar *str1;
+ const gchar *str2;
+ gboolean empty;
+ gboolean match;
+
+ str1 = gtk_entry_get_text (GTK_ENTRY (dialog->entry_password));
+ str2 = gtk_entry_get_text (GTK_ENTRY (dialog->entry_confirm));
+
+ empty = G_STR_EMPTY (str1) && G_STR_EMPTY (str2);
+
+ match = FALSE;
+ match |= empty;
+ match |= str1 && str2 && strcmp (str1, str2) == 0;
+
+ if (match) {
+ gtk_widget_hide (dialog->label_match);
+ } else {
+ gtk_widget_show (dialog->label_match);
+ }
+
+ gtk_widget_set_sensitive (dialog->button_ok, match && !empty);
+}
+
+static void
+change_password_dialog_response_cb (GtkWidget *widget,
+ gint response,
+ GossipChangePasswordDialog *dialog)
+{
+ if (response == GTK_RESPONSE_OK) {
+ change_password_dialog_start (dialog);
+ return;
+ }
+
+ if (response == GTK_RESPONSE_CANCEL && dialog->changing_password) {
+ change_password_dialog_stop (dialog);
+ return;
+ }
+
+ gtk_widget_destroy (widget);
+}
+
+static void
+change_password_dialog_destroy_cb (GtkWidget *widget,
+ GossipChangePasswordDialog *dialog)
+{
+ g_object_unref (dialog->account);
+
+ g_free (dialog);
+}
+
+void
+gossip_change_password_dialog_show (GossipAccount *account)
+{
+ GossipChangePasswordDialog *dialog;
+ GladeXML *glade;
+ GtkWidget *hbox_progress;
+
+ g_return_if_fail (GOSSIP_IS_ACCOUNT (account));
+
+ dialog = g_new0 (GossipChangePasswordDialog, 1);
+
+ dialog->account = g_object_ref (account);
+
+ glade = gossip_glade_get_file ("main.glade",
+ "change_password_dialog",
+ NULL,
+ "change_password_dialog", &dialog->window,
+ "entry_password", &dialog->entry_password,
+ "entry_confirm", &dialog->entry_confirm,
+ "table", &dialog->table,
+ "hbox_progress", &hbox_progress,
+ "label_match", &dialog->label_match,
+ "button_ok", &dialog->button_ok,
+ NULL);
+
+ gossip_glade_connect (glade,
+ dialog,
+ "change_password_dialog", "destroy", change_password_dialog_destroy_cb,
+ "change_password_dialog", "response", change_password_dialog_response_cb,
+ "entry_password", "changed", change_password_dialog_entry_changed_cb,
+ "entry_confirm", "changed", change_password_dialog_entry_changed_cb,
+ NULL);
+
+ g_object_add_weak_pointer (G_OBJECT (dialog->window), (gpointer) &dialog);
+
+ g_object_unref (glade);
+
+ /* Set up throbber */
+ dialog->throbber = ephy_spinner_new ();
+ ephy_spinner_set_size (EPHY_SPINNER (dialog->throbber), GTK_ICON_SIZE_SMALL_TOOLBAR);
+ gtk_box_pack_end (GTK_BOX (hbox_progress), dialog->throbber, FALSE, FALSE, 0);
+ gtk_widget_hide (dialog->throbber);
+
+ gtk_widget_show (dialog->window);
+}
Added: trunk/src/gossip-change-password-dialog.h
==============================================================================
--- (empty file)
+++ trunk/src/gossip-change-password-dialog.h Tue Apr 15 20:28:11 2008
@@ -0,0 +1,32 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2005-2007 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Martyn Russell <martyn imendio com>
+ */
+
+#ifndef __GOSSIP_CHANGE_PASSWORD_DIALOG_H__
+#define __GOSSIP_CHANGE_PASSWORD_DIALOG_H__
+
+G_BEGIN_DECLS
+
+void gossip_change_password_dialog_show (GossipAccount *account);
+
+G_END_DECLS
+
+#endif /* __GOSSIP_CHANGE_PASSWORD_DIALOG_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]