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

#include <gtk/gtk.h>

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;
  GdkGeometry size_hints = {
    300, 150, 600, 500, 0, 0, 1, 1, 0.0, 0.0, GDK_GRAVITY_NORTH_WEST
  };

  gtk_init (NULL, NULL);

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

  window = g_object_new (GTK_TYPE_WINDOW, "type", GTK_WINDOW_TOPLEVEL, NULL);
  gtk_window_set_titlebar (GTK_WINDOW (window), header_bar);
  gtk_window_set_default_size (GTK_WINDOW (window), 450, 200);
  gtk_window_set_geometry_hints (GTK_WINDOW (window), NULL, &size_hints,
                                 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE);

  g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), 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;
}
