using Gtk;


class MyScrolledWindow : Gtk.ScrolledWindow {
  public override void get_preferred_width(out int minimum_width, out int natural_width) {
    var child = this.get_child();
    if (child == null) {
      base.get_preferred_width(out minimum_width, out natural_width);
    } else {
      child.get_preferred_width(out minimum_width, out natural_width);
    }
  }
}

public int main(string[] args) {
	Gtk.init(ref args);

	var w = new Gtk.Window();
	var h = new Gtk.HBox(false, 0);
	//var s = new MyScrolledWindow();
	var s = new Gtk.ScrolledWindow(null, null);
	var t = new Gtk.TextView();
	var b = t.get_buffer();

	b.set_text("This is a very long line that should make the GtkScrolledWindow expand horizontally");

	w.add(h); h.add(s); s.add(t);
	h.child_set_property(s, "expand", true);
	h.child_set_property(s, "fill", false);
	w.show_all();

	w.delete_event.connect(() => { Gtk.main_quit(); return true; });
	Gtk.main();
	return 0;
} 
