aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-10-28 22:34:40 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-11-23 20:14:30 +0800
commit80ff6670675cdfa087c92901d8d96c16f40c5613 (patch)
tree0b1b9cf5e822a9afff5da0d806b259e60efb8a41 /libempathy-gtk
parentadca8bd9665b6455879f2478e51c4bfd53af4d52 (diff)
downloadgsoc2013-empathy-80ff6670675cdfa087c92901d8d96c16f40c5613.tar
gsoc2013-empathy-80ff6670675cdfa087c92901d8d96c16f40c5613.tar.gz
gsoc2013-empathy-80ff6670675cdfa087c92901d8d96c16f40c5613.tar.bz2
gsoc2013-empathy-80ff6670675cdfa087c92901d8d96c16f40c5613.tar.lz
gsoc2013-empathy-80ff6670675cdfa087c92901d8d96c16f40c5613.tar.xz
gsoc2013-empathy-80ff6670675cdfa087c92901d8d96c16f40c5613.tar.zst
gsoc2013-empathy-80ff6670675cdfa087c92901d8d96c16f40c5613.zip
Abstract EmpathyPasswordDialog to EmpathyBasePasswordDialog
I'm going to implement a slidely different version of this dialog so best to re-use as much code as possible. https://bugzilla.gnome.org/show_bug.cgi?id=661640
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/Makefile.am2
-rw-r--r--libempathy-gtk/empathy-base-password-dialog.c302
-rw-r--r--libempathy-gtk/empathy-base-password-dialog.h71
-rw-r--r--libempathy-gtk/empathy-password-dialog.c206
-rw-r--r--libempathy-gtk/empathy-password-dialog.h6
5 files changed, 391 insertions, 196 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index 96ef811b4..960153cfc 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -33,6 +33,7 @@ libempathy_gtk_handwritten_source = \
empathy-account-widget.c \
empathy-avatar-chooser.c \
empathy-avatar-image.c \
+ empathy-base-password-dialog.c \
empathy-call-utils.c \
empathy-cell-renderer-activatable.c \
empathy-cell-renderer-expander.c \
@@ -100,6 +101,7 @@ libempathy_gtk_headers = \
empathy-account-widget.h \
empathy-avatar-chooser.h \
empathy-avatar-image.h \
+ empathy-base-password-dialog.h \
empathy-call-utils.h \
empathy-cell-renderer-activatable.h \
empathy-cell-renderer-expander.h \
diff --git a/libempathy-gtk/empathy-base-password-dialog.c b/libempathy-gtk/empathy-base-password-dialog.c
new file mode 100644
index 000000000..be708e81c
--- /dev/null
+++ b/libempathy-gtk/empathy-base-password-dialog.c
@@ -0,0 +1,302 @@
+/*
+ * empathy-base-password-dialog.c - Source for EmpathyBasePasswordDialog
+ * Copyright (C) 2010 Collabora Ltd.
+ *
+ * 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.
+ *
+ * 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
+ */
+
+#include <config.h>
+
+#include "empathy-base-password-dialog.h"
+
+#include <glib/gi18n-lib.h>
+
+#define DEBUG_FLAG EMPATHY_DEBUG_SASL
+#include <libempathy/empathy-debug.h>
+#include <libempathy/empathy-utils.h>
+
+G_DEFINE_TYPE (EmpathyBasePasswordDialog, empathy_base_password_dialog,
+ GTK_TYPE_MESSAGE_DIALOG)
+
+enum {
+ PROP_ACCOUNT = 1,
+
+ LAST_PROPERTY,
+};
+
+struct _EmpathyBasePasswordDialogPriv {
+ gboolean grabbing;
+};
+
+static void
+empathy_base_password_dialog_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EmpathyBasePasswordDialog *self = (EmpathyBasePasswordDialog *) object;
+
+ switch (property_id)
+ {
+ case PROP_ACCOUNT:
+ g_value_set_object (value, self->account);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+empathy_base_password_dialog_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EmpathyBasePasswordDialog *self = (EmpathyBasePasswordDialog *) object;
+
+ switch (property_id)
+ {
+ case PROP_ACCOUNT:
+ g_assert (self->account == NULL); /* construct only */
+ self->account = g_value_dup_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+empathy_base_password_dialog_dispose (GObject *object)
+{
+ EmpathyBasePasswordDialog *self = (EmpathyBasePasswordDialog *) object;
+
+ tp_clear_object (&self->account);
+
+ G_OBJECT_CLASS (empathy_base_password_dialog_parent_class)->dispose (object);
+}
+
+static void
+clear_icon_released_cb (GtkEntry *entry,
+ GtkEntryIconPosition icon_pos,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ gtk_entry_set_text (entry, "");
+}
+
+static void
+password_entry_changed_cb (GtkEditable *entry,
+ gpointer user_data)
+{
+ EmpathyBasePasswordDialog *self = user_data;
+ const gchar *str;
+
+ str = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY, !EMP_STR_EMPTY (str));
+
+ gtk_widget_set_sensitive (self->ok_button,
+ !EMP_STR_EMPTY (str));
+}
+
+static void
+password_entry_activate_cb (GtkEntry *entry,
+ EmpathyBasePasswordDialog *self)
+{
+ gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_OK);
+}
+
+static gboolean
+base_password_dialog_grab_keyboard (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ EmpathyBasePasswordDialog *self = user_data;
+
+ if (!self->priv->grabbing)
+ {
+ GdkDevice *device = gdk_event_get_device (event);
+
+ if (device != NULL)
+ {
+ GdkGrabStatus status = gdk_device_grab (device,
+ gtk_widget_get_window (widget),
+ GDK_OWNERSHIP_WINDOW,
+ FALSE,
+ GDK_ALL_EVENTS_MASK,
+ NULL,
+ gdk_event_get_time (event));
+
+ if (status != GDK_GRAB_SUCCESS)
+ DEBUG ("Could not grab keyboard; grab status was %u", status);
+ else
+ self->priv->grabbing = TRUE;
+ }
+ else
+ DEBUG ("Could not get the event device!");
+ }
+
+ return FALSE;
+}
+
+static gboolean
+base_password_dialog_ungrab_keyboard (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ EmpathyBasePasswordDialog *self = user_data;
+
+ if (self->priv->grabbing)
+ {
+ GdkDevice *device = gdk_event_get_device (event);
+
+ if (device != NULL)
+ {
+ gdk_device_ungrab (device, gdk_event_get_time (event));
+ self->priv->grabbing = FALSE;
+ }
+ else
+ DEBUG ("Could not get the event device!");
+ }
+
+ return FALSE;
+}
+
+static gboolean
+base_password_dialog_window_state_changed (GtkWidget *widget,
+ GdkEventWindowState *event,
+ gpointer data)
+{
+ GdkWindowState state = gdk_window_get_state (gtk_widget_get_window (widget));
+
+ if (state & GDK_WINDOW_STATE_WITHDRAWN
+ || state & GDK_WINDOW_STATE_ICONIFIED
+ || state & GDK_WINDOW_STATE_FULLSCREEN
+ || state & GDK_WINDOW_STATE_MAXIMIZED)
+ {
+ base_password_dialog_ungrab_keyboard (widget, (GdkEvent *) event, data);
+ }
+ else
+ {
+ base_password_dialog_grab_keyboard (widget, (GdkEvent *) event, data);
+ }
+
+ return FALSE;
+}
+
+static void
+empathy_base_password_dialog_constructed (GObject *object)
+{
+ EmpathyBasePasswordDialog *self;
+ GtkWidget *icon;
+ GtkBox *box;
+ gchar *text;
+
+ self = EMPATHY_BASE_PASSWORD_DIALOG (object);
+
+ g_assert (self->account != NULL);
+
+ self->priv->grabbing = FALSE;
+
+ /* dialog */
+ gtk_dialog_add_button (GTK_DIALOG (self),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+ self->ok_button = gtk_dialog_add_button (GTK_DIALOG (self),
+ GTK_STOCK_OK, GTK_RESPONSE_OK);
+ gtk_widget_set_sensitive (self->ok_button, FALSE);
+
+ text = g_strdup_printf (_("Enter your password for account\n<b>%s</b>"),
+ tp_account_get_display_name (self->account));
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (self), text);
+ g_free (text);
+
+ gtk_window_set_icon_name (GTK_WINDOW (self),
+ GTK_STOCK_DIALOG_AUTHENTICATION);
+
+ box = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self)));
+
+ /* dialog icon */
+ icon = gtk_image_new_from_icon_name (
+ tp_account_get_icon_name (self->account), GTK_ICON_SIZE_DIALOG);
+ gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (self), icon);
+ gtk_widget_show (icon);
+
+ /* entry */
+ self->entry = gtk_entry_new ();
+ gtk_entry_set_visibility (GTK_ENTRY (self->entry), FALSE);
+
+ /* entry clear icon */
+ gtk_entry_set_icon_from_stock (GTK_ENTRY (self->entry),
+ GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
+ gtk_entry_set_icon_sensitive (GTK_ENTRY (self->entry),
+ GTK_ENTRY_ICON_SECONDARY, FALSE);
+
+ g_signal_connect (self->entry, "icon-release",
+ G_CALLBACK (clear_icon_released_cb), NULL);
+ g_signal_connect (self->entry, "changed",
+ G_CALLBACK (password_entry_changed_cb), self);
+ g_signal_connect (self->entry, "activate",
+ G_CALLBACK (password_entry_activate_cb), self);
+
+ gtk_box_pack_start (box, self->entry, FALSE, FALSE, 0);
+ gtk_widget_show (self->entry);
+
+ /* remember password ticky box */
+ self->ticky = gtk_check_button_new_with_label (_("Remember password"));
+
+ gtk_box_pack_start (box, self->ticky, FALSE, FALSE, 0);
+
+ g_signal_connect (self, "window-state-event",
+ G_CALLBACK (base_password_dialog_window_state_changed), self);
+ g_signal_connect (self, "map-event",
+ G_CALLBACK (base_password_dialog_grab_keyboard), self);
+ g_signal_connect (self, "unmap-event",
+ G_CALLBACK (base_password_dialog_ungrab_keyboard), self);
+
+ gtk_widget_grab_focus (self->entry);
+
+ gtk_window_set_position (GTK_WINDOW (self), GTK_WIN_POS_CENTER_ALWAYS);
+}
+
+static void
+empathy_base_password_dialog_init (EmpathyBasePasswordDialog *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ EMPATHY_TYPE_BASE_PASSWORD_DIALOG, EmpathyBasePasswordDialogPriv);
+}
+
+static void
+empathy_base_password_dialog_class_init (EmpathyBasePasswordDialogClass *klass)
+{
+ GParamSpec *pspec;
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (EmpathyBasePasswordDialogPriv));
+
+ oclass->set_property = empathy_base_password_dialog_set_property;
+ oclass->get_property = empathy_base_password_dialog_get_property;
+ oclass->dispose = empathy_base_password_dialog_dispose;
+ oclass->constructed = empathy_base_password_dialog_constructed;
+
+ pspec = g_param_spec_object ("account", "The TpAccount",
+ "The TpAccount to be used.",
+ TP_TYPE_ACCOUNT,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (oclass, PROP_ACCOUNT, pspec);
+}
diff --git a/libempathy-gtk/empathy-base-password-dialog.h b/libempathy-gtk/empathy-base-password-dialog.h
new file mode 100644
index 000000000..c144a665b
--- /dev/null
+++ b/libempathy-gtk/empathy-base-password-dialog.h
@@ -0,0 +1,71 @@
+/*
+ * empathy-base-password-dialog.h - Header for EmpathyBasePasswordDialog
+ * Copyright (C) 2010 Collabora Ltd.
+ *
+ * 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.
+ *
+ * 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 __EMPATHY_BASE_PASSWORD_DIALOG_H__
+#define __EMPATHY_BASE_PASSWORD_DIALOG_H__
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include <libempathy/empathy-server-sasl-handler.h>
+
+#include <extensions/extensions.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EmpathyBasePasswordDialog EmpathyBasePasswordDialog;
+typedef struct _EmpathyBasePasswordDialogClass EmpathyBasePasswordDialogClass;
+typedef struct _EmpathyBasePasswordDialogPriv EmpathyBasePasswordDialogPriv;
+
+struct _EmpathyBasePasswordDialogClass {
+ GtkMessageDialogClass parent_class;
+};
+
+struct _EmpathyBasePasswordDialog {
+ GtkMessageDialog parent;
+ EmpathyBasePasswordDialogPriv *priv;
+
+ /* protected */
+ TpAccount *account;
+ GtkWidget *entry;
+ GtkWidget *ticky;
+ GtkWidget *ok_button;
+};
+
+GType empathy_base_password_dialog_get_type (void);
+
+#define EMPATHY_TYPE_BASE_PASSWORD_DIALOG \
+ (empathy_base_password_dialog_get_type ())
+#define EMPATHY_BASE_PASSWORD_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_BASE_PASSWORD_DIALOG, \
+ EmpathyBasePasswordDialog))
+#define EMPATHY_BASE_PASSWORD_DIALOG_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_BASE_PASSWORD_DIALOG, \
+ EmpathyBasePasswordDialogClass))
+#define EMPATHY_IS_BASE_PASSWORD_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_BASE_PASSWORD_DIALOG))
+#define EMPATHY_IS_BASE_PASSWORD_DIALOG_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_BASE_PASSWORD_DIALOG))
+#define EMPATHY_BASE_PASSWORD_DIALOG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_BASE_PASSWORD_DIALOG, \
+ EmpathyBasePasswordDialogClass))
+
+G_END_DECLS
+
+#endif /* #ifndef __EMPATHY_BASE_PASSWORD_DIALOG_H__*/
diff --git a/libempathy-gtk/empathy-password-dialog.c b/libempathy-gtk/empathy-password-dialog.c
index c23e0d899..339e0a146 100644
--- a/libempathy-gtk/empathy-password-dialog.c
+++ b/libempathy-gtk/empathy-password-dialog.c
@@ -28,7 +28,7 @@
#include <libempathy/empathy-utils.h>
G_DEFINE_TYPE (EmpathyPasswordDialog, empathy_password_dialog,
- GTK_TYPE_MESSAGE_DIALOG)
+ EMPATHY_TYPE_BASE_PASSWORD_DIALOG)
enum {
PROP_HANDLER = 1,
@@ -38,14 +38,6 @@ enum {
struct _EmpathyPasswordDialogPriv {
EmpathyServerSASLHandler *handler;
-
- GtkWidget *entry;
- GtkWidget *ticky;
- GtkWidget *ok_button;
-
- gboolean grabbing;
-
- gboolean dispose_run;
};
static void
@@ -92,11 +84,6 @@ empathy_password_dialog_dispose (GObject *object)
{
EmpathyPasswordDialog *self = (EmpathyPasswordDialog *) object;
- if (self->priv->dispose_run)
- return;
-
- self->priv->dispose_run = TRUE;
-
tp_clear_object (&self->priv->handler);
G_OBJECT_CLASS (empathy_password_dialog_parent_class)->dispose (object);
@@ -108,12 +95,13 @@ password_dialog_response_cb (GtkDialog *dialog,
gpointer user_data)
{
EmpathyPasswordDialog *self = (EmpathyPasswordDialog *) dialog;
+ EmpathyBasePasswordDialog *base = (EmpathyBasePasswordDialog *) dialog;
if (response == GTK_RESPONSE_OK)
{
empathy_server_sasl_handler_provide_password (self->priv->handler,
- gtk_entry_get_text (GTK_ENTRY (self->priv->entry)),
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->ticky)));
+ gtk_entry_get_text (GTK_ENTRY (base->entry)),
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (base->ticky)));
}
else
{
@@ -124,116 +112,6 @@ password_dialog_response_cb (GtkDialog *dialog,
}
static void
-clear_icon_released_cb (GtkEntry *entry,
- GtkEntryIconPosition icon_pos,
- GdkEvent *event,
- gpointer user_data)
-{
- gtk_entry_set_text (entry, "");
-}
-
-static void
-password_entry_changed_cb (GtkEditable *entry,
- gpointer user_data)
-{
- EmpathyPasswordDialog *self = user_data;
- const gchar *str;
-
- str = gtk_entry_get_text (GTK_ENTRY (entry));
-
- gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY, !EMP_STR_EMPTY (str));
-
- gtk_widget_set_sensitive (self->priv->ok_button,
- !EMP_STR_EMPTY (str));
-}
-
-static void
-password_entry_activate_cb (GtkEntry *entry,
- EmpathyPasswordDialog *self)
-{
- gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_OK);
-}
-
-static gboolean
-password_dialog_grab_keyboard (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
-{
- EmpathyPasswordDialog *self = user_data;
-
- if (!self->priv->grabbing)
- {
- GdkDevice *device = gdk_event_get_device (event);
-
- if (device != NULL)
- {
- GdkGrabStatus status = gdk_device_grab (device,
- gtk_widget_get_window (widget),
- GDK_OWNERSHIP_WINDOW,
- FALSE,
- GDK_ALL_EVENTS_MASK,
- NULL,
- gdk_event_get_time (event));
-
- if (status != GDK_GRAB_SUCCESS)
- DEBUG ("Could not grab keyboard; grab status was %u", status);
- else
- self->priv->grabbing = TRUE;
- }
- else
- DEBUG ("Could not get the event device!");
- }
-
- return FALSE;
-}
-
-static gboolean
-password_dialog_ungrab_keyboard (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
-{
- EmpathyPasswordDialog *self = user_data;
-
- if (self->priv->grabbing)
- {
- GdkDevice *device = gdk_event_get_device (event);
-
- if (device != NULL)
- {
- gdk_device_ungrab (device, gdk_event_get_time (event));
- self->priv->grabbing = FALSE;
- }
- else
- DEBUG ("Could not get the event device!");
- }
-
- return FALSE;
-}
-
-static gboolean
-password_dialog_window_state_changed (GtkWidget *widget,
- GdkEventWindowState *event,
- gpointer data)
-{
- GdkWindowState state = gdk_window_get_state (gtk_widget_get_window (widget));
-
- if (state & GDK_WINDOW_STATE_WITHDRAWN
- || state & GDK_WINDOW_STATE_ICONIFIED
- || state & GDK_WINDOW_STATE_FULLSCREEN
- || state & GDK_WINDOW_STATE_MAXIMIZED)
- {
- password_dialog_ungrab_keyboard (widget, (GdkEvent *) event, data);
- }
- else
- {
- password_dialog_grab_keyboard (widget, (GdkEvent *) event, data);
- }
-
- return FALSE;
-}
-
-static void
password_dialog_handler_invalidated_cb (EmpathyServerSASLHandler *handler,
EmpathyPasswordDialog *dialog)
{
@@ -243,90 +121,28 @@ password_dialog_handler_invalidated_cb (EmpathyServerSASLHandler *handler,
static void
empathy_password_dialog_constructed (GObject *object)
{
- EmpathyPasswordDialog *self;
- TpAccount *account;
- GtkWidget *icon;
- GtkBox *box;
+ EmpathyPasswordDialog *self = (EmpathyPasswordDialog *) object;
+ EmpathyBasePasswordDialog *base = (EmpathyBasePasswordDialog *) object;
gchar *text;
- self = EMPATHY_PASSWORD_DIALOG (object);
-
- g_assert (self->priv->handler != NULL);
-
- self->priv->grabbing = FALSE;
-
- account = empathy_server_sasl_handler_get_account (self->priv->handler);
+ G_OBJECT_CLASS (empathy_password_dialog_parent_class)->constructed (object);
tp_g_signal_connect_object (self->priv->handler, "invalidated",
G_CALLBACK (password_dialog_handler_invalidated_cb),
object, 0);
- /* dialog */
- gtk_dialog_add_button (GTK_DIALOG (self),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-
- self->priv->ok_button = gtk_dialog_add_button (GTK_DIALOG (self),
- GTK_STOCK_OK, GTK_RESPONSE_OK);
- gtk_widget_set_sensitive (self->priv->ok_button, FALSE);
-
text = g_strdup_printf (_("Enter your password for account\n<b>%s</b>"),
- tp_account_get_display_name (account));
+ tp_account_get_display_name (base->account));
gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (self), text);
g_free (text);
- gtk_window_set_icon_name (GTK_WINDOW (self),
- GTK_STOCK_DIALOG_AUTHENTICATION);
-
- box = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self)));
-
- /* dialog icon */
- icon = gtk_image_new_from_icon_name (tp_account_get_icon_name (account),
- GTK_ICON_SIZE_DIALOG);
- gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (self), icon);
- gtk_widget_show (icon);
-
- /* entry */
- self->priv->entry = gtk_entry_new ();
- gtk_entry_set_visibility (GTK_ENTRY (self->priv->entry), FALSE);
-
- /* entry clear icon */
- gtk_entry_set_icon_from_stock (GTK_ENTRY (self->priv->entry),
- GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
- gtk_entry_set_icon_sensitive (GTK_ENTRY (self->priv->entry),
- GTK_ENTRY_ICON_SECONDARY, FALSE);
-
- g_signal_connect (self->priv->entry, "icon-release",
- G_CALLBACK (clear_icon_released_cb), NULL);
- g_signal_connect (self->priv->entry, "changed",
- G_CALLBACK (password_entry_changed_cb), self);
- g_signal_connect (self->priv->entry, "activate",
- G_CALLBACK (password_entry_activate_cb), self);
-
- gtk_box_pack_start (box, self->priv->entry, FALSE, FALSE, 0);
- gtk_widget_show (self->priv->entry);
-
- /* remember password ticky box */
- self->priv->ticky = gtk_check_button_new_with_label (_("Remember password"));
-
- gtk_box_pack_start (box, self->priv->ticky, FALSE, FALSE, 0);
-
/* only show it if we actually support it */
if (empathy_server_sasl_handler_can_save_response_somewhere (
self->priv->handler))
- gtk_widget_show (self->priv->ticky);
+ gtk_widget_show (base->ticky);
g_signal_connect (self, "response",
G_CALLBACK (password_dialog_response_cb), self);
- g_signal_connect (self, "window-state-event",
- G_CALLBACK (password_dialog_window_state_changed), self);
- g_signal_connect (self, "map-event",
- G_CALLBACK (password_dialog_grab_keyboard), self);
- g_signal_connect (self, "unmap-event",
- G_CALLBACK (password_dialog_ungrab_keyboard), self);
-
- gtk_widget_grab_focus (self->priv->entry);
-
- gtk_window_set_position (GTK_WINDOW (self), GTK_WIN_POS_CENTER_ALWAYS);
}
static void
@@ -362,5 +178,7 @@ empathy_password_dialog_new (EmpathyServerSASLHandler *handler)
g_assert (EMPATHY_IS_SERVER_SASL_HANDLER (handler));
return g_object_new (EMPATHY_TYPE_PASSWORD_DIALOG,
- "handler", handler, NULL);
+ "handler", handler,
+ "account", empathy_server_sasl_handler_get_account (handler),
+ NULL);
}
diff --git a/libempathy-gtk/empathy-password-dialog.h b/libempathy-gtk/empathy-password-dialog.h
index 97538e8a5..d561af14a 100644
--- a/libempathy-gtk/empathy-password-dialog.h
+++ b/libempathy-gtk/empathy-password-dialog.h
@@ -25,6 +25,8 @@
#include <libempathy/empathy-server-sasl-handler.h>
+#include <libempathy-gtk/empathy-base-password-dialog.h>
+
#include <extensions/extensions.h>
G_BEGIN_DECLS
@@ -34,11 +36,11 @@ typedef struct _EmpathyPasswordDialogClass EmpathyPasswordDialogClass;
typedef struct _EmpathyPasswordDialogPriv EmpathyPasswordDialogPriv;
struct _EmpathyPasswordDialogClass {
- GtkMessageDialogClass parent_class;
+ EmpathyBasePasswordDialogClass parent_class;
};
struct _EmpathyPasswordDialog {
- GtkMessageDialog parent;
+ EmpathyBasePasswordDialog parent;
EmpathyPasswordDialogPriv *priv;
};