]> git.0d.be Git - empathy.git/blob - src/empathy-account-assistant.c
split strings to no translate markups
[empathy.git] / src / empathy-account-assistant.c
1 /*
2  * Copyright (C) 2009 Collabora Ltd.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
19  */
20
21 /* empathy-account-assistant.c */
22
23 #include <glib/gi18n.h>
24 #include <telepathy-glib/util.h>
25 #include <gdk/gdkkeysyms.h>
26
27 #include "empathy-account-assistant.h"
28 #include "empathy-import-widget.h"
29 #include "empathy-import-utils.h"
30 #include "empathy-auto-salut-account-helper.h"
31
32 #include <libempathy/empathy-account-settings.h>
33 #include <libempathy/empathy-utils.h>
34
35 #include <libempathy-gtk/empathy-account-widget.h>
36 #include <libempathy-gtk/empathy-protocol-chooser.h>
37 #include <libempathy-gtk/empathy-ui-utils.h>
38 #include <libempathy-gtk/empathy-conf.h>
39
40 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
41 #include <libempathy/empathy-debug.h>
42
43 G_DEFINE_TYPE (EmpathyAccountAssistant, empathy_account_assistant,
44     GTK_TYPE_ASSISTANT)
45
46 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountAssistant)
47
48 typedef enum {
49   RESPONSE_IMPORT = 1,
50   RESPONSE_ENTER_ACCOUNT = 2,
51   RESPONSE_CREATE_ACCOUNT = 3,
52   RESPONSE_SALUT_ONLY = 4
53 } FirstPageResponse;
54
55 typedef enum {
56   RESPONSE_CREATE_AGAIN = 1,
57   RESPONSE_CREATE_STOP = 2
58 } CreateEnterPageResponse;
59
60 enum {
61   PAGE_INTRO = 0,
62   PAGE_IMPORT = 1,
63   PAGE_ENTER_CREATE = 2,
64   PAGE_SALUT = 3,
65 };
66
67 enum {
68   PROP_PARENT = 1,
69   PROP_CONNECTION_MGRS,
70 };
71
72 typedef struct {
73   FirstPageResponse first_resp;
74   CreateEnterPageResponse create_enter_resp;
75   gboolean enter_create_forward;
76   TpAccountManager *account_mgr;
77   EmpathyConnectionManagers *connection_mgrs;
78
79   /* enter or create page */
80   GtkWidget *enter_or_create_page;
81   GtkWidget *current_account_widget;
82   EmpathyAccountWidget *current_widget_object;
83   GtkWidget *first_label;
84   GtkWidget *second_label;
85   GtkWidget *chooser;
86   GtkWidget *create_again_radio;
87   EmpathyAccountSettings *settings;
88   gboolean is_creating;
89
90   /* import page */
91   EmpathyImportWidget *iw;
92   GtkWidget *import_page;
93
94   /* salut page */
95   GtkWidget *salut_page;
96   EmpathyAccountSettings *salut_settings;
97   GtkWidget *salut_account_widget;
98   gboolean create_salut_account;
99   gboolean display_salut_page;
100
101   GtkWindow *parent_window;
102
103   gboolean dispose_run;
104 } EmpathyAccountAssistantPriv;
105
106 static GtkWidget * account_assistant_build_enter_or_create_page (
107     EmpathyAccountAssistant *self);
108 static void account_assistant_finish_enter_or_create_page (
109     EmpathyAccountAssistant *self,
110     gboolean is_enter);
111
112 static void do_constructed (GObject *object);
113
114 static GtkWidget *
115 build_error_vbox (const gchar *primary_message,
116     const gchar *secondary_message)
117 {
118   GtkWidget *main_vbox, *w, *hbox;
119   PangoAttrList *list;
120
121   main_vbox = gtk_vbox_new (FALSE, 12);
122   gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
123   gtk_widget_show (main_vbox);
124
125   hbox = gtk_hbox_new (FALSE, 12);
126   gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
127   gtk_widget_show (hbox);
128
129   w = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR,
130       GTK_ICON_SIZE_DIALOG);
131   gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
132   gtk_widget_show (w);
133
134   w = gtk_label_new (primary_message);
135   gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
136   list = pango_attr_list_new ();
137   pango_attr_list_insert (list, pango_attr_scale_new (PANGO_SCALE_LARGE));
138   pango_attr_list_insert (list, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
139   gtk_label_set_attributes (GTK_LABEL (w), list);
140   gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
141   gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
142   gtk_widget_show (w);
143
144   pango_attr_list_unref (list);
145
146   w = gtk_label_new (secondary_message);
147   gtk_label_set_use_markup (GTK_LABEL (w), TRUE);
148   gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0);
149   gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
150   gtk_widget_show (w);
151
152   return main_vbox;
153 }
154
155 static GtkWidget *
156 account_assistant_build_error_page (EmpathyAccountAssistant *self,
157     GError *error, gint page_num)
158 {
159   GtkWidget *main_vbox, *w;
160   const char *primary_message;
161   gchar *secondary_message, *markup;
162   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
163
164   if (page_num == PAGE_IMPORT)
165     primary_message = _("There was an error while importing the accounts.");
166   else if (page_num >= PAGE_ENTER_CREATE &&
167       priv->first_resp == RESPONSE_ENTER_ACCOUNT)
168     primary_message = _("There was an error while parsing the account details.");
169   else if (page_num >= PAGE_ENTER_CREATE &&
170       priv->first_resp == RESPONSE_CREATE_ACCOUNT)
171     primary_message = _("There was an error while creating the account.");
172   else
173     primary_message = _("There was an error.");
174
175   markup = g_markup_printf_escaped ("<span style=\"italic\">%s</span>",
176       error->message);
177   secondary_message = g_strdup_printf (_("The error message was: %s"), markup);
178
179   main_vbox = build_error_vbox (primary_message, secondary_message);
180
181   w = gtk_label_new (_("You can either go back and try to enter your "
182           "accounts' details again or quit this assistant and add accounts "
183           "later from the Edit menu."));
184   gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 6);
185   gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
186   gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
187   gtk_widget_show (w);
188
189   g_free (markup);
190   g_free (secondary_message);
191   return main_vbox;
192 }
193
194 static void
195 account_assistant_back_button_clicked_cb (GtkButton *button,
196     EmpathyAccountAssistant *self)
197 {
198   gint page_num;
199
200   page_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button),
201           "page-num"));
202   gtk_assistant_remove_action_widget (GTK_ASSISTANT (self),
203       GTK_WIDGET (button));
204   gtk_assistant_set_current_page (GTK_ASSISTANT (self), page_num);
205 }
206
207 static void
208 account_assistant_present_error_page (EmpathyAccountAssistant *self,
209     GError *error, gint page_num)
210 {
211   GtkWidget *error_page, *back_button;
212   gint num;
213
214   error_page = account_assistant_build_error_page (self, error,
215       page_num);
216   num = gtk_assistant_append_page (GTK_ASSISTANT (self), error_page);
217   gtk_assistant_set_page_title (GTK_ASSISTANT (self), error_page,
218       _("An error occurred"));
219   gtk_assistant_set_page_type (GTK_ASSISTANT (self), error_page,
220       GTK_ASSISTANT_PAGE_SUMMARY);
221
222   back_button = gtk_button_new_from_stock (GTK_STOCK_GO_BACK);
223   gtk_assistant_add_action_widget (GTK_ASSISTANT (self), back_button);
224   g_object_set_data (G_OBJECT (back_button),
225       "page-num", GINT_TO_POINTER (page_num));
226   g_signal_connect (back_button, "clicked",
227       G_CALLBACK (account_assistant_back_button_clicked_cb), self);
228   gtk_widget_show (back_button);
229
230   gtk_assistant_set_current_page (GTK_ASSISTANT (self), num);
231 }
232
233 static void
234 update_create_page_buttons (EmpathyAccountAssistant *self)
235 {
236   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
237   GtkAssistantPageType type;
238
239   if (priv->display_salut_page ||
240       priv->create_enter_resp == RESPONSE_CREATE_AGAIN)
241     type = GTK_ASSISTANT_PAGE_CONTENT;
242   else
243     type = GTK_ASSISTANT_PAGE_CONFIRM;
244
245   gtk_assistant_set_page_type (GTK_ASSISTANT (self), priv->enter_or_create_page,
246       type);
247 }
248
249 static void
250 account_assistant_reset_enter_create_page (EmpathyAccountAssistant *self)
251 {
252   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
253   GtkWidget *page;
254   gint idx;
255
256   page = account_assistant_build_enter_or_create_page (self);
257   idx = gtk_assistant_append_page (GTK_ASSISTANT (self), page);
258   priv->enter_or_create_page = page;
259   update_create_page_buttons (self);
260
261   gtk_assistant_set_current_page (GTK_ASSISTANT (self), idx);
262
263   account_assistant_finish_enter_or_create_page (self,
264       priv->first_resp == RESPONSE_ENTER_ACCOUNT ?
265       TRUE : FALSE);
266 }
267
268 static void
269 account_assistant_account_enabled_cb (GObject *source,
270     GAsyncResult *result,
271     gpointer user_data)
272 {
273   GError *error = NULL;
274   EmpathyAccountAssistant *self = user_data;
275   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
276   const gchar *protocol;
277   TpAccount *account = TP_ACCOUNT (source);
278
279   tp_account_set_enabled_finish (account, result, &error);
280
281   if (error)
282     {
283       g_warning ("Error enabling an account: %s", error->message);
284       g_error_free (error);
285     }
286
287   protocol = tp_account_get_protocol (account);
288   if (!tp_strdiff (protocol, "local-xmpp"))
289     {
290       DEBUG ("Salut account has been created; update gconf key");
291
292       empathy_conf_set_bool (empathy_conf_get (),
293           EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
294           TRUE);
295     }
296
297   if (priv->create_enter_resp == RESPONSE_CREATE_STOP)
298     g_signal_emit_by_name (self, "close");
299   else
300     account_assistant_reset_enter_create_page (self);
301 }
302
303 static void
304 account_assistant_apply_account_cb (GObject *source,
305     GAsyncResult *result,
306     gpointer user_data)
307 {
308   GError *error = NULL;
309   EmpathyAccountAssistant *self = user_data;
310   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
311   EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source);
312   TpAccount *account;
313   gchar *display_name;
314
315   empathy_account_settings_apply_finish (settings, result, &error);
316
317   if (empathy_account_settings_get_display_name (settings) == NULL)
318     {
319       /* set default display name */
320       display_name = empathy_account_widget_get_default_display_name (
321           priv->current_widget_object);
322
323       empathy_account_settings_set_display_name_async (settings,
324           display_name, NULL, NULL);
325
326       g_free (display_name);
327     }
328
329   priv->is_creating = FALSE;
330
331   if (error != NULL)
332     {
333       account_assistant_present_error_page (self, error,
334           gtk_assistant_get_current_page (GTK_ASSISTANT (self)));
335       g_error_free (error);
336       return;
337     }
338
339   /* enable the newly created account */
340   account = empathy_account_settings_get_account (settings);
341   tp_account_set_enabled_async (account, TRUE,
342       account_assistant_account_enabled_cb, self);
343 }
344
345 static void
346 account_assistant_apply_account_and_finish (EmpathyAccountAssistant *self,
347     EmpathyAccountSettings *settings)
348 {
349   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
350
351   if (settings == NULL)
352     return;
353
354   priv->is_creating = TRUE;
355
356   empathy_account_settings_apply_async (settings,
357       account_assistant_apply_account_cb, self);
358 }
359
360 static void
361 account_assistant_handle_apply_cb (EmpathyAccountWidget *widget_object,
362     gboolean is_valid,
363     EmpathyAccountAssistant *self)
364 {
365   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
366
367   gtk_assistant_set_page_complete (GTK_ASSISTANT (self),
368       priv->enter_or_create_page, is_valid);
369 }
370
371 static void
372 account_assistant_protocol_changed_cb (GtkComboBox *chooser,
373     EmpathyAccountAssistant *self)
374 {
375   TpConnectionManager *cm;
376   TpConnectionManagerProtocol *proto;
377   EmpathyAccountSettings *settings;
378   EmpathyAccountAssistantPriv *priv;
379   char *str;
380   GtkWidget *account_widget;
381   EmpathyAccountWidget *widget_object = NULL;
382   gboolean is_gtalk;
383
384   priv = GET_PRIV (self);
385
386   cm = empathy_protocol_chooser_dup_selected (
387       EMPATHY_PROTOCOL_CHOOSER (chooser), &proto, &is_gtalk);
388
389   if (cm == NULL || proto == NULL)
390     /* we are not ready yet */
391     return;
392
393   /* Create account */
394   /* To translator: %s is the protocol name */
395   str = g_strdup_printf (_("New %s account"),
396       empathy_protocol_name_to_display_name (
397           is_gtalk ? "gtalk" : proto->name));
398
399   settings = empathy_account_settings_new (cm->name, proto->name, str);
400
401   if (is_gtalk)
402     empathy_account_settings_set_icon_name_async (settings, "im-google-talk",
403       NULL, NULL);
404
405   if (priv->first_resp == RESPONSE_CREATE_ACCOUNT)
406     empathy_account_settings_set_boolean (settings, "register", TRUE);
407
408   widget_object = empathy_account_widget_new_for_protocol (settings, TRUE);
409   account_widget = empathy_account_widget_get_widget (widget_object);
410
411   if (priv->current_account_widget != NULL)
412     {
413       g_signal_handlers_disconnect_by_func (priv->current_widget_object,
414           account_assistant_handle_apply_cb, self);
415       gtk_widget_destroy (priv->current_account_widget);
416     }
417
418   priv->current_account_widget = account_widget;
419   priv->current_widget_object = widget_object;
420
421   if (priv->settings != NULL)
422     g_object_unref (priv->settings);
423
424   priv->settings = settings;
425
426   g_signal_connect (priv->current_widget_object, "handle-apply",
427       G_CALLBACK (account_assistant_handle_apply_cb), self);
428
429   gtk_box_pack_start (GTK_BOX (priv->enter_or_create_page), account_widget,
430       FALSE, FALSE, 0);
431   gtk_widget_show (account_widget);
432
433   g_free (str);
434 }
435
436 static gboolean
437 account_assistant_chooser_enter_details_filter_func (
438     TpConnectionManager *cm,
439     TpConnectionManagerProtocol *protocol,
440     gboolean is_gtalk,
441     gpointer user_data)
442 {
443   if (!tp_strdiff (protocol->name, "local-xmpp") ||
444       !tp_strdiff (protocol->name, "irc"))
445     return FALSE;
446
447   return TRUE;
448 }
449
450 static gboolean
451 account_assistant_chooser_create_account_filter_func (
452     TpConnectionManager *cm,
453     TpConnectionManagerProtocol *protocol,
454     gboolean is_gtalk,
455     gpointer user_data)
456 {
457   if (is_gtalk)
458     return FALSE;
459
460   return tp_connection_manager_protocol_can_register (protocol);
461 }
462
463 static void
464 account_assistant_finish_enter_or_create_page (EmpathyAccountAssistant *self,
465     gboolean is_enter)
466 {
467   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
468
469   if (is_enter)
470     {
471       gtk_label_set_label (GTK_LABEL (priv->first_label),
472           _("What kind of chat account do you have?"));
473       /*      gtk_label_set_label (GTK_LABEL (priv->second_label),
474           _("If you have other accounts to set up, you can do "
475               "that at any time from the Edit menu."));
476       */
477       gtk_label_set_label (GTK_LABEL (priv->second_label),
478           _("Do you have any other chat accounts you want to set up?"));
479       empathy_protocol_chooser_set_visible (
480           EMPATHY_PROTOCOL_CHOOSER (priv->chooser),
481           account_assistant_chooser_enter_details_filter_func, self);
482
483       gtk_assistant_set_page_title (GTK_ASSISTANT (self),
484           priv->enter_or_create_page, _("Enter your account details"));
485     }
486   else
487     {
488       gtk_label_set_label (GTK_LABEL (priv->first_label),
489           _("What kind of chat account do you want to create?"));
490       /*      gtk_label_set_label (GTK_LABEL (priv->second_label),
491           _("You can register other accounts, or setup "
492               "an existing one at any time from the Edit menu."));
493       */
494       gtk_label_set_label (GTK_LABEL (priv->second_label),
495           _("Do you want to create other chat accounts?"));
496       empathy_protocol_chooser_set_visible (
497           EMPATHY_PROTOCOL_CHOOSER (priv->chooser),
498           account_assistant_chooser_create_account_filter_func, self);
499
500       gtk_assistant_set_page_title (GTK_ASSISTANT (self),
501           priv->enter_or_create_page,
502           _("Enter the details for the new account"));
503     }
504
505   g_signal_connect (priv->chooser, "changed",
506       G_CALLBACK (account_assistant_protocol_changed_cb), self);
507
508   /* trigger show the first account widget */
509   account_assistant_protocol_changed_cb (GTK_COMBO_BOX (priv->chooser), self);
510 }
511
512 static gint
513 account_assistant_page_forward_func (gint current_page,
514     gpointer user_data)
515 {
516   EmpathyAccountAssistant *self = user_data;
517   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
518   gint retval;
519
520   retval = current_page;
521
522   if (current_page == PAGE_INTRO)
523     {
524       if (priv->first_resp == RESPONSE_ENTER_ACCOUNT ||
525           priv->first_resp == RESPONSE_CREATE_ACCOUNT)
526         retval = PAGE_ENTER_CREATE;
527       else if (priv->first_resp == RESPONSE_IMPORT)
528         retval = PAGE_IMPORT;
529       else if (priv->first_resp == RESPONSE_SALUT_ONLY)
530         retval = PAGE_SALUT;
531     }
532   else if (current_page == PAGE_IMPORT)
533     {
534       if (priv->display_salut_page)
535         retval = PAGE_SALUT;
536       else
537         /* Don't go forward */
538         retval = -1;
539     }
540   else if (current_page == PAGE_SALUT)
541     {
542       /* Don't go forward */
543       retval = -1;
544     }
545   else if (current_page >= PAGE_ENTER_CREATE)
546     {
547       if (priv->create_enter_resp == RESPONSE_CREATE_AGAIN)
548         {
549           priv->enter_create_forward = TRUE;
550           retval = current_page;
551         }
552       else if (priv->display_salut_page)
553         {
554           retval = PAGE_SALUT;
555         }
556       else
557         {
558           /* Don't go forward */
559           retval = -1;
560         }
561     }
562
563   return retval;
564 }
565
566 static void
567 update_intro_page_buttons (EmpathyAccountAssistant *self)
568 {
569   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
570   GtkWidget *intro_page;
571
572   intro_page = gtk_assistant_get_nth_page (GTK_ASSISTANT (self),
573       PAGE_INTRO);
574
575   if (priv->first_resp == RESPONSE_SALUT_ONLY &&
576       !priv->display_salut_page)
577     gtk_assistant_set_page_type (GTK_ASSISTANT (self), intro_page,
578         GTK_ASSISTANT_PAGE_SUMMARY);
579   else
580     gtk_assistant_set_page_type (GTK_ASSISTANT (self), intro_page,
581         GTK_ASSISTANT_PAGE_INTRO);
582 }
583
584 static void
585 account_assistant_radio_choice_toggled_cb (GtkToggleButton *button,
586     EmpathyAccountAssistant *self)
587 {
588   FirstPageResponse response;
589   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
590
591   response = GPOINTER_TO_INT (g_object_get_data
592       (G_OBJECT (button), "response"));
593
594   priv->first_resp = response;
595
596   update_intro_page_buttons (self);
597 }
598
599 static GtkWidget *
600 account_assistant_build_introduction_page (EmpathyAccountAssistant *self)
601 {
602   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
603   GtkWidget *main_vbox, *hbox_1, *w, *vbox_1;
604   GtkWidget *radio = NULL;
605   GdkPixbuf *pix;
606   const gchar *str;
607
608   main_vbox = gtk_vbox_new (FALSE, 12);
609   gtk_widget_show (main_vbox);
610   gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
611
612   hbox_1 = gtk_hbox_new (FALSE, 12);
613   gtk_box_pack_start (GTK_BOX (main_vbox), hbox_1, TRUE, TRUE, 0);
614   gtk_widget_show (hbox_1);
615
616   w = gtk_label_new (
617       _("With Empathy you can chat with people "
618         "online nearby and with friends and colleagues "
619         "who use Google Talk, AIM, Windows Live "
620         "and many other chat programs. With a microphone "
621         "or a webcam you can also have audio or video calls."));
622   gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
623   gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
624   gtk_box_pack_start (GTK_BOX (hbox_1), w, FALSE, FALSE, 0);
625   gtk_widget_show (w);
626
627   pix = empathy_pixbuf_from_icon_name_sized ("empathy", 80);
628   w = gtk_image_new_from_pixbuf (pix);
629   gtk_box_pack_start (GTK_BOX (hbox_1), w, FALSE, FALSE, 6);
630   gtk_widget_show (w);
631
632   g_object_unref (pix);
633
634   w = gtk_label_new (_("Do you have an account you've been using "
635           "with another chat program?"));
636   gtk_misc_set_alignment (GTK_MISC (w), 0, 0);
637   gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
638   gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0);
639   gtk_widget_show (w);
640
641   w = gtk_alignment_new (0, 0, 0, 0);
642   gtk_alignment_set_padding (GTK_ALIGNMENT (w), 0, 0, 12, 0);
643   gtk_box_pack_start (GTK_BOX (main_vbox), w, TRUE, TRUE, 0);
644   gtk_widget_show (w);
645
646   vbox_1 = gtk_vbox_new (TRUE, 0);
647   gtk_container_add (GTK_CONTAINER (w), vbox_1);
648   gtk_widget_show (vbox_1);
649
650   if (empathy_import_accounts_to_import ())
651     {
652       hbox_1 = gtk_hbox_new (FALSE, 0);
653       gtk_box_pack_start (GTK_BOX (vbox_1), hbox_1, TRUE, TRUE, 0);
654       gtk_widget_show (hbox_1);
655
656       radio = gtk_radio_button_new_with_label (NULL,
657           _("Yes, import my account details from "));
658       gtk_box_pack_start (GTK_BOX (hbox_1), radio, TRUE, TRUE, 0);
659       g_object_set_data (G_OBJECT (radio), "response",
660           GINT_TO_POINTER (RESPONSE_IMPORT));
661       gtk_widget_show (radio);
662
663       w = gtk_combo_box_new_text ();
664       gtk_combo_box_append_text (GTK_COMBO_BOX (w), "Pidgin");
665       gtk_box_pack_start (GTK_BOX (hbox_1), w, TRUE, TRUE, 0);
666       gtk_combo_box_set_active (GTK_COMBO_BOX (w), 0);
667       gtk_widget_show (w);
668
669       g_signal_connect (radio, "clicked",
670           G_CALLBACK (account_assistant_radio_choice_toggled_cb), self);
671       priv->first_resp = RESPONSE_IMPORT;
672     }
673   else
674     {
675       priv->first_resp = RESPONSE_ENTER_ACCOUNT;
676     }
677
678   str = _("Yes, I'll enter my account details now");
679
680   if (radio == NULL)
681     {
682       radio = gtk_radio_button_new_with_label (NULL, str);
683       w = radio;
684     }
685   else
686     {
687       w = gtk_radio_button_new_with_label_from_widget (
688           GTK_RADIO_BUTTON (radio), str);
689     }
690
691   gtk_box_pack_start (GTK_BOX (vbox_1), w, TRUE, TRUE, 0);
692   g_object_set_data (G_OBJECT (w), "response",
693       GINT_TO_POINTER (RESPONSE_ENTER_ACCOUNT));
694   gtk_widget_show (w);
695
696   g_signal_connect (w, "clicked",
697       G_CALLBACK (account_assistant_radio_choice_toggled_cb), self);
698
699   w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio),
700       _("No, I want a new account"));
701   gtk_box_pack_start (GTK_BOX (vbox_1), w, TRUE, TRUE, 0);
702   g_object_set_data (G_OBJECT (w), "response",
703       GINT_TO_POINTER (RESPONSE_CREATE_ACCOUNT));
704   gtk_widget_show (w);
705
706   g_signal_connect (w, "clicked",
707       G_CALLBACK (account_assistant_radio_choice_toggled_cb), self);
708
709   w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio),
710       _("No, I just want to see people online nearby for now"));
711   gtk_box_pack_start (GTK_BOX (vbox_1), w, TRUE, TRUE, 0);
712   g_object_set_data (G_OBJECT (w), "response",
713       GINT_TO_POINTER (RESPONSE_SALUT_ONLY));
714   gtk_widget_show (w);
715
716   g_signal_connect (w, "clicked",
717       G_CALLBACK (account_assistant_radio_choice_toggled_cb), self);
718
719   return main_vbox;
720 }
721
722 static GtkWidget *
723 account_assistant_build_import_page (EmpathyAccountAssistant *self)
724 {
725   GtkWidget *main_vbox, *w, *import;
726   EmpathyImportWidget *iw;
727   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
728
729   main_vbox = gtk_vbox_new (FALSE, 12);
730   gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
731   w = gtk_label_new (_("Select the accounts you want to import:"));
732   gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
733   gtk_widget_show (w);
734   gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 6);
735
736   w = gtk_alignment_new (0, 0, 0, 0);
737   gtk_alignment_set_padding (GTK_ALIGNMENT (w), 0, 0, 12, 0);
738   gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0);
739   gtk_widget_show (w);
740
741   /* NOTE: this is hardcoded as we support pidgin only */
742   iw = empathy_import_widget_new (EMPATHY_IMPORT_APPLICATION_PIDGIN);
743   import = empathy_import_widget_get_widget (iw);
744   gtk_container_add (GTK_CONTAINER (w), import);
745   gtk_widget_show (import);
746
747   priv->iw = iw;
748
749   gtk_widget_show (main_vbox);
750
751   return main_vbox;
752 }
753
754 static void
755 account_assistant_radio_create_again_clicked_cb (GtkButton *button,
756     EmpathyAccountAssistant *self)
757 {
758   CreateEnterPageResponse response;
759   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
760
761   response = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button),
762           "response"));
763
764   priv->create_enter_resp = response;
765
766   update_create_page_buttons (self);
767 }
768
769 static GtkWidget *
770 account_assistant_build_enter_or_create_page (EmpathyAccountAssistant *self)
771 {
772   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
773   GtkWidget *main_vbox, *w, *chooser, *vbox, *hbox, *radio;
774
775   main_vbox = gtk_vbox_new (FALSE, 12);
776   gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
777   gtk_widget_show (main_vbox);
778
779   w = gtk_label_new (NULL);
780   gtk_misc_set_alignment (GTK_MISC (w), 0, 0);
781   gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0);
782   gtk_widget_show (w);
783   priv->first_label = w;
784
785   w = gtk_alignment_new (0, 0, 0, 0);
786   gtk_alignment_set_padding (GTK_ALIGNMENT (w), 0, 0, 12, 0);
787   gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0);
788   gtk_widget_show (w);
789
790   chooser = empathy_protocol_chooser_new ();
791   gtk_container_add (GTK_CONTAINER (w), chooser);
792   gtk_widget_show (chooser);
793   priv->chooser = chooser;
794
795   vbox = gtk_vbox_new (FALSE, 6);
796   gtk_box_pack_end (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
797   gtk_widget_show (vbox);
798
799   w = gtk_label_new (NULL);
800   gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
801   gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
802   gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
803   gtk_widget_show (w);
804   priv->second_label = w;
805
806   w = gtk_alignment_new (0, 0, 0, 0);
807   gtk_alignment_set_padding (GTK_ALIGNMENT (w), 0, 0, 12, 0);
808   gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
809   gtk_widget_show (w);
810
811   hbox = gtk_hbox_new (FALSE, 6);
812   gtk_container_add (GTK_CONTAINER (w), hbox);
813   gtk_widget_show (hbox);
814
815   radio = gtk_radio_button_new_with_label (NULL, _("Yes"));
816   gtk_box_pack_start (GTK_BOX (hbox), radio, FALSE, FALSE, 0);
817   g_object_set_data (G_OBJECT (radio), "response",
818       GINT_TO_POINTER (RESPONSE_CREATE_AGAIN));
819   gtk_widget_show (radio);
820
821   w = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio),
822       _("No, that's all for now"));
823   gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
824   g_object_set_data (G_OBJECT (w), "response",
825       GINT_TO_POINTER (RESPONSE_CREATE_STOP));
826   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);
827   priv->create_enter_resp = RESPONSE_CREATE_STOP;
828   priv->create_again_radio = w;
829   gtk_widget_show (w);
830
831   g_signal_connect (w, "clicked",
832       G_CALLBACK (account_assistant_radio_create_again_clicked_cb), self);
833   g_signal_connect (radio, "clicked",
834       G_CALLBACK (account_assistant_radio_create_again_clicked_cb), self);
835
836   return main_vbox;
837 }
838
839 static void
840 account_assistant_close_cb (GtkAssistant *assistant,
841     gpointer user_data)
842 {
843   EmpathyAccountAssistantPriv *priv = GET_PRIV (assistant);
844
845   if (priv->is_creating)
846     return;
847
848   gtk_widget_destroy (GTK_WIDGET (assistant));
849 }
850
851 static void
852 impl_signal_apply (GtkAssistant *assistant)
853 {
854   EmpathyAccountAssistant *self = EMPATHY_ACCOUNT_ASSISTANT (assistant);
855   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
856   gint current_page;
857
858   current_page = gtk_assistant_get_current_page (assistant);
859
860   if (current_page == PAGE_SALUT)
861     {
862       if (priv->create_salut_account)
863         account_assistant_apply_account_and_finish (self, priv->salut_settings);
864       return;
865     }
866
867   if (current_page >= PAGE_ENTER_CREATE)
868     account_assistant_apply_account_and_finish (self, priv->settings);
869   else if (current_page == PAGE_IMPORT)
870     empathy_import_widget_add_selected_accounts (priv->iw);
871 }
872
873 static void
874 impl_signal_cancel (GtkAssistant *assistant)
875 {
876   gtk_widget_destroy (GTK_WIDGET (assistant));
877 }
878
879 static void
880 impl_signal_prepare (GtkAssistant *assistant,
881     GtkWidget *current_page)
882 {
883   EmpathyAccountAssistant *self = EMPATHY_ACCOUNT_ASSISTANT (assistant);
884   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
885   gint current_idx;
886
887   current_idx = gtk_assistant_get_current_page (assistant);
888
889   if (current_idx >= PAGE_ENTER_CREATE && current_idx != PAGE_SALUT)
890     {
891       if (!priv->enter_create_forward)
892         {
893           account_assistant_finish_enter_or_create_page (self,
894               priv->first_resp == RESPONSE_ENTER_ACCOUNT ?
895               TRUE : FALSE);
896         }
897       else
898         {
899           priv->enter_create_forward = FALSE;
900           account_assistant_apply_account_and_finish (self, priv->settings);
901         }
902     }
903 }
904
905 static void
906 do_get_property (GObject *object,
907     guint property_id,
908     GValue *value,
909     GParamSpec *pspec)
910 {
911   EmpathyAccountAssistantPriv *priv = GET_PRIV (object);
912
913   switch (property_id)
914     {
915     case PROP_PARENT:
916       g_value_set_object (value, priv->parent_window);
917       break;
918     case PROP_CONNECTION_MGRS:
919       g_value_set_object (value, priv->connection_mgrs);
920       break;
921     default:
922       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
923     }
924 }
925
926 static void
927 do_set_property (GObject *object,
928     guint property_id,
929     const GValue *value,
930     GParamSpec *pspec)
931 {
932   EmpathyAccountAssistantPriv *priv = GET_PRIV (object);
933
934   switch (property_id)
935     {
936     case PROP_PARENT:
937       priv->parent_window = g_value_get_object (value);
938       break;
939     case PROP_CONNECTION_MGRS:
940       priv->connection_mgrs = g_value_dup_object (value);
941       break;
942     default:
943       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
944     }
945 }
946
947 static void
948 do_dispose (GObject *obj)
949 {
950   EmpathyAccountAssistantPriv *priv = GET_PRIV (obj);
951
952   if (priv->dispose_run)
953     return;
954
955   priv->dispose_run = TRUE;
956
957   if (priv->settings != NULL)
958     {
959       g_object_unref (priv->settings);
960       priv->settings = NULL;
961     }
962
963   g_object_unref (priv->account_mgr);
964   priv->account_mgr = NULL;
965
966   g_object_unref (priv->connection_mgrs);
967   priv->connection_mgrs = NULL;
968
969   if (G_OBJECT_CLASS (empathy_account_assistant_parent_class)->dispose != NULL)
970     G_OBJECT_CLASS (empathy_account_assistant_parent_class)->dispose (obj);
971 }
972
973 static void
974 empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass)
975 {
976   GObjectClass *oclass = G_OBJECT_CLASS (klass);
977   GtkAssistantClass *gtkclass = GTK_ASSISTANT_CLASS (klass);
978   GParamSpec *param_spec;
979
980   oclass->get_property = do_get_property;
981   oclass->set_property = do_set_property;
982   oclass->constructed = do_constructed;
983   oclass->dispose = do_dispose;
984
985   gtkclass->apply = impl_signal_apply;
986   gtkclass->prepare = impl_signal_prepare;
987   gtkclass->cancel = impl_signal_cancel;
988
989   param_spec = g_param_spec_object ("parent-window",
990       "parent-window", "The parent window",
991       GTK_TYPE_WINDOW,
992       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
993   g_object_class_install_property (oclass, PROP_PARENT, param_spec);
994
995   param_spec = g_param_spec_object ("connection-managers",
996       "connection-managers", "A EmpathyConnectionManagers",
997       EMPATHY_TYPE_CONNECTION_MANAGERS,
998       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
999   g_object_class_install_property (oclass, PROP_CONNECTION_MGRS, param_spec);
1000
1001   g_type_class_add_private (klass, sizeof (EmpathyAccountAssistantPriv));
1002 }
1003
1004 static void
1005 create_salut_check_box_toggled_cb (GtkWidget *widget,
1006     EmpathyAccountAssistant *self)
1007 {
1008   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
1009   gboolean sensitive;
1010   gboolean page_valid;
1011
1012   sensitive = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
1013
1014   gtk_widget_set_sensitive (priv->salut_account_widget, sensitive);
1015
1016   if (!sensitive)
1017     {
1018       page_valid = TRUE;
1019       priv->create_salut_account = FALSE;
1020     }
1021   else
1022     {
1023       /* page is complete if the account is valid */
1024       page_valid = empathy_account_settings_is_valid (priv->salut_settings);
1025       priv->create_salut_account = TRUE;
1026     }
1027
1028   gtk_assistant_set_page_complete (GTK_ASSISTANT (self), priv->salut_page,
1029       page_valid);
1030 }
1031
1032 static void
1033 account_assistant_salut_handle_apply_cb (EmpathyAccountWidget *widget_object,
1034     gboolean is_valid,
1035     EmpathyAccountAssistant *self)
1036 {
1037   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
1038
1039   gtk_assistant_set_page_complete (GTK_ASSISTANT (self),
1040       priv->salut_page, is_valid);
1041 }
1042
1043 static GtkWidget *
1044 account_assistant_build_salut_page (EmpathyAccountAssistant *self)
1045 {
1046   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
1047   GtkWidget *main_vbox, *hbox_1, *w;
1048   GdkPixbuf *pix;
1049   EmpathyAccountSettings *settings;
1050   GtkWidget *account_widget;
1051   EmpathyAccountWidget *widget_object;
1052   gchar *markup;
1053
1054   main_vbox = gtk_vbox_new (FALSE, 12);
1055   gtk_widget_show (main_vbox);
1056   gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
1057
1058   hbox_1 = gtk_hbox_new (FALSE, 12);
1059   gtk_box_pack_start (GTK_BOX (main_vbox), hbox_1, TRUE, TRUE, 0);
1060   gtk_widget_show (hbox_1);
1061
1062   w = gtk_label_new ("");
1063   markup = g_strdup_printf ("%s (<span style=\"italic\">%s</span>).",
1064       _("Empathy can automatically discover and chat with the people "
1065         "connected on the same network as you. "
1066         "If you want to use this feature, please check that the "
1067         "details below are correct. "
1068         "You can easily change these details later or disable this feature "
1069         "by using the 'Accounts' dialog"),
1070       _("Edit->Accounts"));
1071   gtk_label_set_markup (GTK_LABEL (w), markup);
1072   g_free (markup);
1073   gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
1074   gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
1075   gtk_box_pack_start (GTK_BOX (hbox_1), w, FALSE, FALSE, 0);
1076   gtk_widget_show (w);
1077
1078   pix = empathy_pixbuf_from_icon_name_sized ("im-local-xmpp", 80);
1079   w = gtk_image_new_from_pixbuf (pix);
1080   gtk_box_pack_start (GTK_BOX (hbox_1), w, FALSE, FALSE, 6);
1081   gtk_widget_show (w);
1082
1083   g_object_unref (pix);
1084
1085   w = gtk_check_button_new_with_label (
1086       _("I don't want to enable this feature for now"));
1087   gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0);
1088   g_signal_connect (w, "toggled",
1089       G_CALLBACK (create_salut_check_box_toggled_cb), self);
1090   gtk_widget_show (w);
1091
1092   w = gtk_alignment_new (0, 0, 0, 0);
1093   gtk_alignment_set_padding (GTK_ALIGNMENT (w), 0, 0, 12, 0);
1094   gtk_box_pack_start (GTK_BOX (main_vbox), w, TRUE, TRUE, 0);
1095   gtk_widget_show (w);
1096
1097   settings = create_salut_account_settings ();
1098
1099   widget_object = empathy_account_widget_new_for_protocol (settings, TRUE);
1100   account_widget = empathy_account_widget_get_widget (widget_object);
1101
1102   priv->salut_settings = settings;
1103   priv->salut_account_widget = account_widget;
1104
1105   g_signal_connect (widget_object, "handle-apply",
1106       G_CALLBACK (account_assistant_salut_handle_apply_cb), self);
1107
1108   gtk_box_pack_start (GTK_BOX (main_vbox), account_widget,
1109       FALSE, FALSE, 0);
1110   gtk_widget_show (account_widget);
1111
1112   return main_vbox;
1113 }
1114
1115 static GtkWidget *
1116 account_assistant_build_salut_error_page (EmpathyAccountAssistant *self)
1117 {
1118   GtkWidget *vbox;
1119   gchar *markup;
1120
1121   markup = g_strdup_printf ("%s (<span style=\"italic\">%s</span>).",
1122       _("You won't be able to chat with people connected to your local "
1123         "network, as telepathy-salut is not installed.\nIf you want to enable "
1124         "this feature, please install the telepathy-salut package\nand create "
1125         "a People Nearby account from the Accounts dialog "),
1126         _("Edit->Accounts"));
1127
1128   vbox = build_error_vbox (_("telepathy-salut not installed"), markup);
1129   g_free (markup);
1130   return vbox;
1131 }
1132
1133 static void
1134 account_mgr_prepare_cb (GObject *source_object,
1135     GAsyncResult *result,
1136     gpointer user_data)
1137 {
1138   EmpathyAccountAssistant *self = user_data;
1139   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
1140   TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
1141   GError *error = NULL;
1142
1143   if (!tp_account_manager_prepare_finish (manager, result, &error))
1144     {
1145       DEBUG ("Failed to prepare account manager: %s", error->message);
1146       g_error_free (error);
1147       return;
1148     }
1149
1150   if (!should_create_salut_account (manager))
1151     {
1152       DEBUG ("No need to create a Salut account");
1153       priv->display_salut_page = FALSE;
1154
1155       update_intro_page_buttons (self);
1156
1157       gtk_assistant_set_page_type (GTK_ASSISTANT (self), priv->import_page,
1158           GTK_ASSISTANT_PAGE_CONFIRM);
1159
1160       update_create_page_buttons (self);
1161     }
1162 }
1163
1164 static void
1165 empathy_account_assistant_init (EmpathyAccountAssistant *self)
1166 {
1167   EmpathyAccountAssistantPriv *priv;
1168
1169   priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_ACCOUNT_ASSISTANT,
1170       EmpathyAccountAssistantPriv);
1171   self->priv = priv;
1172
1173   priv->account_mgr = tp_account_manager_dup ();
1174 }
1175
1176 static void
1177 do_constructed (GObject *object)
1178 {
1179   GtkAssistant *assistant = GTK_ASSISTANT (object);
1180   EmpathyAccountAssistant *self = EMPATHY_ACCOUNT_ASSISTANT (object);
1181   EmpathyAccountAssistantPriv *priv = GET_PRIV (object);
1182   GtkWidget *page;
1183
1184   /* set us as transient for the parent window if any */
1185   if (priv->parent_window)
1186     gtk_window_set_transient_for (GTK_WINDOW (object),
1187         priv->parent_window);
1188
1189   /* set the dialog hint, so this will be centered over the parent window */
1190   gtk_window_set_type_hint (GTK_WINDOW (object), GDK_WINDOW_TYPE_HINT_DIALOG);
1191
1192   g_assert (priv->connection_mgrs != NULL);
1193   g_assert (empathy_connection_managers_is_ready (priv->connection_mgrs));
1194
1195   g_signal_connect (self, "close",
1196       G_CALLBACK (account_assistant_close_cb), NULL);
1197
1198   gtk_assistant_set_forward_page_func (assistant,
1199       account_assistant_page_forward_func, self, NULL);
1200
1201   /* first page (introduction) */
1202   page = account_assistant_build_introduction_page (self);
1203   gtk_assistant_append_page (assistant, page);
1204   gtk_assistant_set_page_title (assistant, page,
1205       _("Welcome to Empathy"));
1206   gtk_assistant_set_page_type (assistant, page,
1207       GTK_ASSISTANT_PAGE_INTRO);
1208   gtk_assistant_set_page_complete (assistant, page, TRUE);
1209
1210   /* second page (import accounts) */
1211   page = account_assistant_build_import_page (self);
1212   gtk_assistant_append_page (assistant, page);
1213   gtk_assistant_set_page_title (assistant, page,
1214       _("Import your existing accounts"));
1215   gtk_assistant_set_page_complete (assistant, page, TRUE);
1216   gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONTENT);
1217   priv->import_page = page;
1218
1219   /* third page (enter account details) */
1220   page = account_assistant_build_enter_or_create_page (self);
1221   gtk_assistant_append_page (assistant, page);
1222   gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONTENT);
1223   priv->enter_or_create_page = page;
1224
1225   /* fourth page (salut details) */
1226   if (empathy_connection_managers_get_cm (priv->connection_mgrs, "salut")
1227       != NULL)
1228     {
1229       page = account_assistant_build_salut_page (self);
1230       gtk_assistant_append_page (assistant, page);
1231       gtk_assistant_set_page_title (assistant, page,
1232           _("Please enter personal details"));
1233       gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONFIRM);
1234
1235       priv->create_salut_account = TRUE;
1236     }
1237   else
1238     {
1239       page = account_assistant_build_salut_error_page (self);
1240       gtk_assistant_append_page (assistant, page);
1241       gtk_assistant_set_page_title (assistant, page, _("An error occurred"));
1242       gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_SUMMARY);
1243
1244       priv->create_salut_account = FALSE;
1245     }
1246
1247   priv->salut_page = page;
1248   priv->display_salut_page = TRUE;
1249
1250   tp_account_manager_prepare_async (priv->account_mgr, NULL,
1251       account_mgr_prepare_cb, self);
1252
1253   gtk_window_set_resizable (GTK_WINDOW (self), FALSE);
1254 }
1255
1256 GtkWidget *
1257 empathy_account_assistant_show (GtkWindow *window,
1258     EmpathyConnectionManagers *connection_mgrs)
1259 {
1260   static GtkWidget *dialog = NULL;
1261
1262   if (dialog == NULL)
1263     {
1264       dialog =  g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT,
1265           "parent-window", window,
1266           "connection-managers", connection_mgrs,
1267           NULL);
1268       g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer *) &dialog);
1269     }
1270
1271   gtk_window_present (GTK_WINDOW (dialog));
1272
1273   return dialog;
1274 }
1275
1276