#include <stdio.h>
#include <gtk/gtk.h>

static GtkWidget *dialog = NULL;

static GtkWidget*
create_box (void)
{
  GtkWidget *box = g_object_new (GTK_TYPE_VBOX, NULL);
  guint i, n = 100;
  for (i = 1; i <= n; i++)
    {
      gchar *name = g_strdup_printf ("%d/%d", i, n);
      GtkWidget *child = g_object_new (GTK_TYPE_BUTTON, "label", name, "parent", box, NULL);
      (void) child;
      g_free (name);
    }
  return box;
}

int
main (int   argc,
      char *argv[])
{
  gtk_init (&argc, &argv);
  GtkWidget *box = create_box ();
  GtkWidget *scwin = g_object_new (GTK_TYPE_SCROLLED_WINDOW, NULL);
  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scwin), box);
  GtkWidget *window = g_object_new (GTK_TYPE_WINDOW, "child", scwin, "default-width", 200, "default-height", 200, NULL);
  gtk_widget_show_all (window);
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
  // gtk_container_set_focus_hadjustment (GTK_CONTAINER (scwin), gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (scwin)));
  gtk_container_set_focus_vadjustment (GTK_CONTAINER (GTK_BIN (GTK_BIN (scwin)->child)->child), gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scwin)));
  gtk_main();
  return 0;
}


// gcc -Wall `pkg-config --cflags --libs gtk+-2.0` scrollfocus.c && ./a.out
