]> git.0d.be Git - empathy.git/commitdiff
accounts-dialog: suggest to create a salut account
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 16 Feb 2012 11:15:22 +0000 (12:15 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 16 Feb 2012 16:43:30 +0000 (17:43 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=652669

src/empathy-accounts-dialog.c

index 934e4986e34ab622b64810521733c208ebf20637..b6a47d27570a06bc68dc7b7314d6955ad9413a84 100644 (file)
@@ -51,6 +51,7 @@
 #include <libempathy-gtk/empathy-cell-renderer-activatable.h>
 #include <libempathy-gtk/empathy-contact-widget.h>
 #include <libempathy-gtk/empathy-images.h>
+#include <libempathy-gtk/empathy-local-xmpp-assistant-widget.h>
 #include <libempathy-gtk/empathy-new-account-dialog.h>
 
 #include "empathy-accounts-common.h"
@@ -2053,18 +2054,83 @@ accounts_dialog_set_selected_account (EmpathyAccountsDialog *dialog,
     select_and_scroll_to_iter (dialog, &iter);
 }
 
+static void
+salut_valid_cb (GtkWidget *widget,
+    gboolean valid,
+    GtkWidget *button)
+{
+  gtk_widget_set_sensitive (button, valid);
+}
+
+static void
+maybe_show_salut_dialog (EmpathyAccountsDialog *self)
+{
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (self);
+  GtkWidget *dialog, *widget, *content, *button;
+  gint response;
+
+  if (!empathy_local_xmpp_assistant_widget_should_create_account (
+        priv->account_manager))
+    return;
+
+  widget = empathy_local_xmpp_assistant_widget_new ();
+  gtk_widget_show (widget);
+
+  dialog = gtk_dialog_new ();
+
+  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+
+  gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Ignore"),
+      GTK_RESPONSE_NO);
+
+  button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+      _("_Connect"), GTK_RESPONSE_YES);
+  gtk_widget_set_sensitive (button, FALSE);
+
+  g_signal_connect (widget, "valid", G_CALLBACK (salut_valid_cb),
+      button);
+
+  content = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+  gtk_box_pack_start (GTK_BOX (content), widget, TRUE, TRUE, 0);
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  if (response == GTK_RESPONSE_YES)
+    {
+      empathy_local_xmpp_assistant_widget_create_account (
+          EMPATHY_LOCAL_XMPP_ASSISTANT_WIDGET (widget));
+    }
+
+  gtk_widget_destroy (dialog);
+}
+
+static void
+import_dialog_response_cb (GtkDialog *dialog,
+    gint response_id,
+    EmpathyAccountsDialog *self)
+{
+  maybe_show_salut_dialog (self);
+}
+
 static void
 maybe_show_import_dialog (EmpathyAccountsDialog *self)
 {
   EmpathyAccountsDialogPriv *priv = GET_PRIV (self);
+  GtkWidget *dialog;
 
   if (empathy_accounts_has_non_salut_accounts (priv->account_manager))
     return;
 
   if (!empathy_import_accounts_to_import ())
-    return;
+    {
+      maybe_show_salut_dialog (self);
+      return;
+    }
+
+  dialog = display_import_dialog (self);
 
-  display_import_dialog (self);
+  tp_g_signal_connect_object (dialog, "response",
+      G_CALLBACK (import_dialog_response_cb), self, 0);
 }
 
 static void