]> Pileus Git - grits/blob - src/plugins/test.c
92b588681e263803a515ab2ac843bb0502d3abb3
[grits] / src / plugins / test.c
1 /*
2  * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 /**
19  * SECTION:test
20  * @short_description: Testing plugin
21  *
22  * #GisPluginTest is a testing plugin used during development and as an example
23  * for how to create a plugin.
24  */
25
26 #include <gtk/gtkgl.h>
27 #include <GL/gl.h>
28 #include <GL/glu.h>
29
30 #include <gis.h>
31
32 #include "test.h"
33
34 /***********
35  * Methods *
36  ***********/
37 gboolean _load_marker(gpointer _test)
38 {
39         GisPluginTest *test = _test;
40         GisMarker *marker = gis_marker_new("St. Charles");
41         gis_point_set_lle(gis_object_center(marker), 38.841847, -90.491982, 0);
42         GIS_OBJECT(marker)->lod = EARTH_R;
43         test->marker = gis_viewer_add(test->viewer, GIS_OBJECT(marker), GIS_LEVEL_OVERLAY, 0);
44         return FALSE;
45 }
46 /**
47  * gis_plugin_test_new:
48  * @viewer: the #GisViewer to use for drawing
49  *
50  * Create a new instance of the testing plugin.
51  *
52  * Returns: the new #GisPluginTest
53  */
54 GisPluginTest *gis_plugin_test_new(GisViewer *viewer)
55 {
56         g_debug("GisPluginTest: new");
57         GisPluginTest *test = g_object_new(GIS_TYPE_PLUGIN_TEST, NULL);
58         test->viewer = g_object_ref(viewer);
59         g_idle_add(_load_marker, test);
60         return test;
61 }
62
63
64 /****************
65  * GObject code *
66  ****************/
67 /* Plugin init */
68 static void gis_plugin_test_plugin_init(GisPluginInterface *iface);
69 G_DEFINE_TYPE_WITH_CODE(GisPluginTest, gis_plugin_test, G_TYPE_OBJECT,
70                 G_IMPLEMENT_INTERFACE(GIS_TYPE_PLUGIN,
71                         gis_plugin_test_plugin_init));
72 static void gis_plugin_test_plugin_init(GisPluginInterface *iface)
73 {
74         g_debug("GisPluginTest: plugin_init");
75         /* Add methods to the interface */
76 }
77 /* Class/Object init */
78 static void gis_plugin_test_init(GisPluginTest *test)
79 {
80         g_debug("GisPluginTest: init");
81 }
82 static void gis_plugin_test_dispose(GObject *_test)
83 {
84         g_debug("GisPluginTest: dispose");
85         GisPluginTest *test = GIS_PLUGIN_TEST(_test);
86         if (test->viewer) {
87                 gis_viewer_remove(test->viewer, test->marker);
88                 g_object_unref(test->viewer);
89                 test->viewer = NULL;
90         }
91         G_OBJECT_CLASS(gis_plugin_test_parent_class)->finalize(_test);
92 }
93 static void gis_plugin_test_class_init(GisPluginTestClass *klass)
94 {
95         g_debug("GisPluginTest: class_init");
96         GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
97         gobject_class->dispose = gis_plugin_test_dispose;
98 }