aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-02-11 23:17:03 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-02-12 00:01:38 +0800
commit79718737e209ee469d5b0ea9b7cabf5e6d5adb87 (patch)
treeb25c6f81cd27733295471a4e3f7ec7134effda6e /libempathy-gtk
parent438199f57bc03b42aae12a18888c73597b04c1ec (diff)
downloadgsoc2013-empathy-79718737e209ee469d5b0ea9b7cabf5e6d5adb87.tar
gsoc2013-empathy-79718737e209ee469d5b0ea9b7cabf5e6d5adb87.tar.gz
gsoc2013-empathy-79718737e209ee469d5b0ea9b7cabf5e6d5adb87.tar.bz2
gsoc2013-empathy-79718737e209ee469d5b0ea9b7cabf5e6d5adb87.tar.lz
gsoc2013-empathy-79718737e209ee469d5b0ea9b7cabf5e6d5adb87.tar.xz
gsoc2013-empathy-79718737e209ee469d5b0ea9b7cabf5e6d5adb87.tar.zst
gsoc2013-empathy-79718737e209ee469d5b0ea9b7cabf5e6d5adb87.zip
add the '@chat.facebook.com' suffix to account but dont't display it in the widget
Fixes bug #573194
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-account-widget.c77
1 files changed, 76 insertions, 1 deletions
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 39a3741ed..489a04c00 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -949,6 +949,69 @@ account_widget_is_facebook (EmpathyAccountWidget *self)
"im-facebook");
}
+#define FACEBOOK_SUFFIX "@chat.facebook.com"
+
+static void
+facebook_id_widget_changed_cb (GtkWidget *entry,
+ EmpathyAccountWidget *self)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ const gchar *account;
+
+ account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE);
+
+ account = empathy_account_settings_get_string (priv->settings, "account");
+ if (!EMP_STR_EMPTY (account) &&
+ !g_str_has_suffix (account, FACEBOOK_SUFFIX))
+ {
+ gchar *tmp;
+
+ tmp = g_strdup_printf ("%s%s", account, FACEBOOK_SUFFIX);
+
+ DEBUG ("Change account from '%s' to '%s'", account, tmp);
+
+ empathy_account_settings_set_string (priv->settings, "account", tmp);
+ g_free (tmp);
+ }
+
+ empathy_account_widget_changed (self);
+}
+
+static gchar *
+remove_facebook_suffix (const gchar *str)
+{
+ if (!g_str_has_suffix (str, FACEBOOK_SUFFIX))
+ return g_strdup (str);
+
+ return g_strndup (str, strlen (str) - strlen (FACEBOOK_SUFFIX));
+}
+
+static void
+setup_facebook_id_widget (EmpathyAccountWidget *self,
+ GtkWidget *widget)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ const gchar *str = NULL;
+
+ g_object_set_data_full (G_OBJECT (widget), "param_name",
+ g_strdup ("account"), g_free);
+
+ str = empathy_account_settings_get_string (priv->settings, "account");
+ if (str != NULL)
+ {
+ gchar *tmp;
+
+ tmp = remove_facebook_suffix (str);
+ gtk_entry_set_text (GTK_ENTRY (widget), tmp);
+ g_free (tmp);
+ }
+
+ priv->param_account_widget = widget;
+
+ g_signal_connect (widget, "changed",
+ G_CALLBACK (facebook_id_widget_changed_cb), self);
+}
+
static void
account_widget_build_jabber (EmpathyAccountWidget *self,
const char *filename)
@@ -961,6 +1024,7 @@ account_widget_build_jabber (EmpathyAccountWidget *self,
GtkWidget *label_example_gtalk, *label_example_jabber, *label_example_fb;
gboolean is_gtalk, is_facebook;
GtkWidget *expander_advanced;
+ GtkWidget *entry_id;
is_gtalk = account_widget_is_gtalk (self);
is_facebook = account_widget_is_facebook (self);
@@ -1018,10 +1082,10 @@ account_widget_build_jabber (EmpathyAccountWidget *self,
"label_username_g_example", &label_example_gtalk,
"label_username_f_example", &label_example_fb,
"expander_advanced", &expander_advanced,
+ "entry_id", &entry_id,
NULL);
empathy_account_widget_handle_params (self,
- "entry_id", "account",
"entry_password", "password",
"entry_resource", "resource",
"entry_server", "server",
@@ -1032,6 +1096,17 @@ account_widget_build_jabber (EmpathyAccountWidget *self,
"checkbutton_encryption", "require-encryption",
NULL);
+ if (is_facebook)
+ {
+ /* Facebook special case the entry ID widget to hide the
+ * "@chat.facebook.com" part */
+ setup_facebook_id_widget (self, entry_id);
+ }
+ else
+ {
+ empathy_account_widget_setup_widget (self, entry_id, "account");
+ }
+
self->ui_details->default_focus = g_strdup ("entry_id");
self->ui_details->add_forget = TRUE;
priv->spinbutton_port = spinbutton_port;