]> git.draconx.ca Git - gob-dx.git/blobdiff - examples/gtk-button-count.gob
Release 1.0.3
[gob-dx.git] / examples / gtk-button-count.gob
index 1982146e8fe11ab629667a8206012e2c231c7721..9061c5cd63fdaddc9e1f6170db169e65da82b566 100644 (file)
@@ -16,9 +16,9 @@ class Gtk:Button:Count from Gtk:Button {
                self->count = ARG;
        };
 
-       init(button)
+       init(self)
        {
-               button->count = 0;
+               self->count = 0;
        }
 
        /**
@@ -32,7 +32,9 @@ class Gtk:Button:Count from Gtk:Button {
        GtkWidget *
        new(void)
        {
-               return GTK_WIDGET(GET_NEW);
+               /* It's ok to use a normal cast here, as we are sure that we
+                * have gotten the right type */
+               return (GtkWidget *)GET_NEW;
        }
 
        /**
@@ -47,7 +49,13 @@ class Gtk:Button:Count from Gtk:Button {
        GtkWidget *
        new_with_label(char *label (check null)) onerror NULL
        {
-               return GTK_WIDGET(GET_NEW);
+               /* It's ok to use a normal cast here, as we are sure that we
+                * have gotten the right type */
+               GtkWidget *widget = (GtkWidget *)GET_NEW;
+               GtkWidget *label_widget = gtk_label_new(label);
+               gtk_container_add(GTK_CONTAINER(widget), label_widget);
+               gtk_widget_show(label_widget);
+               return widget;
        }
 
        override (Gtk:Button)