/* gcc -g window-size.c $(pkg-config --cflags --libs gtk+-3.0) */

#include <gtk/gtk.h>

static gboolean
window_delete_event (GtkWidget *widget, GdkEvent *event)
{
  gint height;
  gint width;

  gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
  g_message ("window_delete_event: %d x %d", width, height);
  return GDK_EVENT_PROPAGATE;
}

static void
window_size_allocate (GtkWidget *widget, GdkRectangle *allocation)
{
  gint height;
  gint width;

  gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
  g_message ("window_size_allocate: %d x %d", width, height);
}

gint
main (gint argc, gchar *argv[])
{
  GtkWidget *header_bar;
  GtkWidget *window;

  gtk_init (NULL, NULL);

  header_bar = gtk_header_bar_new ();
  gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (header_bar), TRUE);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_titlebar (GTK_WINDOW (window), header_bar);
  gtk_window_set_default_size (GTK_WINDOW (window), 1017, 600);
  g_signal_connect (window,
                    "delete-event",
                    G_CALLBACK (window_delete_event),
                    NULL);
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
  g_signal_connect (window,
                    "size-allocate",
                    G_CALLBACK (window_size_allocate),
                    NULL);

  gtk_widget_show_all (window);
  gtk_main ();

  return 0;
}
