Commit 77c57d35 authored by Danielle Madeley's avatar Danielle Madeley

empathy-accounts: make CcPage insensitive when assistant is being shown

Also destroy assistant when CcPanel becomes inactive.
parent c2cd8fba
......@@ -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);
}
}
......@@ -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
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment