From 2dd24f923f4d4f2bbc77314445a6b1b6701b3569 Mon Sep 17 00:00:00 2001 From: Victor Kareh Date: Fri, 29 Aug 2025 09:14:41 -0400 Subject: history: Add enable/disable toggle This helps a bit with privacy. By disabling history, it wipes all notifications in the D-Bus buffer and prevents further storage. The history popup is also disabled. Notification storage resumes when history is enabled. Note that this just prevents the mate-notifications-daemon from storing notifications, but it doesn't prevent other processes from capturing them elsewhere. --- src/capplet/mate-notification-applet-history.c | 6 ++++++ src/capplet/mate-notification-properties.c | 3 +++ src/capplet/mate-notification-properties.ui | 16 ++++++++++++++++ src/common/constants.h | 1 + src/daemon/daemon.c | 17 ++++++++++++++++- 5 files changed, 42 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/capplet/mate-notification-applet-history.c b/src/capplet/mate-notification-applet-history.c index cca03d6..ce38a6f 100644 --- a/src/capplet/mate-notification-applet-history.c +++ b/src/capplet/mate-notification-applet-history.c @@ -245,6 +245,12 @@ show_notification_history (MateNotificationHistoryContext *context) return; } + /* Check if history is enabled */ + if (context->settings && !g_settings_get_boolean (context->settings, GSETTINGS_KEY_HISTORY_ENABLED)) { + g_warning ("Cannot show history: history is disabled for privacy"); + return; + } + /* If popup already exists, destroy it (basically toggle off) */ if (context->history_popup) { gtk_widget_destroy (context->history_popup); diff --git a/src/capplet/mate-notification-properties.c b/src/capplet/mate-notification-properties.c index adbbb6b..f81dd2c 100644 --- a/src/capplet/mate-notification-properties.c +++ b/src/capplet/mate-notification-properties.c @@ -44,6 +44,7 @@ typedef struct { GtkWidget* preview_button; GtkWidget* active_checkbox; GtkWidget* dnd_checkbox; + GtkWidget* history_checkbox; GtkWidget* monitor_label; GtkWidget* timeout_spin; GtkWidget* persistence_checkbox; @@ -496,6 +497,7 @@ static gboolean notification_properties_dialog_init(NotificationAppletDialog* di dialog->theme_combo = GTK_WIDGET(gtk_builder_get_object(builder, "theme_combo")); dialog->active_checkbox = GTK_WIDGET(gtk_builder_get_object(builder, "use_active_check")); dialog->dnd_checkbox = GTK_WIDGET(gtk_builder_get_object(builder, "do_not_disturb_check")); + dialog->history_checkbox = GTK_WIDGET(gtk_builder_get_object(builder, "history_enabled_check")); dialog->monitor_label = GTK_WIDGET(gtk_builder_get_object(builder, "monitor_label")); dialog->timeout_spin = GTK_WIDGET(gtk_builder_get_object(builder, "timeout_spin")); dialog->persistence_checkbox = GTK_WIDGET(gtk_builder_get_object(builder, "enable_persistence_check")); @@ -510,6 +512,7 @@ static gboolean notification_properties_dialog_init(NotificationAppletDialog* di g_settings_bind (dialog->gsettings, GSETTINGS_KEY_USE_ACTIVE_MONITOR, dialog->active_checkbox, "active", G_SETTINGS_BIND_DEFAULT); g_settings_bind (dialog->gsettings, GSETTINGS_KEY_DO_NOT_DISTURB, dialog->dnd_checkbox, "active", G_SETTINGS_BIND_DEFAULT); + g_settings_bind (dialog->gsettings, GSETTINGS_KEY_HISTORY_ENABLED, dialog->history_checkbox, "active", G_SETTINGS_BIND_DEFAULT); GtkAdjustment *timeout_adjustment = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(dialog->timeout_spin)); g_settings_bind (dialog->gsettings, GSETTINGS_KEY_DEFAULT_TIMEOUT, timeout_adjustment, "value", G_SETTINGS_BIND_DEFAULT); diff --git a/src/capplet/mate-notification-properties.ui b/src/capplet/mate-notification-properties.ui index 49bc4c8..9b461bf 100644 --- a/src/capplet/mate-notification-properties.ui +++ b/src/capplet/mate-notification-properties.ui @@ -218,6 +218,22 @@ 2 + + + Enable Notification History + True + True + False + start + True + When enabled, notifications are stored for later viewing. When disabled, no notification history is kept for privacy. Note: This only controls MATE's notification storage; system logs may still contain notification data. + + + False + True + 3 + + diff --git a/src/common/constants.h b/src/common/constants.h index 93bb20a..1a81977 100644 --- a/src/common/constants.h +++ b/src/common/constants.h @@ -31,6 +31,7 @@ #define GSETTINGS_KEY_DEFAULT_TIMEOUT "default-timeout" #define GSETTINGS_KEY_ENABLE_PERSISTENCE "enable-persistence" #define GSETTINGS_KEY_SHOW_COUNTDOWN "show-countdown" +#define GSETTINGS_KEY_HISTORY_ENABLED "history-enabled" #define NOTIFICATION_BUS_NAME "org.freedesktop.Notifications" #define NOTIFICATION_BUS_PATH "/org/freedesktop/Notifications" diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 9889d7c..4d303d7 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -528,6 +528,20 @@ static void on_popup_location_changed(GSettings *settings, gchar *key, NotifyDae } } +static void on_history_enabled_changed(GSettings *settings, gchar *key, NotifyDaemon* daemon) +{ + gboolean history_enabled; + + history_enabled = g_settings_get_boolean(daemon->gsettings, key); + daemon->history_enabled = history_enabled; + + if (!history_enabled && daemon->notification_history) { + /* Wipe the history when disabled to preserve privacy */ + g_queue_free_full(daemon->notification_history, (GDestroyNotify)_history_item_free); + daemon->notification_history = g_queue_new(); + } +} + static void notify_daemon_init(NotifyDaemon* daemon) { gchar *location; @@ -541,6 +555,7 @@ static void notify_daemon_init(NotifyDaemon* daemon) daemon->gsettings = g_settings_new (GSETTINGS_SCHEMA); g_signal_connect (daemon->gsettings, "changed::" GSETTINGS_KEY_POPUP_LOCATION, G_CALLBACK (on_popup_location_changed), daemon); + g_signal_connect (daemon->gsettings, "changed::" GSETTINGS_KEY_HISTORY_ENABLED, G_CALLBACK (on_history_enabled_changed), daemon); location = g_settings_get_string (daemon->gsettings, GSETTINGS_KEY_POPUP_LOCATION); daemon->stack_location = get_stack_location_from_string(location); @@ -1986,7 +2001,7 @@ static void _init_notification_history(NotifyDaemon* daemon) { daemon->notification_history = g_queue_new(); daemon->history_max_items = 100; /* Default max items */ - daemon->history_enabled = TRUE; /* Default enabled */ + daemon->history_enabled = g_settings_get_boolean(daemon->gsettings, GSETTINGS_KEY_HISTORY_ENABLED); } static void _cleanup_notification_history(NotifyDaemon* daemon) -- cgit v1.2.1