2 * Copyright (C) 2006-2007 Imendio AB
3 * Copyright (C) 2007-2009 Collabora Ltd.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301 USA
20 * Authors: Xavier Claessens <xclaesse@gmail.com>
21 * Martyn Russell <martyn@imendio.com>
22 * Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
23 * Jonathan Tellier <jonathan.tellier@gmail.com>
31 #include <glib/gi18n-lib.h>
34 #include <mx-gtk/mx-gtk.h>
35 #endif /* HAVE_MEEGO */
36 #include <gio/gdesktopappinfo.h>
38 #include <libempathy/empathy-utils.h>
40 #include <telepathy-glib/account.h>
41 #include <telepathy-glib/account-manager.h>
42 #include <telepathy-glib/connection-manager.h>
43 #include <telepathy-glib/util.h>
44 #include <dbus/dbus-protocol.h>
46 #include "empathy-account-widget.h"
47 #include "empathy-account-widget-private.h"
48 #include "empathy-account-widget-sip.h"
49 #include "empathy-account-widget-irc.h"
50 #include "empathy-ui-utils.h"
52 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
53 #include <libempathy/empathy-debug.h>
55 G_DEFINE_TYPE (EmpathyAccountWidget, empathy_account_widget, G_TYPE_OBJECT)
67 const gchar *label_username_example;
68 gboolean show_advanced;
71 static ServiceInfo services_infos[N_SERVICES] = {
72 { "label_username_example", TRUE },
73 { "label_username_g_example", TRUE },
74 { "label_username_f_example", FALSE },
78 EmpathyAccountSettings *settings;
80 GtkWidget *table_common_settings;
81 GtkWidget *apply_button;
82 GtkWidget *cancel_button;
83 GtkWidget *entry_password;
84 GtkWidget *spinbutton_port;
85 GtkWidget *enabled_checkbox;
86 GtkWidget *radiobutton_reuse;
90 gboolean contains_pending_changes;
92 /* An EmpathyAccountWidget can be used to either create an account or
93 * modify it. When we are creating an account, this member is set to TRUE */
94 gboolean creating_account;
96 /* whether there are any other real accounts. Necessary so we know whether
97 * it's safe to dismiss this widget in some cases (eg, whether the Cancel
98 * button should be sensitive) */
99 gboolean other_accounts_exist;
101 /* if TRUE, the GTK+ destroy signal has been fired and so the widgets
102 * embedded in this account widget can't be used any more
103 * workaround because some async callbacks can be called after the
104 * widget has been destroyed */
107 TpAccountManager *account_manager;
109 GtkWidget *param_account_widget;
110 GtkWidget *param_password_widget;
112 /* Used only for IRC accounts */
113 EmpathyIrcNetworkChooser *irc_network_chooser;
115 /* Used for 'special' XMPP account having a service associated ensuring that
116 * JIDs have a specific suffix; such as Facebook for example */
119 gboolean dispose_run;
120 } EmpathyAccountWidgetPriv;
126 PROP_CREATING_ACCOUNT,
127 PROP_OTHER_ACCOUNTS_EXIST,
137 static void account_widget_apply_and_log_in (EmpathyAccountWidget *);
143 static guint signals[LAST_SIGNAL] = { 0 };
145 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountWidget)
146 #define CHANGED_TIMEOUT 300
149 #define DIGITS "(["DIGIT"]+)"
150 #define ALPHA "a-zA-Z"
151 #define ALPHAS "(["ALPHA"]+)"
152 #define ALPHADIGIT ALPHA DIGIT
153 #define ALPHADIGITS "(["ALPHADIGIT"]+)"
154 #define ALPHADIGITDASH ALPHA DIGIT "-"
155 #define ALPHADIGITDASHS "(["ALPHADIGITDASH"]*)"
157 #define HOSTNUMBER "("DIGITS"\\."DIGITS"\\."DIGITS"\\."DIGITS")"
158 #define TOPLABEL ALPHAS"|(["ALPHA"]" ALPHADIGITDASHS "["ALPHADIGIT"])"
159 #define DOMAINLABEL ALPHADIGITS"|(["ALPHADIGIT"]" ALPHADIGITDASHS \
161 #define HOSTNAME "((" DOMAINLABEL "\\.)+" TOPLABEL ")"
162 /* Based on http://www.ietf.org/rfc/rfc1738.txt (section 5) */
163 #define HOST "("HOSTNAME "|" HOSTNUMBER")"
164 /* Based on http://www.ietf.org/rfc/rfc0822.txt (appendix D) */
165 #define EMAIL_LOCALPART "([^\\(\\)<>@,;:\\\\\"\\[\\]\\s]+)"
167 /* UIN is digital according to the unofficial specification:
168 * http://iserverd.khstu.ru/docum_ext/icqv5.html#CTS
169 * 5 digits minimun according to http://en.wikipedia.org/wiki/ICQ#UIN */
170 #define ICQ_USER_NAME "(["DIGIT"]{5,})"
171 /* Based on http://www.ietf.org/rfc/rfc2812.txt (section 2.3.1) */
172 #define IRC_SPECIAL "_\\[\\]{}\\\\|`^"
173 #define IRC_USER_NAME "(["ALPHA IRC_SPECIAL"]["ALPHADIGITDASH IRC_SPECIAL"]*)"
174 /* Based on http://www.ietf.org/rfc/rfc4622.txt (section 2.2)
175 * We just exclude invalid characters to avoid ucschars and other redundant
177 #define JABBER_USER_NAME "([^@:'\"<>&\\s]+)"
178 /* ID is an email according to the unofficial specification:
179 * http://www.hypothetic.org/docs/msn/general/names.php */
180 #define MSN_USER_NAME EMAIL_LOCALPART
181 /* Based on the official help:
182 * http://help.yahoo.com/l/us/yahoo/edit/registration/edit-01.html */
183 #define YAHOO_USER_NAME "(["ALPHA"]["ALPHADIGIT"_\\.]{3,31})"
185 #define ACCOUNT_REGEX_ICQ "^"ICQ_USER_NAME"$"
186 #define ACCOUNT_REGEX_IRC "^"IRC_USER_NAME"$"
187 #define ACCOUNT_REGEX_JABBER "^"JABBER_USER_NAME"@"HOST"$"
188 #define ACCOUNT_REGEX_MSN "^"MSN_USER_NAME"@"HOST"$"
189 #define ACCOUNT_REGEX_YAHOO "^"YAHOO_USER_NAME"$"
192 account_widget_set_control_buttons_sensitivity (EmpathyAccountWidget *self,
195 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
199 /* we hit this case because of the 'other-accounts-exist' property handler
200 * being called during init (before constructed()) */
201 if (priv->apply_button == NULL || priv->cancel_button == NULL)
204 gtk_widget_set_sensitive (priv->apply_button, sensitive);
205 gtk_widget_set_sensitive (priv->cancel_button,
206 (sensitive || priv->creating_account) && priv->other_accounts_exist);
210 /* We can't grab default if the widget hasn't be packed in a
214 window = gtk_widget_get_toplevel (priv->apply_button);
215 if (window != NULL &&
216 gtk_widget_is_toplevel (window))
218 gtk_widget_set_can_default (priv->apply_button, TRUE);
219 gtk_widget_grab_default (priv->apply_button);
226 account_widget_set_entry_highlighting (GtkEntry *entry, gboolean highlight)
231 g_return_if_fail (GTK_IS_ENTRY (entry));
233 style = gtk_widget_get_style (GTK_WIDGET (entry));
237 color = style->bg[GTK_STATE_SELECTED];
239 /* Here we take the current theme colour and add it to
240 * the colour for white and average the two. This
241 * gives a colour which is inline with the theme but
244 color.red = (color.red + (style->white).red) / 2;
245 color.green = (color.green + (style->white).green) / 2;
246 color.blue = (color.blue + (style->white).blue) / 2;
248 gtk_widget_modify_base (GTK_WIDGET (entry), GTK_STATE_NORMAL, &color);
251 gtk_widget_modify_base (GTK_WIDGET (entry), GTK_STATE_NORMAL, NULL);
255 account_widget_handle_control_buttons_sensitivity (EmpathyAccountWidget *self)
257 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
260 is_valid = empathy_account_settings_is_valid (priv->settings);
263 account_widget_set_control_buttons_sensitivity (self, is_valid);
265 g_signal_emit (self, signals[HANDLE_APPLY], 0, is_valid);
269 account_widget_entry_changed_common (EmpathyAccountWidget *self,
270 GtkEntry *entry, gboolean focus)
273 const gchar *param_name;
274 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
275 gboolean prev_status;
276 gboolean curr_status;
278 str = gtk_entry_get_text (entry);
279 param_name = g_object_get_data (G_OBJECT (entry), "param_name");
280 prev_status = empathy_account_settings_parameter_is_valid (priv->settings,
283 if (EMP_STR_EMPTY (str))
285 const gchar *value = NULL;
287 empathy_account_settings_unset (priv->settings, param_name);
291 value = empathy_account_settings_get_string (priv->settings,
293 DEBUG ("Unset %s and restore to %s", param_name, value);
294 gtk_entry_set_text (entry, value ? value : "");
299 DEBUG ("Setting %s to %s", param_name,
300 tp_strdiff (param_name, "password") ? str : "***");
301 empathy_account_settings_set_string (priv->settings, param_name, str);
304 curr_status = empathy_account_settings_parameter_is_valid (priv->settings,
306 if (curr_status != prev_status)
307 account_widget_set_entry_highlighting (entry, !curr_status);
311 account_widget_entry_changed_cb (GtkEditable *entry,
312 EmpathyAccountWidget *self)
314 account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE);
315 empathy_account_widget_changed (self);
319 account_widget_entry_map_cb (GtkEntry *entry,
320 EmpathyAccountWidget *self)
322 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
323 const gchar *param_name;
326 /* need to initialize input highlighting */
327 param_name = g_object_get_data (G_OBJECT (entry), "param_name");
328 is_valid = empathy_account_settings_parameter_is_valid (priv->settings,
330 account_widget_set_entry_highlighting (entry, !is_valid);
334 account_widget_int_changed_cb (GtkWidget *widget,
335 EmpathyAccountWidget *self)
337 const gchar *param_name;
339 const gchar *signature;
340 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
342 value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
343 param_name = g_object_get_data (G_OBJECT (widget), "param_name");
345 signature = empathy_account_settings_get_dbus_signature (priv->settings,
347 g_return_if_fail (signature != NULL);
349 DEBUG ("Setting %s to %d", param_name, value);
351 switch ((int)*signature)
353 case DBUS_TYPE_INT16:
354 case DBUS_TYPE_INT32:
355 empathy_account_settings_set_int32 (priv->settings, param_name, value);
357 case DBUS_TYPE_INT64:
358 empathy_account_settings_set_int64 (priv->settings, param_name, value);
360 case DBUS_TYPE_UINT16:
361 case DBUS_TYPE_UINT32:
362 empathy_account_settings_set_uint32 (priv->settings, param_name, value);
364 case DBUS_TYPE_UINT64:
365 empathy_account_settings_set_uint64 (priv->settings, param_name, value);
368 g_return_if_reached ();
371 empathy_account_widget_changed (self);
375 account_widget_checkbutton_toggled_cb (GtkWidget *widget,
376 EmpathyAccountWidget *self)
379 gboolean default_value;
380 const gchar *param_name;
381 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
383 value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
384 param_name = g_object_get_data (G_OBJECT (widget), "param_name");
386 /* FIXME: This is ugly! checkbox don't have a "not-set" value so we
387 * always unset the param and set the value if different from the
389 empathy_account_settings_unset (priv->settings, param_name);
390 default_value = empathy_account_settings_get_boolean (priv->settings,
393 if (default_value == value)
395 DEBUG ("Unset %s and restore to %d", param_name, default_value);
399 DEBUG ("Setting %s to %d", param_name, value);
400 empathy_account_settings_set_boolean (priv->settings, param_name, value);
403 empathy_account_widget_changed (self);
407 account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl,
408 EmpathyAccountWidget *self)
410 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
414 value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_ssl));
415 port = empathy_account_settings_get_uint32 (priv->settings, "port");
419 if (port == 5222 || port == 0)
424 if (port == 5223 || port == 0)
428 gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spinbutton_port), port);
430 priv->contains_pending_changes = TRUE;
434 account_widget_combobox_changed_cb (GtkWidget *widget,
435 EmpathyAccountWidget *self)
441 const gchar *default_value = NULL;
442 const gchar *param_name;
443 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
445 if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
448 model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
449 /* the param value is stored in the first column */
450 gtk_tree_model_get (model, &iter, 0, &value, -1);
452 param_name = g_object_get_data (G_OBJECT (widget), "param_name");
454 v = empathy_account_settings_get_default (priv->settings, param_name);
456 default_value = g_value_get_string (v);
458 if (!tp_strdiff (value, default_value))
460 DEBUG ("Unset %s and restore to %s", param_name, default_value);
461 empathy_account_settings_unset (priv->settings, param_name);
465 DEBUG ("Setting %s to %s", param_name, value);
466 empathy_account_settings_set_string (priv->settings, param_name, value);
469 empathy_account_widget_changed (self);
473 clear_icon_released_cb (GtkEntry *entry,
474 GtkEntryIconPosition icon_pos,
476 EmpathyAccountWidget *self)
478 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
479 const gchar *param_name;
481 param_name = g_object_get_data (G_OBJECT (entry), "param_name");
483 DEBUG ("Unset %s", param_name);
484 empathy_account_settings_unset (priv->settings, param_name);
485 gtk_entry_set_text (entry, "");
487 empathy_account_widget_changed (self);
491 password_entry_changed_cb (GtkEditable *entry,
492 EmpathyAccountWidget *self)
496 str = gtk_entry_get_text (GTK_ENTRY (entry));
498 gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
499 GTK_ENTRY_ICON_SECONDARY, !EMP_STR_EMPTY (str));
503 password_entry_activated_cb (GtkEntry *entry,
504 EmpathyAccountWidget *self)
506 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
508 if (gtk_widget_get_sensitive (priv->apply_button))
509 account_widget_apply_and_log_in (self);
513 account_entry_activated_cb (GtkEntry *entry,
514 EmpathyAccountWidget *self)
516 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
518 if (gtk_widget_get_sensitive (priv->apply_button))
519 account_widget_apply_and_log_in (self);
523 empathy_account_widget_setup_widget (EmpathyAccountWidget *self,
525 const gchar *param_name)
527 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
529 g_object_set_data_full (G_OBJECT (widget), "param_name",
530 g_strdup (param_name), g_free);
532 if (GTK_IS_SPIN_BUTTON (widget))
535 const gchar *signature;
537 signature = empathy_account_settings_get_dbus_signature (priv->settings,
539 g_return_if_fail (signature != NULL);
541 switch ((int)*signature)
543 case DBUS_TYPE_INT16:
544 case DBUS_TYPE_INT32:
545 value = empathy_account_settings_get_int32 (priv->settings,
548 case DBUS_TYPE_INT64:
549 value = empathy_account_settings_get_int64 (priv->settings,
552 case DBUS_TYPE_UINT16:
553 case DBUS_TYPE_UINT32:
554 value = empathy_account_settings_get_uint32 (priv->settings,
557 case DBUS_TYPE_UINT64:
558 value = empathy_account_settings_get_uint64 (priv->settings,
562 g_return_if_reached ();
565 gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
567 g_signal_connect (widget, "value-changed",
568 G_CALLBACK (account_widget_int_changed_cb),
571 else if (GTK_IS_ENTRY (widget))
573 const gchar *str = NULL;
575 str = empathy_account_settings_get_string (priv->settings, param_name);
576 gtk_entry_set_text (GTK_ENTRY (widget), str ? str : "");
578 if (!tp_strdiff (param_name, "account"))
579 priv->param_account_widget = widget;
580 else if (!tp_strdiff (param_name, "password"))
581 priv->param_password_widget = widget;
583 if (strstr (param_name, "password"))
585 gtk_entry_set_visibility (GTK_ENTRY (widget), FALSE);
587 /* Add 'clear' icon */
588 gtk_entry_set_icon_from_stock (GTK_ENTRY (widget),
589 GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
591 gtk_entry_set_icon_sensitive (GTK_ENTRY (widget),
592 GTK_ENTRY_ICON_SECONDARY, !EMP_STR_EMPTY (str));
594 g_signal_connect (widget, "icon-release",
595 G_CALLBACK (clear_icon_released_cb), self);
596 g_signal_connect (widget, "changed",
597 G_CALLBACK (password_entry_changed_cb), self);
598 g_signal_connect (widget, "activate",
599 G_CALLBACK (password_entry_activated_cb), self);
601 else if (strstr (param_name, "account"))
602 g_signal_connect (widget, "activate",
603 G_CALLBACK (account_entry_activated_cb), self);
606 g_signal_connect (widget, "changed",
607 G_CALLBACK (account_widget_entry_changed_cb), self);
608 g_signal_connect (widget, "map",
609 G_CALLBACK (account_widget_entry_map_cb), self);
611 else if (GTK_IS_TOGGLE_BUTTON (widget))
613 gboolean value = FALSE;
615 value = empathy_account_settings_get_boolean (priv->settings,
617 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
619 g_signal_connect (widget, "toggled",
620 G_CALLBACK (account_widget_checkbutton_toggled_cb),
623 else if (GTK_IS_COMBO_BOX (widget))
625 /* The combo box's model has to contain the param value in its first
626 * column (as a string) */
632 str = empathy_account_settings_get_string (priv->settings, param_name);
633 model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
635 valid = gtk_tree_model_get_iter_first (model, &iter);
640 gtk_tree_model_get (model, &iter, 0, &name, -1);
641 if (!tp_strdiff (name, str))
643 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget), &iter);
648 valid = gtk_tree_model_iter_next (model, &iter);
654 g_signal_connect (widget, "changed",
655 G_CALLBACK (account_widget_combobox_changed_cb),
660 DEBUG ("Unknown type of widget for param %s", param_name);
665 build_translated_params (void)
669 hash = g_hash_table_new (g_str_hash, g_str_equal);
670 g_hash_table_insert (hash, "account", _("Account"));
671 g_hash_table_insert (hash, "password", _("Password"));
672 g_hash_table_insert (hash, "server", _("Server"));
673 g_hash_table_insert (hash, "port", _("Port"));
679 account_widget_generic_format_param_name (const gchar *param_name)
683 static GHashTable *translated_params = NULL;
685 if (G_UNLIKELY (translated_params == NULL))
686 translated_params = build_translated_params ();
688 /* Translate most common parameters */
689 str = g_hash_table_lookup (translated_params, param_name);
691 return g_strdup (str);
693 str = g_strdup (param_name);
695 if (str && g_ascii_isalpha (str[0]))
696 str[0] = g_ascii_toupper (str[0]);
698 while ((p = strchr (str, '-')) != NULL)
700 if (p[1] != '\0' && g_ascii_isalpha (p[1]))
703 p[1] = g_ascii_toupper (p[1]);
713 accounts_widget_generic_setup (EmpathyAccountWidget *self,
714 GtkWidget *table_common_settings,
715 GtkWidget *table_advanced_settings)
717 TpConnectionManagerParam *params, *param;
718 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
720 params = empathy_account_settings_get_tp_params (priv->settings);
722 for (param = params; param != NULL && param->name != NULL; param++)
724 GtkWidget *table_settings;
726 GtkWidget *widget = NULL;
727 gchar *param_name_formatted;
729 if (param->flags & TP_CONN_MGR_PARAM_FLAG_REQUIRED)
730 table_settings = table_common_settings;
731 else if (priv->simple)
734 table_settings = table_advanced_settings;
736 param_name_formatted = account_widget_generic_format_param_name
738 g_object_get (table_settings, "n-rows", &n_rows, NULL);
739 gtk_table_resize (GTK_TABLE (table_settings), ++n_rows, 2);
741 if (param->dbus_signature[0] == 's')
745 str = g_strdup_printf (_("%s:"), param_name_formatted);
746 widget = gtk_label_new (str);
747 gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
750 gtk_table_attach (GTK_TABLE (table_settings),
756 gtk_widget_show (widget);
758 widget = gtk_entry_new ();
759 if (strcmp (param->name, "account") == 0)
761 g_signal_connect (widget, "realize",
762 G_CALLBACK (gtk_widget_grab_focus),
765 gtk_table_attach (GTK_TABLE (table_settings),
769 GTK_FILL | GTK_EXPAND, 0,
771 gtk_widget_show (widget);
773 /* int types: ynqiuxt. double type is 'd' */
774 else if (param->dbus_signature[0] == 'y' ||
775 param->dbus_signature[0] == 'n' ||
776 param->dbus_signature[0] == 'q' ||
777 param->dbus_signature[0] == 'i' ||
778 param->dbus_signature[0] == 'u' ||
779 param->dbus_signature[0] == 'x' ||
780 param->dbus_signature[0] == 't' ||
781 param->dbus_signature[0] == 'd')
788 switch (param->dbus_signature[0])
790 case 'y': minint = G_MININT8; maxint = G_MAXINT8; break;
791 case 'n': minint = G_MININT16; maxint = G_MAXINT16; break;
792 case 'q': minint = 0; maxint = G_MAXUINT16; break;
793 case 'i': minint = G_MININT32; maxint = G_MAXINT32; break;
794 case 'u': minint = 0; maxint = G_MAXUINT32; break;
795 case 'x': minint = G_MININT64; maxint = G_MAXINT64; break;
796 case 't': minint = 0; maxint = G_MAXUINT64; break;
797 case 'd': minint = G_MININT32; maxint = G_MAXINT32;
799 default: g_assert_not_reached ();
802 str = g_strdup_printf (_("%s:"), param_name_formatted);
803 widget = gtk_label_new (str);
804 gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
807 gtk_table_attach (GTK_TABLE (table_settings),
813 gtk_widget_show (widget);
815 widget = gtk_spin_button_new_with_range (minint, maxint, step);
816 gtk_table_attach (GTK_TABLE (table_settings),
820 GTK_FILL | GTK_EXPAND, 0,
822 gtk_widget_show (widget);
824 else if (param->dbus_signature[0] == 'b')
826 widget = gtk_check_button_new_with_label (param_name_formatted);
827 gtk_table_attach (GTK_TABLE (table_settings),
831 GTK_FILL | GTK_EXPAND, 0,
833 gtk_widget_show (widget);
837 DEBUG ("Unknown signature for param %s: %s",
838 param_name_formatted, param->dbus_signature);
842 empathy_account_widget_setup_widget (self, widget, param->name);
844 g_free (param_name_formatted);
849 account_widget_handle_params_valist (EmpathyAccountWidget *self,
850 const gchar *first_widget,
856 for (name = first_widget; name; name = va_arg (args, const gchar *))
858 const gchar *param_name;
860 param_name = va_arg (args, const gchar *);
861 object = gtk_builder_get_object (self->ui_details->gui, name);
865 g_warning ("Builder is missing object '%s'.", name);
869 empathy_account_widget_setup_widget (self, GTK_WIDGET (object),
875 account_widget_cancel_clicked_cb (GtkWidget *button,
876 EmpathyAccountWidget *self)
878 g_signal_emit (self, signals[CANCELLED], 0);
882 account_widget_account_enabled_cb (GObject *source_object,
886 GError *error = NULL;
887 TpAccount *account = TP_ACCOUNT (source_object);
888 EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
889 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
891 tp_account_set_enabled_finish (account, res, &error);
895 DEBUG ("Could not enable the account: %s", error->message);
896 g_error_free (error);
900 empathy_connect_new_account (account, priv->account_manager);
903 /* unref widget - part of the workaround */
904 g_object_unref (widget);
908 account_widget_applied_cb (GObject *source_object,
912 GError *error = NULL;
914 EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source_object);
915 EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
916 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
918 empathy_account_settings_apply_finish (settings, res, &error);
922 DEBUG ("Could not apply changes to account: %s", error->message);
923 g_error_free (error);
927 account = empathy_account_settings_get_account (priv->settings);
931 if (priv->creating_account)
933 /* By default, when an account is created, we enable it. */
935 /* workaround to keep widget alive during async call */
936 g_object_ref (widget);
938 tp_account_set_enabled_async (account, TRUE,
939 account_widget_account_enabled_cb, widget);
940 g_signal_emit (widget, signals[ACCOUNT_CREATED], 0, account);
942 else if (priv->enabled_checkbox != NULL)
944 gboolean enabled_checked;
948 mx_gtk_light_switch_get_active (
949 MX_GTK_LIGHT_SWITCH (priv->enabled_checkbox));
951 gtk_toggle_button_get_active (
952 GTK_TOGGLE_BUTTON (priv->enabled_checkbox));
953 #endif /* HAVE_MEEGO */
955 if (tp_account_is_enabled (account) && enabled_checked)
957 /* After having applied changes to a user account, we
958 * automatically reconnect it. This is done so the new
959 * information entered by the user is validated on the server. */
960 tp_account_reconnect_async (account, NULL, NULL);
965 if (!priv->destroyed)
966 account_widget_set_control_buttons_sensitivity (widget, FALSE);
968 priv->contains_pending_changes = FALSE;
970 /* unref the widget - part of the workaround */
971 g_object_unref (widget);
975 account_widget_apply_and_log_in (EmpathyAccountWidget *self)
977 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
978 gboolean display_name_overridden;
980 if (priv->radiobutton_reuse != NULL)
982 gboolean reuse = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
983 priv->radiobutton_reuse));
985 DEBUG ("Set register param: %d", !reuse);
986 empathy_account_settings_set_boolean (priv->settings, "register", !reuse);
989 g_object_get (priv->settings,
990 "display-name-overridden", &display_name_overridden, NULL);
992 if (priv->creating_account || !display_name_overridden)
996 /* set default display name for new accounts or update if user didn't
997 * manually override it. */
998 display_name = empathy_account_widget_get_default_display_name (self);
1000 empathy_account_settings_set_display_name_async (priv->settings,
1001 display_name, NULL, NULL);
1003 g_free (display_name);
1006 /* workaround to keep widget alive during async call */
1007 g_object_ref (self);
1008 empathy_account_settings_apply_async (priv->settings,
1009 account_widget_applied_cb, self);
1013 account_widget_apply_clicked_cb (GtkWidget *button,
1014 EmpathyAccountWidget *self)
1016 account_widget_apply_and_log_in (self);
1020 account_widget_setup_generic (EmpathyAccountWidget *self)
1022 GtkWidget *table_common_settings;
1023 GtkWidget *table_advanced_settings;
1025 table_common_settings = GTK_WIDGET (gtk_builder_get_object
1026 (self->ui_details->gui, "table_common_settings"));
1027 table_advanced_settings = GTK_WIDGET (gtk_builder_get_object
1028 (self->ui_details->gui, "table_advanced_settings"));
1030 accounts_widget_generic_setup (self, table_common_settings,
1031 table_advanced_settings);
1033 g_object_unref (self->ui_details->gui);
1037 account_widget_settings_ready_cb (EmpathyAccountSettings *settings,
1041 EmpathyAccountWidget *self = user_data;
1042 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1044 if (empathy_account_settings_is_ready (priv->settings))
1045 account_widget_setup_generic (self);
1049 account_widget_build_generic (EmpathyAccountWidget *self,
1050 const char *filename)
1052 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1053 GtkWidget *expander_advanced;
1055 self->ui_details->gui = empathy_builder_get_file (filename,
1056 "table_common_settings", &priv->table_common_settings,
1057 "vbox_generic_settings", &self->ui_details->widget,
1058 "expander_advanced_settings", &expander_advanced,
1062 gtk_widget_hide (expander_advanced);
1064 g_object_ref (self->ui_details->gui);
1066 if (empathy_account_settings_is_ready (priv->settings))
1067 account_widget_setup_generic (self);
1069 g_signal_connect (priv->settings, "notify::ready",
1070 G_CALLBACK (account_widget_settings_ready_cb), self);
1074 account_widget_launch_external_clicked (GtkWidget *button,
1077 if (!tp_strdiff (tp_account_get_storage_provider (account),
1078 "com.meego.libsocialweb"))
1080 /* we know how to handle this external provider */
1081 GDesktopAppInfo *app_info;
1082 const gchar *args[3] = { NULL, };
1083 GError *error = NULL;
1085 app_info = g_desktop_app_info_new ("gnome-control-center.desktop");
1087 if (app_info == NULL)
1089 g_critical ("Could not locate 'gnome-control-center.desktop'");
1093 args[0] = g_app_info_get_commandline (G_APP_INFO (app_info));
1094 args[1] = "bisho.desktop";
1097 gdk_spawn_on_screen (gtk_widget_get_screen (button),
1098 NULL, (gchar **) args, NULL,
1099 G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error);
1102 g_critical ("Failed to launch editor: %s", error->message);
1103 g_clear_error (&error);
1106 g_object_unref (app_info);
1111 account_widget_build_external (EmpathyAccountWidget *self,
1112 EmpathyAccountSettings *settings)
1114 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1115 TpAccount *account = empathy_account_settings_get_account (settings);
1116 GtkWidget *bar, *widget;
1119 self->ui_details->widget = gtk_vbox_new (FALSE, 6);
1120 priv->table_common_settings = gtk_table_new (1, 2, FALSE);
1122 if (!tp_strdiff (tp_account_get_storage_provider (account),
1123 "com.meego.libsocialweb"))
1125 /* we know how to handle this external provider */
1126 str = g_strdup_printf (
1127 _("The account %s is edited via My Web Accounts."),
1128 empathy_account_settings_get_display_name (settings));
1132 str = g_strdup_printf (
1133 _("The account %s cannot be edited in Empathy."),
1134 empathy_account_settings_get_display_name (settings));
1137 widget = gtk_label_new (str);
1138 gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
1141 bar = gtk_info_bar_new ();
1142 gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_INFO);
1144 GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))),
1146 gtk_container_set_border_width (GTK_CONTAINER (bar), 6);
1148 if (!tp_strdiff (tp_account_get_storage_provider (account),
1149 "com.meego.libsocialweb"))
1151 /* we know how to handle this external provider */
1152 widget = gtk_info_bar_add_button (GTK_INFO_BAR (bar),
1153 _("Launch My Web Accounts"), RESPONSE_LAUNCH);
1155 g_signal_connect (widget, "clicked",
1156 G_CALLBACK (account_widget_launch_external_clicked), account);
1159 gtk_box_pack_start (GTK_BOX (self->ui_details->widget), bar,
1161 gtk_box_pack_start (GTK_BOX (self->ui_details->widget),
1162 priv->table_common_settings, FALSE, TRUE, 0);
1164 gtk_widget_show_all (self->ui_details->widget);
1168 account_widget_build_salut (EmpathyAccountWidget *self,
1169 const char *filename)
1171 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1172 GtkWidget *expander_advanced;
1174 self->ui_details->gui = empathy_builder_get_file (filename,
1175 "table_common_settings", &priv->table_common_settings,
1176 "vbox_salut_settings", &self->ui_details->widget,
1177 "expander_advanced_settings", &expander_advanced,
1180 empathy_account_widget_handle_params (self,
1181 "entry_published", "published-name",
1182 "entry_nickname", "nickname",
1183 "entry_first_name", "first-name",
1184 "entry_last_name", "last-name",
1185 "entry_email", "email",
1190 gtk_widget_hide (expander_advanced);
1192 self->ui_details->default_focus = g_strdup ("entry_first_name");
1196 account_widget_build_irc (EmpathyAccountWidget *self,
1197 const char *filename)
1199 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1201 empathy_account_settings_set_regex (priv->settings, "account",
1206 priv->irc_network_chooser = empathy_account_widget_irc_build_simple (self,
1211 priv->irc_network_chooser = empathy_account_widget_irc_build (self,
1212 filename, &priv->table_common_settings);
1217 account_widget_build_sip (EmpathyAccountWidget *self,
1218 const char *filename)
1220 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1221 empathy_account_widget_sip_build (self, filename,
1222 &priv->table_common_settings);
1226 account_widget_build_msn (EmpathyAccountWidget *self,
1227 const char *filename)
1229 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1231 empathy_account_settings_set_regex (priv->settings, "account",
1236 self->ui_details->gui = empathy_builder_get_file (filename,
1237 "vbox_msn_simple", &self->ui_details->widget,
1240 empathy_account_widget_handle_params (self,
1241 "entry_id_simple", "account",
1242 "entry_password_simple", "password",
1245 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1249 self->ui_details->gui = empathy_builder_get_file (filename,
1250 "table_common_msn_settings", &priv->table_common_settings,
1251 "vbox_msn_settings", &self->ui_details->widget,
1254 empathy_account_widget_handle_params (self,
1255 "entry_id", "account",
1256 "entry_password", "password",
1257 "entry_server", "server",
1258 "spinbutton_port", "port",
1261 self->ui_details->default_focus = g_strdup ("entry_id");
1266 suffix_id_widget_changed_cb (GtkWidget *entry,
1267 EmpathyAccountWidget *self)
1269 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1270 const gchar *account;
1272 g_assert (priv->jid_suffix != NULL);
1274 account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE);
1276 account = empathy_account_settings_get_string (priv->settings, "account");
1277 if (!EMP_STR_EMPTY (account) &&
1278 !g_str_has_suffix (account, priv->jid_suffix))
1282 tmp = g_strdup_printf ("%s%s", account, priv->jid_suffix);
1284 DEBUG ("Change account from '%s' to '%s'", account, tmp);
1286 empathy_account_settings_set_string (priv->settings, "account", tmp);
1290 empathy_account_widget_changed (self);
1294 remove_jid_suffix (EmpathyAccountWidget *self,
1297 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1299 g_assert (priv->jid_suffix != NULL);
1301 if (!g_str_has_suffix (str, priv->jid_suffix))
1302 return g_strdup (str);
1304 return g_strndup (str, strlen (str) - strlen (priv->jid_suffix));
1308 setup_id_widget_with_suffix (EmpathyAccountWidget *self,
1310 const gchar *suffix)
1312 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1313 const gchar *str = NULL;
1315 g_object_set_data_full (G_OBJECT (widget), "param_name",
1316 g_strdup ("account"), g_free);
1318 g_assert (priv->jid_suffix == NULL);
1319 priv->jid_suffix = g_strdup (suffix);
1321 str = empathy_account_settings_get_string (priv->settings, "account");
1326 tmp = remove_jid_suffix (self, str);
1327 gtk_entry_set_text (GTK_ENTRY (widget), tmp);
1331 priv->param_account_widget = widget;
1333 g_signal_connect (widget, "changed",
1334 G_CALLBACK (suffix_id_widget_changed_cb), self);
1338 account_widget_get_service (EmpathyAccountWidget *self)
1340 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1341 const gchar *icon_name, *service;
1343 icon_name = empathy_account_settings_get_icon_name (priv->settings);
1344 service = empathy_account_settings_get_service (priv->settings);
1346 /* Previous versions of Empathy didn't set the Service property on Facebook
1347 * and gtalk accounts, so we check using the icon name as well. */
1348 if (!tp_strdiff (icon_name, "im-google-talk") ||
1349 !tp_strdiff (service, "google-talk"))
1350 return GTALK_SERVICE;
1352 if (!tp_strdiff (icon_name, "im-facebook") ||
1353 !tp_strdiff (service, "facebook"))
1354 return FACEBOOK_SERVICE;
1360 account_widget_build_jabber (EmpathyAccountWidget *self,
1361 const char *filename)
1363 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1364 GtkWidget *spinbutton_port;
1365 GtkWidget *checkbutton_ssl;
1366 GtkWidget *label_id, *label_password;
1367 GtkWidget *label_id_create, *label_password_create;
1368 GtkWidget *label_example_fb;
1369 GtkWidget *label_example;
1370 GtkWidget *expander_advanced;
1371 GtkWidget *entry_id;
1374 service = account_widget_get_service (self);
1376 empathy_account_settings_set_regex (priv->settings, "account",
1377 ACCOUNT_REGEX_JABBER);
1379 if (priv->simple && service == NO_SERVICE)
1381 /* Simple widget for XMPP */
1382 self->ui_details->gui = empathy_builder_get_file (filename,
1383 "vbox_jabber_simple", &self->ui_details->widget,
1384 "label_id_simple", &label_id,
1385 "label_id_create", &label_id_create,
1386 "label_password_simple", &label_password,
1387 "label_password_create", &label_password_create,
1390 if (empathy_account_settings_get_boolean (priv->settings, "register"))
1392 gtk_widget_hide (label_id);
1393 gtk_widget_hide (label_password);
1394 gtk_widget_show (label_id_create);
1395 gtk_widget_show (label_password_create);
1398 empathy_account_widget_handle_params (self,
1399 "entry_id_simple", "account",
1400 "entry_password_simple", "password",
1403 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1405 else if (priv->simple && service == GTALK_SERVICE)
1407 /* Simple widget for Google Talk */
1408 self->ui_details->gui = empathy_builder_get_file (filename,
1409 "vbox_gtalk_simple", &self->ui_details->widget,
1412 empathy_account_widget_handle_params (self,
1413 "entry_id_g_simple", "account",
1414 "entry_password_g_simple", "password",
1417 self->ui_details->default_focus = g_strdup ("entry_id_g_simple");
1419 else if (priv->simple && service == FACEBOOK_SERVICE)
1421 /* Simple widget for Facebook */
1422 self->ui_details->gui = empathy_builder_get_file (filename,
1423 "vbox_fb_simple", &self->ui_details->widget,
1424 "entry_id_fb_simple", &entry_id,
1427 empathy_account_widget_handle_params (self,
1428 "entry_password_fb_simple", "password",
1431 setup_id_widget_with_suffix (self, entry_id, "@chat.facebook.com");
1433 self->ui_details->default_focus = g_strdup ("entry_id_fb_simple");
1437 ServiceInfo info = services_infos[service];
1439 /* Full widget for XMPP, Google Talk and Facebook*/
1440 self->ui_details->gui = empathy_builder_get_file (filename,
1441 "table_common_settings", &priv->table_common_settings,
1442 "vbox_jabber_settings", &self->ui_details->widget,
1443 "spinbutton_port", &spinbutton_port,
1444 "checkbutton_ssl", &checkbutton_ssl,
1445 "label_username_f_example", &label_example_fb,
1446 info.label_username_example, &label_example,
1447 "expander_advanced", &expander_advanced,
1448 "entry_id", &entry_id,
1449 "label_id", &label_id,
1452 empathy_account_widget_handle_params (self,
1453 "entry_password", "password",
1454 "entry_resource", "resource",
1455 "entry_server", "server",
1456 "spinbutton_port", "port",
1457 "spinbutton_priority", "priority",
1458 "checkbutton_ssl", "old-ssl",
1459 "checkbutton_ignore_ssl_errors", "ignore-ssl-errors",
1460 "checkbutton_encryption", "require-encryption",
1463 if (service == FACEBOOK_SERVICE)
1465 gtk_label_set_label (GTK_LABEL (label_id), _("Username:"));
1467 /* Facebook special case the entry ID widget to hide the
1468 * "@chat.facebook.com" part */
1469 setup_id_widget_with_suffix (self, entry_id, "@chat.facebook.com");
1473 empathy_account_widget_setup_widget (self, entry_id, "account");
1476 self->ui_details->default_focus = g_strdup ("entry_id");
1477 priv->spinbutton_port = spinbutton_port;
1479 g_signal_connect (checkbutton_ssl, "toggled",
1480 G_CALLBACK (account_widget_jabber_ssl_toggled_cb),
1483 if (service == FACEBOOK_SERVICE)
1485 GtkContainer *parent;
1488 /* Removing the label from list of focusable widgets */
1489 parent = GTK_CONTAINER (gtk_widget_get_parent (label_example_fb));
1490 children = gtk_container_get_children (parent);
1491 children = g_list_remove (children, label_example_fb);
1492 gtk_container_set_focus_chain (parent, children);
1493 g_list_free (children);
1496 gtk_widget_show (label_example);
1498 if (!info.show_advanced)
1499 gtk_widget_hide (expander_advanced);
1504 account_widget_build_icq (EmpathyAccountWidget *self,
1505 const char *filename)
1507 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1508 GtkWidget *spinbutton_port;
1510 empathy_account_settings_set_regex (priv->settings, "account",
1515 self->ui_details->gui = empathy_builder_get_file (filename,
1516 "vbox_icq_simple", &self->ui_details->widget,
1519 empathy_account_widget_handle_params (self,
1520 "entry_uin_simple", "account",
1521 "entry_password_simple", "password",
1524 self->ui_details->default_focus = g_strdup ("entry_uin_simple");
1528 self->ui_details->gui = empathy_builder_get_file (filename,
1529 "table_common_settings", &priv->table_common_settings,
1530 "vbox_icq_settings", &self->ui_details->widget,
1531 "spinbutton_port", &spinbutton_port,
1534 empathy_account_widget_handle_params (self,
1535 "entry_uin", "account",
1536 "entry_password", "password",
1537 "entry_server", "server",
1538 "spinbutton_port", "port",
1539 "entry_charset", "charset",
1542 self->ui_details->default_focus = g_strdup ("entry_uin");
1547 account_widget_build_aim (EmpathyAccountWidget *self,
1548 const char *filename)
1550 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1551 GtkWidget *spinbutton_port;
1555 self->ui_details->gui = empathy_builder_get_file (filename,
1556 "vbox_aim_simple", &self->ui_details->widget,
1559 empathy_account_widget_handle_params (self,
1560 "entry_screenname_simple", "account",
1561 "entry_password_simple", "password",
1564 self->ui_details->default_focus = g_strdup ("entry_screenname_simple");
1568 self->ui_details->gui = empathy_builder_get_file (filename,
1569 "table_common_settings", &priv->table_common_settings,
1570 "vbox_aim_settings", &self->ui_details->widget,
1571 "spinbutton_port", &spinbutton_port,
1574 empathy_account_widget_handle_params (self,
1575 "entry_screenname", "account",
1576 "entry_password", "password",
1577 "entry_server", "server",
1578 "spinbutton_port", "port",
1581 self->ui_details->default_focus = g_strdup ("entry_screenname");
1586 account_widget_build_yahoo (EmpathyAccountWidget *self,
1587 const char *filename)
1589 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1591 empathy_account_settings_set_regex (priv->settings, "account",
1592 ACCOUNT_REGEX_YAHOO);
1596 self->ui_details->gui = empathy_builder_get_file (filename,
1597 "vbox_yahoo_simple", &self->ui_details->widget,
1600 empathy_account_widget_handle_params (self,
1601 "entry_id_simple", "account",
1602 "entry_password_simple", "password",
1605 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1609 self->ui_details->gui = empathy_builder_get_file (filename,
1610 "table_common_settings", &priv->table_common_settings,
1611 "vbox_yahoo_settings", &self->ui_details->widget,
1614 empathy_account_widget_handle_params (self,
1615 "entry_id", "account",
1616 "entry_password", "password",
1617 "entry_server", "server",
1618 "entry_locale", "room-list-locale",
1619 "entry_charset", "charset",
1620 "spinbutton_port", "port",
1621 "checkbutton_ignore_invites", "ignore-invites",
1624 self->ui_details->default_focus = g_strdup ("entry_id");
1629 account_widget_build_groupwise (EmpathyAccountWidget *self,
1630 const char *filename)
1632 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1636 self->ui_details->gui = empathy_builder_get_file (filename,
1637 "vbox_groupwise_simple", &self->ui_details->widget,
1640 empathy_account_widget_handle_params (self,
1641 "entry_id_simple", "account",
1642 "entry_password_simple", "password",
1645 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1649 self->ui_details->gui = empathy_builder_get_file (filename,
1650 "table_common_groupwise_settings", &priv->table_common_settings,
1651 "vbox_groupwise_settings", &self->ui_details->widget,
1654 empathy_account_widget_handle_params (self,
1655 "entry_id", "account",
1656 "entry_password", "password",
1657 "entry_server", "server",
1658 "spinbutton_port", "port",
1661 self->ui_details->default_focus = g_strdup ("entry_id");
1666 account_widget_destroy_cb (GtkWidget *widget,
1667 EmpathyAccountWidget *self)
1669 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1670 /* set the destroyed flag - workaround */
1671 priv->destroyed = TRUE;
1673 g_object_unref (self);
1677 empathy_account_widget_enabled_cb (TpAccount *account,
1681 EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
1682 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
1683 gboolean enabled = tp_account_is_enabled (account);
1685 if (priv->enabled_checkbox != NULL)
1688 mx_gtk_light_switch_set_active (
1689 MX_GTK_LIGHT_SWITCH (priv->enabled_checkbox),
1692 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->enabled_checkbox),
1694 #endif /* HAVE_MEEGO */
1700 account_widget_switch_flipped_cb (MxGtkLightSwitch *sw,
1704 account_widget_enabled_toggled_cb (GtkToggleButton *toggle_button,
1706 #endif /* HAVE_MEEGO */
1708 EmpathyAccountWidgetPriv *priv = GET_PRIV (user_data);
1713 state = gtk_toggle_button_get_active (toggle_button);
1714 #endif /* HAVE_MEEGO */
1716 account = empathy_account_settings_get_account (priv->settings);
1718 /* Enable the account according to the value of the "Enabled" checkbox */
1719 /* workaround to keep widget alive during async call */
1720 g_object_ref (user_data);
1721 tp_account_set_enabled_async (account, state,
1722 account_widget_account_enabled_cb, user_data);
1726 empathy_account_widget_set_other_accounts_exist (EmpathyAccountWidget *self,
1727 gboolean others_exist)
1729 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1731 priv->other_accounts_exist = others_exist;
1733 if (priv->creating_account)
1734 account_widget_handle_control_buttons_sensitivity (self);
1738 do_set_property (GObject *object,
1740 const GValue *value,
1743 EmpathyAccountWidgetPriv *priv = GET_PRIV (object);
1748 priv->settings = g_value_dup_object (value);
1751 priv->simple = g_value_get_boolean (value);
1753 case PROP_CREATING_ACCOUNT:
1754 priv->creating_account = g_value_get_boolean (value);
1756 case PROP_OTHER_ACCOUNTS_EXIST:
1757 empathy_account_widget_set_other_accounts_exist (
1758 EMPATHY_ACCOUNT_WIDGET (object), g_value_get_boolean (value));
1761 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1766 do_get_property (GObject *object,
1771 EmpathyAccountWidgetPriv *priv = GET_PRIV (object);
1776 g_value_set_string (value,
1777 empathy_account_settings_get_protocol (priv->settings));
1780 g_value_set_object (value, priv->settings);
1783 g_value_set_boolean (value, priv->simple);
1785 case PROP_CREATING_ACCOUNT:
1786 g_value_set_boolean (value, priv->creating_account);
1788 case PROP_OTHER_ACCOUNTS_EXIST:
1789 g_value_set_boolean (value, priv->other_accounts_exist);
1792 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1797 set_apply_button (EmpathyAccountWidget *self)
1799 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1802 /* We can't use the stock button as its accelerator ('A') clashes with the
1804 gtk_button_set_use_stock (GTK_BUTTON (priv->apply_button), FALSE);
1806 gtk_button_set_label (GTK_BUTTON (priv->apply_button), _("A_pply"));
1807 gtk_button_set_use_underline (GTK_BUTTON (priv->apply_button), TRUE);
1809 image = gtk_image_new_from_stock (GTK_STOCK_APPLY, GTK_ICON_SIZE_BUTTON);
1810 gtk_button_set_image (GTK_BUTTON (priv->apply_button), image);
1814 presence_changed_cb (TpAccountManager *manager,
1815 TpConnectionPresenceType state,
1816 const gchar *status,
1817 const gchar *message,
1818 EmpathyAccountWidget *self)
1820 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1822 if (priv->destroyed)
1825 if (priv->apply_button == NULL)
1826 /* This button doesn't exist in 'simple' mode */
1829 if (state > TP_CONNECTION_PRESENCE_TYPE_OFFLINE &&
1830 priv->creating_account)
1832 /* We are online and creating a new account, display a Login button */
1835 gtk_button_set_use_stock (GTK_BUTTON (priv->apply_button), FALSE);
1836 gtk_button_set_label (GTK_BUTTON (priv->apply_button), _("L_og in"));
1838 image = gtk_image_new_from_stock (GTK_STOCK_CONNECT,
1839 GTK_ICON_SIZE_BUTTON);
1840 gtk_button_set_image (GTK_BUTTON (priv->apply_button), image);
1844 /* We are offline or modifying an existing account, display
1846 set_apply_button (self);
1851 account_manager_ready_cb (GObject *source_object,
1852 GAsyncResult *result,
1855 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (user_data);
1856 TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
1857 GError *error = NULL;
1858 TpConnectionPresenceType state;
1860 if (!tp_account_manager_prepare_finish (account_manager, result, &error))
1862 DEBUG ("Failed to prepare account manager: %s", error->message);
1863 g_error_free (error);
1867 state = tp_account_manager_get_most_available_presence (account_manager, NULL,
1870 /* simulate a presence change so the apply button will be changed
1872 presence_changed_cb (account_manager, state, NULL, NULL, self);
1875 g_object_unref (self);
1878 #define WIDGET(cm, proto) \
1879 { #cm, #proto, "empathy-account-widget-"#proto".ui", \
1880 account_widget_build_##proto }
1883 add_enable_checkbox (EmpathyAccountWidget *self,
1886 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1890 GtkWidget *vbox = self->ui_details->widget;
1891 #endif /* HAVE_MEEGO */
1892 guint nb_rows, nb_columns;
1893 gboolean is_enabled;
1895 /* handle the "Enabled" checkbox. We only add it when modifying an account */
1896 if (priv->creating_account || priv->table_common_settings == NULL)
1899 is_enabled = tp_account_is_enabled (account);
1902 w = gtk_label_new (_("Account:"));
1903 gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
1905 priv->enabled_checkbox = mx_gtk_light_switch_new ();
1907 mx_gtk_light_switch_set_active (
1908 MX_GTK_LIGHT_SWITCH (priv->enabled_checkbox), is_enabled);
1910 gtk_widget_show (w);
1912 priv->enabled_checkbox =
1913 gtk_check_button_new_with_mnemonic (_("_Enabled"));
1915 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->enabled_checkbox),
1917 #endif /* HAVE_MEEGO */
1919 g_object_get (priv->table_common_settings, "n-rows", &nb_rows,
1920 "n-columns", &nb_columns, NULL);
1922 gtk_table_resize (GTK_TABLE (priv->table_common_settings), ++nb_rows,
1926 gtk_table_attach (GTK_TABLE (priv->table_common_settings),
1928 0, 1, nb_rows - 1, nb_rows,
1930 gtk_table_attach (GTK_TABLE (priv->table_common_settings),
1931 priv->enabled_checkbox,
1932 1, nb_columns, nb_rows - 1, nb_rows,
1933 GTK_EXPAND | GTK_FILL, 0, 0, 0);
1935 gtk_box_pack_start (GTK_BOX (vbox), priv->enabled_checkbox, FALSE, FALSE, 0);
1936 gtk_box_reorder_child (GTK_BOX (vbox), priv->enabled_checkbox, 0);
1937 #endif /* HAVE_MEEGO */
1939 gtk_widget_show (priv->enabled_checkbox);
1942 g_signal_connect (G_OBJECT (priv->enabled_checkbox), "switch-flipped",
1943 G_CALLBACK (account_widget_switch_flipped_cb), self);
1945 g_signal_connect (G_OBJECT (priv->enabled_checkbox), "toggled",
1946 G_CALLBACK (account_widget_enabled_toggled_cb), self);
1947 #endif /* HAVE_MEEGO */
1951 /* Meego doesn't support registration */
1953 add_register_buttons (EmpathyAccountWidget *self,
1956 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1957 const TpConnectionManagerProtocol *protocol;
1958 GtkWidget *radiobutton_register;
1959 GtkWidget *vbox = self->ui_details->widget;
1961 if (!priv->creating_account)
1964 protocol = empathy_account_settings_get_tp_protocol (priv->settings);
1965 if (protocol == NULL)
1968 if (!tp_connection_manager_protocol_can_register (protocol))
1971 if (account_widget_get_service (self) != NO_SERVICE)
1977 priv->radiobutton_reuse = gtk_radio_button_new_with_label (NULL,
1978 _("This account already exists on the server"));
1979 radiobutton_register = gtk_radio_button_new_with_label (
1980 gtk_radio_button_get_group (GTK_RADIO_BUTTON (priv->radiobutton_reuse)),
1981 _("Create a new account on the server"));
1983 gtk_box_pack_start (GTK_BOX (vbox), priv->radiobutton_reuse, FALSE, FALSE, 0);
1984 gtk_box_pack_start (GTK_BOX (vbox), radiobutton_register, FALSE, FALSE, 0);
1985 gtk_box_reorder_child (GTK_BOX (vbox), priv->radiobutton_reuse, 0);
1986 gtk_box_reorder_child (GTK_BOX (vbox), radiobutton_register, 1);
1987 gtk_widget_show (priv->radiobutton_reuse);
1988 gtk_widget_show (radiobutton_register);
1990 #endif /* HAVE_MEEGO */
1993 remember_password_toggled_cb (GtkToggleButton *button,
1994 EmpathyAccountWidget *self)
1996 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1998 if (gtk_toggle_button_get_active (button))
2000 gtk_widget_set_sensitive (priv->param_password_widget, TRUE);
2004 gtk_widget_set_sensitive (priv->param_password_widget, FALSE);
2005 gtk_entry_set_text (GTK_ENTRY (priv->param_password_widget), "");
2006 empathy_account_settings_unset (priv->settings, "password");
2011 do_constructed (GObject *obj)
2013 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
2014 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2016 TpStorageRestrictionFlags storage_restrictions;
2017 const gchar *display_name, *default_display_name;
2020 const gchar *cm_name;
2021 const gchar *protocol;
2023 void (*func)(EmpathyAccountWidget *self, const gchar *filename);
2025 { "salut", "local-xmpp", "empathy-account-widget-local-xmpp.ui",
2026 account_widget_build_salut },
2027 WIDGET (gabble, jabber),
2028 WIDGET (butterfly, msn),
2031 WIDGET (haze, yahoo),
2032 WIDGET (haze, groupwise),
2034 WIDGET (sofiasip, sip),
2037 account = empathy_account_settings_get_account (priv->settings);
2039 if (account != NULL)
2040 storage_restrictions = tp_account_get_storage_restrictions (account);
2042 storage_restrictions = 0;
2044 /* Empathy can only edit accounts without the Cannot_Set_Parameters flag */
2045 if (storage_restrictions & TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS)
2047 DEBUG ("Account is provided by an external storage provider");
2049 account_widget_build_external (self, priv->settings);
2053 const gchar *protocol, *cm_name;
2055 cm_name = empathy_account_settings_get_cm (priv->settings);
2056 protocol = empathy_account_settings_get_protocol (priv->settings);
2058 for (i = 0 ; i < G_N_ELEMENTS (widgets); i++)
2060 if (!tp_strdiff (widgets[i].cm_name, cm_name) &&
2061 !tp_strdiff (widgets[i].protocol, protocol))
2065 filename = empathy_file_lookup (widgets[i].file,
2067 widgets[i].func (self, filename);
2074 if (i == G_N_ELEMENTS (widgets))
2076 gchar *filename = empathy_file_lookup (
2077 "empathy-account-widget-generic.ui", "libempathy-gtk");
2078 account_widget_build_generic (self, filename);
2083 /* handle default focus */
2084 if (self->ui_details->default_focus != NULL)
2086 GObject *default_focus_entry;
2088 default_focus_entry = gtk_builder_get_object
2089 (self->ui_details->gui, self->ui_details->default_focus);
2090 g_signal_connect (default_focus_entry, "realize",
2091 G_CALLBACK (gtk_widget_grab_focus),
2095 /* remember password */
2096 if (priv->param_password_widget != NULL)
2100 button = gtk_builder_get_object (
2101 self->ui_details->gui, "remember_password");
2105 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
2106 !EMP_STR_EMPTY (empathy_account_settings_get_string (
2107 priv->settings, "password")));
2109 g_signal_connect (button, "toggled",
2110 G_CALLBACK (remember_password_toggled_cb), self);
2111 remember_password_toggled_cb (GTK_TOGGLE_BUTTON (button), self);
2115 /* dup and init the account-manager */
2116 priv->account_manager = tp_account_manager_dup ();
2118 g_object_ref (self);
2119 tp_account_manager_prepare_async (priv->account_manager, NULL,
2120 account_manager_ready_cb, self);
2122 /* handle apply and cancel button */
2123 if (!priv->simple &&
2124 !(storage_restrictions &
2125 TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS))
2127 GtkWidget *hbox = gtk_hbox_new (TRUE, 3);
2130 /* We can't use the stock button as its accelerator ('C') clashes with
2131 * the Close button. */
2132 priv->cancel_button = gtk_button_new ();
2133 gtk_button_set_label (GTK_BUTTON (priv->cancel_button), _("Ca_ncel"));
2134 gtk_button_set_use_underline (GTK_BUTTON (priv->cancel_button), TRUE);
2136 image = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON);
2137 gtk_button_set_image (GTK_BUTTON (priv->cancel_button), image);
2139 priv->apply_button = gtk_button_new ();
2140 set_apply_button (self);
2142 /* We'll change this button to a "Log in" one if we are creating a new
2143 * account and are connected. */
2144 tp_g_signal_connect_object (priv->account_manager,
2145 "most-available-presence-changed",
2146 G_CALLBACK (presence_changed_cb), obj, 0);
2148 gtk_box_pack_end (GTK_BOX (hbox), priv->apply_button, TRUE,
2150 gtk_box_pack_end (GTK_BOX (hbox), priv->cancel_button, TRUE,
2153 gtk_box_pack_end (GTK_BOX (self->ui_details->widget), hbox, FALSE,
2156 g_signal_connect (priv->cancel_button, "clicked",
2157 G_CALLBACK (account_widget_cancel_clicked_cb),
2159 g_signal_connect (priv->apply_button, "clicked",
2160 G_CALLBACK (account_widget_apply_clicked_cb),
2162 gtk_widget_show_all (hbox);
2164 if (priv->creating_account)
2165 /* When creating an account, the user might have nothing to enter.
2166 * That means that no control interaction might occur,
2167 * so we update the control button sensitivity manually.
2169 account_widget_handle_control_buttons_sensitivity (self);
2171 account_widget_set_control_buttons_sensitivity (self, FALSE);
2174 if (account != NULL)
2176 g_signal_connect (account, "notify::enabled",
2177 G_CALLBACK (empathy_account_widget_enabled_cb), self);
2181 add_register_buttons (self, account);
2182 #endif /* HAVE_MEEGO */
2184 /* add the Enable checkbox to accounts that support it */
2185 if (!(storage_restrictions & TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_ENABLED))
2186 add_enable_checkbox (self, account);
2188 /* hook up to widget destruction to unref ourselves */
2189 g_signal_connect (self->ui_details->widget, "destroy",
2190 G_CALLBACK (account_widget_destroy_cb), self);
2192 if (self->ui_details->gui != NULL)
2194 empathy_builder_unref_and_keep_widget (self->ui_details->gui,
2195 self->ui_details->widget);
2196 self->ui_details->gui = NULL;
2199 display_name = empathy_account_settings_get_display_name (priv->settings);
2200 default_display_name = empathy_account_widget_get_default_display_name (self);
2202 if (tp_strdiff (display_name, default_display_name) &&
2203 !priv->creating_account)
2205 /* The display name of the account is not the one that we'd assign by
2206 * default; assume that the user changed it manually */
2207 g_object_set (priv->settings, "display-name-overridden", TRUE, NULL);
2212 do_dispose (GObject *obj)
2214 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
2215 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2217 if (priv->dispose_run)
2220 priv->dispose_run = TRUE;
2222 if (priv->settings != NULL)
2225 account = empathy_account_settings_get_account (priv->settings);
2227 if (account != NULL)
2229 g_signal_handlers_disconnect_by_func (account,
2230 empathy_account_widget_enabled_cb, self);
2233 g_object_unref (priv->settings);
2234 priv->settings = NULL;
2237 if (priv->account_manager != NULL)
2239 g_object_unref (priv->account_manager);
2240 priv->account_manager = NULL;
2243 if (G_OBJECT_CLASS (empathy_account_widget_parent_class)->dispose != NULL)
2244 G_OBJECT_CLASS (empathy_account_widget_parent_class)->dispose (obj);
2248 do_finalize (GObject *obj)
2250 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
2251 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2253 g_free (self->ui_details->default_focus);
2254 g_slice_free (EmpathyAccountWidgetUIDetails, self->ui_details);
2256 g_free (priv->jid_suffix);
2258 if (G_OBJECT_CLASS (empathy_account_widget_parent_class)->finalize != NULL)
2259 G_OBJECT_CLASS (empathy_account_widget_parent_class)->finalize (obj);
2263 empathy_account_widget_class_init (EmpathyAccountWidgetClass *klass)
2265 GObjectClass *oclass = G_OBJECT_CLASS (klass);
2266 GParamSpec *param_spec;
2268 oclass->get_property = do_get_property;
2269 oclass->set_property = do_set_property;
2270 oclass->constructed = do_constructed;
2271 oclass->dispose = do_dispose;
2272 oclass->finalize = do_finalize;
2274 param_spec = g_param_spec_string ("protocol",
2275 "protocol", "The protocol of the account",
2277 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
2278 g_object_class_install_property (oclass, PROP_PROTOCOL, param_spec);
2280 param_spec = g_param_spec_object ("settings",
2281 "settings", "The settings of the account",
2282 EMPATHY_TYPE_ACCOUNT_SETTINGS,
2283 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
2284 g_object_class_install_property (oclass, PROP_SETTINGS, param_spec);
2286 param_spec = g_param_spec_boolean ("simple",
2287 "simple", "Whether the account widget is a simple or an advanced one",
2289 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
2290 g_object_class_install_property (oclass, PROP_SIMPLE, param_spec);
2292 param_spec = g_param_spec_boolean ("creating-account",
2294 "TRUE if we're creating an account, FALSE if we're modifying it",
2296 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
2297 g_object_class_install_property (oclass, PROP_CREATING_ACCOUNT, param_spec);
2299 param_spec = g_param_spec_boolean ("other-accounts-exist",
2300 "other-accounts-exist",
2301 "TRUE if there are any other accounts (even if this isn't yet saved)",
2303 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
2304 g_object_class_install_property (oclass, PROP_OTHER_ACCOUNTS_EXIST,
2307 signals[HANDLE_APPLY] =
2308 g_signal_new ("handle-apply", G_TYPE_FROM_CLASS (klass),
2309 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
2310 g_cclosure_marshal_VOID__BOOLEAN,
2314 /* This signal is emitted when an account has been created and enabled. */
2315 signals[ACCOUNT_CREATED] =
2316 g_signal_new ("account-created", G_TYPE_FROM_CLASS (klass),
2317 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
2318 g_cclosure_marshal_VOID__OBJECT,
2322 signals[CANCELLED] =
2323 g_signal_new ("cancelled", G_TYPE_FROM_CLASS (klass),
2324 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
2325 g_cclosure_marshal_VOID__VOID,
2329 g_type_class_add_private (klass, sizeof (EmpathyAccountWidgetPriv));
2333 empathy_account_widget_init (EmpathyAccountWidget *self)
2335 EmpathyAccountWidgetPriv *priv =
2336 G_TYPE_INSTANCE_GET_PRIVATE ((self), EMPATHY_TYPE_ACCOUNT_WIDGET,
2337 EmpathyAccountWidgetPriv);
2340 priv->dispose_run = FALSE;
2342 self->ui_details = g_slice_new0 (EmpathyAccountWidgetUIDetails);
2345 /* public methods */
2348 empathy_account_widget_discard_pending_changes
2349 (EmpathyAccountWidget *widget)
2351 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
2353 empathy_account_settings_discard_changes (priv->settings);
2354 priv->contains_pending_changes = FALSE;
2358 empathy_account_widget_contains_pending_changes (EmpathyAccountWidget *widget)
2360 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
2362 return priv->contains_pending_changes;
2366 empathy_account_widget_handle_params (EmpathyAccountWidget *self,
2367 const gchar *first_widget,
2372 va_start (args, first_widget);
2373 account_widget_handle_params_valist (self, first_widget, args);
2378 empathy_account_widget_get_widget (EmpathyAccountWidget *widget)
2380 return widget->ui_details->widget;
2383 EmpathyAccountWidget *
2384 empathy_account_widget_new_for_protocol (EmpathyAccountSettings *settings,
2387 EmpathyAccountWidget *self;
2389 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_SETTINGS (settings), NULL);
2392 (EMPATHY_TYPE_ACCOUNT_WIDGET,
2393 "settings", settings, "simple", simple,
2395 empathy_account_settings_get_account (settings) == NULL,
2402 empathy_account_widget_get_default_display_name (EmpathyAccountWidget *self)
2404 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2405 const gchar *login_id;
2406 const gchar *protocol, *p;
2407 gchar *default_display_name;
2410 login_id = empathy_account_settings_get_string (priv->settings, "account");
2411 protocol = empathy_account_settings_get_protocol (priv->settings);
2412 service = account_widget_get_service (self);
2414 if (login_id != NULL)
2416 /* TODO: this should be done in empathy-account-widget-irc */
2417 if (!tp_strdiff (protocol, "irc"))
2419 EmpathyIrcNetwork *network;
2421 network = empathy_irc_network_chooser_get_network (
2422 priv->irc_network_chooser);
2423 g_assert (network != NULL);
2425 /* To translators: The first parameter is the login id and the
2426 * second one is the network. The resulting string will be something
2427 * like: "MyUserName on freenode".
2428 * You should reverse the order of these arguments if the
2429 * server should come before the login id in your locale.*/
2430 default_display_name = g_strdup_printf (_("%1$s on %2$s"),
2431 login_id, empathy_irc_network_get_name (network));
2433 else if (service == FACEBOOK_SERVICE)
2437 tmp = remove_jid_suffix (self, login_id);
2438 default_display_name = g_strdup_printf ("Facebook (%s)", tmp);
2443 default_display_name = g_strdup (login_id);
2446 return default_display_name;
2449 if ((p = empathy_protocol_name_to_display_name (protocol)) != NULL)
2452 if (protocol != NULL)
2454 /* To translators: The parameter is the protocol name. The resulting
2455 * string will be something like: "Jabber Account" */
2456 default_display_name = g_strdup_printf (_("%s Account"), protocol);
2460 default_display_name = g_strdup (_("New account"));
2463 return default_display_name;
2466 /* Used by subclass to indicate that widget contains pending changes */
2468 empathy_account_widget_changed (EmpathyAccountWidget *self)
2470 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2472 account_widget_handle_control_buttons_sensitivity (self);
2473 priv->contains_pending_changes = TRUE;
2477 empathy_account_widget_set_account_param (EmpathyAccountWidget *self,
2478 const gchar *account)
2480 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2482 if (priv->param_account_widget == NULL)
2485 gtk_entry_set_text (GTK_ENTRY (priv->param_account_widget), account);
2489 empathy_account_widget_set_password_param (EmpathyAccountWidget *self,
2490 const gchar *account)
2492 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2494 if (priv->param_password_widget == NULL)
2497 gtk_entry_set_text (GTK_ENTRY (priv->param_password_widget), account);