/* gtk-booton.h */

#ifndef _GTK_BOOTON
#define _GTK_BOOTON

#include <gtk/gtk.h>

G_BEGIN_DECLS

#define GTK_TYPE_BOOTON gtk_booton_get_type()

#define GTK_BOOTON(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BOOTON, GtkBooton))

#define GTK_BOOTON_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_BOOTON, GtkBootonClass))

#define GTK_IS_BOOTON(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BOOTON))

#define GTK_IS_BOOTON_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_BOOTON))

#define GTK_BOOTON_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BOOTON, GtkBootonClass))

typedef struct {
  GtkButton parent;
} GtkBooton;

typedef struct {
  GtkButtonClass parent_class;
} GtkBootonClass;

GType gtk_booton_get_type (void);

static void gtk_booton_unmap (GtkWidget *widget);

GtkWidget * gtk_booton_new (void);

G_END_DECLS

#endif /* _GTK_BOOTON */

/* gtk-booton.c */

G_DEFINE_TYPE (GtkBooton, gtk_booton, GTK_TYPE_BUTTON)


static void
gtk_booton_class_init (GtkBootonClass *klass)
{
        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);

        widget_class->unmap = gtk_booton_unmap;
}

static void
gtk_booton_unmap (GtkWidget *widget)
{
        g_print ("This won't run\n");

        GTK_WIDGET_CLASS (gtk_booton_parent_class)->unmap (widget);
}

static void
gtk_booton_init (GtkBooton *self)
{
}

GtkWidget *
gtk_booton_new (void)
{
        return g_object_new (GTK_TYPE_BOOTON,
                             "label", "Booton!", NULL);
}

int
main (int argc, char **argv)
{
        GtkWidget *window;
        GtkWidget *booton;

        gtk_init (&argc, &argv);

        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        booton = gtk_booton_new();
        gtk_container_add (GTK_CONTAINER (window),
                           booton);
        g_signal_connect (booton, "clicked", G_CALLBACK (gtk_widget_destroy), NULL);
        g_signal_connect_swapped (booton, "unmap", G_CALLBACK (g_print), "This won't be printed\n");
        gtk_widget_show_all (window);

        gtk_main ();

        return 0;
}
