self->ui_details->default_focus = g_strdup ("entry_nickname");
}
+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)
}
}
+#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)
{
}
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,
g_object_unref (settings);
}
-static GtkWidget *
-get_account_setup_widget (EmpathyAccountSettings *settings,
- EmpathyAccountWidget **widget_object)
-{
- const gchar *proto = empathy_account_settings_get_protocol (settings);
- EmpathyConnectionManagers *cm =
- empathy_connection_managers_dup_singleton ();
- GList *cms = empathy_connection_managers_get_cms (cm);
- GList *l;
-
- for (l = cms; l; l = l->next)
- {
- TpConnectionManager *tp_cm = l->data;
- if (tp_connection_manager_has_protocol (tp_cm, proto))
- {
- g_object_unref (cm);
- *widget_object = empathy_account_widget_new_for_protocol (proto,
- settings, FALSE);
- return empathy_account_widget_get_widget (*widget_object);
- }
- }
-
- g_object_unref (cm);
- *widget_object = empathy_account_widget_new_for_protocol ("generic", settings,
- FALSE);
- return empathy_account_widget_get_widget (*widget_object);
-}
-
static void
account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog,
EmpathyAccountSettings *settings)
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
gchar *icon_name;
- priv->settings_widget = get_account_setup_widget (settings, &widget_object);
+ widget_object = empathy_account_widget_new_for_protocol (settings, FALSE);
+
+ priv->settings_widget = empathy_account_widget_get_widget (widget_object);
+
g_signal_connect (widget_object, "account-created",
G_CALLBACK (empathy_account_dialog_account_created_cb), dialog);
g_signal_connect (widget_object, "cancelled",