2 * Copyright (C) 2005-2007 Imendio AB
3 * Copyright (C) 2007-2009 Collabora Ltd.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301 USA
20 * Authors: Martyn Russell <martyn@imendio.com>
21 * Xavier Claessens <xclaesse@gmail.com>
22 * Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
23 * Jonathan Tellier <jonathan.tellier@gmail.com>
32 #include <glib/gi18n-lib.h>
33 #include <dbus/dbus-glib.h>
35 #include <telepathy-glib/account-manager.h>
36 #include <telepathy-glib/defs.h>
37 #include <telepathy-glib/util.h>
39 #include <libempathy/empathy-utils.h>
40 #include <libempathy/empathy-connection-managers.h>
41 #include <libempathy/empathy-connectivity.h>
42 #include <libempathy/empathy-gsettings.h>
44 #include <libempathy-gtk/empathy-ui-utils.h>
45 #include <libempathy-gtk/empathy-protocol-chooser.h>
46 #include <libempathy-gtk/empathy-account-widget.h>
47 #include <libempathy-gtk/empathy-account-widget-irc.h>
48 #include <libempathy-gtk/empathy-account-widget-sip.h>
49 #include <libempathy-gtk/empathy-cell-renderer-activatable.h>
50 #include <libempathy-gtk/empathy-images.h>
52 #include "empathy-accounts-dialog.h"
53 #include "empathy-import-dialog.h"
54 #include "empathy-import-utils.h"
56 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
57 #include <libempathy/empathy-debug.h>
59 /* Flashing delay for icons (milliseconds). */
60 #define FLASH_TIMEOUT 500
62 /* The primary text of the dialog shown to the user when he is about to lose
64 #define PENDING_CHANGES_QUESTION_PRIMARY_TEXT \
65 _("There are unsaved modifications to your %s account.")
66 /* The primary text of the dialog shown to the user when he is about to lose
67 * an unsaved new account */
68 #define UNSAVED_NEW_ACCOUNT_QUESTION_PRIMARY_TEXT \
69 _("Your new account has not been saved yet.")
71 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountsDialog)
72 G_DEFINE_TYPE (EmpathyAccountsDialog, empathy_accounts_dialog, GTK_TYPE_DIALOG);
76 NOTEBOOK_PAGE_ACCOUNT = 0,
81 GtkWidget *alignment_settings;
82 GtkWidget *alignment_infobar;
84 GtkWidget *vbox_details;
86 GtkWidget *label_status;
87 GtkWidget *image_status;
89 GtkWidget *frame_no_protocol;
93 GtkWidget *button_add;
94 GtkWidget *button_remove;
95 GtkWidget *button_import;
97 GtkWidget *combobox_protocol;
98 GtkWidget *hbox_protocol;
100 GtkWidget *image_type;
101 GtkWidget *label_name;
102 GtkWidget *label_type;
103 GtkWidget *settings_widget;
105 GtkWidget *notebook_account;
109 /* We have to keep a reference on the actual EmpathyAccountWidget, not just
110 * his GtkWidget. It is the only reliable source we can query to know if
111 * there are any unsaved changes to the currently selected account. We can't
112 * look at the account settings because it does not contain everything that
113 * can be changed using the EmpathyAccountWidget. For instance, it does not
114 * contain the state of the "Enabled" checkbox. */
115 EmpathyAccountWidget *setting_widget_object;
117 gboolean connecting_show;
120 gulong settings_ready_id;
121 EmpathyAccountSettings *settings_ready;
123 TpAccountManager *account_manager;
124 EmpathyConnectionManagers *cms;
125 EmpathyConnectivity *connectivity;
127 GtkWindow *parent_window;
128 TpAccount *initial_selection;
130 /* Those are needed when changing the selected row. When a user selects
131 * another account and there are unsaved changes on the currently selected
132 * one, a confirmation message box is presented to him. Since his answer
133 * is retrieved asynchronously, we keep some information as member of the
134 * EmpathyAccountsDialog object. */
135 gboolean force_change_row;
136 GtkTreeRowReference *destination_row;
137 } EmpathyAccountsDialogPriv;
143 COL_ACCOUNT_SETTINGS,
151 static EmpathyAccountSettings * accounts_dialog_model_get_selected_settings (
152 EmpathyAccountsDialog *dialog);
154 static gboolean accounts_dialog_get_settings_iter (
155 EmpathyAccountsDialog *dialog,
156 EmpathyAccountSettings *settings,
159 static void accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog);
161 static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
162 EmpathyAccountSettings *settings);
164 static void accounts_dialog_add (EmpathyAccountsDialog *dialog,
165 EmpathyAccountSettings *settings);
167 static void accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog,
168 EmpathyAccountSettings *settings);
170 static void accounts_dialog_connection_changed_cb (TpAccount *account,
174 gchar *dbus_error_name,
176 EmpathyAccountsDialog *dialog);
178 static void accounts_dialog_presence_changed_cb (TpAccount *account,
181 gchar *status_message,
182 EmpathyAccountsDialog *dialog);
184 static void accounts_dialog_model_selection_changed (
185 GtkTreeSelection *selection,
186 EmpathyAccountsDialog *dialog);
189 accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog,
190 const gchar *display_name)
193 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
195 text = g_markup_printf_escaped ("<b>%s</b>", display_name);
196 gtk_label_set_markup (GTK_LABEL (priv->label_name), text);
202 accounts_dialog_status_infobar_set_message (EmpathyAccountsDialog *dialog,
203 const gchar *message)
205 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
206 gchar *message_markup;
208 message_markup = g_markup_printf_escaped ("<i>%s</i>", message);
209 gtk_label_set_markup (GTK_LABEL (priv->label_status), message_markup);
210 g_free (message_markup);
214 accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
217 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
218 gchar *status_message = NULL;
224 GtkTreeSelection *selection;
226 TpAccount *selected_account;
227 gboolean account_enabled;
228 gboolean creating_account;
230 view = GTK_TREE_VIEW (priv->treeview);
231 selection = gtk_tree_view_get_selection (view);
233 if (!gtk_tree_selection_get_selected (selection, &model, &iter))
236 gtk_tree_model_get (model, &iter, COL_ACCOUNT, &selected_account, -1);
237 if (selected_account != NULL)
238 g_object_unref (selected_account);
240 /* do not update the infobar when the account is not selected */
241 if (account != selected_account)
246 status = tp_account_get_connection_status (account, &reason);
247 presence = tp_account_get_current_presence (account, NULL, &status_message);
248 account_enabled = tp_account_is_enabled (account);
249 creating_account = FALSE;
251 if (status == TP_CONNECTION_STATUS_CONNECTED &&
252 (presence == TP_CONNECTION_PRESENCE_TYPE_OFFLINE ||
253 presence == TP_CONNECTION_PRESENCE_TYPE_UNSET))
254 /* If presence is Unset (CM doesn't implement SimplePresence) but we
255 * are connected, consider ourself as Available.
256 * We also check Offline because of this MC5 bug: fd.o #26060 */
257 presence = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
259 /* set presence to offline if account is disabled
260 * (else no icon is shown in infobar)*/
261 if (!account_enabled)
262 presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
266 status = TP_CONNECTION_STATUS_DISCONNECTED;
267 presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
268 account_enabled = FALSE;
269 creating_account = TRUE;
272 gtk_image_set_from_icon_name (GTK_IMAGE (priv->image_status),
273 empathy_icon_name_for_presence (presence), GTK_ICON_SIZE_SMALL_TOOLBAR);
279 case TP_CONNECTION_STATUS_CONNECTING:
280 accounts_dialog_status_infobar_set_message (dialog,
282 gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
285 gtk_spinner_start (GTK_SPINNER (priv->throbber));
286 gtk_widget_show (priv->throbber);
287 gtk_widget_hide (priv->image_status);
289 case TP_CONNECTION_STATUS_CONNECTED:
290 if (g_strcmp0 (status_message, "") == 0)
294 message = g_strdup_printf ("%s",
295 empathy_presence_get_default_message (presence));
297 accounts_dialog_status_infobar_set_message (dialog, message);
304 message = g_strdup_printf ("%s — %s",
305 empathy_presence_get_default_message (presence),
308 accounts_dialog_status_infobar_set_message (dialog, message);
311 gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
314 gtk_widget_show (priv->image_status);
315 gtk_widget_hide (priv->throbber);
317 case TP_CONNECTION_STATUS_DISCONNECTED:
318 if (reason == TP_CONNECTION_STATUS_REASON_REQUESTED)
322 message = g_strdup_printf (_("Offline — %s"),
323 empathy_account_get_error_message (account, NULL));
324 gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
325 GTK_MESSAGE_WARNING);
327 accounts_dialog_status_infobar_set_message (dialog, message);
334 message = g_strdup_printf (_("Disconnected — %s"),
335 empathy_account_get_error_message (account, NULL));
336 gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
339 accounts_dialog_status_infobar_set_message (dialog, message);
343 if (!empathy_connectivity_is_online (priv->connectivity))
344 accounts_dialog_status_infobar_set_message (dialog,
345 _("Offline — No Network Connection"));
347 gtk_spinner_stop (GTK_SPINNER (priv->throbber));
348 gtk_widget_show (priv->image_status);
349 gtk_widget_hide (priv->throbber);
352 accounts_dialog_status_infobar_set_message (dialog, _("Unknown Status"));
353 gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
354 GTK_MESSAGE_WARNING);
356 gtk_spinner_stop (GTK_SPINNER (priv->throbber));
357 gtk_widget_hide (priv->image_status);
358 gtk_widget_hide (priv->throbber);
363 accounts_dialog_status_infobar_set_message (dialog,
364 _("Offline — Account Disabled"));
366 gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
367 GTK_MESSAGE_WARNING);
368 gtk_spinner_stop (GTK_SPINNER (priv->throbber));
369 gtk_widget_show (priv->image_status);
370 gtk_widget_hide (priv->throbber);
373 gtk_widget_show (priv->label_status);
375 if (!creating_account)
376 gtk_widget_show (priv->infobar);
378 gtk_widget_hide (priv->infobar);
380 g_free (status_message);
384 empathy_account_dialog_cancel (EmpathyAccountsDialog *dialog)
388 GtkTreeSelection *selection;
390 EmpathyAccountSettings *settings;
392 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
394 view = GTK_TREE_VIEW (priv->treeview);
395 selection = gtk_tree_view_get_selection (view);
397 if (!gtk_tree_selection_get_selected (selection, &model, &iter))
400 gtk_tree_model_get (model, &iter,
401 COL_ACCOUNT_SETTINGS, &settings,
402 COL_ACCOUNT, &account, -1);
404 empathy_account_widget_discard_pending_changes (priv->setting_widget_object);
408 /* We were creating an account. We remove the selected row */
409 gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
413 /* We were modifying an account. We discard the changes by reloading the
414 * settings and the UI. */
415 accounts_dialog_update_settings (dialog, settings);
416 g_object_unref (account);
419 gtk_widget_set_sensitive (priv->treeview, TRUE);
420 gtk_widget_set_sensitive (priv->button_add, TRUE);
421 gtk_widget_set_sensitive (priv->button_remove, TRUE);
422 gtk_widget_set_sensitive (priv->button_import, TRUE);
424 if (settings != NULL)
425 g_object_unref (settings);
429 empathy_account_dialog_widget_cancelled_cb (
430 EmpathyAccountWidget *widget_object,
431 EmpathyAccountsDialog *dialog)
433 empathy_account_dialog_cancel (dialog);
437 empathy_account_dialog_account_created_cb (EmpathyAccountWidget *widget_object,
439 EmpathyAccountsDialog *dialog)
441 EmpathyAccountSettings *settings =
442 accounts_dialog_model_get_selected_settings (dialog);
443 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
445 accounts_dialog_update_settings (dialog, settings);
446 accounts_dialog_update_status_infobar (dialog,
447 empathy_account_settings_get_account (settings));
449 gtk_widget_set_sensitive (priv->treeview, TRUE);
450 gtk_widget_set_sensitive (priv->button_add, TRUE);
451 gtk_widget_set_sensitive (priv->button_remove, TRUE);
452 gtk_widget_set_sensitive (priv->button_import, TRUE);
455 g_object_unref (settings);
459 accounts_dialog_has_valid_accounts (EmpathyAccountsDialog *dialog)
461 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
466 g_object_get (priv->setting_widget_object,
467 "creating-account", &creating, NULL);
472 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
474 if (gtk_tree_model_get_iter_first (model, &iter))
475 return gtk_tree_model_iter_next (model, &iter);
481 account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog,
482 EmpathyAccountSettings *settings)
484 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
485 const gchar *icon_name;
488 priv->setting_widget_object =
489 empathy_account_widget_new_for_protocol (settings, FALSE);
491 if (accounts_dialog_has_valid_accounts (dialog))
492 empathy_account_widget_set_other_accounts_exist (
493 priv->setting_widget_object, TRUE);
495 priv->settings_widget =
496 empathy_account_widget_get_widget (priv->setting_widget_object);
498 g_signal_connect (priv->setting_widget_object, "account-created",
499 G_CALLBACK (empathy_account_dialog_account_created_cb), dialog);
500 g_signal_connect (priv->setting_widget_object, "cancelled",
501 G_CALLBACK (empathy_account_dialog_widget_cancelled_cb), dialog);
503 gtk_container_add (GTK_CONTAINER (priv->alignment_settings),
504 priv->settings_widget);
505 gtk_widget_show (priv->settings_widget);
507 icon_name = empathy_account_settings_get_icon_name (settings);
509 if (!gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
511 /* show the default icon; keep this in sync with the default
512 * one in empathy-accounts-dialog.ui.
514 icon_name = GTK_STOCK_CUT;
516 gtk_image_set_from_icon_name (GTK_IMAGE (priv->image_type),
517 icon_name, GTK_ICON_SIZE_DIALOG);
518 gtk_widget_set_tooltip_text (priv->image_type,
519 empathy_protocol_name_to_display_name
520 (empathy_account_settings_get_protocol (settings)));
521 gtk_widget_show (priv->image_type);
523 accounts_dialog_update_name_label (dialog,
524 empathy_account_settings_get_display_name (settings));
526 account = empathy_account_settings_get_account (settings);
527 accounts_dialog_update_status_infobar (dialog, account);
531 account_dialog_settings_ready_cb (EmpathyAccountSettings *settings,
533 EmpathyAccountsDialog *dialog)
535 if (empathy_account_settings_is_ready (settings))
536 account_dialog_create_settings_widget (dialog, settings);
540 accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog)
544 GtkTreeSelection *selection;
546 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
549 view = GTK_TREE_VIEW (priv->treeview);
550 model = gtk_tree_view_get_model (view);
552 if (gtk_tree_model_get_iter_first (model, &iter))
554 selection = gtk_tree_view_get_selection (view);
555 gtk_tree_selection_select_iter (selection, &iter);
559 accounts_dialog_update_settings (dialog, NULL);
564 accounts_dialog_has_pending_change (EmpathyAccountsDialog *dialog,
569 GtkTreeSelection *selection;
570 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
572 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
574 if (gtk_tree_selection_get_selected (selection, &model, &iter))
575 gtk_tree_model_get (model, &iter, COL_ACCOUNT, account, -1);
577 return priv->setting_widget_object != NULL
578 && empathy_account_widget_contains_pending_changes (
579 priv->setting_widget_object);
583 accounts_dialog_setup_ui_to_add_account (EmpathyAccountsDialog *dialog)
585 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
586 EmpathyAccountSettings *settings;
588 const gchar *name, *display_name;
589 TpConnectionManager *cm;
590 TpConnectionManagerProtocol *proto;
591 gboolean is_gtalk, is_facebook;
593 cm = empathy_protocol_chooser_dup_selected (
594 EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto, &is_gtalk,
601 else if (is_facebook)
606 display_name = empathy_protocol_name_to_display_name (name);
607 if (display_name == NULL)
608 display_name = proto->name;
611 /* To translator: %s is the name of the protocol, such as "Google Talk" or
614 str = g_strdup_printf (_("New %s account"), display_name);
615 settings = empathy_account_settings_new (cm->name, proto->name, str);
621 empathy_account_settings_set_icon_name_async (settings, "im-google-talk",
623 /* We should not have to set the server but that may cause issue with
625 empathy_account_settings_set_string (settings, "server",
628 else if (is_facebook)
630 empathy_account_settings_set_icon_name_async (settings, "im-facebook",
633 empathy_account_settings_set_string (settings, "server",
634 "chat.facebook.com");
637 accounts_dialog_add (dialog, settings);
638 accounts_dialog_model_set_selected (dialog, settings);
640 gtk_widget_show_all (priv->hbox_protocol);
642 g_object_unref (settings);
647 accounts_dialog_protocol_changed_cb (GtkWidget *widget,
648 EmpathyAccountsDialog *dialog)
650 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
651 GtkTreeSelection *selection;
655 EmpathyAccountSettings *settings;
656 gchar *account = NULL, *password = NULL;
658 /* The "changed" signal is fired during the initiation of the
659 * EmpathyProtocolChooser while populating the widget. Such signals should
660 * be ignored so we check if we are actually creating a new account. */
661 if (priv->setting_widget_object == NULL)
664 g_object_get (priv->setting_widget_object,
665 "creating-account", &creating, NULL);
669 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
671 if (!gtk_tree_selection_get_selected (selection, &model, &iter))
674 /* Save "account" and "password" parameters */
675 g_object_get (priv->setting_widget_object, "settings", &settings, NULL);
677 if (settings != NULL)
679 account = g_strdup (empathy_account_settings_get_string (settings,
681 password = g_strdup (empathy_account_settings_get_string (settings,
683 g_object_unref (settings);
686 /* We are creating a new widget to replace the current one, don't ask
687 * confirmation to the user. */
688 priv->force_change_row = TRUE;
690 /* We'll update the selection after we create the new account widgets;
691 * updating it right now causes problems for the # of accounts = zero case */
692 g_signal_handlers_block_by_func (selection,
693 accounts_dialog_model_selection_changed, dialog);
695 gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
697 g_signal_handlers_unblock_by_func (selection,
698 accounts_dialog_model_selection_changed, dialog);
700 accounts_dialog_setup_ui_to_add_account (dialog);
702 /* Restore "account" and "password" parameters in the new widget */
705 empathy_account_widget_set_account_param (priv->setting_widget_object,
710 if (password != NULL)
712 empathy_account_widget_set_password_param (priv->setting_widget_object,
719 accounts_dialog_show_question_dialog (EmpathyAccountsDialog *dialog,
720 const gchar *primary_text,
721 const gchar *secondary_text,
722 GCallback response_callback,
724 const gchar *first_button_text,
728 GtkWidget *message_dialog;
729 const gchar *button_text;
731 message_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog),
732 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
733 GTK_MESSAGE_QUESTION,
737 gtk_message_dialog_format_secondary_text (
738 GTK_MESSAGE_DIALOG (message_dialog), "%s", secondary_text);
740 va_start (button_args, first_button_text);
741 for (button_text = first_button_text;
743 button_text = va_arg (button_args, const gchar *))
746 response_id = va_arg (button_args, gint);
748 gtk_dialog_add_button (GTK_DIALOG (message_dialog), button_text,
751 va_end (button_args);
753 g_signal_connect (message_dialog, "response", response_callback, user_data);
755 gtk_widget_show (message_dialog);
759 accounts_dialog_add_pending_changes_response_cb (GtkDialog *message_dialog,
763 EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (user_data);
764 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
766 gtk_widget_destroy (GTK_WIDGET (message_dialog));
768 if (response_id == GTK_RESPONSE_YES)
770 empathy_account_widget_discard_pending_changes (
771 priv->setting_widget_object);
772 accounts_dialog_setup_ui_to_add_account (dialog);
777 get_dialog_primary_text (TpAccount *account)
781 /* Existing account */
782 return g_strdup_printf (PENDING_CHANGES_QUESTION_PRIMARY_TEXT,
783 tp_account_get_display_name (account));
787 /* Newly created account */
788 return g_strdup (UNSAVED_NEW_ACCOUNT_QUESTION_PRIMARY_TEXT);
793 accounts_dialog_button_add_clicked_cb (GtkWidget *button,
794 EmpathyAccountsDialog *dialog)
796 TpAccount *account = NULL;
797 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
799 if (accounts_dialog_has_pending_change (dialog, &account))
801 gchar *question_dialog_primary_text = get_dialog_primary_text (account);
803 accounts_dialog_show_question_dialog (dialog,
804 question_dialog_primary_text,
805 _("You are about to create a new account, which will discard\n"
806 "your changes. Are you sure you want to proceed?"),
807 G_CALLBACK (accounts_dialog_add_pending_changes_response_cb),
809 GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
810 GTK_STOCK_DISCARD, GTK_RESPONSE_YES, NULL);
812 g_free (question_dialog_primary_text);
816 accounts_dialog_setup_ui_to_add_account (dialog);
817 gtk_widget_set_sensitive (priv->treeview, FALSE);
818 gtk_widget_set_sensitive (priv->button_add, FALSE);
819 gtk_widget_set_sensitive (priv->button_remove, FALSE);
820 gtk_widget_set_sensitive (priv->button_import, FALSE);
824 g_object_unref (account);
828 accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
829 EmpathyAccountSettings *settings)
831 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
833 if (priv->settings_ready != NULL)
835 g_signal_handler_disconnect (priv->settings_ready,
836 priv->settings_ready_id);
837 priv->settings_ready = NULL;
838 priv->settings_ready_id = 0;
845 GtkTreeSelection *selection;
847 view = GTK_TREE_VIEW (priv->treeview);
848 model = gtk_tree_view_get_model (view);
849 selection = gtk_tree_view_get_selection (view);
851 if (gtk_tree_model_iter_n_children (model, NULL) > 0)
853 /* We have configured accounts, select the first one if there
854 * is no other account selected already. */
855 if (!gtk_tree_selection_get_selected (selection, NULL, NULL))
856 accounts_dialog_model_select_first (dialog);
860 if (empathy_connection_managers_get_cms_num (priv->cms) > 0)
862 /* We have no account configured but we have some
863 * profiles installed. The user obviously wants to add
864 * an account. Click on the Add button for him. */
865 accounts_dialog_button_add_clicked_cb (priv->button_add,
870 /* No account and no profile, warn the user */
871 gtk_widget_hide (priv->vbox_details);
872 gtk_widget_show (priv->frame_no_protocol);
873 gtk_widget_set_sensitive (priv->button_add, FALSE);
877 /* We have an account selected, destroy old settings and create a new
878 * one for the account selected */
879 gtk_widget_hide (priv->frame_no_protocol);
880 gtk_widget_show (priv->vbox_details);
881 gtk_widget_hide (priv->hbox_protocol);
883 if (priv->settings_widget)
885 gtk_widget_destroy (priv->settings_widget);
886 priv->settings_widget = NULL;
889 if (empathy_account_settings_is_ready (settings))
891 account_dialog_create_settings_widget (dialog, settings);
895 priv->settings_ready = settings;
896 priv->settings_ready_id =
897 g_signal_connect (settings, "notify::ready",
898 G_CALLBACK (account_dialog_settings_ready_cb), dialog);
904 accounts_dialog_name_editing_started_cb (GtkCellRenderer *renderer,
905 GtkCellEditable *editable,
907 EmpathyAccountsDialog *dialog)
909 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
911 if (priv->connecting_id)
912 g_source_remove (priv->connecting_id);
914 DEBUG ("Editing account name started; stopping flashing");
918 get_status_icon_for_account (EmpathyAccountsDialog *self,
921 EmpathyAccountsDialogPriv *priv = GET_PRIV (self);
922 TpConnectionStatus status;
923 TpConnectionStatusReason reason;
924 TpConnectionPresenceType presence;
927 return empathy_icon_name_for_presence (TP_CONNECTION_PRESENCE_TYPE_OFFLINE);
929 if (!tp_account_is_enabled (account))
930 return empathy_icon_name_for_presence (TP_CONNECTION_PRESENCE_TYPE_OFFLINE);
932 status = tp_account_get_connection_status (account, &reason);
934 if (status == TP_CONNECTION_STATUS_DISCONNECTED)
936 if (reason != TP_CONNECTION_STATUS_REASON_REQUESTED)
937 /* An error occured */
938 return GTK_STOCK_DIALOG_ERROR;
940 presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
942 else if (status == TP_CONNECTION_STATUS_CONNECTING)
944 /* Account is connecting. Display a blinking account alternating between
945 * the offline icon and the requested presence. */
946 if (priv->connecting_show)
947 presence = tp_account_get_requested_presence (account, NULL, NULL);
949 presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
953 /* status == TP_CONNECTION_STATUS_CONNECTED */
954 presence = tp_account_get_current_presence (account, NULL, NULL);
956 /* If presence is Unset (CM doesn't implement SimplePresence),
957 * display the 'available' icon.
958 * We also check Offline because of this MC5 bug: fd.o #26060 */
959 if (presence == TP_CONNECTION_PRESENCE_TYPE_OFFLINE ||
960 presence == TP_CONNECTION_PRESENCE_TYPE_UNSET)
961 presence = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
964 return empathy_icon_name_for_presence (presence);
968 accounts_dialog_model_status_pixbuf_data_func (GtkTreeViewColumn *tree_column,
969 GtkCellRenderer *cell,
972 EmpathyAccountsDialog *dialog)
976 gtk_tree_model_get (model, iter, COL_ACCOUNT, &account, -1);
979 "icon-name", get_status_icon_for_account (dialog, account),
983 g_object_unref (account);
987 accounts_dialog_model_protocol_pixbuf_data_func (GtkTreeViewColumn *tree_column,
988 GtkCellRenderer *cell,
991 EmpathyAccountsDialog *dialog)
993 EmpathyAccountSettings *settings;
996 TpConnectionStatus status;
998 gtk_tree_model_get (model, iter,
1000 COL_ACCOUNT_SETTINGS, &settings,
1003 icon_name = empathy_account_settings_get_icon_name (settings);
1004 pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
1011 g_object_unref (settings);
1014 g_object_unref (pixbuf);
1018 accounts_dialog_row_changed_foreach (GtkTreeModel *model,
1023 gtk_tree_model_row_changed (model, path, iter);
1029 accounts_dialog_flash_connecting_cb (EmpathyAccountsDialog *dialog)
1032 GtkTreeModel *model;
1033 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1035 priv->connecting_show = !priv->connecting_show;
1037 view = GTK_TREE_VIEW (priv->treeview);
1038 model = gtk_tree_view_get_model (view);
1040 gtk_tree_model_foreach (model, accounts_dialog_row_changed_foreach, NULL);
1046 accounts_dialog_name_edited_cb (GtkCellRendererText *renderer,
1049 EmpathyAccountsDialog *dialog)
1051 EmpathyAccountSettings *settings;
1052 GtkTreeModel *model;
1053 GtkTreePath *treepath;
1055 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1056 gboolean connecting;
1058 empathy_account_manager_get_accounts_connected (&connecting);
1062 priv->connecting_id = g_timeout_add (FLASH_TIMEOUT,
1063 (GSourceFunc) accounts_dialog_flash_connecting_cb,
1067 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
1068 treepath = gtk_tree_path_new_from_string (path);
1069 gtk_tree_model_get_iter (model, &iter, treepath);
1070 gtk_tree_model_get (model, &iter,
1071 COL_ACCOUNT_SETTINGS, &settings,
1073 gtk_list_store_set (GTK_LIST_STORE (model), &iter,
1076 gtk_tree_path_free (treepath);
1078 empathy_account_settings_set_display_name_async (settings, new_text,
1080 g_object_set (settings, "display-name-overridden", TRUE, NULL);
1081 g_object_unref (settings);
1085 accounts_dialog_delete_account_response_cb (GtkDialog *message_dialog,
1090 GtkTreeModel *model;
1092 GtkTreeSelection *selection;
1093 EmpathyAccountsDialog *account_dialog = EMPATHY_ACCOUNTS_DIALOG (user_data);
1094 EmpathyAccountsDialogPriv *priv = GET_PRIV (account_dialog);
1096 if (response_id == GTK_RESPONSE_YES)
1098 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
1100 if (!gtk_tree_selection_get_selected (selection, &model, &iter))
1103 gtk_tree_model_get (model, &iter, COL_ACCOUNT, &account, -1);
1105 if (account != NULL)
1107 tp_account_remove_async (account, NULL, NULL);
1108 g_object_unref (account);
1112 /* No need to call accounts_dialog_model_selection_changed while
1113 * removing as we are going to call accounts_dialog_model_select_first
1114 * right after which will update the selection. */
1115 g_signal_handlers_block_by_func (selection,
1116 accounts_dialog_model_selection_changed, account_dialog);
1118 gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
1120 g_signal_handlers_unblock_by_func (selection,
1121 accounts_dialog_model_selection_changed, account_dialog);
1123 accounts_dialog_model_select_first (account_dialog);
1126 gtk_widget_destroy (GTK_WIDGET (message_dialog));
1130 accounts_dialog_remove_account_iter (EmpathyAccountsDialog *dialog,
1133 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1135 GtkTreeModel *model;
1136 gchar *question_dialog_primary_text;
1138 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
1140 gtk_tree_model_get (model, iter, COL_ACCOUNT, &account, -1);
1142 if (account == NULL || !tp_account_is_valid (account))
1144 if (account != NULL)
1145 g_object_unref (account);
1146 gtk_list_store_remove (GTK_LIST_STORE (model), iter);
1147 accounts_dialog_model_select_first (dialog);
1151 question_dialog_primary_text = g_strdup_printf (
1152 _("Do you want to remove %s from your computer?"),
1153 tp_account_get_display_name (account));
1155 accounts_dialog_show_question_dialog (dialog, question_dialog_primary_text,
1156 _("This will not remove your account on the server."),
1157 G_CALLBACK (accounts_dialog_delete_account_response_cb),
1159 GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
1160 GTK_STOCK_REMOVE, GTK_RESPONSE_YES, NULL);
1162 g_free (question_dialog_primary_text);
1163 g_object_unref (account);
1167 accounts_dialog_button_remove_clicked_cb (GtkWidget *button,
1168 EmpathyAccountsDialog *dialog)
1170 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1172 GtkTreeModel *model;
1173 GtkTreeSelection *selection;
1176 view = GTK_TREE_VIEW (priv->treeview);
1177 model = gtk_tree_view_get_model (view);
1178 selection = gtk_tree_view_get_selection (view);
1179 if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
1182 accounts_dialog_remove_account_iter (dialog, &iter);
1187 accounts_dialog_view_delete_activated_cb (EmpathyCellRendererActivatable *cell,
1188 const gchar *path_string,
1189 EmpathyAccountsDialog *dialog)
1191 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1192 GtkTreeModel *model;
1195 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
1196 if (!gtk_tree_model_get_iter_from_string (model, &iter, path_string))
1199 accounts_dialog_remove_account_iter (dialog, &iter);
1201 #endif /* HAVE_MEEGO */
1204 accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog)
1207 GtkTreeViewColumn *column;
1208 GtkCellRenderer *cell;
1209 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1211 view = GTK_TREE_VIEW (priv->treeview);
1212 gtk_tree_view_set_headers_visible (view, FALSE);
1214 /* Account column */
1215 column = gtk_tree_view_column_new ();
1216 gtk_tree_view_column_set_expand (column, TRUE);
1217 gtk_tree_view_append_column (view, column);
1219 /* Status icon renderer */
1220 cell = gtk_cell_renderer_pixbuf_new ();
1221 gtk_tree_view_column_pack_start (column, cell, FALSE);
1222 gtk_tree_view_column_set_cell_data_func (column, cell,
1223 (GtkTreeCellDataFunc)
1224 accounts_dialog_model_status_pixbuf_data_func,
1228 /* Protocol icon renderer */
1229 cell = gtk_cell_renderer_pixbuf_new ();
1230 gtk_tree_view_column_pack_start (column, cell, FALSE);
1231 gtk_tree_view_column_set_cell_data_func (column, cell,
1232 (GtkTreeCellDataFunc)
1233 accounts_dialog_model_protocol_pixbuf_data_func,
1238 cell = gtk_cell_renderer_text_new ();
1240 "ellipsize", PANGO_ELLIPSIZE_END,
1244 gtk_tree_view_column_pack_start (column, cell, TRUE);
1245 gtk_tree_view_column_add_attribute (column, cell, "text", COL_NAME);
1246 g_signal_connect (cell, "edited",
1247 G_CALLBACK (accounts_dialog_name_edited_cb),
1249 g_signal_connect (cell, "editing-started",
1250 G_CALLBACK (accounts_dialog_name_editing_started_cb),
1252 g_object_set (cell, "ypad", 4, NULL);
1256 cell = empathy_cell_renderer_activatable_new ();
1257 gtk_tree_view_column_pack_start (column, cell, FALSE);
1259 "icon-name", GTK_STOCK_DELETE,
1260 "show-on-select", TRUE,
1263 g_signal_connect (cell, "path-activated",
1264 G_CALLBACK (accounts_dialog_view_delete_activated_cb),
1266 #endif /* HAVE_MEEGO */
1269 static EmpathyAccountSettings *
1270 accounts_dialog_model_get_selected_settings (EmpathyAccountsDialog *dialog)
1273 GtkTreeModel *model;
1274 GtkTreeSelection *selection;
1276 EmpathyAccountSettings *settings;
1277 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1279 view = GTK_TREE_VIEW (priv->treeview);
1280 selection = gtk_tree_view_get_selection (view);
1282 if (!gtk_tree_selection_get_selected (selection, &model, &iter))
1285 gtk_tree_model_get (model, &iter,
1286 COL_ACCOUNT_SETTINGS, &settings, -1);
1292 accounts_dialog_model_selection_changed (GtkTreeSelection *selection,
1293 EmpathyAccountsDialog *dialog)
1295 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1296 EmpathyAccountSettings *settings;
1297 GtkTreeModel *model;
1299 gboolean is_selection;
1300 gboolean creating = FALSE;
1302 is_selection = gtk_tree_selection_get_selected (selection, &model, &iter);
1304 settings = accounts_dialog_model_get_selected_settings (dialog);
1305 accounts_dialog_update_settings (dialog, settings);
1307 if (settings != NULL)
1308 g_object_unref (settings);
1310 if (priv->setting_widget_object != NULL)
1312 g_object_get (priv->setting_widget_object,
1313 "creating-account", &creating, NULL);
1316 /* Update remove button sensitivity */
1317 gtk_widget_set_sensitive (priv->button_remove, is_selection && !creating &&
1322 accounts_dialog_selection_change_response_cb (GtkDialog *message_dialog,
1324 gpointer *user_data)
1326 EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (user_data);
1327 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1329 gtk_widget_destroy (GTK_WIDGET (message_dialog));
1331 if (response_id == GTK_RESPONSE_YES && priv->destination_row != NULL)
1333 /* The user wants to lose unsaved changes to the currently selected
1334 * account and select another account. We discard the changes and
1335 * select the other account. */
1337 GtkTreeSelection *selection;
1339 priv->force_change_row = TRUE;
1340 empathy_account_widget_discard_pending_changes (
1341 priv->setting_widget_object);
1343 path = gtk_tree_row_reference_get_path (priv->destination_row);
1344 selection = gtk_tree_view_get_selection (
1345 GTK_TREE_VIEW (priv->treeview));
1349 /* This will trigger a call to
1350 * accounts_dialog_account_selection_change() */
1351 gtk_tree_selection_select_path (selection, path);
1352 gtk_tree_path_free (path);
1355 gtk_tree_row_reference_free (priv->destination_row);
1359 priv->force_change_row = FALSE;
1364 accounts_dialog_account_selection_change (GtkTreeSelection *selection,
1365 GtkTreeModel *model,
1367 gboolean path_currently_selected,
1370 TpAccount *account = NULL;
1371 EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (data);
1372 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1375 if (priv->force_change_row)
1377 /* We came back here because the user wants to discard changes to his
1378 * modified account. The changes have already been discarded so we
1379 * just change the selected row. */
1380 priv->force_change_row = FALSE;
1384 if (accounts_dialog_has_pending_change (dialog, &account))
1386 /* The currently selected account has some unsaved changes. We ask
1387 * the user if he really wants to lose his changes and select another
1389 gchar *question_dialog_primary_text = get_dialog_primary_text (account);
1390 priv->destination_row = gtk_tree_row_reference_new (model, path);
1392 accounts_dialog_show_question_dialog (dialog,
1393 question_dialog_primary_text,
1394 _("You are about to select another account, which will discard\n"
1395 "your changes. Are you sure you want to proceed?"),
1396 G_CALLBACK (accounts_dialog_selection_change_response_cb),
1398 GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
1399 GTK_STOCK_DISCARD, GTK_RESPONSE_YES, NULL);
1401 g_free (question_dialog_primary_text);
1409 if (account != NULL)
1410 g_object_unref (account);
1416 accounts_dialog_model_setup (EmpathyAccountsDialog *dialog)
1418 GtkListStore *store;
1419 GtkTreeSelection *selection;
1420 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1422 store = gtk_list_store_new (COL_COUNT,
1423 G_TYPE_STRING, /* name */
1424 G_TYPE_UINT, /* status */
1425 TP_TYPE_ACCOUNT, /* account */
1426 EMPATHY_TYPE_ACCOUNT_SETTINGS); /* settings */
1428 gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview),
1429 GTK_TREE_MODEL (store));
1431 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
1432 gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
1433 gtk_tree_selection_set_select_function (selection,
1434 accounts_dialog_account_selection_change, dialog, NULL);
1436 g_signal_connect (selection, "changed",
1437 G_CALLBACK (accounts_dialog_model_selection_changed),
1440 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
1441 COL_NAME, GTK_SORT_ASCENDING);
1443 accounts_dialog_model_add_columns (dialog);
1445 g_object_unref (store);
1449 accounts_dialog_get_settings_iter (EmpathyAccountsDialog *dialog,
1450 EmpathyAccountSettings *settings,
1454 GtkTreeSelection *selection;
1455 GtkTreeModel *model;
1457 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1459 /* Update the status in the model */
1460 view = GTK_TREE_VIEW (priv->treeview);
1461 selection = gtk_tree_view_get_selection (view);
1462 model = gtk_tree_view_get_model (view);
1464 for (ok = gtk_tree_model_get_iter_first (model, iter);
1466 ok = gtk_tree_model_iter_next (model, iter))
1468 EmpathyAccountSettings *this_settings;
1471 gtk_tree_model_get (model, iter,
1472 COL_ACCOUNT_SETTINGS, &this_settings,
1475 equal = (this_settings == settings);
1476 g_object_unref (this_settings);
1486 accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog,
1491 GtkTreeSelection *selection;
1492 GtkTreeModel *model;
1494 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1496 /* Update the status in the model */
1497 view = GTK_TREE_VIEW (priv->treeview);
1498 selection = gtk_tree_view_get_selection (view);
1499 model = gtk_tree_view_get_model (view);
1501 for (ok = gtk_tree_model_get_iter_first (model, iter);
1503 ok = gtk_tree_model_iter_next (model, iter))
1505 EmpathyAccountSettings *settings;
1508 gtk_tree_model_get (model, iter,
1509 COL_ACCOUNT_SETTINGS, &settings,
1512 equal = empathy_account_settings_has_account (settings, account);
1513 g_object_unref (settings);
1523 accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog,
1524 EmpathyAccountSettings *settings)
1526 GtkTreeSelection *selection;
1528 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1530 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
1531 if (accounts_dialog_get_settings_iter (dialog, settings, &iter))
1532 gtk_tree_selection_select_iter (selection, &iter);
1535 accounts_dialog_add (EmpathyAccountsDialog *dialog,
1536 EmpathyAccountSettings *settings)
1538 GtkTreeModel *model;
1541 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1543 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
1544 name = empathy_account_settings_get_display_name (settings);
1546 gtk_list_store_append (GTK_LIST_STORE (model), &iter);
1548 gtk_list_store_set (GTK_LIST_STORE (model), &iter,
1550 COL_STATUS, TP_CONNECTION_STATUS_DISCONNECTED,
1551 COL_ACCOUNT_SETTINGS, settings,
1556 accounts_dialog_connection_changed_cb (TpAccount *account,
1560 gchar *dbus_error_name,
1561 GHashTable *details,
1562 EmpathyAccountsDialog *dialog)
1564 GtkTreeModel *model;
1567 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1569 /* Update the status-infobar in the details view */
1570 accounts_dialog_update_status_infobar (dialog, account);
1572 /* Update the status in the model */
1573 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
1575 if (accounts_dialog_get_account_iter (dialog, account, &iter))
1579 gtk_list_store_set (GTK_LIST_STORE (model), &iter,
1580 COL_STATUS, current,
1583 path = gtk_tree_model_get_path (model, &iter);
1584 gtk_tree_model_row_changed (model, path, &iter);
1585 gtk_tree_path_free (path);
1588 empathy_account_manager_get_accounts_connected (&found);
1590 if (!found && priv->connecting_id)
1592 g_source_remove (priv->connecting_id);
1593 priv->connecting_id = 0;
1596 if (found && !priv->connecting_id)
1597 priv->connecting_id = g_timeout_add (FLASH_TIMEOUT,
1598 (GSourceFunc) accounts_dialog_flash_connecting_cb,
1603 update_account_in_treeview (EmpathyAccountsDialog *self,
1606 EmpathyAccountsDialogPriv *priv = GET_PRIV (self);
1608 GtkTreeModel *model;
1610 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
1611 if (accounts_dialog_get_account_iter (self, account, &iter))
1615 path = gtk_tree_model_get_path (model, &iter);
1616 gtk_tree_model_row_changed (model, path, &iter);
1617 gtk_tree_path_free (path);
1622 accounts_dialog_presence_changed_cb (TpAccount *account,
1625 gchar *status_message,
1626 EmpathyAccountsDialog *dialog)
1628 /* Update the status-infobar in the details view */
1629 accounts_dialog_update_status_infobar (dialog, account);
1631 update_account_in_treeview (dialog, account);
1635 accounts_dialog_account_display_name_changed_cb (TpAccount *account,
1639 const gchar *display_name;
1641 GtkTreeModel *model;
1642 EmpathyAccountSettings *settings;
1643 TpAccount *selected_account;
1644 EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (user_data);
1645 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1647 display_name = tp_account_get_display_name (account);
1648 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
1649 settings = accounts_dialog_model_get_selected_settings (dialog);
1650 if (settings == NULL)
1653 selected_account = empathy_account_settings_get_account (settings);
1655 if (accounts_dialog_get_account_iter (dialog, account, &iter))
1657 gtk_list_store_set (GTK_LIST_STORE (model), &iter,
1658 COL_NAME, display_name,
1662 if (selected_account == account)
1663 accounts_dialog_update_name_label (dialog, display_name);
1665 g_object_unref (settings);
1669 accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
1672 EmpathyAccountSettings *settings;
1673 GtkTreeModel *model;
1675 TpConnectionStatus status;
1678 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1680 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
1681 status = tp_account_get_connection_status (account, NULL);
1682 name = tp_account_get_display_name (account);
1683 enabled = tp_account_is_enabled (account);
1685 settings = empathy_account_settings_new_for_account (account);
1687 if (!accounts_dialog_get_account_iter (dialog, account, &iter))
1688 gtk_list_store_append (GTK_LIST_STORE (model), &iter);
1690 gtk_list_store_set (GTK_LIST_STORE (model), &iter,
1693 COL_ACCOUNT, account,
1694 COL_ACCOUNT_SETTINGS, settings,
1697 accounts_dialog_connection_changed_cb (account,
1700 TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED,
1705 tp_g_signal_connect_object (account, "notify::display-name",
1706 G_CALLBACK (accounts_dialog_account_display_name_changed_cb),
1709 tp_g_signal_connect_object (account, "status-changed",
1710 G_CALLBACK (accounts_dialog_connection_changed_cb), dialog, 0);
1711 tp_g_signal_connect_object (account, "presence-changed",
1712 G_CALLBACK (accounts_dialog_presence_changed_cb), dialog, 0);
1714 g_object_unref (settings);
1718 account_prepare_cb (GObject *source_object,
1719 GAsyncResult *result,
1722 EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (user_data);
1723 TpAccount *account = TP_ACCOUNT (source_object);
1724 GError *error = NULL;
1726 if (!tp_account_prepare_finish (account, result, &error))
1728 DEBUG ("Failed to prepare account: %s", error->message);
1729 g_error_free (error);
1733 accounts_dialog_add_account (dialog, account);
1737 accounts_dialog_account_validity_changed_cb (TpAccountManager *manager,
1740 EmpathyAccountsDialog *dialog)
1742 tp_account_prepare_async (account, NULL, account_prepare_cb, dialog);
1746 accounts_dialog_accounts_model_row_inserted_cb (GtkTreeModel *model,
1749 EmpathyAccountsDialog *dialog)
1751 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1753 if (priv->setting_widget_object != NULL &&
1754 accounts_dialog_has_valid_accounts (dialog))
1756 empathy_account_widget_set_other_accounts_exist (
1757 priv->setting_widget_object, TRUE);
1762 accounts_dialog_accounts_model_row_deleted_cb (GtkTreeModel *model,
1764 EmpathyAccountsDialog *dialog)
1766 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1768 if (priv->setting_widget_object != NULL &&
1769 !accounts_dialog_has_valid_accounts (dialog))
1771 empathy_account_widget_set_other_accounts_exist (
1772 priv->setting_widget_object, FALSE);
1777 accounts_dialog_account_removed_cb (TpAccountManager *manager,
1779 EmpathyAccountsDialog *dialog)
1782 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1784 if (accounts_dialog_get_account_iter (dialog, account, &iter))
1786 gtk_list_store_remove (GTK_LIST_STORE (
1787 gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview))), &iter);
1792 enable_or_disable_account (EmpathyAccountsDialog *dialog,
1796 GtkTreeModel *model;
1797 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1799 /* Update the status in the model */
1800 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
1802 /* Update the status-infobar in the details view */
1803 accounts_dialog_update_status_infobar (dialog, account);
1805 DEBUG ("Account %s is now %s",
1806 tp_account_get_display_name (account),
1807 enabled ? "enabled" : "disabled");
1811 accounts_dialog_account_disabled_cb (TpAccountManager *manager,
1813 EmpathyAccountsDialog *dialog)
1815 enable_or_disable_account (dialog, account, FALSE);
1816 update_account_in_treeview (dialog, account);
1820 accounts_dialog_account_enabled_cb (TpAccountManager *manager,
1822 EmpathyAccountsDialog *dialog)
1824 enable_or_disable_account (dialog, account, TRUE);
1828 accounts_dialog_button_import_clicked_cb (GtkWidget *button,
1829 EmpathyAccountsDialog *dialog)
1831 GtkWidget *import_dialog;
1833 import_dialog = empathy_import_dialog_new (GTK_WINDOW (dialog),
1835 gtk_widget_show (import_dialog);
1839 accounts_dialog_close_response_cb (GtkDialog *message_dialog,
1843 GtkWidget *account_dialog = GTK_WIDGET (user_data);
1845 gtk_widget_destroy (GTK_WIDGET (message_dialog));
1847 if (response_id == GTK_RESPONSE_YES)
1848 gtk_widget_destroy (account_dialog);
1852 accounts_dialog_delete_event_cb (GtkWidget *widget,
1854 EmpathyAccountsDialog *dialog)
1856 /* we maunally handle responses to delete events */
1861 accounts_dialog_set_selected_account (EmpathyAccountsDialog *dialog,
1864 GtkTreeSelection *selection;
1866 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1868 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
1869 if (accounts_dialog_get_account_iter (dialog, account, &iter))
1870 gtk_tree_selection_select_iter (selection, &iter);
1874 finished_loading (EmpathyAccountsDialog *self)
1876 EmpathyAccountsDialogPriv *priv = GET_PRIV (self);
1877 GtkTreeSelection *selection;
1878 gboolean has_selected;
1880 priv->loading = FALSE;
1882 gtk_widget_set_sensitive (priv->button_add, TRUE);
1883 gtk_widget_set_sensitive (priv->button_import, TRUE);
1884 gtk_widget_set_sensitive (priv->treeview, TRUE);
1886 /* Sensitive the remove button if there is an account selected */
1887 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
1888 has_selected = gtk_tree_selection_get_selected (selection, NULL, NULL);
1889 gtk_widget_set_sensitive (priv->button_remove, has_selected);
1891 gtk_spinner_stop (GTK_SPINNER (priv->spinner));
1892 gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook_account),
1893 NOTEBOOK_PAGE_ACCOUNT);
1897 accounts_dialog_cms_prepare_cb (GObject *source,
1898 GAsyncResult *result,
1901 EmpathyConnectionManagers *cms = EMPATHY_CONNECTION_MANAGERS (source);
1902 EmpathyAccountsDialog *dialog = user_data;
1903 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1905 if (!empathy_connection_managers_prepare_finish (cms, result, NULL))
1908 accounts_dialog_update_settings (dialog, NULL);
1910 if (priv->initial_selection != NULL)
1912 accounts_dialog_set_selected_account (dialog, priv->initial_selection);
1913 g_object_unref (priv->initial_selection);
1914 priv->initial_selection = NULL;
1918 finished_loading (dialog);
1922 accounts_dialog_accounts_setup (EmpathyAccountsDialog *dialog)
1924 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
1925 GList *accounts, *l;
1927 g_signal_connect (priv->account_manager, "account-validity-changed",
1928 G_CALLBACK (accounts_dialog_account_validity_changed_cb),
1930 g_signal_connect (priv->account_manager, "account-removed",
1931 G_CALLBACK (accounts_dialog_account_removed_cb),
1933 g_signal_connect (priv->account_manager, "account-enabled",
1934 G_CALLBACK (accounts_dialog_account_enabled_cb),
1936 g_signal_connect (priv->account_manager, "account-disabled",
1937 G_CALLBACK (accounts_dialog_account_disabled_cb),
1940 /* Add existing accounts */
1941 accounts = tp_account_manager_get_valid_accounts (priv->account_manager);
1942 for (l = accounts; l; l = l->next)
1944 accounts_dialog_add_account (dialog, l->data);
1946 g_list_free (accounts);
1948 priv->cms = empathy_connection_managers_dup_singleton ();
1950 empathy_connection_managers_prepare_async (priv->cms,
1951 accounts_dialog_cms_prepare_cb, dialog);
1953 accounts_dialog_model_select_first (dialog);
1957 accounts_dialog_manager_ready_cb (GObject *source_object,
1958 GAsyncResult *result,
1961 TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
1962 GError *error = NULL;
1964 if (!tp_account_manager_prepare_finish (manager, result, &error))
1966 DEBUG ("Failed to prepare account manager: %s", error->message);
1967 g_error_free (error);
1971 accounts_dialog_accounts_setup (user_data);
1975 dialog_response_cb (GtkWidget *widget,
1979 EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (widget);
1981 if (response_id == GTK_RESPONSE_HELP)
1983 empathy_url_show (widget, "ghelp:empathy?accounts-window");
1985 else if (response_id == GTK_RESPONSE_CLOSE ||
1986 response_id == GTK_RESPONSE_DELETE_EVENT)
1988 TpAccount *account = NULL;
1990 if (accounts_dialog_has_pending_change (dialog, &account))
1992 gchar *question_dialog_primary_text = get_dialog_primary_text (
1995 accounts_dialog_show_question_dialog (dialog,
1996 question_dialog_primary_text,
1997 _("You are about to close the window, which will discard\n"
1998 "your changes. Are you sure you want to proceed?"),
1999 G_CALLBACK (accounts_dialog_close_response_cb),
2001 GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
2002 GTK_STOCK_DISCARD, GTK_RESPONSE_YES, NULL);
2004 g_free (question_dialog_primary_text);
2008 gtk_widget_destroy (widget);
2011 if (account != NULL)
2012 g_object_unref (account);
2017 accounts_dialog_build_ui (EmpathyAccountsDialog *dialog)
2019 GtkWidget *top_hbox;
2022 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
2023 GtkWidget *content_area;
2024 GtkWidget *action_area, *vbox, *hbox, *align;
2027 filename = empathy_file_lookup ("empathy-accounts-dialog.ui", "src");
2029 gui = empathy_builder_get_file (filename,
2030 "accounts_dialog_hbox", &top_hbox,
2031 "vbox_details", &priv->vbox_details,
2032 "frame_no_protocol", &priv->frame_no_protocol,
2033 "alignment_settings", &priv->alignment_settings,
2034 "alignment_infobar", &priv->alignment_infobar,
2035 "treeview", &priv->treeview,
2036 "button_add", &priv->button_add,
2037 "button_remove", &priv->button_remove,
2038 "button_import", &priv->button_import,
2039 "hbox_protocol", &priv->hbox_protocol,
2040 "notebook_account", &priv->notebook_account,
2041 "alignment_loading", &alig,
2045 gtk_widget_set_no_show_all (priv->frame_no_protocol, TRUE);
2047 empathy_builder_connect (gui, dialog,
2048 "button_add", "clicked", accounts_dialog_button_add_clicked_cb,
2049 "button_remove", "clicked", accounts_dialog_button_remove_clicked_cb,
2050 "button_import", "clicked", accounts_dialog_button_import_clicked_cb,
2053 content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
2055 gtk_container_add (GTK_CONTAINER (content_area), top_hbox);
2057 g_object_unref (gui);
2059 action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
2062 gtk_widget_hide (action_area);
2063 gtk_widget_hide (priv->button_remove);
2064 #endif /* HAVE_MEEGO */
2066 /* Display loading page */
2067 priv->loading = TRUE;
2069 priv->spinner = gtk_spinner_new ();
2071 gtk_spinner_start (GTK_SPINNER (priv->spinner));
2072 gtk_widget_show (priv->spinner);
2074 gtk_container_add (GTK_CONTAINER (alig), priv->spinner);
2076 gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook_account),
2077 NOTEBOOK_PAGE_LOADING);
2079 /* Remove button is insensitive until we have a selected account */
2080 gtk_widget_set_sensitive (priv->button_remove, FALSE);
2082 /* Add and Import buttons and treeview are insensitive while the dialog
2084 gtk_widget_set_sensitive (priv->button_add, FALSE);
2085 gtk_widget_set_sensitive (priv->button_import, FALSE);
2086 gtk_widget_set_sensitive (priv->treeview, FALSE);
2088 priv->combobox_protocol = empathy_protocol_chooser_new ();
2089 gtk_box_pack_start (GTK_BOX (priv->hbox_protocol), priv->combobox_protocol,
2091 g_signal_connect (priv->combobox_protocol, "changed",
2092 G_CALLBACK (accounts_dialog_protocol_changed_cb),
2095 if (priv->parent_window)
2096 gtk_window_set_transient_for (GTK_WINDOW (dialog),
2097 priv->parent_window);
2099 priv->infobar = gtk_info_bar_new ();
2100 gtk_container_add (GTK_CONTAINER (priv->alignment_infobar),
2102 gtk_widget_show (priv->infobar);
2104 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (priv->infobar));
2106 priv->image_type = gtk_image_new_from_stock (GTK_STOCK_CUT,
2107 GTK_ICON_SIZE_DIALOG);
2108 gtk_misc_set_alignment (GTK_MISC (priv->image_type), 0.0, 0.5);
2109 gtk_box_pack_start (GTK_BOX (content_area), priv->image_type, FALSE, FALSE, 0);
2110 gtk_widget_show (priv->image_type);
2112 vbox = gtk_vbox_new (FALSE, 6);
2113 gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
2114 gtk_widget_show (vbox);
2117 align = gtk_alignment_new (0.5, 0.0, 0.0, 0.0);
2118 gtk_widget_show (align);
2120 priv->label_name = gtk_label_new (NULL);
2121 gtk_container_add (GTK_CONTAINER (align), priv->label_name);
2122 gtk_widget_show (priv->label_name);
2124 gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
2127 align = gtk_alignment_new (0.5, 0.0, 0.0, 0.0);
2128 gtk_widget_show (align);
2129 hbox = gtk_hbox_new (FALSE, 6);
2130 gtk_widget_show (hbox);
2131 gtk_container_add (GTK_CONTAINER (align), hbox);
2133 gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
2135 /* set up spinner */
2136 priv->throbber = gtk_spinner_new ();
2138 priv->image_status = gtk_image_new_from_icon_name (
2139 empathy_icon_name_for_presence (
2140 TP_CONNECTION_PRESENCE_TYPE_OFFLINE), GTK_ICON_SIZE_SMALL_TOOLBAR);
2142 priv->label_status = gtk_label_new (NULL);
2143 gtk_label_set_line_wrap (GTK_LABEL (priv->label_status), TRUE);
2144 gtk_widget_show (priv->label_status);
2146 gtk_box_pack_start (GTK_BOX (hbox), priv->throbber, FALSE, FALSE, 0);
2147 gtk_box_pack_start (GTK_BOX (hbox), priv->image_status, FALSE, FALSE, 3);
2148 gtk_box_pack_start (GTK_BOX (hbox), priv->label_status, TRUE, TRUE, 0);
2150 /* Tweak the dialog */
2151 gtk_window_set_title (GTK_WINDOW (dialog), _("Messaging and VoIP Accounts"));
2152 gtk_window_set_role (GTK_WINDOW (dialog), "accounts");
2154 gtk_window_set_default_size (GTK_WINDOW (dialog), 640, 450);
2156 gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
2158 /* FIXME: Remove this once we unconditionally depend on GTK+ 3 */
2160 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
2163 /* add dialog buttons */
2164 gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_END);
2166 gtk_dialog_add_buttons (GTK_DIALOG (dialog),
2167 GTK_STOCK_HELP, GTK_RESPONSE_HELP,
2168 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
2171 g_signal_connect (dialog, "response",
2172 G_CALLBACK (dialog_response_cb), dialog);
2174 g_signal_connect (dialog, "delete-event",
2175 G_CALLBACK (accounts_dialog_delete_event_cb), dialog);
2179 do_dispose (GObject *obj)
2181 EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (obj);
2182 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
2184 if (priv->connecting_id != 0)
2186 g_source_remove (priv->connecting_id);
2187 priv->connecting_id = 0;
2190 if (priv->account_manager != NULL)
2192 g_object_unref (priv->account_manager);
2193 priv->account_manager = NULL;
2196 if (priv->cms != NULL)
2198 g_object_unref (priv->cms);
2202 if (priv->connectivity)
2204 g_object_unref (priv->connectivity);
2205 priv->connectivity = NULL;
2208 if (priv->initial_selection != NULL)
2210 g_object_unref (priv->initial_selection);
2211 priv->initial_selection = NULL;
2214 G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->dispose (obj);
2218 do_get_property (GObject *object,
2223 EmpathyAccountsDialogPriv *priv = GET_PRIV (object);
2225 switch (property_id)
2228 g_value_set_object (value, priv->parent_window);
2231 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
2236 do_set_property (GObject *object,
2238 const GValue *value,
2241 EmpathyAccountsDialogPriv *priv = GET_PRIV (object);
2243 switch (property_id)
2246 priv->parent_window = g_value_get_object (value);
2249 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
2254 do_constructed (GObject *object)
2256 EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (object);
2257 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
2258 GtkTreeModel *model;
2259 GSettings *gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
2261 accounts_dialog_build_ui (dialog);
2262 accounts_dialog_model_setup (dialog);
2264 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
2265 g_signal_connect (model, "row-inserted",
2266 (GCallback) accounts_dialog_accounts_model_row_inserted_cb, dialog);
2267 g_signal_connect (model, "row-deleted",
2268 (GCallback) accounts_dialog_accounts_model_row_deleted_cb, dialog);
2270 /* Set up signalling */
2271 priv->account_manager = tp_account_manager_dup ();
2273 tp_account_manager_prepare_async (priv->account_manager, NULL,
2274 accounts_dialog_manager_ready_cb, dialog);
2276 if (empathy_import_accounts_to_import ())
2278 gtk_widget_show (priv->button_import);
2280 if (!g_settings_get_boolean (gsettings, EMPATHY_PREFS_IMPORT_ASKED))
2282 GtkWidget *import_dialog;
2284 g_settings_set_boolean (gsettings, EMPATHY_PREFS_IMPORT_ASKED, TRUE);
2285 import_dialog = empathy_import_dialog_new (GTK_WINDOW (dialog),
2287 gtk_widget_show (import_dialog);
2291 priv->connectivity = empathy_connectivity_dup_singleton ();
2293 g_object_unref (gsettings);
2297 empathy_accounts_dialog_class_init (EmpathyAccountsDialogClass *klass)
2299 GObjectClass *oclass = G_OBJECT_CLASS (klass);
2300 GParamSpec *param_spec;
2302 oclass->dispose = do_dispose;
2303 oclass->constructed = do_constructed;
2304 oclass->set_property = do_set_property;
2305 oclass->get_property = do_get_property;
2307 param_spec = g_param_spec_object ("parent",
2308 "parent", "The parent window",
2310 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
2311 g_object_class_install_property (oclass, PROP_PARENT, param_spec);
2313 g_type_class_add_private (klass, sizeof (EmpathyAccountsDialogPriv));
2317 empathy_accounts_dialog_init (EmpathyAccountsDialog *dialog)
2319 EmpathyAccountsDialogPriv *priv;
2321 priv = G_TYPE_INSTANCE_GET_PRIVATE ((dialog),
2322 EMPATHY_TYPE_ACCOUNTS_DIALOG,
2323 EmpathyAccountsDialogPriv);
2324 dialog->priv = priv;
2327 /* public methods */
2330 empathy_accounts_dialog_show (GtkWindow *parent,
2331 TpAccount *selected_account)
2333 EmpathyAccountsDialog *dialog;
2334 EmpathyAccountsDialogPriv *priv;
2336 dialog = g_object_new (EMPATHY_TYPE_ACCOUNTS_DIALOG,
2337 "parent", parent, NULL);
2339 priv = GET_PRIV (dialog);
2341 if (selected_account)
2343 if (priv->cms != NULL && empathy_connection_managers_is_ready (priv->cms))
2344 accounts_dialog_set_selected_account (dialog, selected_account);
2346 /* save the selection to set it later when the cms
2349 priv->initial_selection = g_object_ref (selected_account);
2352 gtk_window_present (GTK_WINDOW (dialog));
2354 return GTK_WIDGET (dialog);
2358 empathy_accounts_dialog_show_application (GdkScreen *screen,
2359 TpAccount *selected_account,
2363 GError *error = NULL;
2364 const gchar *argv[4] = { NULL, };
2366 gchar *account_option = NULL;
2369 g_return_if_fail (GDK_IS_SCREEN (screen));
2370 g_return_if_fail (!selected_account || TP_IS_ACCOUNT (selected_account));
2372 /* Try to run from source directory if possible */
2373 path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "src",
2374 "empathy-accounts", NULL);
2376 if (!g_file_test (path, G_FILE_TEST_EXISTS))
2379 path = g_build_filename (BIN_DIR, "empathy-accounts", NULL);
2384 if (selected_account != NULL)
2386 const gchar *account_path;
2388 account_path = tp_proxy_get_object_path (TP_PROXY (selected_account));
2389 account_option = g_strdup_printf ("--select-account=%s",
2390 &account_path[strlen (TP_ACCOUNT_OBJECT_PATH_BASE)]);
2392 argv[i++] = account_option;
2396 argv[i++] = "--if-needed";
2399 argv[i++] = "--hidden";
2401 DEBUG ("Launching empathy-accounts (if_needed: %d, hidden: %d, account: %s)",
2403 selected_account == NULL ? "<none selected>" :
2404 tp_proxy_get_object_path (TP_PROXY (selected_account)));
2406 gdk_spawn_on_screen (screen, NULL, (gchar**) argv, NULL, G_SPAWN_SEARCH_PATH,
2407 NULL, NULL, NULL, &error);
2410 g_warning ("Failed to open accounts dialog: %s", error->message);
2411 g_error_free (error);
2414 g_free (account_option);
2419 empathy_accounts_dialog_is_creating (EmpathyAccountsDialog *dialog)
2421 EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
2422 gboolean result = FALSE;
2424 if (priv->setting_widget_object == NULL)
2427 g_object_get (priv->setting_widget_object,
2428 "creating-account", &result, NULL);