X-Git-Url: http://pileus.org/git/?p=grits;a=blobdiff_plain;f=src%2Fplugins%2Ftest.c;h=f42f02cadf9e44684c4aff1ca16d43dad1874a7b;hp=87b0a6123e8dd9bf7928d3ea90bd5b3883ed9980;hb=d8948985b467a5cfd0447ae413ed1c5d01afb024;hpb=c2e39b9d64035038a19d753129cc2124b4ed1382
diff --git a/src/plugins/test.c b/src/plugins/test.c
index 87b0a61..f42f02c 100644
--- a/src/plugins/test.c
+++ b/src/plugins/test.c
@@ -15,29 +15,49 @@
* along with this program. If not, see .
*/
+/**
+ * SECTION:test
+ * @short_description: Testing plugin
+ *
+ * #GisPluginTest is a testing plugin used during development and as an example
+ * for how to create a plugin.
+ */
+
#include
#include
#include
-#include
+#include
#include "test.h"
/***********
* Methods *
***********/
+gboolean _load_marker(gpointer _test)
+{
+ GisPluginTest *test = _test;
+ GisMarker *marker = gis_marker_new("St. Charles");
+ gis_point_set_lle(gis_object_center(marker), 38.841847, -90.491982, 0);
+ GIS_OBJECT(marker)->lod = EARTH_R;
+ test->marker = gis_viewer_add(test->viewer, GIS_OBJECT(marker), GIS_LEVEL_OVERLAY, 0);
+ return FALSE;
+}
+/**
+ * gis_plugin_test_new:
+ * @viewer: the #GisViewer to use for drawing
+ *
+ * Create a new instance of the testing plugin.
+ *
+ * Returns: the new #GisPluginTest
+ */
GisPluginTest *gis_plugin_test_new(GisViewer *viewer)
{
g_debug("GisPluginTest: new");
- GisPluginTest *self = g_object_new(GIS_TYPE_PLUGIN_TEST, NULL);
- self->viewer = viewer;
-
- GisMarker *marker = gis_marker_new("St. Charles");
- gis_point_set_lle(gis_object_center(GIS_OBJECT(marker)), 38.841847, -90.491982, 0);
- GIS_OBJECT(marker)->lod = EARTH_R/4;
- gis_viewer_add(self->viewer, GIS_OBJECT(marker), GIS_LEVEL_OVERLAY, 0);
-
- return self;
+ GisPluginTest *test = g_object_new(GIS_TYPE_PLUGIN_TEST, NULL);
+ test->viewer = g_object_ref(viewer);
+ g_idle_add(_load_marker, test);
+ return test;
}
@@ -55,11 +75,24 @@ static void gis_plugin_test_plugin_init(GisPluginInterface *iface)
/* Add methods to the interface */
}
/* Class/Object init */
-static void gis_plugin_test_init(GisPluginTest *self)
+static void gis_plugin_test_init(GisPluginTest *test)
{
g_debug("GisPluginTest: init");
}
+static void gis_plugin_test_dispose(GObject *_test)
+{
+ g_debug("GisPluginTest: dispose");
+ GisPluginTest *test = GIS_PLUGIN_TEST(_test);
+ if (test->viewer) {
+ gis_viewer_remove(test->viewer, test->marker);
+ g_object_unref(test->viewer);
+ test->viewer = NULL;
+ }
+ G_OBJECT_CLASS(gis_plugin_test_parent_class)->finalize(_test);
+}
static void gis_plugin_test_class_init(GisPluginTestClass *klass)
{
g_debug("GisPluginTest: class_init");
+ GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
+ gobject_class->dispose = gis_plugin_test_dispose;
}