#include <gtk/gtk.h>

GtkWidget *window = 0;
GtkWidget *headerbar = 0;

static void on_button_clicked( GtkWidget *widget,
           gpointer   data )
{
  gtk_widget_destroy (headerbar);
}

static gboolean delete_event( GtkWidget *widget,
                GdkEvent  *event,
                gpointer   data )
{
  return FALSE;
}


int main(int argc, char *argv[])
{
  GtkWidget *button;


  gtk_init (&argc, &argv);
  
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_container_set_border_width (GTK_CONTAINER (window), 10);
  g_signal_connect (window, "delete-event",
    G_CALLBACK (delete_event), NULL);

  headerbar = gtk_header_bar_new ();
  g_object_ref_sink( G_OBJECT (headerbar));
  gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), "test");
  gtk_window_set_titlebar (GTK_WINDOW(window), headerbar);
  gtk_widget_show (headerbar);

  
  button = gtk_button_new_with_label ("Destroy the GtkHeaderBar");
  g_signal_connect (button, "clicked",
    G_CALLBACK (on_button_clicked), NULL);
  
  /* This packs the button into the window (a gtk container). */
  gtk_container_add (GTK_CONTAINER (window), button);
  gtk_widget_show (button);
  gtk_widget_show (window);
  
  gtk_main ();
  
  return 0;
}
