2 * azimuth.c - Source for Azimith
3 * Copyright (C) 2010 Guillaume Desmottes
4 * @author Guillaume Desmottes <gdesmott@gnome.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #include "position-publisher.h"
28 G_DEFINE_TYPE(Azimuth, azimuth, G_TYPE_OBJECT)
30 /* private structure */
31 typedef struct _AzimuthPrivate AzimuthPrivate;
33 struct _AzimuthPrivate
36 PositionPublisher *publisher;
39 #define AZIMUTH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), AZIMUTH_TYPE, AzimuthPrivate))
42 azimuth_init (Azimuth *obj)
44 AzimuthPrivate *priv = AZIMUTH_GET_PRIVATE (obj);
46 priv->loop = g_main_loop_new (NULL, FALSE);
47 priv->publisher = NULL;
51 azimuth_dispose (GObject *object)
53 Azimuth *self = AZIMUTH (object);
54 AzimuthPrivate *priv = AZIMUTH_GET_PRIVATE (self);
56 if (priv->publisher != NULL)
58 g_object_unref (priv->publisher);
59 priv->publisher = NULL;
62 if (priv->loop != NULL)
64 g_main_loop_unref (priv->loop);
68 if (G_OBJECT_CLASS (azimuth_parent_class)->dispose)
69 G_OBJECT_CLASS (azimuth_parent_class)->dispose (object);
73 azimuth_class_init (AzimuthClass *azimuth_class)
75 GObjectClass *object_class = G_OBJECT_CLASS (azimuth_class);
77 g_type_class_add_private (azimuth_class, sizeof (AzimuthPrivate));
79 object_class->dispose = azimuth_dispose;
85 return g_object_new (AZIMUTH_TYPE,
90 azimuth_run (Azimuth *self)
92 AzimuthPrivate *priv = AZIMUTH_GET_PRIVATE (self);
94 g_assert (priv->publisher == NULL);
95 priv->publisher = position_publisher_new ();
97 g_print ("azimuth running\n");
98 g_main_loop_run (priv->loop);