diff options
-rw-r--r-- | libempathy-gtk/empathy-account-widget.c | 103 | ||||
-rw-r--r-- | libempathy-gtk/empathy-account-widget.h | 1 | ||||
-rw-r--r-- | src/empathy-account-assistant.c | 3 | ||||
-rw-r--r-- | src/empathy-accounts-dialog.c | 33 |
4 files changed, 70 insertions, 70 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, diff --git a/libempathy-gtk/empathy-account-widget.h b/libempathy-gtk/empathy-account-widget.h index 415934a2d..d4111eba2 100644 --- a/libempathy-gtk/empathy-account-widget.h +++ b/libempathy-gtk/empathy-account-widget.h @@ -62,7 +62,6 @@ GType empathy_account_widget_get_type (void); GtkWidget *empathy_account_widget_get_widget (EmpathyAccountWidget *widget); EmpathyAccountWidget * empathy_account_widget_new_for_protocol ( - const char *protocol, EmpathyAccountSettings *settings, gboolean simple); diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 54fe684a8..c8379ae02 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -324,8 +324,7 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser, if (priv->first_resp == RESPONSE_CREATE_ACCOUNT) empathy_account_settings_set_boolean (settings, "register", TRUE); - widget_object = empathy_account_widget_new_for_protocol (proto->name, - settings, TRUE); + widget_object = empathy_account_widget_new_for_protocol (settings, TRUE); account_widget = empathy_account_widget_get_widget (widget_object); if (priv->current_account_widget != NULL) diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 1cb903ec0..0daeb47cf 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -245,34 +245,6 @@ empathy_account_dialog_account_created_cb (EmpathyAccountWidget *widget_object, 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) @@ -281,7 +253,10 @@ account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, 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", |