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

const char text[] =
  "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod "
  "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
  "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
  "commodo consequat.";

static GtkWidget *create_widget() {
  GtkWidget *widget = gtk_text_view_new();
  gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)),
    text, strlen(text));
  gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(widget), GTK_WRAP_WORD);
//gtk_widget_set_hexpand(widget, TRUE);  /* helps with 'initial' sizings */
  return widget;
}

int main(int argc, char **argv) {
  gtk_init(&argc, &argv);

  GtkWidget *grid = gtk_grid_new();
  gtk_grid_attach(GTK_GRID(grid), create_widget(), 0, 0, 1, 1);
  gtk_grid_attach(GTK_GRID(grid), create_widget(), 0, 1, 1, 1);
  gtk_grid_attach(GTK_GRID(grid), create_widget(), 0, 2, 1, 1);

  GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
    grid);

  GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(GTK_WINDOW(window), 500, 300);
  gtk_container_add(GTK_CONTAINER(window), scrolled_window);

  g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
  gtk_widget_show_all(window);
  gtk_main();
  return 0;
}

