X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Fplugins%2Ftest.c;h=4dbc8380dfa50823a87c1c03c4b78a8cbe9b5a1a;hb=14c34a746fc94a9e5477d081275f04bd1c8b5d6d;hp=5be0fd7a0eb9f6feef69dc8d360e42b0e3bc1952;hpb=1ccb2426332856ef04f0bfb35716520a94e0d32c;p=grits diff --git a/src/plugins/test.c b/src/plugins/test.c index 5be0fd7..4dbc838 100644 --- a/src/plugins/test.c +++ b/src/plugins/test.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Andy Spencer + * Copyright (C) 2009-2010 Andy Spencer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,6 +15,14 @@ * 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 @@ -26,17 +34,26 @@ /*********** * Methods * ***********/ +/** + * 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; + GisPluginTest *test = g_object_new(GIS_TYPE_PLUGIN_TEST, NULL); + test->viewer = g_object_ref(viewer); GisMarker *marker = gis_marker_new("St. Charles"); gis_point_set_lle(gis_object_center(marker), 38.841847, -90.491982, 0); - gis_viewer_add(self->viewer, GIS_OBJECT(marker)); + GIS_OBJECT(marker)->lod = EARTH_R; + test->marker = gis_viewer_add(test->viewer, GIS_OBJECT(marker), GIS_LEVEL_OVERLAY, 0); - return self; + return test; } @@ -54,11 +71,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; }