Skip to content

Commit

Permalink
application: load a GoaClient on init
Browse files Browse the repository at this point in the history
It is done here to make it reusable for
the future initial setup dialog too.
  • Loading branch information
GeorgesStavracas authored and erick2red committed May 25, 2015
1 parent a61a970 commit 71d93bd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/gcal-application.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@
#include <glib-object.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
#include <goa/goa.h>

#define CSS_FILE "resource:///org/gnome/calendar/gtk-styles.css"

struct _GcalApplicationPrivate
{
GtkWidget *window;

GoaClient *client;

GSettings *settings;
GcalManager *manager;

Expand Down Expand Up @@ -89,6 +92,10 @@ static void gcal_application_dbus_unregister (GApplication *
GDBusConnection *connection,
const gchar *object_path);

static void gcal_application_goa_client_ready (GObject *source,
GAsyncResult *result,
gpointer user_data);

G_DEFINE_TYPE_WITH_PRIVATE (GcalApplication, gcal_application, GTK_TYPE_APPLICATION);

static gboolean show_version = FALSE;
Expand Down Expand Up @@ -212,9 +219,33 @@ gcal_application_init (GcalApplication *self)
priv->search_provider = gcal_shell_search_provider_new ();
gcal_shell_search_provider_connect (priv->search_provider, priv->manager);

goa_client_new (NULL, // we won't really cancel it
(GAsyncReadyCallback) gcal_application_goa_client_ready,
self);

self->priv = priv;
}

static void
gcal_application_goa_client_ready (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
GcalApplicationPrivate *priv = GCAL_APPLICATION (user_data)->priv;
GError *error = NULL;

priv->client = goa_client_new_finish (result, &error);

if (error != NULL)
{
g_warning ("%s: Error retrieving GoaClient: %s",
G_STRFUNC,
error->message);

g_error_free (error);
}
}

static void
gcal_application_finalize (GObject *object)
{
Expand Down
2 changes: 2 additions & 0 deletions src/gcal-application.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "gcal-manager.h"

#include <gtk/gtk.h>
#include <goa/goa.h>

G_BEGIN_DECLS

Expand Down Expand Up @@ -58,6 +59,7 @@ void gcal_application_set_uuid (GcalApplication *application,
const gchar *uuid);
void gcal_application_set_initial_date (GcalApplication *application,
const icaltimetype *date);
GoaClient* gcal_application_get_client (GcalApplication *application);

G_END_DECLS

Expand Down

0 comments on commit 71d93bd

Please sign in to comment.