/* gcc gtk-bugs-02.c $(pkg-config --cflags --libs gtk+-3.0 glib-2.0) */

#include <gtk/gtk.h>

int
main (void)
{
  GtkCellRenderer *cell;
  GtkListStore *model;
  GtkSettings *settings;
  GtkStyleContext *context;
  GtkTreeIter iter;
  GtkTreeViewColumn *column;
  GtkWidget *sw;
  GtkWidget *view;
  GtkWidget *window;

  gtk_init (NULL, NULL);

  settings = gtk_settings_get_default ();
  g_object_set (settings, "gtk-application-prefer-dark-theme", TRUE, NULL);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 160, 160);
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

  model = gtk_list_store_new (1, G_TYPE_STRING);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "HELLO WORLD", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "FOO BAR BAZ", -1);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, "GOODBYE WORLD", -1);

  sw = gtk_scrolled_window_new (NULL, NULL);
  gtk_container_add (GTK_CONTAINER (window), sw);

  view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);
  context = gtk_widget_get_style_context (view);
  gtk_style_context_add_class (context, "content-view");
  gtk_container_add (GTK_CONTAINER (sw), view);

  column = gtk_tree_view_column_new ();
  gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);

  cell = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column, cell, TRUE);
  gtk_tree_view_column_add_attribute (column, cell, "text", 0);

  gtk_widget_show_all (window);
  gtk_main ();

  g_object_unref (model);
  return 0;
}
