X-Git-Url: http://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/40647d7b7b7fbeae828e0a032a3c3a5f204cdfa8..714b58ab4606ed4d40cec3702cb378938f8c883f:/examples/gtk-button-count.gob diff --git a/examples/gtk-button-count.gob b/examples/gtk-button-count.gob index 0d039dc..9061c5c 100644 --- a/examples/gtk-button-count.gob +++ b/examples/gtk-button-count.gob @@ -1,3 +1,10 @@ +/* + * This is an example button widget which counts the number of clicks + * + * It is also showing how you can use inline gtk-doc like documentation + * which will be correctly translated and put into the resulting source + * file + */ class Gtk:Button:Count from Gtk:Button { public int count; @@ -9,25 +16,46 @@ class Gtk:Button:Count from Gtk:Button { self->count = ARG; }; - init(button) + init(self) { - button->count = 0; + self->count = 0; } + /** + * new: + * + * Makes a new #GtkButtonCount widget + * + * Returns: a new widget + **/ public 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; } - /* new button but with a label inside it already, the 'label' - argument must not be NULL or we will return NULL */ + /** + * new_with_label: + * @label: the label text + * + * Makes a new #GtkButtonCount widget with a label + * + * Returns: a new widget + **/ public 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)