[gnome-calendar/calendar-editor] application: move GoaClient to manager
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/calendar-editor] application: move GoaClient to manager
- Date: Fri, 1 May 2015 11:56:46 +0000 (UTC)
commit 6e848bc2a956ce4918d7c30740de064bf440b903
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri May 1 08:56:19 2015 -0300
application: move GoaClient to manager
src/gcal-application.c | 73 ----------------------------------------------
src/gcal-application.h | 3 --
src/gcal-manager.c | 60 +++++++++++++++++++++++++++++++++++++-
src/gcal-manager.h | 6 ++++
src/gcal-source-dialog.c | 42 --------------------------
5 files changed, 65 insertions(+), 119 deletions(-)
---
diff --git a/src/gcal-application.c b/src/gcal-application.c
index 1e0433d..cf71e82 100644
--- a/src/gcal-application.c
+++ b/src/gcal-application.c
@@ -38,8 +38,6 @@ struct _GcalApplicationPrivate
{
GtkWidget *window;
- GoaClient *client;
-
GSettings *settings;
GcalManager *manager;
@@ -52,14 +50,6 @@ struct _GcalApplicationPrivate
icaltimetype *initial_date;
};
-enum
-{
- GOA_CLIENT_READY,
- NUM_SIGNALS
-};
-
-static guint signals[NUM_SIGNALS] = { 0, };
-
static void gcal_application_finalize (GObject *object);
static void gcal_application_activate (GApplication *app);
@@ -100,10 +90,6 @@ 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;
@@ -211,22 +197,6 @@ gcal_application_class_init (GcalApplicationClass *klass)
application_class->dbus_register = gcal_application_dbus_register;
application_class->dbus_unregister = gcal_application_dbus_unregister;
-
- /**
- * GcalApplication::goa-client-ready:
- *
- * Emited when the #GoaClient asyncronous loading is finished.
- */
- signals[GOA_CLIENT_READY] = g_signal_new ("source-removed",
- GCAL_TYPE_APPLICATION,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GcalApplicationClass, goa_client_ready),
- NULL,
- NULL,
- NULL,
- G_TYPE_NONE,
- 1,
- GOA_TYPE_CLIENT);
}
static void
@@ -243,36 +213,10 @@ 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);
-
- g_signal_emit (user_data, signals[GOA_CLIENT_READY], 0, priv->client);
-
- 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)
{
GcalApplicationPrivate *priv = GCAL_APPLICATION (object)->priv;
@@ -635,20 +579,3 @@ gcal_application_set_initial_date (GcalApplication *application,
g_free (priv->initial_date);
priv->initial_date = gcal_dup_icaltime (date);
}
-
-/**
- * gcal_application_get_client:
- * @application: a #GcalApplication
- *
- * Retrieves the internal #GoaClient from @application. It
- * should not be unreferenced after usage.
- *
- * Returns: (transfer none): the #GoaClient of @application
- */
-GoaClient*
-gcal_application_get_client (GcalApplication *application)
-{
- g_return_val_if_fail (GCAL_IS_APPLICATION (application), NULL);
-
- return application->priv->client;
-}
diff --git a/src/gcal-application.h b/src/gcal-application.h
index 4aaca56..e820d2f 100644
--- a/src/gcal-application.h
+++ b/src/gcal-application.h
@@ -49,8 +49,6 @@ struct _GcalApplication
struct _GcalApplicationClass
{
GtkApplicationClass parent_class;
-
- void (*goa_client_ready) (GcalApplication *app, GoaClient *client);
};
GType gcal_application_get_type (void) G_GNUC_CONST;
@@ -61,7 +59,6 @@ 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
diff --git a/src/gcal-manager.c b/src/gcal-manager.c
index 1898658..0f68596 100644
--- a/src/gcal-manager.c
+++ b/src/gcal-manager.c
@@ -67,7 +67,10 @@ typedef struct
GCancellable *async_ops;
+ GoaClient *client;
+
/* state flags */
+ gboolean goa_client_ready;
gchar **disabled_sources;
gint sources_at_launch;
@@ -102,6 +105,7 @@ enum
SOURCE_REMOVED,
LOAD_COMPLETED,
QUERY_COMPLETED,
+ GOA_CLIENT_READY,
NUM_SIGNALS
};
@@ -675,12 +679,42 @@ gcal_manager_class_init (GcalManagerClass *klass)
G_STRUCT_OFFSET (GcalManagerClass, query_completed),
NULL, NULL, NULL,
G_TYPE_NONE, 0);
+
+ signals[GOA_CLIENT_READY] = g_signal_new ("goa-client-ready", GCAL_TYPE_MANAGER, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GcalManagerClass, goa_client_ready),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1, GOA_TYPE_CLIENT);
+}
+
+static void
+gcal_manager_client_ready_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GcalManagerPrivate *priv = gcal_manager_get_instance_private (GCAL_MANAGER (user_data));
+ GError *error = NULL;
+
+ priv->client = goa_client_new_finish (result, &error);
+ priv->goa_client_ready = TRUE;
+
+ g_signal_emit (user_data, signals[GOA_CLIENT_READY], 0, priv->client);
+
+ if (error != NULL)
+ {
+ g_warning ("%s: Error retrieving GoaClient: %s",
+ G_STRFUNC,
+ error->message);
+
+ g_error_free (error);
+ }
}
static void
gcal_manager_init (GcalManager *self)
{
- ;
+ goa_client_new (NULL, // we won't really cancel it
+ (GAsyncReadyCallback) gcal_manager_client_ready_cb,
+ self);
}
static void
@@ -1495,3 +1529,27 @@ gcal_manager_get_event_from_shell_search (GcalManager *manager,
return new_data;
}
+
+gboolean
+gcal_manager_is_client_ready (GcalManager *manager)
+{
+ GcalManagerPrivate *priv;
+
+ g_return_val_if_fail (GCAL_IS_MANAGER (manager), FALSE);
+
+ priv = gcal_manager_get_instance_private (manager);
+
+ return priv->goa_client_ready;
+}
+
+GoaClient*
+gcal_manager_get_client (GcalManager *manager)
+{
+ GcalManagerPrivate *priv;
+
+ g_return_val_if_fail (GCAL_IS_MANAGER (manager), FALSE);
+
+ priv = gcal_manager_get_instance_private (manager);
+
+ return priv->client;
+}
diff --git a/src/gcal-manager.h b/src/gcal-manager.h
index e12d01b..364244b 100644
--- a/src/gcal-manager.h
+++ b/src/gcal-manager.h
@@ -23,6 +23,7 @@
#include "e-cal-data-model.h"
#include <libical/icaltime.h>
+#include <goa/goa.h>
G_BEGIN_DECLS
@@ -51,6 +52,7 @@ struct _GcalManagerClass
void (*source_removed) (GcalManager *manager, ESource *source);
void (*load_completed) (GcalManager *manager);
void (*query_completed) (GcalManager *manager);
+ void (*goa_client_ready) (GcalManager *manager, GoaClient *client);
};
typedef struct
@@ -161,6 +163,10 @@ gboolean gcal_manager_load_completed (GcalManager *manager
GcalEventData* gcal_manager_get_event_from_shell_search (GcalManager *manager,
const gchar *uuid);
+gboolean gcal_manager_is_client_ready (GcalManager *manager);
+
+GoaClient* gcal_manager_get_client (GcalManager *manager);
+
G_END_DECLS
#endif /* __GCAL_MANAGER_H__ */
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index 5ba4a31..b10bb74 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gcal-application.h"
#include "gcal-source-dialog.h"
#include "gcal-utils.h"
@@ -89,7 +88,6 @@ typedef struct
GSimpleActionGroup *action_group;
/* manager */
- GcalApplication *application;
GcalManager *manager;
} GcalSourceDialogPrivate;
@@ -1825,44 +1823,6 @@ gcal_source_dialog_constructed (GObject *object)
}
static void
-gcal_source_dialog_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GcalSourceDialog *self = GCAL_SOURCE_DIALOG (object);
-
- switch (prop_id)
- {
- case PROP_APPLICATION:
- g_value_set_object (value, self->priv->application);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
-gcal_source_dialog_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GcalSourceDialog *self = GCAL_SOURCE_DIALOG (object);
-
- switch (prop_id)
- {
- case PROP_APPLICATION:
- self->priv->application = g_value_get_object (value);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -1876,8 +1836,6 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
g_type_ensure (E_TYPE_SOURCE_LOCAL);
object_class->constructed = gcal_source_dialog_constructed;
- object_class->get_property = gcal_source_dialog_get_property;
- object_class->set_property = gcal_source_dialog_set_property;
widget_class = GTK_WIDGET_CLASS (klass);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]