[gnome-devel-docs] Vala TextView example changed to place Window things in the Window class.
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] Vala TextView example changed to place Window things in the Window class.
- Date: Mon, 2 Jul 2012 02:34:27 +0000 (UTC)
commit 504fae760056e984b30652485deb6964a62a6bd5
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date: Sun Jul 1 21:55:42 2012 -0400
Vala TextView example changed to place Window things in the Window class.
platform-demos/C/samples/textview.vala | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/platform-demos/C/samples/textview.vala b/platform-demos/C/samples/textview.vala
index a049e21..fd835a7 100644
--- a/platform-demos/C/samples/textview.vala
+++ b/platform-demos/C/samples/textview.vala
@@ -3,25 +3,30 @@ public class MyApplication : Gtk.Application {
/* Override the 'activate' signal of GLib.Application. */
protected override void activate () {
/* Create the window of this applicationt. */
- var window = new Gtk.ApplicationWindow (this);
- window.title = "TextView Example";
- window.set_default_size (220, 200);
+ new MyWindow (this).show_all ();
+ }
+}
+
+/* This is the window. */
+class MyWindow: Gtk.ApplicationWindow {
+ internal MyWindow (MyApplication app) {
+ Object (application: app, title: "TextView Example");
+ this.set_default_size (220, 200);
var buffer = new Gtk.TextBuffer (null); //stores text to be displayed
var textview = new Gtk.TextView.with_buffer (buffer); //displays TextBuffer
textview.set_wrap_mode (Gtk.WrapMode.WORD); //sets line wrapping
var scrolled_window = new Gtk.ScrolledWindow (null, null);
- scrolled_window.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+ scrolled_window.set_policy (Gtk.PolicyType.AUTOMATIC,
+ Gtk.PolicyType.AUTOMATIC);
scrolled_window.add_with_viewport (textview);
scrolled_window.set_border_width (5);
- window.add (scrolled_window);
- window.show_all ();
+ this.add (scrolled_window);
}
}
-
/* main creates and runs the application. */
public int main (string[] args) {
return new MyApplication ().run (args);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]