]> git.0d.be Git - empathy.git/commitdiff
empathy-accounts: make CcPage insensitive when assistant is being shown
authorDanielle Madeley <danielle.madeley@collabora.co.uk>
Wed, 10 Mar 2010 04:54:51 +0000 (15:54 +1100)
committerDanielle Madeley <danielle.madeley@collabora.co.uk>
Wed, 10 Mar 2010 10:43:43 +0000 (21:43 +1100)
Also destroy assistant when CcPanel becomes inactive.

src/cc-empathy-accounts-page.c
src/cc-empathy-accounts-page.h
src/cc-empathy-accounts-panel.c
src/empathy-account-assistant.c

index 383e20d417338525a17360b1299bf00f7efcec66..48330f6f07160c2e3d5170816565536023e37a56 100644 (file)
@@ -32,6 +32,9 @@
 #include <libempathy/empathy-connection-managers.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
 
+#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
+#include <libempathy/empathy-debug.h>
+
 #include "cc-empathy-accounts-page.h"
 #include "empathy-accounts-common.h"
 #include "empathy-account-assistant.h"
@@ -45,6 +48,8 @@ struct CcEmpathyAccountsPagePrivate
    * destroyed in our finalize(), since it invalidates its children (even if
    * they've already been reparented by the time it is destroyed) */
   GtkWidget *accounts_window;
+
+  GtkWidget *assistant;
 };
 
 G_DEFINE_TYPE (CcEmpathyAccountsPage, cc_empathy_accounts_page, CC_TYPE_PAGE)
@@ -87,6 +92,9 @@ account_assistant_closed_cb (GtkWidget *widget,
       empathy_account_dialog_cancel (
         EMPATHY_ACCOUNTS_DIALOG (page->priv->accounts_window));
     }
+
+  gtk_widget_set_sensitive (GTK_WIDGET (page), TRUE);
+  page->priv->assistant = NULL;
 }
 
 static void
@@ -112,10 +120,14 @@ connection_managers_prepare (GObject *source,
 
   if (!empathy_accounts_has_non_salut_accounts (account_mgr))
     {
-      GtkWidget *w;
-      w = empathy_account_assistant_show (NULL, cm_mgr);
+      GtkWindow *parent;
 
-      empathy_signal_connect_weak (w, "hide",
+      parent = empathy_get_toplevel_window (GTK_WIDGET (page));
+      page->priv->assistant = empathy_account_assistant_show (parent, cm_mgr);
+
+      gtk_widget_set_sensitive (GTK_WIDGET (page), FALSE);
+
+      empathy_signal_connect_weak (page->priv->assistant, "hide",
         G_CALLBACK (account_assistant_closed_cb),
         G_OBJECT (page));
     }
@@ -172,6 +184,8 @@ active_changed (CcPage *base_page,
   CcEmpathyAccountsPage *page = CC_EMPATHY_ACCOUNTS_PAGE (base_page);
   TpAccountManager *account_manager;
 
+  DEBUG ("%s: active = %i", G_STRLOC, is_active);
+
   if (is_active)
     {
       /* unref'd in final endpoint callbacks */
@@ -232,3 +246,18 @@ cc_empathy_accounts_page_new (void)
 
   return CC_PAGE (object);
 }
+
+void
+cc_empathy_accounts_page_destroy_dialogs (CcEmpathyAccountsPage *self)
+{
+  /* This function is really kludgey, it is called by the AccountPanel to
+   * remove any child dialogs (i.e. this assistant). I personally feel this
+   * would be better in active_changed, but the Page doesn't seem to receive
+   * that signal when the panel does. */
+
+  if (self->priv->assistant != NULL)
+    {
+      DEBUG ("Destroying assistant");
+      gtk_widget_destroy (self->priv->assistant);
+    }
+}
index 7c360874e23d7d141be56a5be661f00c43eb6963..4139a33f80d9d6196f3170ffdbbe6efca9cff77e 100644 (file)
@@ -48,6 +48,7 @@ typedef struct
 
 GType   cc_empathy_accounts_page_get_type   (void);
 CcPage* cc_empathy_accounts_page_new        (void);
+void    cc_empathy_accounts_page_destroy_dialogs (CcEmpathyAccountsPage *self);
 
 G_END_DECLS
 
index 63500e66cd0f2ecd7f11154a8535b9146a639e27..d69325b7bc0c6f4a6083bb9f447cee1a7ead7aeb 100644 (file)
@@ -28,6 +28,9 @@
 
 #include <gconf/gconf-client.h>
 
+#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
+#include <libempathy/empathy-debug.h>
+
 #include "cc-empathy-accounts-panel.h"
 #include "cc-empathy-accounts-page.h"
 
@@ -55,6 +58,24 @@ setup_panel (CcEmpathyAccountsPanel *panel)
       NULL);
 }
 
+static void
+cc_empathy_accounts_panel_active_changed (CcPanel *self,
+    gboolean is_active)
+{
+  DEBUG ("%s: active = %i", G_STRLOC, is_active);
+
+  if (!is_active)
+    {
+      /* why doesn't control-center call active-changed on the Page? */
+      cc_empathy_accounts_page_destroy_dialogs (
+          CC_EMPATHY_ACCOUNTS_PAGE (
+            CC_EMPATHY_ACCOUNTS_PANEL (self)->priv->empathy_accounts_page));
+    }
+
+  CC_PANEL_CLASS (cc_empathy_accounts_panel_parent_class)->active_changed (
+      self, is_active);
+}
+
 static GObject *
 cc_empathy_accounts_panel_constructor (GType type,
     guint n_construct_properties,
@@ -96,7 +117,10 @@ cc_empathy_accounts_panel_finalize (GObject *object)
 static void
 cc_empathy_accounts_panel_class_init (CcEmpathyAccountsPanelClass *klass)
 {
-  GObjectClass  *object_class = G_OBJECT_CLASS (klass);
+  CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  panel_class->active_changed = cc_empathy_accounts_panel_active_changed;
 
   object_class->constructor = cc_empathy_accounts_panel_constructor;
   object_class->finalize = cc_empathy_accounts_panel_finalize;
index e5c5e80c2ba60e08f7715c2520911c41a48d73fe..63949ed26a0c9066d017d4f589fbd6b2cb4793f9 100644 (file)
@@ -1320,7 +1320,7 @@ empathy_account_assistant_show (GtkWindow *window,
 
   if (dialog == NULL)
     {
-      dialog =  g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT,
+      dialog = g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT,
           "parent-window", window,
           "connection-managers", connection_mgrs,
           NULL);