// gcc -Wall $(pkg-config --cflags gtk+-3.0) -o scrollbar-bug769566 scrollbar-bug769566.c $(pkg-config --libs gtk+-3.0)

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

GtkAdjustment *adj;
int val = 10;

#define FAKE_TYPE_VTE (fake_vte_get_type ())
G_DECLARE_FINAL_TYPE(FakeVte, fake_vte, FAKE, VTE, GtkLabel)

FakeVte *fake_vte_new (void);

struct _FakeVte {
  GtkLabel parent_instance;
};

G_DEFINE_TYPE(FakeVte, fake_vte, GTK_TYPE_LABEL)

static void
fake_vte_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
  GTK_WIDGET_CLASS (fake_vte_parent_class)->size_allocate (widget, allocation);
  gtk_adjustment_set_value (adj, ++val);
}

static void
fake_vte_init (FakeVte *vte) {}

static void
fake_vte_class_init (FakeVteClass *klass)
{
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
  widget_class->size_allocate = fake_vte_size_allocate;
}

FakeVte *
fake_vte_new (void)
{
  return g_object_new (FAKE_TYPE_VTE, NULL);
}

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

  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);

  GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_container_add (GTK_CONTAINER (window), hbox);

  FakeVte *fake_vte = fake_vte_new ();
  gtk_label_set_text (GTK_LABEL (fake_vte), "Fake Vte");
  gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (fake_vte), TRUE, TRUE, 0);
  
  adj = gtk_adjustment_new (val, 0, 100, 1, 1, 10);
  GtkWidget *scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adj);
  gtk_box_pack_end (GTK_BOX (hbox), scrollbar, FALSE, FALSE, 0);

  gtk_widget_show_all (window);
  gtk_main ();
  return 0;
}
