aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-account-widget.c
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-08-27 23:56:42 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-08-28 23:57:46 +0800
commit91c325aabdb286f44729cb5ee7f69afd717dcca6 (patch)
treebb0f38beb5e70279efa7377ee232a210873fa9cd /libempathy-gtk/empathy-account-widget.c
parent04434d6dd476e0613685adecfbad9b03eb4c2e4e (diff)
downloadgsoc2013-empathy-91c325aabdb286f44729cb5ee7f69afd717dcca6.tar
gsoc2013-empathy-91c325aabdb286f44729cb5ee7f69afd717dcca6.tar.gz
gsoc2013-empathy-91c325aabdb286f44729cb5ee7f69afd717dcca6.tar.bz2
gsoc2013-empathy-91c325aabdb286f44729cb5ee7f69afd717dcca6.tar.lz
gsoc2013-empathy-91c325aabdb286f44729cb5ee7f69afd717dcca6.tar.xz
gsoc2013-empathy-91c325aabdb286f44729cb5ee7f69afd717dcca6.tar.zst
gsoc2013-empathy-91c325aabdb286f44729cb5ee7f69afd717dcca6.zip
Base the selected widget both on the CM and the protocol
Previously Empathy would select the custom account widget purely based on the protocol, the problem here is that these widgets assume one specific connection manager and its set of parameters. Which triggered bugs if the intended cm for a protocol isn't installed, but haze is and provides the protocol.
Diffstat (limited to 'libempathy-gtk/empathy-account-widget.c')
-rw-r--r--libempathy-gtk/empathy-account-widget.c103
1 files changed, 65 insertions, 38 deletions
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 5863d4980..801510043 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -739,6 +739,24 @@ account_widget_build_salut (EmpathyAccountWidget *self,
}
static void
+account_widget_build_irc (EmpathyAccountWidget *self,
+ const char *filename)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ empathy_account_widget_irc_build (self, filename,
+ &priv->table_common_settings);
+}
+
+static void
+account_widget_build_sip (EmpathyAccountWidget *self,
+ const char *filename)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ empathy_account_widget_sip_build (self, filename,
+ &priv->table_common_settings);
+}
+
+static void
account_widget_build_msn (EmpathyAccountWidget *self,
const char *filename)
{
@@ -1088,52 +1106,63 @@ do_get_property (GObject *object,
}
}
+#define WIDGET(cm, proto) \
+ { #cm, #proto, "empathy-account-widget-"#proto".ui", \
+ account_widget_build_##proto }
+
static void
do_constructed (GObject *obj)
{
EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
EmpathyAccount *account;
- char *uiname, *filename;
-
- uiname = g_strconcat ("empathy-account-widget-", priv->protocol,
- ".ui", NULL);
- filename = empathy_file_lookup (uiname, "libempathy-gtk");
-
- if (!tp_strdiff (priv->protocol, "local-xmpp"))
- account_widget_build_salut (self, filename);
- else if (!tp_strdiff (priv->protocol, "msn"))
- account_widget_build_msn (self, filename);
- else if (!tp_strdiff (priv->protocol, "jabber"))
- account_widget_build_jabber (self, filename);
- else if (!tp_strdiff (priv->protocol, "icq"))
- account_widget_build_icq (self, filename);
- else if (!tp_strdiff (priv->protocol, "aim"))
- account_widget_build_aim (self, filename);
- else if (!tp_strdiff (priv->protocol, "yahoo"))
- account_widget_build_yahoo (self, filename);
- else if (!tp_strdiff (priv->protocol, "groupwise"))
- account_widget_build_groupwise (self, filename);
- else if (!tp_strdiff (priv->protocol, "irc"))
- empathy_account_widget_irc_build (self, filename,
- &priv->table_common_settings);
- else if (!tp_strdiff (priv->protocol, "sip"))
- empathy_account_widget_sip_build (self, filename,
- &priv->table_common_settings);
- else if (!tp_strdiff (priv->protocol, "generic"))
- account_widget_build_generic (self, filename);
- else
+ const gchar *protocol, *cm_name;
+ int i = 0;
+ struct {
+ const gchar *cm_name;
+ const gchar *protocol;
+ const char *file;
+ void (*func)(EmpathyAccountWidget *self, const gchar *filename);
+ } widgets [] = {
+ { "salut", "local-xmpp", "empathy-account-widget-local-xmpp.ui",
+ account_widget_build_salut },
+ WIDGET (gabble, jabber),
+ WIDGET (butterfly, msn),
+ WIDGET (haze, icq),
+ WIDGET (haze, aim),
+ WIDGET (haze, yahoo),
+ WIDGET (haze, groupwise),
+ WIDGET (idle, irc),
+ WIDGET (sofiasip, sip),
+ };
+
+ cm_name = empathy_account_settings_get_cm (priv->settings);
+ protocol = empathy_account_settings_get_protocol (priv->settings);
+
+ for (i = 0 ; i < G_N_ELEMENTS (widgets); i++)
{
- g_free (filename);
+ if (!tp_strdiff (widgets[i].cm_name, cm_name) &&
+ !tp_strdiff (widgets[i].protocol, protocol))
+ {
+ gchar *filename;
+
+ filename = empathy_file_lookup (widgets[i].file,
+ "libempathy-gtk");
+ widgets[i].func (self, filename);
+ g_free (filename);
+
+ break;
+ }
+ }
- filename = empathy_file_lookup (
+ if (i == G_N_ELEMENTS (widgets))
+ {
+ gchar *filename = empathy_file_lookup (
"empathy-account-widget-generic.ui", "libempathy-gtk");
account_widget_build_generic (self, filename);
+ g_free (filename);
}
- g_free (uiname);
- g_free (filename);
-
/* handle default focus */
if (self->ui_details->default_focus != NULL)
{
@@ -1383,17 +1412,15 @@ empathy_account_widget_get_widget (EmpathyAccountWidget *widget)
}
EmpathyAccountWidget *
-empathy_account_widget_new_for_protocol (const char *protocol,
- EmpathyAccountSettings *settings,
+empathy_account_widget_new_for_protocol (EmpathyAccountSettings *settings,
gboolean simple)
{
EmpathyAccountWidget *self;
g_return_val_if_fail (EMPATHY_IS_ACCOUNT_SETTINGS (settings), NULL);
- g_return_val_if_fail (protocol != NULL, NULL);
self = g_object_new
- (EMPATHY_TYPE_ACCOUNT_WIDGET, "protocol", protocol,
+ (EMPATHY_TYPE_ACCOUNT_WIDGET,
"settings", settings, "simple", simple,
"creating-account",
empathy_account_settings_get_account (settings) == NULL,