aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Tellier <jonathan.tellier@gmail.com>2009-08-13 20:56:02 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-08-22 23:46:40 +0800
commitadc79c5d0574f548cfe2b89cb0e04d74a5d1e40e (patch)
tree0d709a920dcba9c23e59b6028f228852213b438b
parent165945e35293556ba6d133f5f90a7251de8d8e4b (diff)
downloadgsoc2013-empathy-adc79c5d0574f548cfe2b89cb0e04d74a5d1e40e.tar
gsoc2013-empathy-adc79c5d0574f548cfe2b89cb0e04d74a5d1e40e.tar.gz
gsoc2013-empathy-adc79c5d0574f548cfe2b89cb0e04d74a5d1e40e.tar.bz2
gsoc2013-empathy-adc79c5d0574f548cfe2b89cb0e04d74a5d1e40e.tar.lz
gsoc2013-empathy-adc79c5d0574f548cfe2b89cb0e04d74a5d1e40e.tar.xz
gsoc2013-empathy-adc79c5d0574f548cfe2b89cb0e04d74a5d1e40e.tar.zst
gsoc2013-empathy-adc79c5d0574f548cfe2b89cb0e04d74a5d1e40e.zip
First part of an overhaul of the accounts dialog
-rw-r--r--libempathy-gtk/empathy-account-widget-jabber.ui53
-rw-r--r--libempathy-gtk/empathy-account-widget.c302
-rw-r--r--libempathy-gtk/empathy-account-widget.h16
-rw-r--r--libempathy/empathy-account-manager.c9
-rw-r--r--libempathy/empathy-account-settings.c49
-rw-r--r--libempathy/empathy-account-settings.h3
-rw-r--r--src/empathy-account-assistant.c5
-rw-r--r--src/empathy-accounts-dialog.c416
-rw-r--r--src/empathy-accounts-dialog.ui137
9 files changed, 628 insertions, 362 deletions
diff --git a/libempathy-gtk/empathy-account-widget-jabber.ui b/libempathy-gtk/empathy-account-widget-jabber.ui
index d1c28774b..5fddcb7b8 100644
--- a/libempathy-gtk/empathy-account-widget-jabber.ui
+++ b/libempathy-gtk/empathy-account-widget-jabber.ui
@@ -21,7 +21,7 @@
<child>
<object class="GtkTable" id="table_common_settings">
<property name="visible">True</property>
- <property name="n_rows">2</property>
+ <property name="n_rows">3</property>
<property name="n_columns">3</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
@@ -35,8 +35,8 @@
<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="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
@@ -55,7 +55,7 @@
<child>
<object class="GtkLabel" id="label_id">
<property name="visible">True</property>
- <property name="xalign">0</property>
+ <property name="xalign">1</property>
<property name="label" translatable="yes">Login I_D:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">entry_id</property>
@@ -81,8 +81,8 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -90,18 +90,47 @@
<child>
<object class="GtkLabel" id="label_password">
<property name="visible">True</property>
- <property name="xalign">0</property>
+ <property name="xalign">1</property>
<property name="label" translatable="yes">Pass_word:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">entry_password</property>
</object>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label_login_example">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">&lt;span size="small"&gt;Example:&lt;/span&gt;</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_username_example">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">&lt;span size="small"&gt;test@jabber.org&lt;/span&gt;</property>
+ <property name="use_markup">True</property>
+ </object>
+ <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>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -114,7 +143,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
- <object class="GtkVBox" id="vbox1">
+ <object class="GtkVBox" id="vbox_advanced">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
@@ -227,7 +256,7 @@
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
- <object class="GtkAlignment" id="alignment1">
+ <object class="GtkAlignment" id="alignment_server_settings">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
@@ -371,7 +400,7 @@
</packing>
</child>
<child>
- <object class="GtkAlignment" id="alignment1">
+ <object class="GtkAlignment" id="alignment_simple_jabber_id">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 713f50048..2f6537aeb 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2006-2007 Imendio AB
* Copyright (C) 2007-2009 Collabora Ltd.
@@ -21,6 +20,7 @@
* Authors: Xavier Claessens <xclaesse@gmail.com>
* Martyn Russell <martyn@imendio.com>
* Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
+ * Jonathan Tellier <jonathan.tellier@gmail.com>
*/
#include <config.h>
@@ -52,24 +52,41 @@ typedef struct {
char *protocol;
EmpathyAccountSettings *settings;
+ GtkWidget *table_common_settings;
GtkWidget *apply_button;
+ GtkWidget *cancel_button;
GtkWidget *entry_password;
GtkWidget *button_forget;
GtkWidget *spinbutton_port;
+ GtkWidget *enabled_checkbox;
gboolean simple;
+ /* An EmpathyAccountWidget can be used to either create an account or
+ * modify it. When we are creating an account, this member is set to TRUE */
+ gboolean creating_account;
+
+ /* After having applied changes to a user account, we automatically
+ * disconnect him. Once he's disconnected, he will be reconnected,
+ * depending on the value of this member which should be set to the checked
+ * state of the "Enabled" checkbox. This is done so the new information
+ * entered by the user is validated on the server. */
+ gboolean re_enable_accound;
+
gboolean dispose_run;
} EmpathyAccountWidgetPriv;
enum {
PROP_PROTOCOL = 1,
PROP_SETTINGS,
- PROP_SIMPLE
+ PROP_SIMPLE,
+ PROP_CREATING_ACCOUNT
};
enum {
HANDLE_APPLY,
+ ACCOUNT_CREATED,
+ CANCELLED,
LAST_SIGNAL
};
@@ -79,7 +96,20 @@ static guint signals[LAST_SIGNAL] = { 0 };
#define CHANGED_TIMEOUT 300
static void
-account_widget_handle_apply_sensitivity (EmpathyAccountWidget *self)
+account_widget_set_control_buttons_sensitivity (EmpathyAccountWidget *self,
+ gboolean sensitive)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+
+ if (!priv->simple)
+ {
+ gtk_widget_set_sensitive (priv->apply_button, sensitive);
+ gtk_widget_set_sensitive (priv->cancel_button, sensitive);
+ }
+}
+
+static void
+account_widget_handle_control_buttons_sensitivity (EmpathyAccountWidget *self)
{
EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
gboolean is_valid;
@@ -87,7 +117,10 @@ account_widget_handle_apply_sensitivity (EmpathyAccountWidget *self)
is_valid = empathy_account_settings_is_valid (priv->settings);
if (!priv->simple)
- gtk_widget_set_sensitive (priv->apply_button, is_valid);
+ {
+ gtk_widget_set_sensitive (priv->apply_button, is_valid);
+ gtk_widget_set_sensitive (priv->cancel_button, is_valid);
+ }
g_signal_emit (self, signals[HANDLE_APPLY], 0, is_valid);
}
@@ -120,11 +153,9 @@ account_widget_entry_changed_common (EmpathyAccountWidget *self,
else
{
DEBUG ("Setting %s to %s", param_name,
- strstr (param_name, "password") ? "***" : str);
+ tp_strdiff (param_name, "password") ? str : "***");
empathy_account_settings_set_string (priv->settings, param_name, str);
}
-
- account_widget_handle_apply_sensitivity (self);
}
static gboolean
@@ -142,6 +173,7 @@ account_widget_entry_changed_cb (GtkEditable *entry,
EmpathyAccountWidget *self)
{
account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE);
+ account_widget_handle_control_buttons_sensitivity (self);
}
static void
@@ -182,7 +214,7 @@ account_widget_int_changed_cb (GtkWidget *widget,
g_return_if_reached ();
}
- account_widget_handle_apply_sensitivity (self);
+ account_widget_handle_control_buttons_sensitivity (self);
}
static void
@@ -214,7 +246,7 @@ account_widget_checkbutton_toggled_cb (GtkWidget *widget,
empathy_account_settings_set_boolean (priv->settings, param_name, value);
}
- account_widget_handle_apply_sensitivity (self);
+ account_widget_handle_control_buttons_sensitivity (self);
}
static void
@@ -231,7 +263,7 @@ account_widget_forget_clicked_cb (GtkWidget *button,
empathy_account_settings_unset (priv->settings, param_name);
gtk_entry_set_text (GTK_ENTRY (priv->entry_password), "");
- account_widget_handle_apply_sensitivity (self);
+ account_widget_handle_control_buttons_sensitivity (self);
}
static void
@@ -541,12 +573,96 @@ account_widget_handle_params_valist (EmpathyAccountWidget *self,
}
static void
+account_widget_cancel_clicked_cb (GtkWidget *button,
+ EmpathyAccountWidget *self)
+{
+ g_signal_emit (self, signals[CANCELLED], 0);
+}
+
+static void
+account_widget_account_enabled_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error = NULL;
+ EmpathyAccount *account = EMPATHY_ACCOUNT (source_object);
+ EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
+
+ empathy_account_set_enabled_finish (account, res, &error);
+
+ if (error != NULL)
+ {
+ DEBUG ("Could not automatically enable new account: %s", error->message);
+ g_error_free (error);
+ }
+ else
+ {
+ g_signal_emit (widget, signals[ACCOUNT_CREATED], 0);
+ }
+}
+
+static void
+account_widget_applied_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error = NULL;
+ EmpathyAccount *account;
+ EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source_object);
+ EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
+
+ empathy_account_settings_apply_finish (settings, res, &error);
+
+ if (error != NULL)
+ {
+ DEBUG ("Could not apply changes to account: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ account = empathy_account_settings_get_account (priv->settings);
+
+ if (priv->creating_account)
+ {
+ /* By default, when an account is created, we enable it. */
+ empathy_account_set_enabled_async (account, TRUE,
+ account_widget_account_enabled_cb, widget);
+ }
+ else if (account != NULL && priv->enabled_checkbox != NULL)
+ {
+ gboolean enabled_checked;
+
+ enabled_checked = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (priv->enabled_checkbox));
+
+ if (empathy_account_is_enabled (account))
+ {
+ /* We want to disable the account (and possibly re-enable it) to make
+ * sure that the new settings are effective */
+ priv->re_enable_accound = enabled_checked;
+ empathy_account_set_enabled_async (account, FALSE, NULL, NULL);
+ }
+ else
+ {
+ /* The account is already disable so we just enable it according
+ * to the value of the "Enabled" checkbox */
+ empathy_account_set_enabled_async (account, enabled_checked,
+ NULL, NULL);
+ }
+ }
+
+ account_widget_set_control_buttons_sensitivity (widget, FALSE);
+}
+
+static void
account_widget_apply_clicked_cb (GtkWidget *button,
EmpathyAccountWidget *self)
{
EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
- empathy_account_settings_apply_async (priv->settings, NULL, NULL);
+ empathy_account_settings_apply_async (priv->settings,
+ account_widget_applied_cb, self);
}
static void
@@ -686,7 +802,7 @@ account_widget_build_jabber (EmpathyAccountWidget *self,
gtk_widget_show (label_id_create);
gtk_widget_show (label_password_create);
}
-
+
empathy_account_widget_handle_params (self,
"entry_id_simple", "account",
"entry_password_simple", "password",
@@ -697,6 +813,7 @@ account_widget_build_jabber (EmpathyAccountWidget *self,
else
{
self->ui_details->gui = empathy_builder_get_file (filename,
+ "table_common_settings", &priv->table_common_settings,
"vbox_jabber_settings", &self->ui_details->widget,
"spinbutton_port", &spinbutton_port,
"checkbutton_ssl", &checkbutton_ssl,
@@ -808,7 +925,7 @@ account_widget_build_yahoo (EmpathyAccountWidget *self,
const char *filename)
{
EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-
+
if (priv->simple)
{
self->ui_details->gui = empathy_builder_get_file (filename,
@@ -889,6 +1006,37 @@ account_widget_destroy_cb (GtkWidget *widget,
}
static void
+empathy_account_widget_enabled_cb (EmpathyAccount *account,
+ GParamSpec *spec,
+ gpointer user_data)
+{
+ EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
+ gboolean enabled = empathy_account_is_enabled (account);
+
+ if (!enabled && priv->re_enable_accound)
+ {
+ /* The account has been disabled because we were applying changes.
+ * However, the user wants the account to be enabled so let's re-enable
+ * it */
+ empathy_account_set_enabled_async (account, TRUE, NULL, NULL);
+ }
+ else if (priv->enabled_checkbox != NULL)
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->enabled_checkbox),
+ enabled);
+ }
+}
+
+static void
+account_widget_enabled_toggled_cb (GtkToggleButton *toggle_button,
+ gpointer user_data)
+{
+ account_widget_handle_control_buttons_sensitivity (
+ EMPATHY_ACCOUNT_WIDGET (user_data));
+}
+
+static void
do_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -907,6 +1055,9 @@ do_set_property (GObject *object,
case PROP_SIMPLE:
priv->simple = g_value_get_boolean (value);
break;
+ case PROP_CREATING_ACCOUNT:
+ priv->creating_account = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -931,6 +1082,9 @@ do_get_property (GObject *object,
case PROP_SIMPLE:
g_value_set_boolean (value, priv->simple);
break;
+ case PROP_CREATING_ACCOUNT:
+ g_value_set_boolean (value, priv->creating_account);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -941,6 +1095,7 @@ do_constructed (GObject *obj)
{
EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ EmpathyAccount *account;
char *uiname, *filename;
uiname = g_strconcat ("empathy-account-widget-", priv->protocol,
@@ -1012,18 +1167,64 @@ do_constructed (GObject *obj)
self);
}
- /* handle apply button */
+ /* handle apply and cancel button */
if (!priv->simple)
{
+ GtkWidget *hbox = gtk_hbox_new (TRUE, 3);
+
+ priv->cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
priv->apply_button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
- gtk_box_pack_end (GTK_BOX (self->ui_details->widget), priv->apply_button,
- FALSE, FALSE, 3);
+ gtk_box_pack_end (GTK_BOX (hbox), priv->apply_button, TRUE,
+ TRUE, 3);
+ gtk_box_pack_end (GTK_BOX (hbox), priv->cancel_button, TRUE,
+ TRUE, 3);
+
+ gtk_box_pack_end (GTK_BOX (self->ui_details->widget), hbox, FALSE,
+ FALSE, 3);
+
+ g_signal_connect (priv->cancel_button, "clicked",
+ G_CALLBACK (account_widget_cancel_clicked_cb),
+ self);
g_signal_connect (priv->apply_button, "clicked",
G_CALLBACK (account_widget_apply_clicked_cb),
self);
- account_widget_handle_apply_sensitivity (self);
- gtk_widget_show (priv->apply_button);
+ gtk_widget_show_all (hbox);
+ account_widget_set_control_buttons_sensitivity(self, FALSE);
+ }
+
+ account = empathy_account_settings_get_account (priv->settings);
+
+ if (account != NULL)
+ {
+ g_signal_connect (account, "notify::enabled",
+ G_CALLBACK (empathy_account_widget_enabled_cb), self);
+ }
+
+ /* handle the "Enabled" checkbox. We only add it when modifying an account */
+ if (!priv->creating_account && priv->table_common_settings != NULL)
+ {
+ guint nb_rows, nb_columns;
+
+ priv->enabled_checkbox =
+ gtk_check_button_new_with_label (_("Enabled"));
+ gtk_toggle_button_set_active (
+ GTK_TOGGLE_BUTTON (priv->enabled_checkbox),
+ empathy_account_is_enabled (account));
+
+ g_object_get (priv->table_common_settings, "n-rows", &nb_rows,
+ "n-columns", &nb_columns, NULL);
+
+ gtk_table_resize (GTK_TABLE (priv->table_common_settings), ++nb_rows,
+ nb_columns);
+
+ gtk_table_attach_defaults (GTK_TABLE (priv->table_common_settings),
+ priv->enabled_checkbox, 0, nb_columns, nb_rows - 1, nb_rows);
+
+ gtk_widget_show (priv->enabled_checkbox);
+
+ g_signal_connect (G_OBJECT (priv->enabled_checkbox), "toggled",
+ G_CALLBACK (account_widget_enabled_toggled_cb), self);
}
/* hook up to widget destruction to unref ourselves */
@@ -1046,8 +1247,19 @@ do_dispose (GObject *obj)
priv->dispose_run = TRUE;
+ empathy_account_settings_is_ready (priv->settings);
+
if (priv->settings != NULL)
{
+ EmpathyAccount *account;
+ account = empathy_account_settings_get_account (priv->settings);
+
+ if (account != NULL)
+ {
+ g_signal_handlers_disconnect_by_func (account,
+ empathy_account_widget_enabled_cb, self);
+ }
+
g_object_unref (priv->settings);
priv->settings = NULL;
}
@@ -1101,6 +1313,13 @@ empathy_account_widget_class_init (EmpathyAccountWidgetClass *klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (oclass, PROP_SIMPLE, param_spec);
+ param_spec = g_param_spec_boolean ("creating-account",
+ "creating-account",
+ "TRUE if we're creating an account, FALSE if we're modifying it",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ g_object_class_install_property (oclass, PROP_CREATING_ACCOUNT, param_spec);
+
signals[HANDLE_APPLY] =
g_signal_new ("handle-apply", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
@@ -1108,6 +1327,21 @@ empathy_account_widget_class_init (EmpathyAccountWidgetClass *klass)
G_TYPE_NONE,
1, G_TYPE_BOOLEAN);
+ /* This signal is emitted when an account has been created and enabled. */
+ signals[ACCOUNT_CREATED] =
+ g_signal_new ("account-created", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ signals[CANCELLED] =
+ g_signal_new ("cancelled", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
g_type_class_add_private (klass, sizeof (EmpathyAccountWidgetPriv));
}
@@ -1139,26 +1373,15 @@ empathy_account_widget_handle_params (EmpathyAccountWidget *self,
}
GtkWidget *
-empathy_account_widget_new_for_protocol (const char *protocol,
- EmpathyAccountSettings *settings)
+empathy_account_widget_get_widget (EmpathyAccountWidget *widget)
{
- EmpathyAccountWidget *self;
- EmpathyAccountWidgetPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_ACCOUNT_SETTINGS (settings), NULL);
- g_return_val_if_fail (settings != NULL, NULL);
-
- self = g_object_new
- (EMPATHY_TYPE_ACCOUNT_WIDGET, "protocol", protocol,
- "settings", settings, NULL);
- priv = GET_PRIV (self);
-
- return self->ui_details->widget;
+ return widget->ui_details->widget;
}
-GtkWidget *
-empathy_account_widget_simple_new_for_protocol (const char *protocol,
- EmpathyAccountSettings *settings, EmpathyAccountWidget **object)
+EmpathyAccountWidget *
+empathy_account_widget_new_for_protocol (const char *protocol,
+ EmpathyAccountSettings *settings,
+ gboolean simple)
{
EmpathyAccountWidget *self;
@@ -1167,9 +1390,10 @@ empathy_account_widget_simple_new_for_protocol (const char *protocol,
self = g_object_new
(EMPATHY_TYPE_ACCOUNT_WIDGET, "protocol", protocol,
- "settings", settings, "simple", TRUE, NULL);
-
- *object = self;
+ "settings", settings, "simple", simple,
+ "creating-account",
+ empathy_account_settings_get_account (settings) == NULL,
+ NULL);
- return self->ui_details->widget;
+ return self;
}
diff --git a/libempathy-gtk/empathy-account-widget.h b/libempathy-gtk/empathy-account-widget.h
index ab4e62b45..f44edcc6a 100644
--- a/libempathy-gtk/empathy-account-widget.h
+++ b/libempathy-gtk/empathy-account-widget.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2006-2007 Imendio AB
* Copyright (C) 2007-2008 Collabora Ltd.
@@ -60,12 +59,15 @@ typedef struct {
GType empathy_account_widget_get_type (void);
-GtkWidget *empathy_account_widget_new_for_protocol (const char *protocol,
- EmpathyAccountSettings *settings);
-GtkWidget * empathy_account_widget_simple_new_for_protocol
- (const char *protocol,
- EmpathyAccountSettings *settings,
- EmpathyAccountWidget **object);
+GtkWidget *empathy_account_widget_get_widget (EmpathyAccountWidget *widget);
+
+//EmpathyAccountWidget *empathy_account_widget_new_for_protocol (
+// const char *protocol,
+// EmpathyAccountSettings *settings);
+EmpathyAccountWidget * empathy_account_widget_new_for_protocol (
+ const char *protocol,
+ EmpathyAccountSettings *settings,
+ gboolean simple);
G_END_DECLS
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c
index 83de26c67..2f0f13415 100644
--- a/libempathy/empathy-account-manager.c
+++ b/libempathy/empathy-account-manager.c
@@ -372,11 +372,14 @@ account_manager_got_all_cb (TpProxy *proxy,
accounts = tp_asv_get_boxed (properties, "ValidAccounts",
EMPATHY_ARRAY_TYPE_OBJECT);
- for (i = 0; i < accounts->len; i++)
+ if (accounts != NULL)
{
- gchar *name = g_ptr_array_index (accounts, i);
+ for (i = 0; i < accounts->len; i++)
+ {
+ gchar *name = g_ptr_array_index (accounts, i);
- empathy_account_manager_get_account (manager, name);
+ empathy_account_manager_get_account (manager, name);
+ }
}
empathy_account_manager_check_ready (manager);
diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c
index ce0ba1bfa..6129570c2 100644
--- a/libempathy/empathy-account-settings.c
+++ b/libempathy/empathy-account-settings.c
@@ -40,6 +40,7 @@ enum {
PROP_CM_NAME,
PROP_PROTOCOL,
PROP_DISPLAY_NAME,
+ PROP_DISPLAY_NAME_OVERRIDDEN,
PROP_READY
};
@@ -61,6 +62,7 @@ struct _EmpathyAccountSettingsPriv
gchar *protocol;
gchar *display_name;
gchar *icon_name;
+ gboolean display_name_overridden;
gboolean ready;
GHashTable *parameters;
@@ -86,7 +88,7 @@ empathy_account_settings_init (EmpathyAccountSettings *obj)
priv->account_manager = empathy_account_manager_dup_singleton ();
priv->parameters = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, (GDestroyNotify) tp_g_value_slice_free);
+ g_free, (GDestroyNotify) tp_g_value_slice_free);
priv->unset_parameters = g_array_new (TRUE, FALSE, sizeof (gchar *));
}
@@ -121,6 +123,9 @@ empathy_account_settings_set_property (GObject *object,
case PROP_DISPLAY_NAME:
priv->display_name = g_value_dup_string (value);
break;
+ case PROP_DISPLAY_NAME_OVERRIDDEN:
+ priv->display_name_overridden = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -150,6 +155,9 @@ empathy_account_settings_get_property (GObject *object,
case PROP_DISPLAY_NAME:
g_value_set_string (value, priv->display_name);
break;
+ case PROP_DISPLAY_NAME_OVERRIDDEN:
+ g_value_set_boolean (value, priv->display_name_overridden);
+ break;
case PROP_READY:
g_value_set_boolean (value, priv->ready);
break;
@@ -240,6 +248,13 @@ empathy_account_settings_class_init (
NULL,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_DISPLAY_NAME_OVERRIDDEN,
+ g_param_spec_boolean ("display-name-overridden",
+ "display-name-overridden",
+ "Whether the display name for this account has been manually overridden",
+ FALSE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
+
g_object_class_install_property (object_class, PROP_READY,
g_param_spec_boolean ("ready",
"Ready",
@@ -560,9 +575,6 @@ empathy_account_settings_get_dbus_signature (EmpathyAccountSettings *settings,
p = empathy_account_settings_get_tp_param (settings, param);
- if (p == NULL)
- return NULL;
-
return p->dbus_signature;
}
@@ -610,6 +622,21 @@ empathy_account_settings_unset (EmpathyAccountSettings *settings,
g_hash_table_remove (priv->parameters, param);
}
+void
+empathy_account_settings_discard_changes (EmpathyAccountSettings *settings)
+{
+ EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
+
+ if (g_hash_table_size (priv->parameters) > 0)
+ g_hash_table_remove_all (priv->parameters);
+
+ if (priv->unset_parameters->len > 0)
+ {
+ g_array_remove_range (priv->unset_parameters, 0,
+ priv->unset_parameters->len);
+ }
+}
+
const gchar *
empathy_account_settings_get_string (EmpathyAccountSettings *settings,
const gchar *param)
@@ -960,13 +987,9 @@ empathy_account_settings_created_cb (GObject *source,
EMPATHY_ACCOUNT_MANAGER (source), result, &error);
if (account == NULL)
- {
- g_simple_async_result_set_from_error (priv->apply_result, error);
- }
+ g_simple_async_result_set_from_error (priv->apply_result, error);
else
- {
- priv->account = g_object_ref (account);
- }
+ priv->account = g_object_ref (account);
r = priv->apply_result;
priv->apply_result = NULL;
@@ -1065,6 +1088,12 @@ empathy_account_settings_apply_async (EmpathyAccountSettings *settings,
if (priv->account == NULL)
{
+ const gchar *default_display_name;
+ default_display_name = empathy_account_settings_get_string (settings,
+ "account");
+ empathy_account_settings_set_display_name_async (settings,
+ default_display_name, NULL, NULL);
+
if (empathy_account_manager_is_ready (priv->account_manager))
empathy_account_settings_do_create_account (settings);
else
diff --git a/libempathy/empathy-account-settings.h b/libempathy/empathy-account-settings.h
index 9bb6657e2..476bfb397 100644
--- a/libempathy/empathy-account-settings.h
+++ b/libempathy/empathy-account-settings.h
@@ -86,6 +86,9 @@ TpConnectionManagerParam *empathy_account_settings_get_tp_params (
void empathy_account_settings_unset (EmpathyAccountSettings *settings,
const gchar *param);
+void empathy_account_settings_discard_changes (
+ EmpathyAccountSettings *settings);
+
const GValue *empathy_account_settings_get (EmpathyAccountSettings *settings,
const gchar *param);
diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c
index 613ba4b8c..8b803a9b6 100644
--- a/src/empathy-account-assistant.c
+++ b/src/empathy-account-assistant.c
@@ -334,8 +334,9 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser,
if (priv->first_resp == RESPONSE_CREATE_ACCOUNT)
empathy_account_settings_set_boolean (settings, "register", TRUE);
- account_widget = empathy_account_widget_simple_new_for_protocol
- (proto->name, settings, &widget_object);
+ widget_object = empathy_account_widget_new_for_protocol (proto->name,
+ settings, TRUE);
+ account_widget = empathy_account_widget_get_widget (widget_object);
if (priv->current_account_widget != NULL)
{
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index e985befc8..30a7f72a8 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -20,6 +20,7 @@
* Authors: Martyn Russell <martyn@imendio.com>
* Xavier Claessens <xclaesse@gmail.com>
* Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
+ * Jonathan Tellier <jonathan.tellier@gmail.com>
*/
#include <config.h>
@@ -42,7 +43,9 @@
#include <libempathy-gtk/empathy-account-widget.h>
#include <libempathy-gtk/empathy-account-widget-irc.h>
#include <libempathy-gtk/empathy-account-widget-sip.h>
+#include <libempathy-gtk/empathy-cell-renderer-activatable.h>
#include <libempathy-gtk/empathy-conf.h>
+#include <libempathy-gtk/empathy-images.h>
#include "empathy-accounts-dialog.h"
#include "empathy-import-dialog.h"
@@ -70,8 +73,6 @@ typedef struct {
GtkWidget *treeview;
GtkWidget *button_add;
- GtkWidget *button_remove;
- GtkWidget *button_import;
GtkWidget *frame_new_account;
GtkWidget *combobox_protocol;
@@ -100,7 +101,6 @@ typedef struct {
} EmpathyAccountsDialogPriv;
enum {
- COL_ENABLED,
COL_NAME,
COL_STATUS,
COL_ACCOUNT_POINTER,
@@ -112,28 +112,86 @@ enum {
PROP_PARENT = 1
};
-static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
+static EmpathyAccountSettings * accounts_dialog_model_get_selected_settings (
+ EmpathyAccountsDialog *dialog);
+
+static void accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog);
+
+static void accounts_dialog_update (EmpathyAccountsDialog *dialog,
EmpathyAccountSettings *settings);
-static void accounts_dialog_button_import_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog);
+static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
+ EmpathyAccountSettings *settings);
static void
accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog,
- EmpathyAccountSettings *settings)
+ const gchar *display_name)
{
gchar *text;
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- text = g_markup_printf_escaped ("<big><b>%s</b></big>",
- empathy_account_settings_get_display_name (settings));
+ text = g_markup_printf_escaped ("<big><b>%s</b></big>", display_name);
gtk_label_set_markup (GTK_LABEL (priv->label_name), text);
g_free (text);
}
+static void
+empathy_account_dialog_widget_cancelled_cb (EmpathyAccountWidget *widget_object,
+ EmpathyAccountsDialog *dialog)
+{
+ GtkTreeView *view;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ EmpathyAccountSettings *settings;
+ EmpathyAccount *account;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ view = GTK_TREE_VIEW (priv->treeview);
+ selection = gtk_tree_view_get_selection (view);
+
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return;
+
+ gtk_tree_model_get (model, &iter,
+ COL_ACCOUNT_SETTINGS_POINTER, &settings,
+ COL_ACCOUNT_POINTER, &account, -1);
+
+ empathy_account_settings_discard_changes (settings);
+
+ if (account == NULL)
+ {
+ /* We were creating an account. We remove the selected row */
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ }
+ else
+ {
+ /* We were modifying an account. We discard the changes by reloading the
+ * settings and the UI. */
+ accounts_dialog_update_settings (dialog, settings);
+ g_object_unref (account);
+ }
+
+ if (settings != NULL)
+ g_object_unref (settings);
+}
+
+static void
+empathy_account_dialog_account_created_cb (EmpathyAccountWidget *widget_object,
+ EmpathyAccountsDialog *dialog)
+{
+ EmpathyAccountSettings *settings =
+ accounts_dialog_model_get_selected_settings (dialog);
+ accounts_dialog_update_settings (dialog, settings);
+
+ if (settings)
+ g_object_unref (settings);
+}
+
static GtkWidget *
-get_account_setup_widget (EmpathyAccountSettings *settings)
+get_account_setup_widget (EmpathyAccountSettings *settings,
+ EmpathyAccountWidget **widget_object)
{
const gchar *proto = empathy_account_settings_get_protocol (settings);
EmpathyConnectionManagers *cm =
@@ -147,23 +205,31 @@ get_account_setup_widget (EmpathyAccountSettings *settings)
if (tp_connection_manager_has_protocol (tp_cm, proto))
{
g_object_unref (cm);
- return empathy_account_widget_new_for_protocol
- (proto, settings);
+ *widget_object = empathy_account_widget_new_for_protocol (proto,
+ settings, FALSE);
+ return empathy_account_widget_get_widget (*widget_object);
}
}
g_object_unref (cm);
- return empathy_account_widget_new_for_protocol ("generic", settings);
+ *widget_object = empathy_account_widget_new_for_protocol ("generic", settings,
+ FALSE);
+ return empathy_account_widget_get_widget (*widget_object);
}
static void
account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog,
EmpathyAccountSettings *settings)
{
+ EmpathyAccountWidget *widget_object = NULL;
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
gchar *icon_name;
- priv->settings_widget = get_account_setup_widget (settings);
+ priv->settings_widget = get_account_setup_widget (settings, &widget_object);
+ g_signal_connect (widget_object, "account-created",
+ G_CALLBACK (empathy_account_dialog_account_created_cb), dialog);
+ g_signal_connect (widget_object, "cancelled",
+ G_CALLBACK (empathy_account_dialog_widget_cancelled_cb), dialog);
gtk_container_add (GTK_CONTAINER (priv->alignment_settings),
priv->settings_widget);
@@ -176,7 +242,10 @@ account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog,
gtk_widget_set_tooltip_text (priv->image_type,
empathy_account_settings_get_protocol (settings));
- accounts_dialog_update_name_label (dialog, settings);
+ accounts_dialog_update_name_label (dialog,
+ empathy_account_settings_get_display_name(settings));
+
+ g_free (icon_name);
}
static void
@@ -241,17 +310,13 @@ accounts_dialog_button_add_clicked_cb (GtkWidget *button,
EmpathyAccountsDialog *dialog)
{
GtkTreeView *view;
- GtkTreeSelection *selection;
GtkTreeModel *model;
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
view = GTK_TREE_VIEW (priv->treeview);
model = gtk_tree_view_get_model (view);
- selection = gtk_tree_view_get_selection (view);
- gtk_tree_selection_unselect_all (selection);
gtk_widget_set_sensitive (priv->button_add, FALSE);
- gtk_widget_set_sensitive (priv->button_remove, FALSE);
gtk_widget_hide (priv->vbox_details);
gtk_widget_hide (priv->frame_no_protocol);
gtk_widget_show (priv->frame_new_account);
@@ -300,7 +365,7 @@ accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
if (empathy_connection_managers_get_cms_num (priv->cms) > 0)
{
/* We have no account configured but we have some
- * profiles instsalled. The user obviously wants to add
+ * profiles installed. The user obviously wants to add
* an account. Click on the Add button for him. */
accounts_dialog_button_add_clicked_cb (priv->button_add,
dialog);
@@ -312,7 +377,6 @@ accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
gtk_widget_hide (priv->frame_new_account);
gtk_widget_show (priv->frame_no_protocol);
gtk_widget_set_sensitive (priv->button_add, FALSE);
- gtk_widget_set_sensitive (priv->button_remove, FALSE);
return;
}
@@ -322,7 +386,6 @@ accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
gtk_widget_hide (priv->frame_no_protocol);
gtk_widget_show (priv->vbox_details);
gtk_widget_set_sensitive (priv->button_add, TRUE);
- gtk_widget_set_sensitive (priv->button_remove, TRUE);
if (priv->settings_widget)
{
@@ -413,38 +476,6 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column,
g_object_unref (pixbuf);
}
-static void
-accounts_dialog_enable_toggled_cb (GtkCellRendererToggle *cell_renderer,
- gchar *path,
- EmpathyAccountsDialog *dialog)
-{
- EmpathyAccount *account;
- GtkTreeModel *model;
- GtkTreePath *treepath;
- GtkTreeIter iter;
- gboolean enabled;
- EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
- treepath = gtk_tree_path_new_from_string (path);
- gtk_tree_model_get_iter (model, &iter, treepath);
- gtk_tree_model_get (model, &iter,
- COL_ACCOUNT_POINTER, &account,
- -1);
- gtk_tree_path_free (treepath);
-
- if (account == NULL)
- return;
-
- enabled = empathy_account_is_enabled (account);
- empathy_account_set_enabled_async (account, !enabled, NULL, NULL);
-
- DEBUG ("%s account %s", enabled ? "Disabled" : "Enable",
- empathy_account_get_display_name (account));
-
- g_object_unref (account);
-}
-
static gboolean
accounts_dialog_row_changed_foreach (GtkTreeModel *model,
GtkTreePath *path,
@@ -506,10 +537,103 @@ accounts_dialog_name_edited_cb (GtkCellRendererText *renderer,
empathy_account_settings_set_display_name_async (settings, new_text,
NULL, NULL);
+ g_object_set (settings, "display-name-overridden", TRUE, NULL);
g_object_unref (settings);
}
static void
+accounts_dialog_delete_account_response_cb (GtkDialog *message_dialog,
+ gint response_id,
+ gpointer user_data)
+{
+ EmpathyAccount *account;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ EmpathyAccountsDialog *account_dialog = EMPATHY_ACCOUNTS_DIALOG (user_data);
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (account_dialog);
+
+ if (response_id == GTK_RESPONSE_YES)
+ {
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
+
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return;
+
+ gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1);
+
+ if (account != NULL)
+ {
+ empathy_account_remove_async (account, NULL, NULL);
+ g_object_unref (account);
+ }
+
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ accounts_dialog_model_select_first (account_dialog);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (message_dialog));
+}
+
+static void
+accounts_dialog_view_delete_activated_cb (EmpathyCellRendererActivatable *cell,
+ const gchar *path_string,
+ EmpathyAccountsDialog *dialog)
+{
+ EmpathyAccount *account;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkWidget *message_dialog;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
+
+ if (!gtk_tree_model_get_iter_from_string (model, &iter, path_string))
+ return;
+
+ gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1);
+
+ if (account == NULL || !empathy_account_is_valid (account))
+ {
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ accounts_dialog_model_select_first (dialog);
+ return;
+ }
+
+ message_dialog = gtk_message_dialog_new
+ (GTK_WINDOW (priv->window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("You are about to remove your %s account!\n"
+ "Are you sure you want to proceed?"),
+ empathy_account_get_display_name (account));
+
+ gtk_message_dialog_format_secondary_text
+ (GTK_MESSAGE_DIALOG (message_dialog),
+ _("Any associated conversations and chat rooms will NOT be "
+ "removed if you decide to proceed.\n"
+ "\n"
+ "Should you decide to add the account back at a later time, "
+ "they will still be available."));
+
+ gtk_dialog_add_button (GTK_DIALOG (message_dialog),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_NO);
+ gtk_dialog_add_button (GTK_DIALOG (message_dialog),
+ GTK_STOCK_REMOVE,
+ GTK_RESPONSE_YES);
+
+ g_signal_connect (message_dialog, "response",
+ G_CALLBACK (accounts_dialog_delete_account_response_cb), dialog);
+
+ gtk_widget_show (message_dialog);
+
+ if (account != NULL)
+ g_object_unref (account);
+}
+
+static void
accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog)
{
GtkTreeView *view;
@@ -518,22 +642,11 @@ accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog)
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
view = GTK_TREE_VIEW (priv->treeview);
- gtk_tree_view_set_headers_visible (view, TRUE);
-
- /* Enabled column */
- cell = gtk_cell_renderer_toggle_new ();
- gtk_tree_view_insert_column_with_attributes (view, -1,
- _("Enabled"),
- cell,
- "active", COL_ENABLED,
- NULL);
- g_signal_connect (cell, "toggled",
- G_CALLBACK (accounts_dialog_enable_toggled_cb),
- dialog);
+ gtk_tree_view_set_headers_visible (view, FALSE);
/* Account column */
column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, _("Accounts"));
+ //gtk_tree_view_column_set_title (column, _("Accounts"));
gtk_tree_view_column_set_expand (column, TRUE);
gtk_tree_view_append_column (view, column);
@@ -561,6 +674,17 @@ accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog)
g_signal_connect (cell, "editing-started",
G_CALLBACK (accounts_dialog_name_editing_started_cb),
dialog);
+
+ /* Delete column */
+ cell = empathy_cell_renderer_activatable_new ();
+ gtk_tree_view_column_pack_start (column, cell, FALSE);
+ g_object_set (cell,
+ "icon-name", GTK_STOCK_DELETE,
+ NULL);
+
+ g_signal_connect (cell, "path-activated",
+ G_CALLBACK (accounts_dialog_view_delete_activated_cb),
+ dialog);
}
static EmpathyAccountSettings *
@@ -589,6 +713,7 @@ static void
accounts_dialog_model_selection_changed (GtkTreeSelection *selection,
EmpathyAccountsDialog *dialog)
{
+// EmpathyAccountsDialogPriv priv = GET_PRIV (dialog);
EmpathyAccountSettings *settings;
GtkTreeModel *model;
GtkTreeIter iter;
@@ -597,6 +722,10 @@ accounts_dialog_model_selection_changed (GtkTreeSelection *selection,
is_selection = gtk_tree_selection_get_selected (selection, &model, &iter);
settings = accounts_dialog_model_get_selected_settings (dialog);
+
+ if (settings != NULL)
+ empathy_account_settings_discard_changes (settings);
+
accounts_dialog_update_settings (dialog, settings);
if (settings)
@@ -611,7 +740,6 @@ accounts_dialog_model_setup (EmpathyAccountsDialog *dialog)
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
store = gtk_list_store_new (COL_COUNT,
- G_TYPE_BOOLEAN, /* enabled */
G_TYPE_STRING, /* name */
G_TYPE_UINT, /* status */
EMPATHY_TYPE_ACCOUNT, /* account */
@@ -709,27 +837,6 @@ accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog,
return FALSE;
}
-static EmpathyAccount *
-accounts_dialog_model_get_selected_account (EmpathyAccountsDialog *dialog)
-{
- GtkTreeView *view;
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- EmpathyAccount *account;
- EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
-
- view = GTK_TREE_VIEW (priv->treeview);
- selection = gtk_tree_view_get_selection (view);
-
- if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- return NULL;
-
- gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1);
-
- return account;
-}
-
static void
accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog,
EmpathyAccountSettings *settings)
@@ -742,33 +849,6 @@ accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog,
if (accounts_dialog_get_settings_iter (dialog, settings, &iter))
gtk_tree_selection_select_iter (selection, &iter);
}
-
-static gboolean
-accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog)
-{
- GtkTreeView *view;
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- EmpathyAccount *account;
- EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
-
- view = GTK_TREE_VIEW (priv->treeview);
- selection = gtk_tree_view_get_selection (view);
-
- if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- return FALSE;
-
- gtk_tree_model_get (model, &iter,
- COL_ACCOUNT_POINTER, &account,
- -1);
-
- if (account != NULL)
- empathy_account_remove_async (account, NULL, NULL);
-
- return gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
-}
-
static void
accounts_dialog_add (EmpathyAccountsDialog *dialog,
EmpathyAccountSettings *settings)
@@ -784,7 +864,6 @@ accounts_dialog_add (EmpathyAccountsDialog *dialog,
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_ENABLED, FALSE,
COL_NAME, name,
COL_STATUS, TP_CONNECTION_STATUS_DISCONNECTED,
COL_ACCOUNT_SETTINGS_POINTER, settings,
@@ -857,7 +936,6 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
settings = empathy_account_settings_new_for_account (account);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_ENABLED, enabled,
COL_NAME, name,
COL_STATUS, status,
COL_ACCOUNT_POINTER, account,
@@ -871,7 +949,7 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
TP_CONNECTION_STATUS_DISCONNECTED,
dialog);
- g_object_unref (settings);
+ //g_object_unref (settings);
}
static void
@@ -898,7 +976,6 @@ accounts_dialog_update (EmpathyAccountsDialog *dialog,
accounts_dialog_get_settings_iter (dialog, settings, &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_ENABLED, enabled,
COL_NAME, name,
COL_STATUS, status,
COL_ACCOUNT_POINTER, account,
@@ -934,7 +1011,6 @@ enable_or_disable_account (EmpathyAccountsDialog *dialog,
gboolean enabled)
{
GtkTreeModel *model;
- GtkTreeIter iter;
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
/* Update the status in the model */
@@ -943,11 +1019,6 @@ enable_or_disable_account (EmpathyAccountsDialog *dialog,
DEBUG ("Account %s is now %s",
empathy_account_get_display_name (account),
enabled ? "enabled" : "disabled");
-
- if (accounts_dialog_get_account_iter (dialog, account, &iter))
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_ENABLED, enabled,
- -1);
}
static void
@@ -989,7 +1060,14 @@ accounts_dialog_account_changed_cb (EmpathyAccountManager *manager,
selected_settings = accounts_dialog_model_get_selected_settings (dialog);
if (settings == selected_settings)
- accounts_dialog_update_name_label (dialog, settings);
+ accounts_dialog_update_name_label (dialog,
+ empathy_account_settings_get_display_name(settings));
+
+ if (settings)
+ g_object_unref (settings);
+
+ if (selected_settings)
+ g_object_unref (selected_settings);
}
static void
@@ -1037,7 +1115,10 @@ accounts_dialog_button_back_clicked_cb (GtkWidget *button,
EmpathyAccountSettings *settings;
settings = accounts_dialog_model_get_selected_settings (dialog);
- accounts_dialog_update (dialog, settings);
+ accounts_dialog_update_settings (dialog, settings);
+
+ if (settings)
+ g_object_unref (settings);
}
static void
@@ -1048,69 +1129,6 @@ accounts_dialog_button_help_clicked_cb (GtkWidget *button,
}
static void
-accounts_dialog_button_remove_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog)
-{
- EmpathyAccount *account;
- GtkWidget *message_dialog;
- gint res;
- EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
-
- account = accounts_dialog_model_get_selected_account (dialog);
-
- if (account == NULL || !empathy_account_is_valid (account))
- {
- accounts_dialog_model_remove_selected (dialog);
- accounts_dialog_model_select_first (dialog);
- return;
- }
- message_dialog = gtk_message_dialog_new
- (GTK_WINDOW (priv->window),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- _("You are about to remove your %s account!\n"
- "Are you sure you want to proceed?"),
- empathy_account_get_display_name (account));
-
- gtk_message_dialog_format_secondary_text
- (GTK_MESSAGE_DIALOG (message_dialog),
- _("Any associated conversations and chat rooms will NOT be "
- "removed if you decide to proceed.\n"
- "\n"
- "Should you decide to add the account back at a later time, "
- "they will still be available."));
-
- gtk_dialog_add_button (GTK_DIALOG (message_dialog),
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_NO);
- gtk_dialog_add_button (GTK_DIALOG (message_dialog),
- GTK_STOCK_REMOVE,
- GTK_RESPONSE_YES);
-
- gtk_widget_show (message_dialog);
- res = gtk_dialog_run (GTK_DIALOG (message_dialog));
-
- if (res == GTK_RESPONSE_YES)
- {
- accounts_dialog_model_remove_selected (dialog);
- accounts_dialog_model_select_first (dialog);
- }
- gtk_widget_destroy (message_dialog);
-}
-
-static void
-accounts_dialog_button_import_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog)
-{
- EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- GtkWidget *import_dialog;
-
- import_dialog = empathy_import_dialog_new (GTK_WINDOW (priv->window), TRUE);
- gtk_widget_show (import_dialog);
-}
-
-static void
accounts_dialog_response_cb (GtkWidget *widget,
gint response,
EmpathyAccountsDialog *dialog)
@@ -1186,8 +1204,6 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog)
"image_type", &priv->image_type,
"label_name", &priv->label_name,
"button_add", &priv->button_add,
- "button_remove", &priv->button_remove,
- "button_import", &priv->button_import,
NULL);
g_free (filename);
@@ -1197,15 +1213,13 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog)
"button_create", "clicked", accounts_dialog_button_create_clicked_cb,
"button_back", "clicked", accounts_dialog_button_back_clicked_cb,
"button_add", "clicked", accounts_dialog_button_add_clicked_cb,
- "button_remove", "clicked", accounts_dialog_button_remove_clicked_cb,
- "button_import", "clicked", accounts_dialog_button_import_clicked_cb,
"button_help", "clicked", accounts_dialog_button_help_clicked_cb,
NULL);
g_object_unref (gui);
priv->combobox_protocol = empathy_protocol_chooser_new ();
- gtk_box_pack_end (GTK_BOX (priv->hbox_type),
+ gtk_box_pack_start (GTK_BOX (priv->hbox_type),
priv->combobox_protocol,
TRUE, TRUE, 0);
gtk_widget_show (priv->combobox_protocol);
@@ -1386,19 +1400,15 @@ do_constructed (GObject *object)
if (!import_asked)
{
- GtkWidget *import_dialog;
-
+ GtkWidget *import_dialog;
+
empathy_conf_set_bool (empathy_conf_get (),
EMPATHY_PREFS_IMPORT_ASKED, TRUE);
import_dialog = empathy_import_dialog_new (GTK_WINDOW (priv->window),
FALSE);
- gtk_widget_show (import_dialog);
+ gtk_widget_show (import_dialog);
}
}
- else
- {
- gtk_widget_set_sensitive (priv->button_import, FALSE);
- }
}
static void
diff --git a/src/empathy-accounts-dialog.ui b/src/empathy-accounts-dialog.ui
index 7c899a3cb..edd8f20a4 100644
--- a/src/empathy-accounts-dialog.ui
+++ b/src/empathy-accounts-dialog.ui
@@ -2,10 +2,6 @@
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy toplevel-contextual -->
- <object class="GtkImage" id="add_image">
- <property name="stock">gtk-add</property>
- <property name="icon-size">4</property>
- </object>
<object class="GtkDialog" id="accounts_dialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Accounts</property>
@@ -46,62 +42,18 @@
</packing>
</child>
<child>
- <object class="GtkVBox" id="vbox1">
+ <object class="GtkButton" id="button_add">
+ <property name="label" translatable="yes">_Add...</property>
<property name="visible">True</property>
- <property name="spacing">6</property>
- <property name="homogeneous">True</property>
- <child>
- <object class="GtkHBox" id="hbox148">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <property name="homogeneous">True</property>
- <child>
- <object class="GtkButton" id="button_add">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="image">add_image</property>
- <property name="label" translatable="yes">_Add...</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="button_remove">
- <property name="label">gtk-remove</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="button_import">
- <property name="label" translatable="yes">Import Accounts...</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">add_image</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
- <property name="position">1</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
@@ -128,11 +80,11 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Gmail</property>
+ <property name="selectable">True</property>
<attributes>
<attribute name="weight" value="bold"/>
- <attribute name="scale" value="1.2"/>
+ <attribute name="scale" value="1.200000"/>
</attributes>
- <property name="selectable">True</property>
</object>
<packing>
<property name="position">0</property>
@@ -206,29 +158,6 @@
<property name="visible">True</property>
<property name="spacing">12</property>
<child>
- <object class="GtkHBox" id="hbox_type">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="label645">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Type:</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="orientation">vertical</property>
@@ -347,12 +276,45 @@
</object>
</child>
<child type="label">
- <object class="GtkLabel" id="label643">
+ <object class="GtkHBox" id="hbox_add_account">
<property name="visible">True</property>
- <property name="label" translatable="yes">Add Account</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
+ <child>
+ <object class="GtkLabel" id="label643">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Add new</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="padding">5</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox_type">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label645">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">account</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
</child>
</object>
@@ -454,4 +416,7 @@
<action-widget response="-7">button_close</action-widget>
</action-widgets>
</object>
+ <object class="GtkImage" id="add_image">
+ <property name="stock">gtk-add</property>
+ </object>
</interface>