+/*
+ * azimuth.c - Source for Azimith
+ * Copyright (C) 2010 Guillaume Desmottes
+ * @author Guillaume Desmottes <gdesmott@gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "azimuth.h"
+#include "position-publisher.h"
+
+G_DEFINE_TYPE(Azimuth, azimuth, G_TYPE_OBJECT)
+
+/* private structure */
+typedef struct _AzimuthPrivate AzimuthPrivate;
+
+struct _AzimuthPrivate
+{
+ GMainLoop *loop;
+ PositionPublisher *publisher;
+};
+
+#define AZIMUTH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), AZIMUTH_TYPE, AzimuthPrivate))
+
+static void
+azimuth_init (Azimuth *obj)
+{
+ AzimuthPrivate *priv = AZIMUTH_GET_PRIVATE (obj);
+
+ priv->loop = g_main_loop_new (NULL, FALSE);
+ priv->publisher = NULL;
+}
+
+static void
+azimuth_dispose (GObject *object)
+{
+ Azimuth *self = AZIMUTH (object);
+ AzimuthPrivate *priv = AZIMUTH_GET_PRIVATE (self);
+
+ if (priv->publisher != NULL)
+ {
+ g_object_unref (priv->publisher);
+ priv->publisher = NULL;
+ }
+
+ if (priv->loop != NULL)
+ {
+ g_main_loop_unref (priv->loop);
+ priv->loop = NULL;
+ }
+
+ if (G_OBJECT_CLASS (azimuth_parent_class)->dispose)
+ G_OBJECT_CLASS (azimuth_parent_class)->dispose (object);
+}
+
+static void
+azimuth_class_init (AzimuthClass *azimuth_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (azimuth_class);
+
+ g_type_class_add_private (azimuth_class, sizeof (AzimuthPrivate));
+
+ object_class->dispose = azimuth_dispose;
+}
+
+Azimuth *
+azimuth_new (void)
+{
+ return g_object_new (AZIMUTH_TYPE,
+ NULL);
+}
+
+void
+azimuth_run (Azimuth *self)
+{
+ AzimuthPrivate *priv = AZIMUTH_GET_PRIVATE (self);
+
+ g_assert (priv->publisher == NULL);
+ priv->publisher = position_publisher_new ();
+
+ g_print ("azimuth running\n");
+ g_main_loop_run (priv->loop);
+}