From d2af4a2c5f4db82ef2ada876773a3ef0676d6464 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 14 Mar 2023 15:53:21 -0300 Subject: privacy: Connect 'activate-link' on row subtitle This is a massive hack, can break on future releases of libadwaita, and must be confined specifically to stable releases where a proper fix cannot be made. Crawl through the widget hierarchy to find the subtitle label of the action row, and connect to the 'activate-link' signal from it. Closes https://gitlab.gnome.org/GNOME/gnome-initial-setup/-/issues/181 --- .../pages/privacy/gis-privacy-page.c | 37 ++++++++++++++++++++++ .../pages/privacy/gis-privacy-page.ui | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/gnome-initial-setup/pages/privacy/gis-privacy-page.c b/gnome-initial-setup/pages/privacy/gis-privacy-page.c index 464d383..9c19889 100644 --- a/gnome-initial-setup/pages/privacy/gis-privacy-page.c +++ b/gnome-initial-setup/pages/privacy/gis-privacy-page.c @@ -40,6 +40,7 @@ struct _GisPrivacyPagePrivate { + GtkWidget *location_row; GtkWidget *location_switch; GtkWidget *reporting_group; GtkWidget *reporting_row; @@ -229,6 +230,34 @@ activate_link (GtkLabel *label, return TRUE; } +static GtkWidget * +get_subtitle_widget_from_row (GtkWidget *row) +{ + GtkWidget *subtitle_label; + GtkWidget *prefixes_box; + GtkWidget *title_label; + GtkWidget *header_box; + GtkWidget *title_box; + GtkWidget *image; + + /* XXX: this is a dirty hack to fix issue #181 [1] and must only be + * applied to stable branches where a proper fix cannot be made. Sorry. + * + * [1] https://gitlab.gnome.org/GNOME/gnome-initial-setup/-/issues/181 + */ + + header_box = gtk_list_box_row_get_child (GTK_LIST_BOX_ROW (row)); + + prefixes_box = gtk_widget_get_first_child (header_box); + image = gtk_widget_get_next_sibling (prefixes_box); + title_box = gtk_widget_get_next_sibling (image); + + title_label = gtk_widget_get_first_child (title_box); + subtitle_label = gtk_widget_get_next_sibling (title_label); + + return subtitle_label; +} + static void gis_privacy_page_locale_changed (GisPage *page) { @@ -242,6 +271,7 @@ gis_privacy_page_class_init (GisPrivacyPageClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/initial-setup/gis-privacy-page.ui"); + gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisPrivacyPage, location_row); gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisPrivacyPage, location_switch); gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisPrivacyPage, reporting_group); gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisPrivacyPage, reporting_row); @@ -258,8 +288,15 @@ gis_privacy_page_class_init (GisPrivacyPageClass *klass) static void gis_privacy_page_init (GisPrivacyPage *page) { + GisPrivacyPagePrivate *priv = gis_privacy_page_get_instance_private (page); + g_type_ensure (GIS_TYPE_PAGE_HEADER); gtk_widget_init_template (GTK_WIDGET (page)); + + g_signal_connect (get_subtitle_widget_from_row (priv->location_row), + "activate-link", + G_CALLBACK (activate_link), + page); } GisPage * diff --git a/gnome-initial-setup/pages/privacy/gis-privacy-page.ui b/gnome-initial-setup/pages/privacy/gis-privacy-page.ui index 84ea8e3..359e424 100644 --- a/gnome-initial-setup/pages/privacy/gis-privacy-page.ui +++ b/gnome-initial-setup/pages/privacy/gis-privacy-page.ui @@ -22,7 +22,7 @@ - + True Location Services Allows applications to determine your geographical location. Uses the Mozilla Location Service (<a href='https://location.services.mozilla.com/privacy'>privacy policy</a>). -- cgit v1.2.1