diff options
author | Felipe Borges <felipeborges@gnome.org> | 2023-01-03 14:13:14 +0100 |
---|---|---|
committer | Felipe Borges <felipeborges@gnome.org> | 2023-01-03 14:13:14 +0100 |
commit | e0e814332d07397b632ad15c81326d56bd927b6b (patch) | |
tree | 012259187dc9a176da8bb23f8085bfe9f0a60627 | |
parent | 088edd6c35d3ebfbe4381ef5baa0cfa98191b224 (diff) | |
download | gnome-control-center-notifications-filter-off-system-notifications.tar.gz |
notifications: Don't list system servicesnotifications-filter-off-system-notifications
The current system related entries are ambiguous, as it isn't clear
what the actual notifications are.
System services should handle their own notification settings
instead.
Fixes #527
-rw-r--r-- | panels/notifications/cc-notifications-panel.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/panels/notifications/cc-notifications-panel.c b/panels/notifications/cc-notifications-panel.c index b8242726c..fd79cbdad 100644 --- a/panels/notifications/cc-notifications-panel.c +++ b/panels/notifications/cc-notifications-panel.c @@ -281,6 +281,26 @@ add_application (CcNotificationsPanel *panel, g_hash_table_add (panel->known_applications, g_strdup (app->canonical_app_id)); } +static gboolean +app_is_system_service (GDesktopAppInfo *app) +{ + g_auto(GStrv) split = NULL; + const gchar *categories; + + categories = g_desktop_app_info_get_categories (app); + if (categories == NULL || categories[0] == '\0') + return FALSE; + + split = g_strsplit (categories, ";", -1); + if (g_strv_contains ((const gchar* const*) split, "X-GNOME-Settings-Panel") || + g_strv_contains ((const gchar* const*) split, "Settings") || + g_strv_contains ((const gchar* const*) split, "System")) { + return TRUE; + } + + return FALSE; +} + static void maybe_add_app_id (CcNotificationsPanel *panel, const char *canonical_app_id) @@ -311,6 +331,11 @@ maybe_add_app_id (CcNotificationsPanel *panel, return; } + if (app_is_system_service (G_DESKTOP_APP_INFO (app_info))) { + /* We don't want to show system services in the notification list */ + return; + } + app = g_slice_new (Application); app->canonical_app_id = g_strdup (canonical_app_id); app->settings = g_object_ref (settings); @@ -400,6 +425,11 @@ load_apps (CcNotificationsPanel *panel) app = iter->data; if (g_desktop_app_info_get_boolean (app, "X-GNOME-UsesNotifications")) { + if (app_is_system_service (app)) { + g_debug ("Skipped app '%s', as it is a system service", g_app_info_get_id (G_APP_INFO (app))); + continue; + } + process_app_info (panel, G_APP_INFO (app)); g_debug ("Processing app '%s'", g_app_info_get_id (G_APP_INFO (app))); } else { |