[gnome-initial-setup/gbsneto/timezone-regressions] Add test program for GisLocationEntry
- From: Will Thompson <wjt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/gbsneto/timezone-regressions] Add test program for GisLocationEntry
- Date: Mon, 15 Aug 2022 14:53:35 +0000 (UTC)
commit 4b580c53dd3245cd293de8db5fe8e7068fd684aa
Author: Will Thompson <wjt endlessos org>
Date: Mon Aug 15 15:52:29 2022 +0100
Add test program for GisLocationEntry
This is for interactive testing only; it is neither installed nor run by the build system.
gnome-initial-setup/meson.build | 8 ++--
gnome-initial-setup/pages/timezone/meson.build | 15 ++++++
.../pages/timezone/test-gis-location-entry.c | 54 ++++++++++++++++++++++
3 files changed, 74 insertions(+), 3 deletions(-)
---
diff --git a/gnome-initial-setup/meson.build b/gnome-initial-setup/meson.build
index fac8d1b8..3127803c 100644
--- a/gnome-initial-setup/meson.build
+++ b/gnome-initial-setup/meson.build
@@ -1,7 +1,5 @@
sources = []
-subdir('pages')
-
resources = gnome.compile_resources(
'gis-assistant-resources',
files('gis-assistant.gresource.xml'),
@@ -38,6 +36,10 @@ geocode_glib_2_dep = dependency(
],
)
+gweather_dep = dependency('gweather4')
+
+subdir('pages')
+
dependencies = [
dependency ('libnm', version: '>= 1.2'),
dependency ('libnma-gtk4', version: '>= 1.0'),
@@ -52,7 +54,7 @@ dependencies = [
dependency ('glib-2.0', version: '>= 2.63.1'),
dependency ('gio-unix-2.0', version: '>= 2.53.0'),
dependency ('gdm', version: '>= 3.8.3'),
- dependency ('gweather4'),
+ gweather_dep,
dependency ('libgeoclue-2.0', version: '>= 2.3.1'),
cc.find_library('m', required: false),
dependency ('pango', version: '>= 1.32.5'),
diff --git a/gnome-initial-setup/pages/timezone/meson.build b/gnome-initial-setup/pages/timezone/meson.build
index 04c2f922..54a974e0 100644
--- a/gnome-initial-setup/pages/timezone/meson.build
+++ b/gnome-initial-setup/pages/timezone/meson.build
@@ -28,3 +28,18 @@ sources += files(
'gis-timezone-page.c',
'gis-timezone-page.h'
)
+
+executable('test-gis-location-entry',
+ files(
+ 'gis-location-entry.c',
+ 'gis-location-entry.h',
+ 'test-gis-location-entry.c',
+ ),
+ dependencies: [
+ libadwaita_dep,
+ gweather_dep,
+ geocode_glib_2_dep,
+ ],
+ include_directories: config_h_dir,
+ install: false,
+)
\ No newline at end of file
diff --git a/gnome-initial-setup/pages/timezone/test-gis-location-entry.c
b/gnome-initial-setup/pages/timezone/test-gis-location-entry.c
new file mode 100644
index 00000000..c6413e82
--- /dev/null
+++ b/gnome-initial-setup/pages/timezone/test-gis-location-entry.c
@@ -0,0 +1,54 @@
+#include "config.h"
+
+#include "gis-location-entry.h"
+
+#include <adwaita.h>
+
+static void
+entry_location_changed (GObject *object,
+ GParamSpec *param,
+ gpointer data)
+{
+ GtkLabel *label = GTK_LABEL (data);
+ GisLocationEntry *entry = GIS_LOCATION_ENTRY (object);
+ g_autoptr(GWeatherLocation) location = NULL;
+ const gchar *message = NULL;
+
+ location = gis_location_entry_get_location (entry);
+ message = location != NULL ? gweather_location_get_name (location) : "No location selected";
+ g_message ("%s: %s", G_STRLOC, message);
+ gtk_label_set_text (label, message);
+}
+
+static void
+activate_cb (GtkApplication *app)
+{
+ GtkWidget *window = gtk_application_window_new (app);
+ GtkWidget *box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ GtkWidget *label = gtk_label_new ("Pick a location…");
+ GtkWidget *entry = gis_location_entry_new (NULL);
+
+ gtk_box_append (GTK_BOX (box), label);
+ gtk_box_append (GTK_BOX (box), entry);
+
+ g_signal_connect (entry, "notify::location",
+ G_CALLBACK (entry_location_changed), label);
+
+ gtk_window_set_title (GTK_WINDOW (window), "Hello");
+ gtk_window_set_default_size (GTK_WINDOW (window), 1024, 768);
+ gtk_window_set_child (GTK_WINDOW (window), box);
+ gtk_window_present (GTK_WINDOW (window));
+}
+
+int
+main (int argc,
+ char *argv[])
+{
+ g_autoptr (AdwApplication) app = NULL;
+
+ app = adw_application_new ("org.gnome.InitialSetup.TestLocationEntry", G_APPLICATION_FLAGS_NONE);
+
+ g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);
+
+ return g_application_run (G_APPLICATION (app), argc, argv);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]