[libadwaita/wip/exalm/docs: 3/3] Add a hello world example
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/docs: 3/3] Add a hello world example
- Date: Mon, 27 Dec 2021 18:29:58 +0000 (UTC)
commit 7b6d9622c01580c1178ec9648c9c56fb5e36c0ca
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Dec 27 14:51:14 2021 +0500
Add a hello world example
examples/hello-world/hello.c | 26 ++++++++++++++++++++++++++
examples/hello-world/meson.build | 13 +++++++++++++
examples/meson.build | 5 +++++
meson.build | 1 +
po/POTFILES.skip | 1 +
5 files changed, 46 insertions(+)
---
diff --git a/examples/hello-world/hello.c b/examples/hello-world/hello.c
new file mode 100644
index 00000000..7a1409e8
--- /dev/null
+++ b/examples/hello-world/hello.c
@@ -0,0 +1,26 @@
+#include <adwaita.h>
+
+static void
+activate_cb (GtkApplication *app)
+{
+ GtkWidget *window = gtk_application_window_new (app);
+ GtkWidget *label = gtk_label_new ("Hello World");
+
+ gtk_window_set_title (GTK_WINDOW (window), "Hello");
+ gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
+ gtk_window_set_child (GTK_WINDOW (window), label);
+ gtk_window_present (GTK_WINDOW (window));
+}
+
+int
+main (int argc,
+ char *argv[])
+{
+ g_autoptr (AdwApplication) app = NULL;
+
+ app = adw_application_new ("org.example.Hello", G_APPLICATION_FLAGS_NONE);
+
+ g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);
+
+ return g_application_run (G_APPLICATION (app), argc, argv);
+}
diff --git a/examples/hello-world/meson.build b/examples/hello-world/meson.build
new file mode 100644
index 00000000..928a4e19
--- /dev/null
+++ b/examples/hello-world/meson.build
@@ -0,0 +1,13 @@
+# Uncomment to build separately
+# project('hello', 'c')
+
+gnome = import('gnome')
+
+executable('hello',
+ 'hello.c',
+ dependencies: [
+ dependency('gtk4'),
+ dependency('libadwaita-1'),
+ ],
+ install: false,
+)
diff --git a/examples/meson.build b/examples/meson.build
new file mode 100644
index 00000000..bbacb3f4
--- /dev/null
+++ b/examples/meson.build
@@ -0,0 +1,5 @@
+if get_option('examples')
+
+subdir('hello-world')
+
+endif
diff --git a/meson.build b/meson.build
index baba25be..a746bfbd 100644
--- a/meson.build
+++ b/meson.build
@@ -120,6 +120,7 @@ gnome = import('gnome')
subdir('src')
subdir('po')
subdir('demo')
+subdir('examples')
subdir('tests')
subdir('doc')
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index c60b8aed..ed5b6652 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -2,3 +2,4 @@
# Please keep this file sorted alphabetically.
demo/
doc/
+examples/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]