[gtk-web: 1/2] Added Perl example
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-web: 1/2] Added Perl example
- Date: Tue, 24 Mar 2020 13:31:13 +0000 (UTC)
commit 7ce85ea4468d1ad8629c173ea75647f7c8342686
Author: Красимир Беров <berov cpan org>
Date: Sun Mar 22 22:06:35 2020 +0200
Added Perl example
_data/sample_codes.yml | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
---
diff --git a/_data/sample_codes.yml b/_data/sample_codes.yml
index 594bbe5..dce34a6 100644
--- a/_data/sample_codes.yml
+++ b/_data/sample_codes.yml
@@ -134,3 +134,34 @@ codes:
return g_application_run (G_APPLICATION (app), argc, argv);
}
```
+ - name: Perl
+ ext: pl
+ snippet: |
+ ```perl
+ #!/usr/bin/env perl
+ use strict; use warnings; use utf8;
+ use Glib::IO;
+ use Gtk3;
+
+ # Create a new application
+ my $app =
+ Gtk3::Application->new('com.example.Gtk3Application', 'G_APPLICATION_FLAGS_NONE');
+
+ # When the application is launched…
+ $app->signal_connect(
+ activate => sub {
+ my $app = shift;
+ # … create a new window …
+ my $win = Gtk3::ApplicationWindow->new($app);
+ # … with a button in it …
+ my $btn = Gtk3::Button->new('Hello World!');
+ # … which closes the window when clicked
+ $btn->signal_connect(clicked => sub { $win->destroy });
+ $win->add($btn);
+ $win->show_all();
+ }
+ );
+
+ # Run the application
+ $app->run(\@ARGV);
+ ```
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]