From e05fb7b3e36c052baf0dd607ddeb22c0a2b5cbde Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:47:04 +0200 Subject: Adding upstream version 43.2. Signed-off-by: Daniel Baumann --- .../pages/timezone/test-gis-location-entry.c | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 gnome-initial-setup/pages/timezone/test-gis-location-entry.c (limited to 'gnome-initial-setup/pages/timezone/test-gis-location-entry.c') 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 0000000..c6413e8 --- /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 + +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); +} -- cgit v1.2.3