1/* This is the application. */ 2public class MyApplication : Gtk.Application { 3 /* Override the 'activate' signal of GLib.Application. */ 4 protected override void activate () { 5 /* Create the window of this application. */ 6 new MyWindow (this).show_all (); 7 } 8} 9 10/* This is the window. */ 11class MyWindow: Gtk.ApplicationWindow { 12 internal MyWindow (MyApplication app) { 13 Object (application: app, title: "TextView Example"); 14 this.set_default_size (220, 200); 15 16 var buffer = new Gtk.TextBuffer (null); //stores text to be displayed 17 var textview = new Gtk.TextView.with_buffer (buffer); //displays TextBuffer 18 textview.set_wrap_mode (Gtk.WrapMode.WORD); //sets line wrapping 19 20 var scrolled_window = new Gtk.ScrolledWindow (null, null); 21 scrolled_window.set_policy (Gtk.PolicyType.AUTOMATIC, 22 Gtk.PolicyType.AUTOMATIC); 23 24 scrolled_window.add (textview); 25 scrolled_window.set_border_width (5); 26 27 this.add (scrolled_window); 28 } 29} 30/* main creates and runs the application. */ 31public int main (string[] args) { 32 return new MyApplication ().run (args); 33} 34