Commit a24db41f authored by Guillaume Desmottes's avatar Guillaume Desmottes

Pass a ready EmpathyConnectionManagers to empathy_account_assistant_show

This kinda suck but we have to construct the assistant in a sync way so can't
wait for the manager to become ready.
parent fcfdcc40
......@@ -65,7 +65,8 @@ enum {
};
enum {
PROP_PARENT = 1
PROP_PARENT = 1,
PROP_CONNECTION_MGRS,
};
typedef struct {
......@@ -73,6 +74,7 @@ typedef struct {
CreateEnterPageResponse create_enter_resp;
gboolean enter_create_forward;
TpAccountManager *account_mgr;
EmpathyConnectionManagers *connection_mgrs;
/* enter or create page */
GtkWidget *enter_or_create_page;
......@@ -860,6 +862,9 @@ do_get_property (GObject *object,
case PROP_PARENT:
g_value_set_object (value, priv->parent_window);
break;
case PROP_CONNECTION_MGRS:
g_value_set_object (value, priv->connection_mgrs);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
......@@ -878,6 +883,9 @@ do_set_property (GObject *object,
case PROP_PARENT:
priv->parent_window = g_value_get_object (value);
break;
case PROP_CONNECTION_MGRS:
priv->connection_mgrs = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
......@@ -895,6 +903,9 @@ do_constructed (GObject *object)
/* set the dialog hint, so this will be centered over the parent window */
gtk_window_set_type_hint (GTK_WINDOW (object), GDK_WINDOW_TYPE_HINT_DIALOG);
g_assert (priv->connection_mgrs != NULL);
g_assert (empathy_connection_managers_is_ready (priv->connection_mgrs));
}
static void
......@@ -916,6 +927,9 @@ do_dispose (GObject *obj)
g_object_unref (priv->account_mgr);
priv->account_mgr = NULL;
g_object_unref (priv->connection_mgrs);
priv->connection_mgrs = NULL;
if (G_OBJECT_CLASS (empathy_account_assistant_parent_class)->dispose != NULL)
G_OBJECT_CLASS (empathy_account_assistant_parent_class)->dispose (obj);
}
......@@ -942,6 +956,12 @@ empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (oclass, PROP_PARENT, param_spec);
param_spec = g_param_spec_object ("connection-managers",
"connection-managers", "A EmpathyConnectionManagers",
EMPATHY_TYPE_CONNECTION_MANAGERS,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (oclass, PROP_CONNECTION_MGRS, param_spec);
g_type_class_add_private (klass, sizeof (EmpathyAccountAssistantPriv));
}
......@@ -1138,14 +1158,17 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self)
}
GtkWidget *
empathy_account_assistant_show (GtkWindow *window)
empathy_account_assistant_show (GtkWindow *window,
EmpathyConnectionManagers *connection_mgrs)
{
static GtkWidget *dialog = NULL;
if (dialog == NULL)
{
dialog = g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT, "parent-window",
window, NULL);
dialog = g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT,
"parent-window", window,
"connection-managers", connection_mgrs,
NULL);
g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer *) &dialog);
}
......
......@@ -26,6 +26,8 @@
#include <glib-object.h>
#include <gtk/gtk.h>
#include <libempathy/empathy-connection-managers.h>
G_BEGIN_DECLS
#define EMPATHY_TYPE_ACCOUNT_ASSISTANT empathy_account_assistant_get_type()
......@@ -56,7 +58,8 @@ typedef struct {
GType empathy_account_assistant_get_type (void);
GtkWidget *empathy_account_assistant_show (GtkWindow *parent);
GtkWidget *empathy_account_assistant_show (GtkWindow *parent,
EmpathyConnectionManagers *connection_mgrs);
G_END_DECLS
......
......@@ -228,7 +228,8 @@ connection_managers_prepare_cb (GObject *source,
goto out;
if (should_show_account_assistant (account_mgr, cm_mgr))
empathy_account_assistant_show (GTK_WINDOW (empathy_main_window_get ()));
empathy_account_assistant_show (GTK_WINDOW (empathy_main_window_get ()),
cm_mgr);
out:
g_object_unref (cm_mgr);
......@@ -335,21 +336,47 @@ migrate_config_to_xdg_dir (void)
g_free (old_dir);
}
static void
connection_managers_prepare_for_accounts (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
EmpathyConnectionManagers *cm_mgr = EMPATHY_CONNECTION_MANAGERS (source);
GtkWidget *ui;
if (!empathy_connection_managers_prepare_finish (cm_mgr, result, NULL))
goto out;
ui = empathy_account_assistant_show (GTK_WINDOW (empathy_main_window_get ()),
cm_mgr);
if (account_dialog_only)
g_signal_connect (ui, "destroy", G_CALLBACK (gtk_main_quit), NULL);
out:
g_object_unref (cm_mgr);
}
static void
do_show_accounts_ui (GtkWindow *window,
TpAccountManager *manager)
{
if (has_non_salut_accounts (manager))
{
GtkWidget *ui;
GtkWidget *ui;
ui = empathy_accounts_dialog_show (window, NULL);
if (has_non_salut_accounts (manager))
ui = empathy_accounts_dialog_show (window, NULL);
if (account_dialog_only)
g_signal_connect (ui, "destroy", G_CALLBACK (gtk_main_quit), NULL);
}
else
ui = empathy_account_assistant_show (window);
{
EmpathyConnectionManagers *cm_mgr;
if (account_dialog_only)
g_signal_connect (ui, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
empathy_connection_managers_prepare_async (cm_mgr,
connection_managers_prepare_for_accounts, NULL);
}
}
static void
......
......@@ -5,19 +5,36 @@
#include <libempathy-gtk/empathy-ui-utils.h>
#include "empathy-account-assistant.h"
int main (int argc, char **argv)
static void
managers_prepare_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
GtkWidget *assistant;
EmpathyConnectionManagers *managers = EMPATHY_CONNECTION_MANAGERS (source);
gtk_init (&argc, &argv);
empathy_gtk_init ();
g_assert (empathy_connection_managers_prepare_finish (managers, result,
NULL));
assistant = empathy_account_assistant_show (NULL);
assistant = empathy_account_assistant_show (NULL, managers);
gtk_widget_show_all (assistant);
g_signal_connect_swapped (assistant, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
}
int main (int argc, char **argv)
{
EmpathyConnectionManagers *managers;
gtk_init (&argc, &argv);
empathy_gtk_init ();
managers = empathy_connection_managers_dup_singleton ();
empathy_connection_managers_prepare_async (managers,
managers_prepare_cb, NULL);
gtk_main ();
......
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