[libadwaita/wip/exalm/docs: 7/7] Add a hello world example
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/docs: 7/7] Add a hello world example
- Date: Mon, 27 Dec 2021 09:52:30 +0000 (UTC)
commit 973a013bcddc1c0641a0d85048cbcb961c2b3967
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 | 1 +
meson.build | 1 +
po/POTFILES.skip | 1 +
5 files changed, 42 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..0cd0f1d9
--- /dev/null
+++ b/examples/meson.build
@@ -0,0 +1 @@
+subdir('hello-world')
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]