/* less expensive than G_TYPE_INSTANCE_GET_PRIVATE */
#define MILK_MAIN_WINDOW_PRIVATE(o) ((MILK_MAIN_WINDOW ((o)))->priv)
+static GtkWidget *default_window = NULL;
+
struct _MilkMainWindowPrivate
{
MilkAuth *auth;
g_object_unref (task);
}
+static gboolean
+begin_auth_idle (MilkMainWindow *window)
+{
+ MilkMainWindowPrivate *priv;
+
+ priv = MILK_MAIN_WINDOW_PRIVATE (window);
+
+ /* FIXME: is there a better place for this? */
+ priv->auth = milk_auth_get_default ();
+ /* FIXME: plug this into the task model */
+
+ /* FIXME: cut this */
+ g_debug ("trying to run the milk auth demo");
+ /* FIXME: cut this */
+ milk_auth_run_demo (priv->auth);
+
+ return FALSE;
+}
+
static void
milk_main_window_constructed (GObject* object)
{
hildon_window_set_app_menu (
HILDON_WINDOW (self), HILDON_APP_MENU (priv->app_menu));
- /* FIXME: is there a better place for this? */
- priv->auth = milk_auth_get_default ();
- /* FIXME: plug this into the task model */
-
- /* FIXME: cut this */
- g_debug ("trying to run the milk auth demo");
- /* FIXME: cut this */
- milk_auth_run_demo (priv->auth);
+ /* break a cyclical dependency by doing this after the window is
+ * constructed */
+ g_idle_add ((GSourceFunc) begin_auth_idle, self);
}
static void
}
GtkWidget*
-milk_main_window_new ()
+milk_main_window_get_default ()
{
- return g_object_new (MILK_TYPE_MAIN_WINDOW,
- NULL);
+ if (!default_window) {
+ default_window = g_object_new (MILK_TYPE_MAIN_WINDOW, NULL);
+ }
+
+ return default_window;
}