Blame platform-demos/C/samples/textview.vala
|
Packit |
1470ea |
/* This is the application. */
|
|
Packit |
1470ea |
public class MyApplication : Gtk.Application {
|
|
Packit |
1470ea |
/* Override the 'activate' signal of GLib.Application. */
|
|
Packit |
1470ea |
protected override void activate () {
|
|
Packit |
1470ea |
/* Create the window of this application. */
|
|
Packit |
1470ea |
new MyWindow (this).show_all ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* This is the window. */
|
|
Packit |
1470ea |
class MyWindow: Gtk.ApplicationWindow {
|
|
Packit |
1470ea |
internal MyWindow (MyApplication app) {
|
|
Packit |
1470ea |
Object (application: app, title: "TextView Example");
|
|
Packit |
1470ea |
this.set_default_size (220, 200);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
var buffer = new Gtk.TextBuffer (null); //stores text to be displayed
|
|
Packit |
1470ea |
var textview = new Gtk.TextView.with_buffer (buffer); //displays TextBuffer
|
|
Packit |
1470ea |
textview.set_wrap_mode (Gtk.WrapMode.WORD); //sets line wrapping
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
var scrolled_window = new Gtk.ScrolledWindow (null, null);
|
|
Packit |
1470ea |
scrolled_window.set_policy (Gtk.PolicyType.AUTOMATIC,
|
|
Packit |
1470ea |
Gtk.PolicyType.AUTOMATIC);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
scrolled_window.add (textview);
|
|
Packit |
1470ea |
scrolled_window.set_border_width (5);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
this.add (scrolled_window);
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
/* main creates and runs the application. */
|
|
Packit |
1470ea |
public int main (string[] args) {
|
|
Packit |
1470ea |
return new MyApplication ().run (args);
|
|
Packit |
1470ea |
}
|