[gtk-web: 1/2] add vala code for GTK Hello World




commit e35ce14142d71f1d0b09b68fb0cf2bc52fac8bc9
Author: Akarin <769218589 qq com>
Date:   Thu Mar 18 21:51:47 2021 +0000

    add vala code for GTK Hello World

 _docs/language-bindings/vala.md | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/_docs/language-bindings/vala.md b/_docs/language-bindings/vala.md
index f926067..ffcef61 100644
--- a/_docs/language-bindings/vala.md
+++ b/_docs/language-bindings/vala.md
@@ -20,6 +20,34 @@ You can see many Vala and GTK based projects[GNOME Wiki](https://wiki.gnome.org/
 
 [**Vala**](https://wiki.gnome.org/Projects/Vala/) website lists various [Vala's GTK 
tutorial](https://wiki.gnome.org/Projects/Vala/Documentation#GUI_Programming) [GTK's Vala 
tutorial](https://developer.gnome.org/gnome-devel-demos/stable/beginner.vala.html.en) that range from 
introduction to the usage of Gtk and much more.
 
+## A Hello World app
+Below is an `Hello World` program that can be used as an example to get started with GTK Vala binding.
+```vala
+int main (string[] argv) {
+    // Create a new application
+    var app = new Gtk.Application ("com.example.GtkApplication",
+                                   GLib.ApplicationFlags.FLAGS_NONE);
+
+    app.activate.connect (() => {
+        // Create a new window
+        var window = new Gtk.ApplicationWindow (app);
+
+        // Create a new button
+        var button = new Gtk.Button.with_label ("Hello, World!");
+
+        // When the button is clicked, close the window
+        button.clicked.connect (() => {
+            window.close ();
+        });
+
+        window.set_child (button);
+        window.present ();
+    });
+
+    return app.run (argv);
+}
+```
+
 ## Contribute
 
 If you are interested in contributing to the Vala and GTK binding project, you can get a head start by 
reading the instructions on how to get started for contributing to Vala 
[here](https://wiki.gnome.org/Projects/Vala/Bindings).


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]