[gtk-web: 2/2] Merge branch 'wip/exalm/vala' into 'master'
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-web: 2/2] Merge branch 'wip/exalm/vala' into 'master'
- Date: Wed, 19 Feb 2020 22:09:01 +0000 (UTC)
commit 9e4e5c22a871d9b955fef08ecab235db6257d982
Merge: b6404a0 5136088
Author: Emmanuele Bassi <ebassi gmail com>
Date: Wed Feb 19 22:08:45 2020 +0000
Merge branch 'wip/exalm/vala' into 'master'
sample_codes: Add Vala example
See merge request Infrastructure/gtk-web!29
_data/sample_codes.yml | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
---
diff --cc _data/sample_codes.yml
index d802214,68b1da5..32defc2
--- a/_data/sample_codes.yml
+++ b/_data/sample_codes.yml
@@@ -72,13 -72,41 +72,41 @@@ codes
}
fn main() {
- let application =
- gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default())
- .expect("Initialization failed...");
-
- application.connect_activate(|app| on_activate(app));
- application.run(&args().collect::<Vec<_>>());
+ // Create a new application
+ let app = gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default())
+ .expect("Initialization failed...");
+ app.connect_activate(|app| on_activate(app));
+ // Run the application
+ app.run(&std::env::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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]