]> Pileus Git - grits/blobdiff - src/plugin-example.c
destructors, still need to free data in plugins though
[grits] / src / plugin-example.c
index 553dd3d6acb6aabe90ed74905e2d271e50461f8e..f2ae95ed364715bd5bb230829108e2ca6ab0c743 100644 (file)
 #include <GL/gl.h>
 
 #include "aweather-gui.h"
-#include "aweather-plugin.h"
 #include "plugin-example.h"
 
 /****************
  * GObject code *
  ****************/
+/* Plugin init */
 static void aweather_example_plugin_init(AWeatherPluginInterface *iface);
 static void aweather_example_expose(AWeatherPlugin *_example);
 G_DEFINE_TYPE_WITH_CODE(AWeatherExample, aweather_example, G_TYPE_OBJECT,
                G_IMPLEMENT_INTERFACE(AWEATHER_TYPE_PLUGIN,
                        aweather_example_plugin_init));
-static void aweather_example_class_init(AWeatherExampleClass *klass)
-{
-       GObjectClass *object_class = (GObjectClass*)klass;
-}
 static void aweather_example_plugin_init(AWeatherPluginInterface *iface)
 {
+       g_debug("AWeatherExample: plugin_init");
        /* Add methods to the interface */
        iface->expose = aweather_example_expose;
 }
+/* Class/Object init */
 static void aweather_example_init(AWeatherExample *example)
 {
+       g_debug("AWeatherExample: init");
        /* Set defaults */
        example->gui      = NULL;
        example->button   = NULL;
        example->rotation = 30.0;
 }
+static void aweather_example_dispose(GObject *gobject)
+{
+       g_debug("AWeatherExample: dispose");
+       AWeatherExample *self = AWEATHER_EXAMPLE(gobject);
+       /* Drop references */
+       G_OBJECT_CLASS(aweather_example_parent_class)->dispose(gobject);
+}
+static void aweather_example_finalize(GObject *gobject)
+{
+       g_debug("AWeatherExample: finalize");
+       AWeatherExample *self = AWEATHER_EXAMPLE(gobject);
+       /* Free data */
+       G_OBJECT_CLASS(aweather_example_parent_class)->finalize(gobject);
+
+}
+static void aweather_example_class_init(AWeatherExampleClass *klass)
+{
+       g_debug("AWeatherExample: class_init");
+       GObjectClass *gobject_class = (GObjectClass*)klass;
+       gobject_class->dispose  = aweather_example_dispose;
+       gobject_class->finalize = aweather_example_finalize;
+}
 
 /***********
  * Helpers *
@@ -67,7 +88,7 @@ static gboolean rotate(gpointer _example)
  ***********/
 AWeatherExample *aweather_example_new(AWeatherGui *gui)
 {
-       //g_message("aweather_view_new");
+       g_debug("AWeatherExample: new");
        AWeatherExample *example = g_object_new(AWEATHER_TYPE_EXAMPLE, NULL);
        example->gui = gui;
 
@@ -75,7 +96,7 @@ AWeatherExample *aweather_example_new(AWeatherGui *gui)
        GtkWidget *config  = aweather_gui_get_widget(gui, "tabs");
 
        /* Add configuration tab */
-       GtkWidget *label = gtk_label_new("example");
+       GtkWidget *label = gtk_label_new("Example");
        example->button = GTK_TOGGLE_BUTTON(gtk_toggle_button_new_with_label("Rotate"));
        gtk_notebook_append_page(GTK_NOTEBOOK(config), GTK_WIDGET(example->button), label);
 
@@ -89,7 +110,7 @@ AWeatherExample *aweather_example_new(AWeatherGui *gui)
 static void aweather_example_expose(AWeatherPlugin *_example)
 {
        AWeatherExample *example = AWEATHER_EXAMPLE(_example);
-       g_message("aweather_example_expose");
+       g_debug("AWeatherExample: expose");
        glDisable(GL_TEXTURE_2D);
        glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity();
        glOrtho(-1,1,-1,1,-10,10);