]> Pileus Git - grits/blobdiff - src/plugins/test.c
Remove object when test plugin unloads
[grits] / src / plugins / test.c
index 2e4cbf81f3a4cd2259833239b9ca2074bc3910f5..51be90ef88c04cbb796923315c4b741f5e2453b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
+ * Copyright (C) 2009-2011 Andy Spencer <andy753421@gmail.com>
  *
  * 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
@@ -25,9 +25,6 @@
 
 #include <string.h>
 
-#include <GL/gl.h>
-#include <GL/glu.h>
-
 #include <gdk/gdkkeysyms.h>
 #include <grits.h>
 
@@ -125,7 +122,7 @@ void _load_poly(GritsPluginTest *test)
        test->poly->color[2]  = test->poly->border[2] = 0;
        test->poly->color[3]  = 0.2;
        test->poly->border[3] = 1;
-       test->poly->width     = 10;
+       test->poly->width     = 6;
        grits_viewer_add(test->viewer, GRITS_OBJECT(test->poly),  GRITS_LEVEL_OVERLAY, TRUE);
        g_signal_connect(test->poly, "enter",        G_CALLBACK(on_poly_enter),  NULL);
        g_signal_connect(test->poly, "leave",        G_CALLBACK(on_poly_leave),  NULL);
@@ -133,6 +130,21 @@ void _load_poly(GritsPluginTest *test)
        g_signal_connect(test->poly, "key-press",    G_CALLBACK(on_poly_key),    NULL);
 }
 
+void _load_line(GritsPluginTest *test)
+{
+       test->line = grits_line_parse("30,-80 30,-120 50,-120 50,-80", "\t", " ", ",");
+       test->line->color[0]  = 1;
+       test->line->color[1]  = 0;
+       test->line->color[2]  = 0;
+       test->line->color[3]  = 1;
+       test->line->width     = 8;
+       grits_viewer_add(test->viewer, GRITS_OBJECT(test->line),  GRITS_LEVEL_OVERLAY, TRUE);
+       g_signal_connect(test->line, "enter",        G_CALLBACK(on_poly_enter),  NULL);
+       g_signal_connect(test->line, "leave",        G_CALLBACK(on_poly_leave),  NULL);
+       g_signal_connect(test->line, "button-press", G_CALLBACK(on_poly_button), NULL);
+       g_signal_connect(test->line, "key-press",    G_CALLBACK(on_poly_key),    NULL);
+}
+
 /**
  * grits_plugin_test_new:
  * @viewer: the #GritsViewer to use for drawing
@@ -148,6 +160,7 @@ GritsPluginTest *grits_plugin_test_new(GritsViewer *viewer)
        test->viewer = g_object_ref(viewer);
        _load_marker(test);
        _load_poly(test);
+       _load_line(test);
        return test;
 }
 
@@ -175,7 +188,9 @@ static void grits_plugin_test_dispose(GObject *_test)
        g_debug("GritsPluginTest: dispose");
        GritsPluginTest *test = GRITS_PLUGIN_TEST(_test);
        if (test->viewer) {
-               grits_viewer_remove(test->viewer, test->marker);
+               grits_viewer_remove(test->viewer, GRITS_OBJECT(test->marker));
+               grits_viewer_remove(test->viewer, GRITS_OBJECT(test->poly));
+               grits_viewer_remove(test->viewer, GRITS_OBJECT(test->line));
                g_object_unref(test->viewer);
                test->viewer = NULL;
        }