#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-connection-managers.h>
#include <libempathy/empathy-connectivity.h>
-#include <libempathy/empathy-gsettings.h>
#include <libempathy-gtk/empathy-ui-utils.h>
#include <libempathy-gtk/empathy-protocol-chooser.h>
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountsDialog)
G_DEFINE_TYPE (EmpathyAccountsDialog, empathy_accounts_dialog, GTK_TYPE_DIALOG);
+enum
+{
+ NOTEBOOK_PAGE_ACCOUNT = 0,
+ NOTEBOOK_PAGE_LOADING
+};
+
typedef struct {
GtkWidget *alignment_settings;
GtkWidget *alignment_infobar;
GtkWidget *label_type;
GtkWidget *settings_widget;
+ GtkWidget *notebook_account;
+ GtkWidget *spinner;
+ gboolean loading;
+
/* We have to keep a reference on the actual EmpathyAccountWidget, not just
* his GtkWidget. It is the only reliable source we can query to know if
* there are any unsaved changes to the currently selected account. We can't
gchar *message;
message = g_strdup_printf (_("Offline — %s"),
- empathy_status_reason_get_default_message (reason));
+ empathy_account_get_error_message (account, NULL));
gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
GTK_MESSAGE_WARNING);
gchar *message;
message = g_strdup_printf (_("Disconnected — %s"),
- empathy_status_reason_get_default_message (reason));
+ empathy_account_get_error_message (account, NULL));
gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
GTK_MESSAGE_ERROR);
EmpathyAccountSettings *settings)
{
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- gchar *icon_name;
+ const gchar *icon_name;
TpAccount *account;
priv->setting_widget_object =
{
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
EmpathyAccountSettings *settings;
- gchar *str;
- const gchar *name, *display_name;
- TpConnectionManager *cm;
- TpConnectionManagerProtocol *proto;
- gboolean is_gtalk, is_facebook;
-
- cm = empathy_protocol_chooser_dup_selected (
- EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto, &is_gtalk,
- &is_facebook);
- if (cm == NULL)
- return;
-
- if (is_gtalk)
- name = "gtalk";
- else if (is_facebook)
- name ="facebook";
- else
- name = proto->name;
- display_name = empathy_protocol_name_to_display_name (name);
- if (display_name == NULL)
- display_name = proto->name;
-
- /* Create account */
- /* To translator: %s is the name of the protocol, such as "Google Talk" or
- * "Yahoo!"
- */
- str = g_strdup_printf (_("New %s account"), display_name);
- settings = empathy_account_settings_new (cm->name, proto->name, str);
-
- g_free (str);
-
- if (is_gtalk)
- {
- empathy_account_settings_set_icon_name_async (settings, "im-google-talk",
- NULL, NULL);
- /* We should not have to set the server but that may cause issue with
- * buggy router. */
- empathy_account_settings_set_string (settings, "server",
- "talk.google.com");
- }
- else if (is_facebook)
- {
- empathy_account_settings_set_icon_name_async (settings, "im-facebook",
- NULL, NULL);
-
- empathy_account_settings_set_string (settings, "server",
- "chat.facebook.com");
- }
+ settings = empathy_protocol_chooser_create_account_settings (
+ EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol));
+ if (settings == NULL)
+ return;
accounts_dialog_add (dialog, settings);
accounts_dialog_model_set_selected (dialog, settings);
gtk_widget_show_all (priv->hbox_protocol);
g_object_unref (settings);
- g_object_unref (cm);
}
static void
}
/* Update remove button sensitivity */
- gtk_widget_set_sensitive (priv->button_remove, is_selection && !creating);
+ gtk_widget_set_sensitive (priv->button_remove, is_selection && !creating &&
+ !priv->loading);
}
static void
gtk_tree_selection_select_iter (selection, &iter);
}
+static void
+finished_loading (EmpathyAccountsDialog *self)
+{
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (self);
+ GtkTreeSelection *selection;
+ gboolean has_selected;
+
+ priv->loading = FALSE;
+
+ gtk_widget_set_sensitive (priv->button_add, TRUE);
+ gtk_widget_set_sensitive (priv->button_import, TRUE);
+ gtk_widget_set_sensitive (priv->treeview, TRUE);
+
+ /* Sensitive the remove button if there is an account selected */
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
+ has_selected = gtk_tree_selection_get_selected (selection, NULL, NULL);
+ gtk_widget_set_sensitive (priv->button_remove, has_selected);
+
+ gtk_spinner_stop (GTK_SPINNER (priv->spinner));
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook_account),
+ NOTEBOOK_PAGE_ACCOUNT);
+}
+
static void
accounts_dialog_cms_prepare_cb (GObject *source,
GAsyncResult *result,
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
if (!empathy_connection_managers_prepare_finish (cms, result, NULL))
- return;
+ goto out;
accounts_dialog_update_settings (dialog, NULL);
g_object_unref (priv->initial_selection);
priv->initial_selection = NULL;
}
+
+out:
+ finished_loading (dialog);
}
static void
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
GtkWidget *content_area;
GtkWidget *action_area, *vbox, *hbox, *align;
+ GtkWidget *alig;
filename = empathy_file_lookup ("empathy-accounts-dialog.ui", "src");
"button_remove", &priv->button_remove,
"button_import", &priv->button_import,
"hbox_protocol", &priv->hbox_protocol,
+ "notebook_account", &priv->notebook_account,
+ "alignment_loading", &alig,
NULL);
g_free (filename);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_container_add (GTK_CONTAINER (content_area), top_hbox);
+ gtk_box_pack_start (GTK_BOX (content_area), top_hbox, TRUE, TRUE, 0);
g_object_unref (gui);
gtk_widget_hide (priv->button_remove);
#endif /* HAVE_MEEGO */
- /* Remove button is unsensitive until we have a selected account */
+ /* Display loading page */
+ priv->loading = TRUE;
+
+ priv->spinner = gtk_spinner_new ();
+
+ gtk_spinner_start (GTK_SPINNER (priv->spinner));
+ gtk_widget_show (priv->spinner);
+
+ gtk_container_add (GTK_CONTAINER (alig), priv->spinner);
+
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook_account),
+ NOTEBOOK_PAGE_LOADING);
+
+ /* Remove button is insensitive until we have a selected account */
gtk_widget_set_sensitive (priv->button_remove, FALSE);
+ /* Add and Import buttons and treeview are insensitive while the dialog
+ * is loading */
+ gtk_widget_set_sensitive (priv->button_add, FALSE);
+ gtk_widget_set_sensitive (priv->button_import, FALSE);
+ gtk_widget_set_sensitive (priv->treeview, FALSE);
+
priv->combobox_protocol = empathy_protocol_chooser_new ();
gtk_box_pack_start (GTK_BOX (priv->hbox_protocol), priv->combobox_protocol,
TRUE, TRUE, 0);
gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
-
/* add dialog buttons */
gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_END);
EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (object);
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
GtkTreeModel *model;
- GSettings *gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
accounts_dialog_build_ui (dialog);
accounts_dialog_model_setup (dialog);
tp_account_manager_prepare_async (priv->account_manager, NULL,
accounts_dialog_manager_ready_cb, dialog);
- if (empathy_import_accounts_to_import ())
- {
- gtk_widget_show (priv->button_import);
-
- if (!g_settings_get_boolean (gsettings, EMPATHY_PREFS_IMPORT_ASKED))
- {
- GtkWidget *import_dialog;
-
- g_settings_set_boolean (gsettings, EMPATHY_PREFS_IMPORT_ASKED, TRUE);
- import_dialog = empathy_import_dialog_new (GTK_WINDOW (dialog),
- FALSE);
- gtk_widget_show (import_dialog);
- }
- }
-
priv->connectivity = empathy_connectivity_dup_singleton ();
-
- g_object_unref (gsettings);
}
static void
gboolean hidden)
{
GError *error = NULL;
- gchar *argv[4] = { NULL, };
+ const gchar *argv[4] = { NULL, };
gint i = 0;
gchar *account_option = NULL;
gchar *path;
selected_account == NULL ? "<none selected>" :
tp_proxy_get_object_path (TP_PROXY (selected_account)));
- gdk_spawn_on_screen (screen, NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
+ gdk_spawn_on_screen (screen, NULL, (gchar**) argv, NULL, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, &error);
if (error != NULL)
{