From b6fd39a9ba8c783ed182ef9e9c9e1635402e4b96 Mon Sep 17 00:00:00 2001 From: Automeris naranja Date: Mon, 8 Apr 2024 20:17:42 -0300 Subject: [PATCH] apps: Use a dialog to show "App is not sandboxed" info AdwBanners shouldn't have a custom child, because this breaks the banner adaptiveness. Said that, use the default AdwBanner button which triggers a dialog to inform the user the consequences of running an unsandboxed app. Closes https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/2975 --- panels/applications/applications.css | 7 ++ .../applications/applications.gresource.xml | 1 + panels/applications/cc-applications-panel.c | 21 +++++- panels/applications/cc-applications-panel.ui | 74 ++++++++++++++++--- 4 files changed, 90 insertions(+), 13 deletions(-) create mode 100644 panels/applications/applications.css diff --git a/panels/applications/applications.css b/panels/applications/applications.css new file mode 100644 index 0000000000..f90a21d2a2 --- /dev/null +++ b/panels/applications/applications.css @@ -0,0 +1,7 @@ +/* Sandbox info dialog */ +.sandbox-info-icon { + border-radius: 9999px; + min-width: 64px; + min-height: 64px; + background-color: alpha(@error_color, .25); +} diff --git a/panels/applications/applications.gresource.xml b/panels/applications/applications.gresource.xml index 7a869ee8b9..2d7d063f6e 100644 --- a/panels/applications/applications.gresource.xml +++ b/panels/applications/applications.gresource.xml @@ -7,5 +7,6 @@ cc-applications-row.ui cc-info-row.ui cc-snap-row.ui + applications.css diff --git a/panels/applications/cc-applications-panel.c b/panels/applications/cc-applications-panel.c index 94cf17f372..6f087685f6 100644 --- a/panels/applications/cc-applications-panel.c +++ b/panels/applications/cc-applications-panel.c @@ -90,7 +90,6 @@ struct _CcApplicationsPanel GtkButton *launch_button; GtkButton *view_details_button; AdwBanner *sandbox_banner; - GtkWidget *sandbox_info_button; GDBusProxy *perm_store; GSettings *media_handling_settings; @@ -143,6 +142,8 @@ struct _CcApplicationsPanel CcInfoRow *total; GtkButton *clear_cache_button; + AdwDialog *sandbox_info_dialog; + guint64 app_size; guint64 cache_size; guint64 data_size; @@ -1220,6 +1221,12 @@ on_storage_row_activated_cb (CcApplicationsPanel *self) adw_dialog_present (self->storage_dialog, GTK_WIDGET (self)); } +static void +on_sandbox_banner_button_activated_cb (CcApplicationsPanel *self) +{ + adw_dialog_present (self->sandbox_info_dialog, GTK_WIDGET (self)); +} + static void on_items_changed_cb (GListModel *list, guint position, @@ -1652,7 +1659,6 @@ cc_applications_panel_dispose (GObject *object) { CcApplicationsPanel *self = CC_APPLICATIONS_PANEL (object); - g_clear_pointer (&self->sandbox_info_button, gtk_widget_unparent); g_clear_pointer (&self->builtin_dialog, adw_dialog_force_close); g_clear_pointer (&self->handler_dialog, adw_dialog_force_close); g_clear_pointer (&self->storage_dialog, adw_dialog_force_close); @@ -1798,7 +1804,6 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass) gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, wallpaper); gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, removable_media_settings); gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, sandbox_banner); - gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, sandbox_info_button); gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, screenshot); gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, shortcuts); gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, search); @@ -1806,6 +1811,7 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass) gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, storage); gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, storage_dialog); gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, total); + gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, sandbox_info_dialog); gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, usage_section); gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, view_details_button); @@ -1831,6 +1837,7 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass) gtk_widget_class_bind_template_callback (widget_class, on_app_search_entry_search_stopped_cb); gtk_widget_class_bind_template_callback (widget_class, on_storage_row_activated_cb); + gtk_widget_class_bind_template_callback (widget_class, on_sandbox_banner_button_activated_cb); } static GtkWidget * @@ -1852,11 +1859,19 @@ cc_applications_panel_init (CcApplicationsPanel *self) g_resources_register (cc_applications_get_resource ()); + g_autoptr(GtkCssProvider) provider = NULL; + g_type_ensure (CC_TYPE_INFO_ROW); g_type_ensure (CC_TYPE_LIST_ROW); gtk_widget_init_template (GTK_WIDGET (self)); + provider = gtk_css_provider_new (); + gtk_css_provider_load_from_resource (provider, "/org/gnome/control-center/applications/applications.css"); + gtk_style_context_add_provider_for_display (gdk_display_get_default (), + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + gtk_widget_set_visible (GTK_WIDGET (self->install_button), gnome_software_is_installed ()); g_signal_connect_object (self->app_listbox, "row-activated", diff --git a/panels/applications/cc-applications-panel.ui b/panels/applications/cc-applications-panel.ui index 3ddaf015c0..237ee07540 100644 --- a/panels/applications/cc-applications-panel.ui +++ b/panels/applications/cc-applications-panel.ui @@ -155,15 +155,8 @@ False True - - - - end - center - 3 - App settings cannot be fully enforced for apps which are not sandboxed. These apps may use permissions which are not shown. - - + L_earn More + @@ -268,7 +261,7 @@ - Scr_eenshots + Screens_hots Take pictures of the screen at any time True @@ -541,6 +534,67 @@ + + + 420 + + + + + False + + + + + never + True + + + vertical + 24 + 12 + 24 + 24 + 24 + + + + large + center + channel-insecure + + + + + + + App is not sandboxed + True + center + + + + + + + True + center + App settings cannot be fully enforced for apps which are not sandboxed. +These apps may use permissions which are not shown. + + + + + + + + + + horizontal -- GitLab