[gtk-web: 1/2] sample_codes: Add Vala example



commit 5136088be71287297f88ed27dbdffb6e5157321c
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Thu Feb 20 00:05:03 2020 +0500

    sample_codes: Add Vala example

 _data/sample_codes.yml | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/_data/sample_codes.yml b/_data/sample_codes.yml
index 5fb1c69..68b1da5 100644
--- a/_data/sample_codes.yml
+++ b/_data/sample_codes.yml
@@ -80,6 +80,34 @@ codes:
           application.run(&args().collect::<Vec<_>>());
       }
       ```
+  - name: Vala
+    ext: vala
+    snippet: |
+      ```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, destroy the window
+              button.clicked.connect (() => {
+                  window.destroy ();
+              });
+
+              window.add (button);
+              window.show_all ();
+          });
+
+          return app.run (argv);
+      }
+      ```
   - name: C
     ext: c
     snippet: |


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