From d1b63113259cdda95d961f892650a0503654cf76 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 10 Mar 2022 11:06:19 +0000 Subject: [PATCH] ui: Disable markup in widgets derived from AdwPreferencesRow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a follow-up to !1280. If a recent enough version of libadwaita is available, it disables markup in widgets derived from `AdwPreferencesRow`, rather than having to explicitly escape all label contents. This is not worth bumping our libadwaita dependency for, as it’s a simple and small set of changes, and libadwaita 1.2.0 is not quite released yet (so won’t be in distros for a while). Signed-off-by: Philip Withnall --- src/gs-app-details-page.c | 3 +++ src/gs-context-dialog-row.c | 4 ++++ src/gs-details-page.c | 9 +++++++++ src/gs-prefs-dialog.c | 9 +++++++++ src/gs-prefs-dialog.ui | 4 ++-- src/gs-repos-dialog.c | 3 +++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/gs-app-details-page.c b/src/gs-app-details-page.c index 80de5ea56..88b38d8e3 100644 --- a/src/gs-app-details-page.c +++ b/src/gs-app-details-page.c @@ -97,6 +97,9 @@ add_permissions_row (GsAppDetailsPage *page, if (!is_warning_row) gtk_widget_set_opacity (image, 0); +#if ADW_CHECK_VERSION(1,2,0) + adw_preferences_row_set_use_markup (ADW_PREFERENCES_ROW (row), FALSE); +#endif adw_action_row_add_prefix (ADW_ACTION_ROW (row), image); adw_preferences_row_set_title (ADW_PREFERENCES_ROW (row), title); adw_action_row_set_subtitle (ADW_ACTION_ROW (row), subtitle); diff --git a/src/gs-context-dialog-row.c b/src/gs-context-dialog-row.c index 73f8fcbfc..420816f98 100644 --- a/src/gs-context-dialog-row.c +++ b/src/gs-context-dialog-row.c @@ -74,6 +74,10 @@ static void gs_context_dialog_row_init (GsContextDialogRow *self) { gtk_widget_init_template (GTK_WIDGET (self)); + +#if ADW_CHECK_VERSION(1,2,0) + adw_preferences_row_set_use_markup (ADW_PREFERENCES_ROW (self), FALSE); +#endif } static void diff --git a/src/gs-details-page.c b/src/gs-details-page.c index a35a4e967..03bdc0b6e 100644 --- a/src/gs-details-page.c +++ b/src/gs-details-page.c @@ -953,10 +953,19 @@ update_action_row_from_link (AdwActionRow *row, AsUrlKind url_kind) { const gchar *url = gs_app_get_url (app, url_kind); + +#if ADW_CHECK_VERSION(1,2,0) + adw_preferences_row_set_use_markup (ADW_PREFERENCES_ROW (row), FALSE); + + if (url != NULL) + adw_action_row_set_subtitle (row, url); +#else if (url != NULL) { g_autofree gchar *escaped_url = g_markup_escape_text (url, -1); adw_action_row_set_subtitle (row, escaped_url); } +#endif + gtk_widget_set_visible (GTK_WIDGET (row), url != NULL); return (url != NULL); diff --git a/src/gs-prefs-dialog.c b/src/gs-prefs-dialog.c index 3c24dba0e..df49aa034 100644 --- a/src/gs-prefs-dialog.c +++ b/src/gs-prefs-dialog.c @@ -25,6 +25,8 @@ struct _GsPrefsDialog GsPluginLoader *plugin_loader; GtkWidget *switch_updates; GtkWidget *switch_updates_notify; + AdwActionRow *automatic_updates_row; + AdwActionRow *automatic_update_notifications_row; }; G_DEFINE_TYPE (GsPrefsDialog, gs_prefs_dialog, ADW_TYPE_PREFERENCES_WINDOW) @@ -58,6 +60,11 @@ gs_prefs_dialog_init (GsPrefsDialog *dialog) dialog->switch_updates, "active", G_SETTINGS_BIND_DEFAULT); + +#if ADW_CHECK_VERSION(1,2,0) + adw_preferences_row_set_use_markup (ADW_PREFERENCES_ROW (dialog->automatic_updates_row), FALSE); + adw_preferences_row_set_use_markup (ADW_PREFERENCES_ROW (dialog->automatic_update_notifications_row), FALSE); +#endif } static void @@ -71,6 +78,8 @@ gs_prefs_dialog_class_init (GsPrefsDialogClass *klass) gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-prefs-dialog.ui"); gtk_widget_class_bind_template_child (widget_class, GsPrefsDialog, switch_updates); gtk_widget_class_bind_template_child (widget_class, GsPrefsDialog, switch_updates_notify); + gtk_widget_class_bind_template_child (widget_class, GsPrefsDialog, automatic_updates_row); + gtk_widget_class_bind_template_child (widget_class, GsPrefsDialog, automatic_update_notifications_row); } GtkWidget * diff --git a/src/gs-prefs-dialog.ui b/src/gs-prefs-dialog.ui index d5cdbcd62..3fcb8c1bd 100644 --- a/src/gs-prefs-dialog.ui +++ b/src/gs-prefs-dialog.ui @@ -15,7 +15,7 @@ To avoid charges and network caps, software updates are not automatically downloaded on mobile or metered connections. - + Automatic Updates Downloads and installs software updates in the background, when possible. 0 @@ -28,7 +28,7 @@ - + Automatic Update Notifications Show notifications when updates have been automatically installed. 0 diff --git a/src/gs-repos-dialog.c b/src/gs-repos-dialog.c index 40fccd5ec..bb9546392 100644 --- a/src/gs-repos-dialog.c +++ b/src/gs-repos-dialog.c @@ -502,6 +502,9 @@ get_sources_cb (GsPluginLoader *plugin_loader, gtk_widget_show (widget); row = adw_action_row_new (); +#if ADW_CHECK_VERSION(1,2,0) + adw_preferences_row_set_use_markup (ADW_PREFERENCES_ROW (row), FALSE); +#endif adw_preferences_row_set_title (ADW_PREFERENCES_ROW (row), _("Enable New Repositories")); adw_action_row_set_subtitle (ADW_ACTION_ROW (row), _("Turn on new repositories when they are added.")); adw_action_row_set_activatable_widget (ADW_ACTION_ROW (row), widget); -- GitLab