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 EmpathyAccountSettings *settings;
69 GtkWidget *table_common_settings;
70 GtkWidget *apply_button;
71 GtkWidget *cancel_button;
72 GtkWidget *entry_password;
73 GtkWidget *spinbutton_port;
74 GtkWidget *enabled_checkbox;
75 GtkWidget *radiobutton_reuse;
79 gboolean contains_pending_changes;
81 /* An EmpathyAccountWidget can be used to either create an account or
82 * modify it. When we are creating an account, this member is set to TRUE */
83 gboolean creating_account;
85 /* whether there are any other real accounts. Necessary so we know whether
86 * it's safe to dismiss this widget in some cases (eg, whether the Cancel
87 * button should be sensitive) */
88 gboolean other_accounts_exist;
90 /* if TRUE, the GTK+ destroy signal has been fired and so the widgets
91 * embedded in this account widget can't be used any more
92 * workaround because some async callbacks can be called after the
93 * widget has been destroyed */
96 TpAccountManager *account_manager;
98 GtkWidget *param_account_widget;
99 GtkWidget *param_password_widget;
101 /* Used only for IRC accounts */
102 EmpathyIrcNetworkChooser *irc_network_chooser;
104 /* Used for 'special' XMPP account having a service associated ensuring that
105 * JIDs have a specific suffix; such as Facebook for example */
108 gboolean dispose_run;
109 } EmpathyAccountWidgetPriv;
115 PROP_CREATING_ACCOUNT,
116 PROP_OTHER_ACCOUNTS_EXIST,
126 static void account_widget_apply_and_log_in (EmpathyAccountWidget *);
132 static guint signals[LAST_SIGNAL] = { 0 };
134 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountWidget)
135 #define CHANGED_TIMEOUT 300
138 #define DIGITS "(["DIGIT"]+)"
139 #define ALPHA "a-zA-Z"
140 #define ALPHAS "(["ALPHA"]+)"
141 #define ALPHADIGIT ALPHA DIGIT
142 #define ALPHADIGITS "(["ALPHADIGIT"]+)"
143 #define ALPHADIGITDASH ALPHA DIGIT "-"
144 #define ALPHADIGITDASHS "(["ALPHADIGITDASH"]*)"
146 #define HOSTNUMBER "("DIGITS"\\."DIGITS"\\."DIGITS"\\."DIGITS")"
147 #define TOPLABEL ALPHAS"|(["ALPHA"]" ALPHADIGITDASHS "["ALPHADIGIT"])"
148 #define DOMAINLABEL ALPHADIGITS"|(["ALPHADIGIT"]" ALPHADIGITDASHS \
150 #define HOSTNAME "((" DOMAINLABEL "\\.)+" TOPLABEL ")"
151 /* Based on http://www.ietf.org/rfc/rfc1738.txt (section 5) */
152 #define HOST "("HOSTNAME "|" HOSTNUMBER")"
153 /* Based on http://www.ietf.org/rfc/rfc0822.txt (appendix D) */
154 #define EMAIL_LOCALPART "([^\\(\\)<>@,;:\\\\\"\\[\\]\\s]+)"
156 /* UIN is digital according to the unofficial specification:
157 * http://iserverd.khstu.ru/docum_ext/icqv5.html#CTS
158 * 5 digits minimun according to http://en.wikipedia.org/wiki/ICQ#UIN */
159 #define ICQ_USER_NAME "(["DIGIT"]{5,})"
160 /* Based on http://www.ietf.org/rfc/rfc2812.txt (section 2.3.1) */
161 #define IRC_SPECIAL "_\\[\\]{}\\\\|`^"
162 #define IRC_USER_NAME "(["ALPHA IRC_SPECIAL"]["ALPHADIGITDASH IRC_SPECIAL"]*)"
163 /* Based on http://www.ietf.org/rfc/rfc4622.txt (section 2.2)
164 * We just exclude invalid characters to avoid ucschars and other redundant
166 #define JABBER_USER_NAME "([^@:'\"<>&\\s]+)"
167 /* ID is an email according to the unofficial specification:
168 * http://www.hypothetic.org/docs/msn/general/names.php */
169 #define MSN_USER_NAME EMAIL_LOCALPART
170 /* Based on the official help:
171 * http://help.yahoo.com/l/us/yahoo/edit/registration/edit-01.html */
172 #define YAHOO_USER_NAME "(["ALPHA"]["ALPHADIGIT"_\\.]{3,31})"
174 #define ACCOUNT_REGEX_ICQ "^"ICQ_USER_NAME"$"
175 #define ACCOUNT_REGEX_IRC "^"IRC_USER_NAME"$"
176 #define ACCOUNT_REGEX_JABBER "^"JABBER_USER_NAME"@"HOST"$"
177 #define ACCOUNT_REGEX_MSN "^"MSN_USER_NAME"@"HOST"$"
178 #define ACCOUNT_REGEX_YAHOO "^"YAHOO_USER_NAME"$"
181 account_widget_set_control_buttons_sensitivity (EmpathyAccountWidget *self,
184 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
188 /* we hit this case because of the 'other-accounts-exist' property handler
189 * being called during init (before constructed()) */
190 if (priv->apply_button == NULL || priv->cancel_button == NULL)
193 gtk_widget_set_sensitive (priv->apply_button, sensitive);
194 gtk_widget_set_sensitive (priv->cancel_button,
195 (sensitive || priv->creating_account) && priv->other_accounts_exist);
199 /* We can't grab default if the widget hasn't be packed in a
203 window = gtk_widget_get_toplevel (priv->apply_button);
204 if (window != NULL &&
205 gtk_widget_is_toplevel (window))
207 gtk_widget_set_can_default (priv->apply_button, TRUE);
208 gtk_widget_grab_default (priv->apply_button);
215 account_widget_set_entry_highlighting (GtkEntry *entry, gboolean highlight)
220 g_return_if_fail (GTK_IS_ENTRY (entry));
222 style = gtk_widget_get_style (GTK_WIDGET (entry));
226 color = style->bg[GTK_STATE_SELECTED];
228 /* Here we take the current theme colour and add it to
229 * the colour for white and average the two. This
230 * gives a colour which is inline with the theme but
233 color.red = (color.red + (style->white).red) / 2;
234 color.green = (color.green + (style->white).green) / 2;
235 color.blue = (color.blue + (style->white).blue) / 2;
237 gtk_widget_modify_base (GTK_WIDGET (entry), GTK_STATE_NORMAL, &color);
240 gtk_widget_modify_base (GTK_WIDGET (entry), GTK_STATE_NORMAL, NULL);
244 account_widget_handle_control_buttons_sensitivity (EmpathyAccountWidget *self)
246 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
249 is_valid = empathy_account_settings_is_valid (priv->settings);
252 account_widget_set_control_buttons_sensitivity (self, is_valid);
254 g_signal_emit (self, signals[HANDLE_APPLY], 0, is_valid);
258 account_widget_entry_changed_common (EmpathyAccountWidget *self,
259 GtkEntry *entry, gboolean focus)
262 const gchar *param_name;
263 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
264 gboolean prev_status;
265 gboolean curr_status;
267 str = gtk_entry_get_text (entry);
268 param_name = g_object_get_data (G_OBJECT (entry), "param_name");
269 prev_status = empathy_account_settings_parameter_is_valid (priv->settings,
272 if (EMP_STR_EMPTY (str))
274 const gchar *value = NULL;
276 empathy_account_settings_unset (priv->settings, param_name);
280 value = empathy_account_settings_get_string (priv->settings,
282 DEBUG ("Unset %s and restore to %s", param_name, value);
283 gtk_entry_set_text (entry, value ? value : "");
288 DEBUG ("Setting %s to %s", param_name,
289 tp_strdiff (param_name, "password") ? str : "***");
290 empathy_account_settings_set_string (priv->settings, param_name, str);
293 curr_status = empathy_account_settings_parameter_is_valid (priv->settings,
295 if (curr_status != prev_status)
296 account_widget_set_entry_highlighting (entry, !curr_status);
300 account_widget_entry_changed_cb (GtkEditable *entry,
301 EmpathyAccountWidget *self)
303 account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE);
304 empathy_account_widget_changed (self);
308 account_widget_entry_map_cb (GtkEntry *entry,
309 EmpathyAccountWidget *self)
311 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
312 const gchar *param_name;
315 /* need to initialize input highlighting */
316 param_name = g_object_get_data (G_OBJECT (entry), "param_name");
317 is_valid = empathy_account_settings_parameter_is_valid (priv->settings,
319 account_widget_set_entry_highlighting (entry, !is_valid);
323 account_widget_int_changed_cb (GtkWidget *widget,
324 EmpathyAccountWidget *self)
326 const gchar *param_name;
328 const gchar *signature;
329 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
331 value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
332 param_name = g_object_get_data (G_OBJECT (widget), "param_name");
334 signature = empathy_account_settings_get_dbus_signature (priv->settings,
336 g_return_if_fail (signature != NULL);
338 DEBUG ("Setting %s to %d", param_name, value);
340 switch ((int)*signature)
342 case DBUS_TYPE_INT16:
343 case DBUS_TYPE_INT32:
344 empathy_account_settings_set_int32 (priv->settings, param_name, value);
346 case DBUS_TYPE_INT64:
347 empathy_account_settings_set_int64 (priv->settings, param_name, value);
349 case DBUS_TYPE_UINT16:
350 case DBUS_TYPE_UINT32:
351 empathy_account_settings_set_uint32 (priv->settings, param_name, value);
353 case DBUS_TYPE_UINT64:
354 empathy_account_settings_set_uint64 (priv->settings, param_name, value);
357 g_return_if_reached ();
360 empathy_account_widget_changed (self);
364 account_widget_checkbutton_toggled_cb (GtkWidget *widget,
365 EmpathyAccountWidget *self)
368 gboolean default_value;
369 const gchar *param_name;
370 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
372 value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
373 param_name = g_object_get_data (G_OBJECT (widget), "param_name");
375 /* FIXME: This is ugly! checkbox don't have a "not-set" value so we
376 * always unset the param and set the value if different from the
378 empathy_account_settings_unset (priv->settings, param_name);
379 default_value = empathy_account_settings_get_boolean (priv->settings,
382 if (default_value == value)
384 DEBUG ("Unset %s and restore to %d", param_name, default_value);
388 DEBUG ("Setting %s to %d", param_name, value);
389 empathy_account_settings_set_boolean (priv->settings, param_name, value);
392 empathy_account_widget_changed (self);
396 account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl,
397 EmpathyAccountWidget *self)
399 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
403 value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_ssl));
404 port = empathy_account_settings_get_uint32 (priv->settings, "port");
408 if (port == 5222 || port == 0)
413 if (port == 5223 || port == 0)
417 gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spinbutton_port), port);
419 priv->contains_pending_changes = TRUE;
423 account_widget_combobox_changed_cb (GtkWidget *widget,
424 EmpathyAccountWidget *self)
430 const gchar *default_value = NULL;
431 const gchar *param_name;
432 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
434 if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
437 model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
438 /* the param value is stored in the first column */
439 gtk_tree_model_get (model, &iter, 0, &value, -1);
441 param_name = g_object_get_data (G_OBJECT (widget), "param_name");
443 v = empathy_account_settings_get_default (priv->settings, param_name);
445 default_value = g_value_get_string (v);
447 if (!tp_strdiff (value, default_value))
449 DEBUG ("Unset %s and restore to %s", param_name, default_value);
450 empathy_account_settings_unset (priv->settings, param_name);
454 DEBUG ("Setting %s to %s", param_name, value);
455 empathy_account_settings_set_string (priv->settings, param_name, value);
458 empathy_account_widget_changed (self);
462 clear_icon_released_cb (GtkEntry *entry,
463 GtkEntryIconPosition icon_pos,
465 EmpathyAccountWidget *self)
467 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
468 const gchar *param_name;
470 param_name = g_object_get_data (G_OBJECT (entry), "param_name");
472 DEBUG ("Unset %s", param_name);
473 empathy_account_settings_unset (priv->settings, param_name);
474 gtk_entry_set_text (entry, "");
476 empathy_account_widget_changed (self);
480 password_entry_changed_cb (GtkEditable *entry,
481 EmpathyAccountWidget *self)
485 str = gtk_entry_get_text (GTK_ENTRY (entry));
487 gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
488 GTK_ENTRY_ICON_SECONDARY, !EMP_STR_EMPTY (str));
492 password_entry_activated_cb (GtkEntry *entry,
493 EmpathyAccountWidget *self)
495 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
497 if (gtk_widget_get_sensitive (priv->apply_button))
498 account_widget_apply_and_log_in (self);
502 account_entry_activated_cb (GtkEntry *entry,
503 EmpathyAccountWidget *self)
505 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
507 if (gtk_widget_get_sensitive (priv->apply_button))
508 account_widget_apply_and_log_in (self);
512 empathy_account_widget_setup_widget (EmpathyAccountWidget *self,
514 const gchar *param_name)
516 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
518 g_object_set_data_full (G_OBJECT (widget), "param_name",
519 g_strdup (param_name), g_free);
521 if (GTK_IS_SPIN_BUTTON (widget))
524 const gchar *signature;
526 signature = empathy_account_settings_get_dbus_signature (priv->settings,
528 g_return_if_fail (signature != NULL);
530 switch ((int)*signature)
532 case DBUS_TYPE_INT16:
533 case DBUS_TYPE_INT32:
534 value = empathy_account_settings_get_int32 (priv->settings,
537 case DBUS_TYPE_INT64:
538 value = empathy_account_settings_get_int64 (priv->settings,
541 case DBUS_TYPE_UINT16:
542 case DBUS_TYPE_UINT32:
543 value = empathy_account_settings_get_uint32 (priv->settings,
546 case DBUS_TYPE_UINT64:
547 value = empathy_account_settings_get_uint64 (priv->settings,
551 g_return_if_reached ();
554 gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
556 g_signal_connect (widget, "value-changed",
557 G_CALLBACK (account_widget_int_changed_cb),
560 else if (GTK_IS_ENTRY (widget))
562 const gchar *str = NULL;
564 str = empathy_account_settings_get_string (priv->settings, param_name);
565 gtk_entry_set_text (GTK_ENTRY (widget), str ? str : "");
567 if (!tp_strdiff (param_name, "account"))
568 priv->param_account_widget = widget;
569 else if (!tp_strdiff (param_name, "password"))
570 priv->param_password_widget = widget;
572 if (strstr (param_name, "password"))
574 gtk_entry_set_visibility (GTK_ENTRY (widget), FALSE);
576 /* Add 'clear' icon */
577 gtk_entry_set_icon_from_stock (GTK_ENTRY (widget),
578 GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
580 gtk_entry_set_icon_sensitive (GTK_ENTRY (widget),
581 GTK_ENTRY_ICON_SECONDARY, !EMP_STR_EMPTY (str));
583 g_signal_connect (widget, "icon-release",
584 G_CALLBACK (clear_icon_released_cb), self);
585 g_signal_connect (widget, "changed",
586 G_CALLBACK (password_entry_changed_cb), self);
587 g_signal_connect (widget, "activate",
588 G_CALLBACK (password_entry_activated_cb), self);
590 else if (strstr (param_name, "account"))
591 g_signal_connect (widget, "activate",
592 G_CALLBACK (account_entry_activated_cb), self);
595 g_signal_connect (widget, "changed",
596 G_CALLBACK (account_widget_entry_changed_cb), self);
597 g_signal_connect (widget, "map",
598 G_CALLBACK (account_widget_entry_map_cb), self);
600 else if (GTK_IS_TOGGLE_BUTTON (widget))
602 gboolean value = FALSE;
604 value = empathy_account_settings_get_boolean (priv->settings,
606 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
608 g_signal_connect (widget, "toggled",
609 G_CALLBACK (account_widget_checkbutton_toggled_cb),
612 else if (GTK_IS_COMBO_BOX (widget))
614 /* The combo box's model has to contain the param value in its first
615 * column (as a string) */
621 str = empathy_account_settings_get_string (priv->settings, param_name);
622 model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
624 valid = gtk_tree_model_get_iter_first (model, &iter);
629 gtk_tree_model_get (model, &iter, 0, &name, -1);
630 if (!tp_strdiff (name, str))
632 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget), &iter);
637 valid = gtk_tree_model_iter_next (model, &iter);
643 g_signal_connect (widget, "changed",
644 G_CALLBACK (account_widget_combobox_changed_cb),
649 DEBUG ("Unknown type of widget for param %s", param_name);
654 build_translated_params (void)
658 hash = g_hash_table_new (g_str_hash, g_str_equal);
659 g_hash_table_insert (hash, "account", _("Account"));
660 g_hash_table_insert (hash, "password", _("Password"));
661 g_hash_table_insert (hash, "server", _("Server"));
662 g_hash_table_insert (hash, "port", _("Port"));
668 account_widget_generic_format_param_name (const gchar *param_name)
672 static GHashTable *translated_params = NULL;
674 if (G_UNLIKELY (translated_params == NULL))
675 translated_params = build_translated_params ();
677 /* Translate most common parameters */
678 str = g_hash_table_lookup (translated_params, param_name);
680 return g_strdup (str);
682 str = g_strdup (param_name);
684 if (str && g_ascii_isalpha (str[0]))
685 str[0] = g_ascii_toupper (str[0]);
687 while ((p = strchr (str, '-')) != NULL)
689 if (p[1] != '\0' && g_ascii_isalpha (p[1]))
692 p[1] = g_ascii_toupper (p[1]);
702 accounts_widget_generic_setup (EmpathyAccountWidget *self,
703 GtkWidget *table_common_settings,
704 GtkWidget *table_advanced_settings)
706 TpConnectionManagerParam *params, *param;
707 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
709 params = empathy_account_settings_get_tp_params (priv->settings);
711 for (param = params; param != NULL && param->name != NULL; param++)
713 GtkWidget *table_settings;
715 GtkWidget *widget = NULL;
716 gchar *param_name_formatted;
718 if (param->flags & TP_CONN_MGR_PARAM_FLAG_REQUIRED)
719 table_settings = table_common_settings;
720 else if (priv->simple)
723 table_settings = table_advanced_settings;
725 param_name_formatted = account_widget_generic_format_param_name
727 g_object_get (table_settings, "n-rows", &n_rows, NULL);
728 gtk_table_resize (GTK_TABLE (table_settings), ++n_rows, 2);
730 if (param->dbus_signature[0] == 's')
734 str = g_strdup_printf (_("%s:"), param_name_formatted);
735 widget = gtk_label_new (str);
736 gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
739 gtk_table_attach (GTK_TABLE (table_settings),
745 gtk_widget_show (widget);
747 widget = gtk_entry_new ();
748 if (strcmp (param->name, "account") == 0)
750 g_signal_connect (widget, "realize",
751 G_CALLBACK (gtk_widget_grab_focus),
754 gtk_table_attach (GTK_TABLE (table_settings),
758 GTK_FILL | GTK_EXPAND, 0,
760 gtk_widget_show (widget);
762 /* int types: ynqiuxt. double type is 'd' */
763 else if (param->dbus_signature[0] == 'y' ||
764 param->dbus_signature[0] == 'n' ||
765 param->dbus_signature[0] == 'q' ||
766 param->dbus_signature[0] == 'i' ||
767 param->dbus_signature[0] == 'u' ||
768 param->dbus_signature[0] == 'x' ||
769 param->dbus_signature[0] == 't' ||
770 param->dbus_signature[0] == 'd')
777 switch (param->dbus_signature[0])
779 case 'y': minint = G_MININT8; maxint = G_MAXINT8; break;
780 case 'n': minint = G_MININT16; maxint = G_MAXINT16; break;
781 case 'q': minint = 0; maxint = G_MAXUINT16; break;
782 case 'i': minint = G_MININT32; maxint = G_MAXINT32; break;
783 case 'u': minint = 0; maxint = G_MAXUINT32; break;
784 case 'x': minint = G_MININT64; maxint = G_MAXINT64; break;
785 case 't': minint = 0; maxint = G_MAXUINT64; break;
786 case 'd': minint = G_MININT32; maxint = G_MAXINT32;
788 default: g_assert_not_reached ();
791 str = g_strdup_printf (_("%s:"), param_name_formatted);
792 widget = gtk_label_new (str);
793 gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
796 gtk_table_attach (GTK_TABLE (table_settings),
802 gtk_widget_show (widget);
804 widget = gtk_spin_button_new_with_range (minint, maxint, step);
805 gtk_table_attach (GTK_TABLE (table_settings),
809 GTK_FILL | GTK_EXPAND, 0,
811 gtk_widget_show (widget);
813 else if (param->dbus_signature[0] == 'b')
815 widget = gtk_check_button_new_with_label (param_name_formatted);
816 gtk_table_attach (GTK_TABLE (table_settings),
820 GTK_FILL | GTK_EXPAND, 0,
822 gtk_widget_show (widget);
826 DEBUG ("Unknown signature for param %s: %s",
827 param_name_formatted, param->dbus_signature);
831 empathy_account_widget_setup_widget (self, widget, param->name);
833 g_free (param_name_formatted);
838 account_widget_handle_params_valist (EmpathyAccountWidget *self,
839 const gchar *first_widget,
845 for (name = first_widget; name; name = va_arg (args, const gchar *))
847 const gchar *param_name;
849 param_name = va_arg (args, const gchar *);
850 object = gtk_builder_get_object (self->ui_details->gui, name);
854 g_warning ("Builder is missing object '%s'.", name);
858 empathy_account_widget_setup_widget (self, GTK_WIDGET (object),
864 account_widget_cancel_clicked_cb (GtkWidget *button,
865 EmpathyAccountWidget *self)
867 g_signal_emit (self, signals[CANCELLED], 0);
871 account_widget_account_enabled_cb (GObject *source_object,
875 GError *error = NULL;
876 TpAccount *account = TP_ACCOUNT (source_object);
877 EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
878 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
880 tp_account_set_enabled_finish (account, res, &error);
884 DEBUG ("Could not enable the account: %s", error->message);
885 g_error_free (error);
889 empathy_connect_new_account (account, priv->account_manager);
892 /* unref widget - part of the workaround */
893 g_object_unref (widget);
897 account_widget_applied_cb (GObject *source_object,
901 GError *error = NULL;
903 EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source_object);
904 EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
905 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
907 empathy_account_settings_apply_finish (settings, res, &error);
911 DEBUG ("Could not apply changes to account: %s", error->message);
912 g_error_free (error);
916 account = empathy_account_settings_get_account (priv->settings);
920 if (priv->creating_account)
922 /* By default, when an account is created, we enable it. */
924 /* workaround to keep widget alive during async call */
925 g_object_ref (widget);
927 tp_account_set_enabled_async (account, TRUE,
928 account_widget_account_enabled_cb, widget);
929 g_signal_emit (widget, signals[ACCOUNT_CREATED], 0, account);
931 else if (priv->enabled_checkbox != NULL)
933 gboolean enabled_checked;
937 mx_gtk_light_switch_get_active (
938 MX_GTK_LIGHT_SWITCH (priv->enabled_checkbox));
940 gtk_toggle_button_get_active (
941 GTK_TOGGLE_BUTTON (priv->enabled_checkbox));
942 #endif /* HAVE_MEEGO */
944 if (tp_account_is_enabled (account) && enabled_checked)
946 /* After having applied changes to a user account, we
947 * automatically reconnect it. This is done so the new
948 * information entered by the user is validated on the server. */
949 tp_account_reconnect_async (account, NULL, NULL);
954 if (!priv->destroyed)
955 account_widget_set_control_buttons_sensitivity (widget, FALSE);
957 priv->contains_pending_changes = FALSE;
959 /* unref the widget - part of the workaround */
960 g_object_unref (widget);
964 account_widget_apply_and_log_in (EmpathyAccountWidget *self)
966 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
967 gboolean display_name_overridden;
969 if (priv->radiobutton_reuse != NULL)
971 gboolean reuse = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
972 priv->radiobutton_reuse));
974 DEBUG ("Set register param: %d", !reuse);
975 empathy_account_settings_set_boolean (priv->settings, "register", !reuse);
978 g_object_get (priv->settings,
979 "display-name-overridden", &display_name_overridden, NULL);
981 if (priv->creating_account || !display_name_overridden)
985 /* set default display name for new accounts or update if user didn't
986 * manually override it. */
987 display_name = empathy_account_widget_get_default_display_name (self);
989 empathy_account_settings_set_display_name_async (priv->settings,
990 display_name, NULL, NULL);
992 g_free (display_name);
995 /* workaround to keep widget alive during async call */
997 empathy_account_settings_apply_async (priv->settings,
998 account_widget_applied_cb, self);
1002 account_widget_apply_clicked_cb (GtkWidget *button,
1003 EmpathyAccountWidget *self)
1005 account_widget_apply_and_log_in (self);
1009 account_widget_setup_generic (EmpathyAccountWidget *self)
1011 GtkWidget *table_common_settings;
1012 GtkWidget *table_advanced_settings;
1014 table_common_settings = GTK_WIDGET (gtk_builder_get_object
1015 (self->ui_details->gui, "table_common_settings"));
1016 table_advanced_settings = GTK_WIDGET (gtk_builder_get_object
1017 (self->ui_details->gui, "table_advanced_settings"));
1019 accounts_widget_generic_setup (self, table_common_settings,
1020 table_advanced_settings);
1022 g_object_unref (self->ui_details->gui);
1026 account_widget_settings_ready_cb (EmpathyAccountSettings *settings,
1030 EmpathyAccountWidget *self = user_data;
1031 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1033 if (empathy_account_settings_is_ready (priv->settings))
1034 account_widget_setup_generic (self);
1038 account_widget_build_generic (EmpathyAccountWidget *self,
1039 const char *filename)
1041 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1042 GtkWidget *expander_advanced;
1044 self->ui_details->gui = empathy_builder_get_file (filename,
1045 "table_common_settings", &priv->table_common_settings,
1046 "vbox_generic_settings", &self->ui_details->widget,
1047 "expander_advanced_settings", &expander_advanced,
1051 gtk_widget_hide (expander_advanced);
1053 g_object_ref (self->ui_details->gui);
1055 if (empathy_account_settings_is_ready (priv->settings))
1056 account_widget_setup_generic (self);
1058 g_signal_connect (priv->settings, "notify::ready",
1059 G_CALLBACK (account_widget_settings_ready_cb), self);
1063 account_widget_launch_external_clicked (GtkWidget *button,
1066 if (!tp_strdiff (tp_account_get_storage_provider (account),
1067 "com.meego.libsocialweb"))
1069 /* we know how to handle this external provider */
1070 GDesktopAppInfo *app_info;
1071 const gchar *args[3] = { NULL, };
1072 GError *error = NULL;
1074 app_info = g_desktop_app_info_new ("gnome-control-center.desktop");
1076 if (app_info == NULL)
1078 g_critical ("Could not locate 'gnome-control-center.desktop'");
1082 args[0] = g_app_info_get_commandline (G_APP_INFO (app_info));
1083 args[1] = "bisho.desktop";
1086 gdk_spawn_on_screen (gtk_widget_get_screen (button),
1087 NULL, (gchar **) args, NULL,
1088 G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error);
1091 g_critical ("Failed to launch editor: %s", error->message);
1092 g_clear_error (&error);
1095 g_object_unref (app_info);
1100 account_widget_build_external (EmpathyAccountWidget *self,
1101 EmpathyAccountSettings *settings)
1103 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1104 TpAccount *account = empathy_account_settings_get_account (settings);
1105 GtkWidget *bar, *widget;
1108 self->ui_details->widget = gtk_vbox_new (FALSE, 6);
1109 priv->table_common_settings = gtk_table_new (1, 2, FALSE);
1111 if (!tp_strdiff (tp_account_get_storage_provider (account),
1112 "com.meego.libsocialweb"))
1114 /* we know how to handle this external provider */
1115 str = g_strdup_printf (
1116 _("The account %s is edited via My Web Accounts."),
1117 empathy_account_settings_get_display_name (settings));
1121 str = g_strdup_printf (
1122 _("The account %s cannot be edited in Empathy."),
1123 empathy_account_settings_get_display_name (settings));
1126 widget = gtk_label_new (str);
1127 gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
1130 bar = gtk_info_bar_new ();
1131 gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_INFO);
1133 GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))),
1135 gtk_container_set_border_width (GTK_CONTAINER (bar), 6);
1137 if (!tp_strdiff (tp_account_get_storage_provider (account),
1138 "com.meego.libsocialweb"))
1140 /* we know how to handle this external provider */
1141 widget = gtk_info_bar_add_button (GTK_INFO_BAR (bar),
1142 _("Launch My Web Accounts"), RESPONSE_LAUNCH);
1144 g_signal_connect (widget, "clicked",
1145 G_CALLBACK (account_widget_launch_external_clicked), account);
1148 gtk_box_pack_start (GTK_BOX (self->ui_details->widget), bar,
1150 gtk_box_pack_start (GTK_BOX (self->ui_details->widget),
1151 priv->table_common_settings, FALSE, TRUE, 0);
1153 gtk_widget_show_all (self->ui_details->widget);
1157 account_widget_build_salut (EmpathyAccountWidget *self,
1158 const char *filename)
1160 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1161 GtkWidget *expander_advanced;
1163 self->ui_details->gui = empathy_builder_get_file (filename,
1164 "table_common_settings", &priv->table_common_settings,
1165 "vbox_salut_settings", &self->ui_details->widget,
1166 "expander_advanced_settings", &expander_advanced,
1169 empathy_account_widget_handle_params (self,
1170 "entry_published", "published-name",
1171 "entry_nickname", "nickname",
1172 "entry_first_name", "first-name",
1173 "entry_last_name", "last-name",
1174 "entry_email", "email",
1179 gtk_widget_hide (expander_advanced);
1181 self->ui_details->default_focus = g_strdup ("entry_first_name");
1185 account_widget_build_irc (EmpathyAccountWidget *self,
1186 const char *filename)
1188 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1190 empathy_account_settings_set_regex (priv->settings, "account",
1195 priv->irc_network_chooser = empathy_account_widget_irc_build_simple (self,
1200 priv->irc_network_chooser = empathy_account_widget_irc_build (self,
1201 filename, &priv->table_common_settings);
1206 account_widget_build_sip (EmpathyAccountWidget *self,
1207 const char *filename)
1209 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1210 empathy_account_widget_sip_build (self, filename,
1211 &priv->table_common_settings);
1215 account_widget_build_msn (EmpathyAccountWidget *self,
1216 const char *filename)
1218 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1220 empathy_account_settings_set_regex (priv->settings, "account",
1225 self->ui_details->gui = empathy_builder_get_file (filename,
1226 "vbox_msn_simple", &self->ui_details->widget,
1229 empathy_account_widget_handle_params (self,
1230 "entry_id_simple", "account",
1231 "entry_password_simple", "password",
1234 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1238 self->ui_details->gui = empathy_builder_get_file (filename,
1239 "table_common_msn_settings", &priv->table_common_settings,
1240 "vbox_msn_settings", &self->ui_details->widget,
1243 empathy_account_widget_handle_params (self,
1244 "entry_id", "account",
1245 "entry_password", "password",
1246 "entry_server", "server",
1247 "spinbutton_port", "port",
1250 self->ui_details->default_focus = g_strdup ("entry_id");
1255 suffix_id_widget_changed_cb (GtkWidget *entry,
1256 EmpathyAccountWidget *self)
1258 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1259 const gchar *account;
1261 g_assert (priv->jid_suffix != NULL);
1263 account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE);
1265 account = empathy_account_settings_get_string (priv->settings, "account");
1266 if (!EMP_STR_EMPTY (account) &&
1267 !g_str_has_suffix (account, priv->jid_suffix))
1271 tmp = g_strdup_printf ("%s%s", account, priv->jid_suffix);
1273 DEBUG ("Change account from '%s' to '%s'", account, tmp);
1275 empathy_account_settings_set_string (priv->settings, "account", tmp);
1279 empathy_account_widget_changed (self);
1283 remove_jid_suffix (EmpathyAccountWidget *self,
1286 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1288 g_assert (priv->jid_suffix != NULL);
1290 if (!g_str_has_suffix (str, priv->jid_suffix))
1291 return g_strdup (str);
1293 return g_strndup (str, strlen (str) - strlen (priv->jid_suffix));
1297 setup_id_widget_with_suffix (EmpathyAccountWidget *self,
1299 const gchar *suffix)
1301 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1302 const gchar *str = NULL;
1304 g_object_set_data_full (G_OBJECT (widget), "param_name",
1305 g_strdup ("account"), g_free);
1307 g_assert (priv->jid_suffix == NULL);
1308 priv->jid_suffix = g_strdup (suffix);
1310 str = empathy_account_settings_get_string (priv->settings, "account");
1315 tmp = remove_jid_suffix (self, str);
1316 gtk_entry_set_text (GTK_ENTRY (widget), tmp);
1320 priv->param_account_widget = widget;
1322 g_signal_connect (widget, "changed",
1323 G_CALLBACK (suffix_id_widget_changed_cb), self);
1327 account_widget_get_service (EmpathyAccountWidget *self)
1329 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1330 const gchar *icon_name, *service;
1332 icon_name = empathy_account_settings_get_icon_name (priv->settings);
1333 service = empathy_account_settings_get_service (priv->settings);
1335 /* Previous versions of Empathy didn't set the Service property on Facebook
1336 * and gtalk accounts, so we check using the icon name as well. */
1337 if (!tp_strdiff (icon_name, "im-google-talk") ||
1338 !tp_strdiff (service, "google-talk"))
1339 return GTALK_SERVICE;
1341 if (!tp_strdiff (icon_name, "im-facebook") ||
1342 !tp_strdiff (service, "facebook"))
1343 return FACEBOOK_SERVICE;
1345 if (!tp_strdiff (service, "ovi-chat"))
1352 account_widget_build_jabber (EmpathyAccountWidget *self,
1353 const char *filename)
1355 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1356 GtkWidget *spinbutton_port;
1357 GtkWidget *checkbutton_ssl;
1358 GtkWidget *label_id, *label_password;
1359 GtkWidget *label_id_create, *label_password_create;
1360 GtkWidget *label_example_gtalk, *label_example_jabber, *label_example_fb;
1361 GtkWidget *label_example_ovi;
1362 GtkWidget *expander_advanced;
1363 GtkWidget *entry_id;
1366 service = account_widget_get_service (self);
1368 empathy_account_settings_set_regex (priv->settings, "account",
1369 ACCOUNT_REGEX_JABBER);
1371 if (priv->simple && service == NO_SERVICE)
1373 /* Simple widget for XMPP */
1374 self->ui_details->gui = empathy_builder_get_file (filename,
1375 "vbox_jabber_simple", &self->ui_details->widget,
1376 "label_id_simple", &label_id,
1377 "label_id_create", &label_id_create,
1378 "label_password_simple", &label_password,
1379 "label_password_create", &label_password_create,
1382 if (empathy_account_settings_get_boolean (priv->settings, "register"))
1384 gtk_widget_hide (label_id);
1385 gtk_widget_hide (label_password);
1386 gtk_widget_show (label_id_create);
1387 gtk_widget_show (label_password_create);
1390 empathy_account_widget_handle_params (self,
1391 "entry_id_simple", "account",
1392 "entry_password_simple", "password",
1395 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1397 else if (priv->simple && service == GTALK_SERVICE)
1399 /* Simple widget for Google Talk */
1400 self->ui_details->gui = empathy_builder_get_file (filename,
1401 "vbox_gtalk_simple", &self->ui_details->widget,
1404 empathy_account_widget_handle_params (self,
1405 "entry_id_g_simple", "account",
1406 "entry_password_g_simple", "password",
1409 self->ui_details->default_focus = g_strdup ("entry_id_g_simple");
1411 else if (priv->simple && service == FACEBOOK_SERVICE)
1413 /* Simple widget for Facebook */
1414 self->ui_details->gui = empathy_builder_get_file (filename,
1415 "vbox_fb_simple", &self->ui_details->widget,
1416 "entry_id_fb_simple", &entry_id,
1419 empathy_account_widget_handle_params (self,
1420 "entry_password_fb_simple", "password",
1423 setup_id_widget_with_suffix (self, entry_id, "@chat.facebook.com");
1425 self->ui_details->default_focus = g_strdup ("entry_id_fb_simple");
1427 else if (priv->simple && service == OVI_SERVICE)
1429 /* Simple widget for Ovi */
1430 self->ui_details->gui = empathy_builder_get_file (filename,
1431 "vbox_ovi_simple", &self->ui_details->widget,
1432 "entry_id_ovi_simple", &entry_id,
1435 empathy_account_widget_handle_params (self,
1436 "entry_password_ovi_simple", "password",
1439 setup_id_widget_with_suffix (self, entry_id, "@ovi.com");
1441 self->ui_details->default_focus = g_strdup ("entry_id_ovi_simple");
1445 /* Full widget for XMPP, Google Talk and Facebook*/
1446 self->ui_details->gui = empathy_builder_get_file (filename,
1447 "table_common_settings", &priv->table_common_settings,
1448 "vbox_jabber_settings", &self->ui_details->widget,
1449 "spinbutton_port", &spinbutton_port,
1450 "checkbutton_ssl", &checkbutton_ssl,
1451 "label_username_example", &label_example_jabber,
1452 "label_username_g_example", &label_example_gtalk,
1453 "label_username_f_example", &label_example_fb,
1454 "label_username_ovi_example", &label_example_ovi,
1455 "expander_advanced", &expander_advanced,
1456 "entry_id", &entry_id,
1457 "label_id", &label_id,
1460 empathy_account_widget_handle_params (self,
1461 "entry_password", "password",
1462 "entry_resource", "resource",
1463 "entry_server", "server",
1464 "spinbutton_port", "port",
1465 "spinbutton_priority", "priority",
1466 "checkbutton_ssl", "old-ssl",
1467 "checkbutton_ignore_ssl_errors", "ignore-ssl-errors",
1468 "checkbutton_encryption", "require-encryption",
1471 if (service == FACEBOOK_SERVICE)
1473 gtk_label_set_label (GTK_LABEL (label_id), _("Username:"));
1475 /* Facebook special case the entry ID widget to hide the
1476 * "@chat.facebook.com" part */
1477 setup_id_widget_with_suffix (self, entry_id, "@chat.facebook.com");
1479 else if (service == OVI_SERVICE)
1481 gtk_label_set_label (GTK_LABEL (label_id), _("Username:"));
1483 setup_id_widget_with_suffix (self, entry_id, "@ovi.com");
1487 empathy_account_widget_setup_widget (self, entry_id, "account");
1490 self->ui_details->default_focus = g_strdup ("entry_id");
1491 priv->spinbutton_port = spinbutton_port;
1493 g_signal_connect (checkbutton_ssl, "toggled",
1494 G_CALLBACK (account_widget_jabber_ssl_toggled_cb),
1497 if (service == GTALK_SERVICE)
1499 gtk_widget_show (label_example_gtalk);
1501 else if (service == FACEBOOK_SERVICE)
1503 GtkContainer *parent;
1506 /* Removing the label from list of focusable widgets */
1507 parent = GTK_CONTAINER (gtk_widget_get_parent (label_example_fb));
1508 children = gtk_container_get_children (parent);
1509 children = g_list_remove (children, label_example_fb);
1510 gtk_container_set_focus_chain (parent, children);
1511 g_list_free (children);
1513 gtk_widget_hide (expander_advanced);
1515 else if (service == OVI_SERVICE)
1517 gtk_widget_show (label_example_ovi);
1518 gtk_widget_hide (expander_advanced);
1522 gtk_widget_show (label_example_jabber);
1528 account_widget_build_icq (EmpathyAccountWidget *self,
1529 const char *filename)
1531 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1532 GtkWidget *spinbutton_port;
1534 empathy_account_settings_set_regex (priv->settings, "account",
1539 self->ui_details->gui = empathy_builder_get_file (filename,
1540 "vbox_icq_simple", &self->ui_details->widget,
1543 empathy_account_widget_handle_params (self,
1544 "entry_uin_simple", "account",
1545 "entry_password_simple", "password",
1548 self->ui_details->default_focus = g_strdup ("entry_uin_simple");
1552 self->ui_details->gui = empathy_builder_get_file (filename,
1553 "table_common_settings", &priv->table_common_settings,
1554 "vbox_icq_settings", &self->ui_details->widget,
1555 "spinbutton_port", &spinbutton_port,
1558 empathy_account_widget_handle_params (self,
1559 "entry_uin", "account",
1560 "entry_password", "password",
1561 "entry_server", "server",
1562 "spinbutton_port", "port",
1563 "entry_charset", "charset",
1566 self->ui_details->default_focus = g_strdup ("entry_uin");
1571 account_widget_build_aim (EmpathyAccountWidget *self,
1572 const char *filename)
1574 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1575 GtkWidget *spinbutton_port;
1579 self->ui_details->gui = empathy_builder_get_file (filename,
1580 "vbox_aim_simple", &self->ui_details->widget,
1583 empathy_account_widget_handle_params (self,
1584 "entry_screenname_simple", "account",
1585 "entry_password_simple", "password",
1588 self->ui_details->default_focus = g_strdup ("entry_screenname_simple");
1592 self->ui_details->gui = empathy_builder_get_file (filename,
1593 "table_common_settings", &priv->table_common_settings,
1594 "vbox_aim_settings", &self->ui_details->widget,
1595 "spinbutton_port", &spinbutton_port,
1598 empathy_account_widget_handle_params (self,
1599 "entry_screenname", "account",
1600 "entry_password", "password",
1601 "entry_server", "server",
1602 "spinbutton_port", "port",
1605 self->ui_details->default_focus = g_strdup ("entry_screenname");
1610 account_widget_build_yahoo (EmpathyAccountWidget *self,
1611 const char *filename)
1613 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1615 empathy_account_settings_set_regex (priv->settings, "account",
1616 ACCOUNT_REGEX_YAHOO);
1620 self->ui_details->gui = empathy_builder_get_file (filename,
1621 "vbox_yahoo_simple", &self->ui_details->widget,
1624 empathy_account_widget_handle_params (self,
1625 "entry_id_simple", "account",
1626 "entry_password_simple", "password",
1629 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1633 self->ui_details->gui = empathy_builder_get_file (filename,
1634 "table_common_settings", &priv->table_common_settings,
1635 "vbox_yahoo_settings", &self->ui_details->widget,
1638 empathy_account_widget_handle_params (self,
1639 "entry_id", "account",
1640 "entry_password", "password",
1641 "entry_server", "server",
1642 "entry_locale", "room-list-locale",
1643 "entry_charset", "charset",
1644 "spinbutton_port", "port",
1645 "checkbutton_ignore_invites", "ignore-invites",
1648 self->ui_details->default_focus = g_strdup ("entry_id");
1653 account_widget_build_groupwise (EmpathyAccountWidget *self,
1654 const char *filename)
1656 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1660 self->ui_details->gui = empathy_builder_get_file (filename,
1661 "vbox_groupwise_simple", &self->ui_details->widget,
1664 empathy_account_widget_handle_params (self,
1665 "entry_id_simple", "account",
1666 "entry_password_simple", "password",
1669 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1673 self->ui_details->gui = empathy_builder_get_file (filename,
1674 "table_common_groupwise_settings", &priv->table_common_settings,
1675 "vbox_groupwise_settings", &self->ui_details->widget,
1678 empathy_account_widget_handle_params (self,
1679 "entry_id", "account",
1680 "entry_password", "password",
1681 "entry_server", "server",
1682 "spinbutton_port", "port",
1685 self->ui_details->default_focus = g_strdup ("entry_id");
1690 account_widget_destroy_cb (GtkWidget *widget,
1691 EmpathyAccountWidget *self)
1693 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1694 /* set the destroyed flag - workaround */
1695 priv->destroyed = TRUE;
1697 g_object_unref (self);
1701 empathy_account_widget_enabled_cb (TpAccount *account,
1705 EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
1706 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
1707 gboolean enabled = tp_account_is_enabled (account);
1709 if (priv->enabled_checkbox != NULL)
1712 mx_gtk_light_switch_set_active (
1713 MX_GTK_LIGHT_SWITCH (priv->enabled_checkbox),
1716 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->enabled_checkbox),
1718 #endif /* HAVE_MEEGO */
1724 account_widget_switch_flipped_cb (MxGtkLightSwitch *sw,
1728 account_widget_enabled_toggled_cb (GtkToggleButton *toggle_button,
1730 #endif /* HAVE_MEEGO */
1732 EmpathyAccountWidgetPriv *priv = GET_PRIV (user_data);
1737 state = gtk_toggle_button_get_active (toggle_button);
1738 #endif /* HAVE_MEEGO */
1740 account = empathy_account_settings_get_account (priv->settings);
1742 /* Enable the account according to the value of the "Enabled" checkbox */
1743 /* workaround to keep widget alive during async call */
1744 g_object_ref (user_data);
1745 tp_account_set_enabled_async (account, state,
1746 account_widget_account_enabled_cb, user_data);
1750 empathy_account_widget_set_other_accounts_exist (EmpathyAccountWidget *self,
1751 gboolean others_exist)
1753 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1755 priv->other_accounts_exist = others_exist;
1757 if (priv->creating_account)
1758 account_widget_handle_control_buttons_sensitivity (self);
1762 do_set_property (GObject *object,
1764 const GValue *value,
1767 EmpathyAccountWidgetPriv *priv = GET_PRIV (object);
1772 priv->settings = g_value_dup_object (value);
1775 priv->simple = g_value_get_boolean (value);
1777 case PROP_CREATING_ACCOUNT:
1778 priv->creating_account = g_value_get_boolean (value);
1780 case PROP_OTHER_ACCOUNTS_EXIST:
1781 empathy_account_widget_set_other_accounts_exist (
1782 EMPATHY_ACCOUNT_WIDGET (object), g_value_get_boolean (value));
1785 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1790 do_get_property (GObject *object,
1795 EmpathyAccountWidgetPriv *priv = GET_PRIV (object);
1800 g_value_set_string (value,
1801 empathy_account_settings_get_protocol (priv->settings));
1804 g_value_set_object (value, priv->settings);
1807 g_value_set_boolean (value, priv->simple);
1809 case PROP_CREATING_ACCOUNT:
1810 g_value_set_boolean (value, priv->creating_account);
1812 case PROP_OTHER_ACCOUNTS_EXIST:
1813 g_value_set_boolean (value, priv->other_accounts_exist);
1816 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1821 set_apply_button (EmpathyAccountWidget *self)
1823 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1826 /* We can't use the stock button as its accelerator ('A') clashes with the
1828 gtk_button_set_use_stock (GTK_BUTTON (priv->apply_button), FALSE);
1830 gtk_button_set_label (GTK_BUTTON (priv->apply_button), _("A_pply"));
1831 gtk_button_set_use_underline (GTK_BUTTON (priv->apply_button), TRUE);
1833 image = gtk_image_new_from_stock (GTK_STOCK_APPLY, GTK_ICON_SIZE_BUTTON);
1834 gtk_button_set_image (GTK_BUTTON (priv->apply_button), image);
1838 presence_changed_cb (TpAccountManager *manager,
1839 TpConnectionPresenceType state,
1840 const gchar *status,
1841 const gchar *message,
1842 EmpathyAccountWidget *self)
1844 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1846 if (priv->destroyed)
1849 if (priv->apply_button == NULL)
1850 /* This button doesn't exist in 'simple' mode */
1853 if (state > TP_CONNECTION_PRESENCE_TYPE_OFFLINE &&
1854 priv->creating_account)
1856 /* We are online and creating a new account, display a Login button */
1859 gtk_button_set_use_stock (GTK_BUTTON (priv->apply_button), FALSE);
1860 gtk_button_set_label (GTK_BUTTON (priv->apply_button), _("L_og in"));
1862 image = gtk_image_new_from_stock (GTK_STOCK_CONNECT,
1863 GTK_ICON_SIZE_BUTTON);
1864 gtk_button_set_image (GTK_BUTTON (priv->apply_button), image);
1868 /* We are offline or modifying an existing account, display
1870 set_apply_button (self);
1875 account_manager_ready_cb (GObject *source_object,
1876 GAsyncResult *result,
1879 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (user_data);
1880 TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
1881 GError *error = NULL;
1882 TpConnectionPresenceType state;
1884 if (!tp_account_manager_prepare_finish (account_manager, result, &error))
1886 DEBUG ("Failed to prepare account manager: %s", error->message);
1887 g_error_free (error);
1891 state = tp_account_manager_get_most_available_presence (account_manager, NULL,
1894 /* simulate a presence change so the apply button will be changed
1896 presence_changed_cb (account_manager, state, NULL, NULL, self);
1899 g_object_unref (self);
1902 #define WIDGET(cm, proto) \
1903 { #cm, #proto, "empathy-account-widget-"#proto".ui", \
1904 account_widget_build_##proto }
1907 add_enable_checkbox (EmpathyAccountWidget *self,
1910 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1914 GtkWidget *vbox = self->ui_details->widget;
1915 #endif /* HAVE_MEEGO */
1916 guint nb_rows, nb_columns;
1917 gboolean is_enabled;
1919 /* handle the "Enabled" checkbox. We only add it when modifying an account */
1920 if (priv->creating_account || priv->table_common_settings == NULL)
1923 is_enabled = tp_account_is_enabled (account);
1926 w = gtk_label_new (_("Account:"));
1927 gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
1929 priv->enabled_checkbox = mx_gtk_light_switch_new ();
1931 mx_gtk_light_switch_set_active (
1932 MX_GTK_LIGHT_SWITCH (priv->enabled_checkbox), is_enabled);
1934 gtk_widget_show (w);
1936 priv->enabled_checkbox =
1937 gtk_check_button_new_with_mnemonic (_("_Enabled"));
1939 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->enabled_checkbox),
1941 #endif /* HAVE_MEEGO */
1943 g_object_get (priv->table_common_settings, "n-rows", &nb_rows,
1944 "n-columns", &nb_columns, NULL);
1946 gtk_table_resize (GTK_TABLE (priv->table_common_settings), ++nb_rows,
1950 gtk_table_attach (GTK_TABLE (priv->table_common_settings),
1952 0, 1, nb_rows - 1, nb_rows,
1954 gtk_table_attach (GTK_TABLE (priv->table_common_settings),
1955 priv->enabled_checkbox,
1956 1, nb_columns, nb_rows - 1, nb_rows,
1957 GTK_EXPAND | GTK_FILL, 0, 0, 0);
1959 gtk_box_pack_start (GTK_BOX (vbox), priv->enabled_checkbox, FALSE, FALSE, 0);
1960 gtk_box_reorder_child (GTK_BOX (vbox), priv->enabled_checkbox, 0);
1961 #endif /* HAVE_MEEGO */
1963 gtk_widget_show (priv->enabled_checkbox);
1966 g_signal_connect (G_OBJECT (priv->enabled_checkbox), "switch-flipped",
1967 G_CALLBACK (account_widget_switch_flipped_cb), self);
1969 g_signal_connect (G_OBJECT (priv->enabled_checkbox), "toggled",
1970 G_CALLBACK (account_widget_enabled_toggled_cb), self);
1971 #endif /* HAVE_MEEGO */
1975 /* Meego doesn't support registration */
1977 add_register_buttons (EmpathyAccountWidget *self,
1980 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1981 const TpConnectionManagerProtocol *protocol;
1982 GtkWidget *radiobutton_register;
1983 GtkWidget *vbox = self->ui_details->widget;
1985 if (!priv->creating_account)
1988 protocol = empathy_account_settings_get_tp_protocol (priv->settings);
1989 if (protocol == NULL)
1992 if (!tp_connection_manager_protocol_can_register (protocol))
1995 if (account_widget_get_service (self) != NO_SERVICE)
2001 priv->radiobutton_reuse = gtk_radio_button_new_with_label (NULL,
2002 _("This account already exists on the server"));
2003 radiobutton_register = gtk_radio_button_new_with_label (
2004 gtk_radio_button_get_group (GTK_RADIO_BUTTON (priv->radiobutton_reuse)),
2005 _("Create a new account on the server"));
2007 gtk_box_pack_start (GTK_BOX (vbox), priv->radiobutton_reuse, FALSE, FALSE, 0);
2008 gtk_box_pack_start (GTK_BOX (vbox), radiobutton_register, FALSE, FALSE, 0);
2009 gtk_box_reorder_child (GTK_BOX (vbox), priv->radiobutton_reuse, 0);
2010 gtk_box_reorder_child (GTK_BOX (vbox), radiobutton_register, 1);
2011 gtk_widget_show (priv->radiobutton_reuse);
2012 gtk_widget_show (radiobutton_register);
2014 #endif /* HAVE_MEEGO */
2017 do_constructed (GObject *obj)
2019 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
2020 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2022 TpStorageRestrictionFlags storage_restrictions;
2023 const gchar *display_name, *default_display_name;
2026 const gchar *cm_name;
2027 const gchar *protocol;
2029 void (*func)(EmpathyAccountWidget *self, const gchar *filename);
2031 { "salut", "local-xmpp", "empathy-account-widget-local-xmpp.ui",
2032 account_widget_build_salut },
2033 WIDGET (gabble, jabber),
2034 WIDGET (butterfly, msn),
2037 WIDGET (haze, yahoo),
2038 WIDGET (haze, groupwise),
2040 WIDGET (sofiasip, sip),
2043 account = empathy_account_settings_get_account (priv->settings);
2045 if (account != NULL)
2046 storage_restrictions = tp_account_get_storage_restrictions (account);
2048 storage_restrictions = 0;
2050 /* Empathy can only edit accounts without the Cannot_Set_Parameters flag */
2051 if (storage_restrictions & TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS)
2053 DEBUG ("Account is provided by an external storage provider");
2055 account_widget_build_external (self, priv->settings);
2059 const gchar *protocol, *cm_name;
2061 cm_name = empathy_account_settings_get_cm (priv->settings);
2062 protocol = empathy_account_settings_get_protocol (priv->settings);
2064 for (i = 0 ; i < G_N_ELEMENTS (widgets); i++)
2066 if (!tp_strdiff (widgets[i].cm_name, cm_name) &&
2067 !tp_strdiff (widgets[i].protocol, protocol))
2071 filename = empathy_file_lookup (widgets[i].file,
2073 widgets[i].func (self, filename);
2080 if (i == G_N_ELEMENTS (widgets))
2082 gchar *filename = empathy_file_lookup (
2083 "empathy-account-widget-generic.ui", "libempathy-gtk");
2084 account_widget_build_generic (self, filename);
2089 /* handle default focus */
2090 if (self->ui_details->default_focus != NULL)
2092 GObject *default_focus_entry;
2094 default_focus_entry = gtk_builder_get_object
2095 (self->ui_details->gui, self->ui_details->default_focus);
2096 g_signal_connect (default_focus_entry, "realize",
2097 G_CALLBACK (gtk_widget_grab_focus),
2101 /* dup and init the account-manager */
2102 priv->account_manager = tp_account_manager_dup ();
2104 g_object_ref (self);
2105 tp_account_manager_prepare_async (priv->account_manager, NULL,
2106 account_manager_ready_cb, self);
2108 /* handle apply and cancel button */
2109 if (!priv->simple &&
2110 !(storage_restrictions &
2111 TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS))
2113 GtkWidget *hbox = gtk_hbox_new (TRUE, 3);
2116 /* We can't use the stock button as its accelerator ('C') clashes with
2117 * the Close button. */
2118 priv->cancel_button = gtk_button_new ();
2119 gtk_button_set_label (GTK_BUTTON (priv->cancel_button), _("Ca_ncel"));
2120 gtk_button_set_use_underline (GTK_BUTTON (priv->cancel_button), TRUE);
2122 image = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON);
2123 gtk_button_set_image (GTK_BUTTON (priv->cancel_button), image);
2125 priv->apply_button = gtk_button_new ();
2126 set_apply_button (self);
2128 /* We'll change this button to a "Log in" one if we are creating a new
2129 * account and are connected. */
2130 tp_g_signal_connect_object (priv->account_manager,
2131 "most-available-presence-changed",
2132 G_CALLBACK (presence_changed_cb), obj, 0);
2134 gtk_box_pack_end (GTK_BOX (hbox), priv->apply_button, TRUE,
2136 gtk_box_pack_end (GTK_BOX (hbox), priv->cancel_button, TRUE,
2139 gtk_box_pack_end (GTK_BOX (self->ui_details->widget), hbox, FALSE,
2142 g_signal_connect (priv->cancel_button, "clicked",
2143 G_CALLBACK (account_widget_cancel_clicked_cb),
2145 g_signal_connect (priv->apply_button, "clicked",
2146 G_CALLBACK (account_widget_apply_clicked_cb),
2148 gtk_widget_show_all (hbox);
2150 if (priv->creating_account)
2151 /* When creating an account, the user might have nothing to enter.
2152 * That means that no control interaction might occur,
2153 * so we update the control button sensitivity manually.
2155 account_widget_handle_control_buttons_sensitivity (self);
2157 account_widget_set_control_buttons_sensitivity (self, FALSE);
2160 if (account != NULL)
2162 g_signal_connect (account, "notify::enabled",
2163 G_CALLBACK (empathy_account_widget_enabled_cb), self);
2167 add_register_buttons (self, account);
2168 #endif /* HAVE_MEEGO */
2170 /* add the Enable checkbox to accounts that support it */
2171 if (!(storage_restrictions & TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_ENABLED))
2172 add_enable_checkbox (self, account);
2174 /* hook up to widget destruction to unref ourselves */
2175 g_signal_connect (self->ui_details->widget, "destroy",
2176 G_CALLBACK (account_widget_destroy_cb), self);
2178 if (self->ui_details->gui != NULL)
2180 empathy_builder_unref_and_keep_widget (self->ui_details->gui,
2181 self->ui_details->widget);
2182 self->ui_details->gui = NULL;
2185 display_name = empathy_account_settings_get_display_name (priv->settings);
2186 default_display_name = empathy_account_widget_get_default_display_name (self);
2188 if (tp_strdiff (display_name, default_display_name) &&
2189 !priv->creating_account)
2191 /* The display name of the account is not the one that we'd assign by
2192 * default; assume that the user changed it manually */
2193 g_object_set (priv->settings, "display-name-overridden", TRUE, NULL);
2198 do_dispose (GObject *obj)
2200 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
2201 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2203 if (priv->dispose_run)
2206 priv->dispose_run = TRUE;
2208 if (priv->settings != NULL)
2211 account = empathy_account_settings_get_account (priv->settings);
2213 if (account != NULL)
2215 g_signal_handlers_disconnect_by_func (account,
2216 empathy_account_widget_enabled_cb, self);
2219 g_object_unref (priv->settings);
2220 priv->settings = NULL;
2223 if (priv->account_manager != NULL)
2225 g_object_unref (priv->account_manager);
2226 priv->account_manager = NULL;
2229 if (G_OBJECT_CLASS (empathy_account_widget_parent_class)->dispose != NULL)
2230 G_OBJECT_CLASS (empathy_account_widget_parent_class)->dispose (obj);
2234 do_finalize (GObject *obj)
2236 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
2237 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2239 g_free (self->ui_details->default_focus);
2240 g_slice_free (EmpathyAccountWidgetUIDetails, self->ui_details);
2242 g_free (priv->jid_suffix);
2244 if (G_OBJECT_CLASS (empathy_account_widget_parent_class)->finalize != NULL)
2245 G_OBJECT_CLASS (empathy_account_widget_parent_class)->finalize (obj);
2249 empathy_account_widget_class_init (EmpathyAccountWidgetClass *klass)
2251 GObjectClass *oclass = G_OBJECT_CLASS (klass);
2252 GParamSpec *param_spec;
2254 oclass->get_property = do_get_property;
2255 oclass->set_property = do_set_property;
2256 oclass->constructed = do_constructed;
2257 oclass->dispose = do_dispose;
2258 oclass->finalize = do_finalize;
2260 param_spec = g_param_spec_string ("protocol",
2261 "protocol", "The protocol of the account",
2263 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
2264 g_object_class_install_property (oclass, PROP_PROTOCOL, param_spec);
2266 param_spec = g_param_spec_object ("settings",
2267 "settings", "The settings of the account",
2268 EMPATHY_TYPE_ACCOUNT_SETTINGS,
2269 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
2270 g_object_class_install_property (oclass, PROP_SETTINGS, param_spec);
2272 param_spec = g_param_spec_boolean ("simple",
2273 "simple", "Whether the account widget is a simple or an advanced one",
2275 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
2276 g_object_class_install_property (oclass, PROP_SIMPLE, param_spec);
2278 param_spec = g_param_spec_boolean ("creating-account",
2280 "TRUE if we're creating an account, FALSE if we're modifying it",
2282 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
2283 g_object_class_install_property (oclass, PROP_CREATING_ACCOUNT, param_spec);
2285 param_spec = g_param_spec_boolean ("other-accounts-exist",
2286 "other-accounts-exist",
2287 "TRUE if there are any other accounts (even if this isn't yet saved)",
2289 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
2290 g_object_class_install_property (oclass, PROP_OTHER_ACCOUNTS_EXIST,
2293 signals[HANDLE_APPLY] =
2294 g_signal_new ("handle-apply", G_TYPE_FROM_CLASS (klass),
2295 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
2296 g_cclosure_marshal_VOID__BOOLEAN,
2300 /* This signal is emitted when an account has been created and enabled. */
2301 signals[ACCOUNT_CREATED] =
2302 g_signal_new ("account-created", G_TYPE_FROM_CLASS (klass),
2303 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
2304 g_cclosure_marshal_VOID__OBJECT,
2308 signals[CANCELLED] =
2309 g_signal_new ("cancelled", G_TYPE_FROM_CLASS (klass),
2310 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
2311 g_cclosure_marshal_VOID__VOID,
2315 g_type_class_add_private (klass, sizeof (EmpathyAccountWidgetPriv));
2319 empathy_account_widget_init (EmpathyAccountWidget *self)
2321 EmpathyAccountWidgetPriv *priv =
2322 G_TYPE_INSTANCE_GET_PRIVATE ((self), EMPATHY_TYPE_ACCOUNT_WIDGET,
2323 EmpathyAccountWidgetPriv);
2326 priv->dispose_run = FALSE;
2328 self->ui_details = g_slice_new0 (EmpathyAccountWidgetUIDetails);
2331 /* public methods */
2334 empathy_account_widget_discard_pending_changes
2335 (EmpathyAccountWidget *widget)
2337 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
2339 empathy_account_settings_discard_changes (priv->settings);
2340 priv->contains_pending_changes = FALSE;
2344 empathy_account_widget_contains_pending_changes (EmpathyAccountWidget *widget)
2346 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
2348 return priv->contains_pending_changes;
2352 empathy_account_widget_handle_params (EmpathyAccountWidget *self,
2353 const gchar *first_widget,
2358 va_start (args, first_widget);
2359 account_widget_handle_params_valist (self, first_widget, args);
2364 empathy_account_widget_get_widget (EmpathyAccountWidget *widget)
2366 return widget->ui_details->widget;
2369 EmpathyAccountWidget *
2370 empathy_account_widget_new_for_protocol (EmpathyAccountSettings *settings,
2373 EmpathyAccountWidget *self;
2375 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_SETTINGS (settings), NULL);
2378 (EMPATHY_TYPE_ACCOUNT_WIDGET,
2379 "settings", settings, "simple", simple,
2381 empathy_account_settings_get_account (settings) == NULL,
2388 empathy_account_widget_get_default_display_name (EmpathyAccountWidget *self)
2390 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2391 const gchar *login_id;
2392 const gchar *protocol, *p;
2393 gchar *default_display_name;
2396 login_id = empathy_account_settings_get_string (priv->settings, "account");
2397 protocol = empathy_account_settings_get_protocol (priv->settings);
2398 service = account_widget_get_service (self);
2400 if (login_id != NULL)
2402 /* TODO: this should be done in empathy-account-widget-irc */
2403 if (!tp_strdiff (protocol, "irc"))
2405 EmpathyIrcNetwork *network;
2407 network = empathy_irc_network_chooser_get_network (
2408 priv->irc_network_chooser);
2409 g_assert (network != NULL);
2411 /* To translators: The first parameter is the login id and the
2412 * second one is the network. The resulting string will be something
2413 * like: "MyUserName on freenode".
2414 * You should reverse the order of these arguments if the
2415 * server should come before the login id in your locale.*/
2416 default_display_name = g_strdup_printf (_("%1$s on %2$s"),
2417 login_id, empathy_irc_network_get_name (network));
2419 else if (service == FACEBOOK_SERVICE)
2423 tmp = remove_jid_suffix (self, login_id);
2424 default_display_name = g_strdup_printf ("Facebook (%s)", tmp);
2427 else if (service == OVI_SERVICE)
2431 tmp = remove_jid_suffix (self, login_id);
2432 default_display_name = g_strdup_printf ("Ovi (%s)", tmp);
2437 default_display_name = g_strdup (login_id);
2440 return default_display_name;
2443 if ((p = empathy_protocol_name_to_display_name (protocol)) != NULL)
2446 if (protocol != NULL)
2448 /* To translators: The parameter is the protocol name. The resulting
2449 * string will be something like: "Jabber Account" */
2450 default_display_name = g_strdup_printf (_("%s Account"), protocol);
2454 default_display_name = g_strdup (_("New account"));
2457 return default_display_name;
2460 /* Used by subclass to indicate that widget contains pending changes */
2462 empathy_account_widget_changed (EmpathyAccountWidget *self)
2464 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2466 account_widget_handle_control_buttons_sensitivity (self);
2467 priv->contains_pending_changes = TRUE;
2471 empathy_account_widget_set_account_param (EmpathyAccountWidget *self,
2472 const gchar *account)
2474 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2476 if (priv->param_account_widget == NULL)
2479 gtk_entry_set_text (GTK_ENTRY (priv->param_account_widget), account);
2483 empathy_account_widget_set_password_param (EmpathyAccountWidget *self,
2484 const gchar *account)
2486 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2488 if (priv->param_password_widget == NULL)
2491 gtk_entry_set_text (GTK_ENTRY (priv->param_password_widget), account);