summaryrefslogtreecommitdiff
path: root/src/capplet
diff options
context:
space:
mode:
Diffstat (limited to 'src/capplet')
-rw-r--r--src/capplet/Makefile.am10
-rw-r--r--src/capplet/mate-notification-applet-dbus.c214
-rw-r--r--src/capplet/mate-notification-applet-dbus.h52
-rw-r--r--src/capplet/mate-notification-applet-history.c421
-rw-r--r--src/capplet/mate-notification-applet-history.h59
-rw-r--r--src/capplet/mate-notification-applet-menu.xml6
-rw-r--r--src/capplet/mate-notification-applet.c378
-rw-r--r--src/capplet/mate-notification-properties.c79
-rw-r--r--src/capplet/mate-notification-properties.ui136
9 files changed, 1285 insertions, 70 deletions
diff --git a/src/capplet/Makefile.am b/src/capplet/Makefile.am
index af7569a..0017ab6 100644
--- a/src/capplet/Makefile.am
+++ b/src/capplet/Makefile.am
@@ -45,6 +45,10 @@ libmate_notification_applet_la_SOURCES = \
$(mate_notification_applet_resources_files) \
../common/constants.h \
mate-notification-applet.c \
+ mate-notification-applet-dbus.h \
+ mate-notification-applet-dbus.c \
+ mate-notification-applet-history.h \
+ mate-notification-applet-history.c \
$(NULL)
libmate_notification_applet_la_CFLAGS = \
@@ -64,6 +68,10 @@ mate_notification_applet_SOURCES = \
$(mate_notification_applet_resources_files) \
../common/constants.h \
mate-notification-applet.c \
+ mate-notification-applet-dbus.h \
+ mate-notification-applet-dbus.c \
+ mate-notification-applet-history.h \
+ mate-notification-applet-history.c \
$(NULL)
mate_notification_applet_CFLAGS = \
@@ -104,6 +112,8 @@ EXTRA_DIST = \
$(mate_notification_properties_resources_xml) \
mate-notification-applet-menu.xml \
mate-notification-properties.ui \
+ mate-notification-applet-dbus.h \
+ mate-notification-applet-history.h \
$(NULL)
-include $(top_srcdir)/git.mk
diff --git a/src/capplet/mate-notification-applet-dbus.c b/src/capplet/mate-notification-applet-dbus.c
new file mode 100644
index 0000000..68ed6f3
--- /dev/null
+++ b/src/capplet/mate-notification-applet-dbus.c
@@ -0,0 +1,214 @@
+/* mate-notification-applet-dbus.c - MATE Notification Applet - D-Bus Context
+ *
+ * Copyright (C) 2025 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "mate-notification-applet-dbus.h"
+#include "../common/constants.h"
+
+MateNotificationDBusContext *
+dbus_context_new (void)
+{
+ MateNotificationDBusContext *context = g_new0 (MateNotificationDBusContext, 1);
+ context->daemon_proxy = NULL;
+ context->daemon_available = FALSE;
+ context->watch_id = 0;
+ return context;
+}
+
+void
+dbus_context_free (MateNotificationDBusContext *context)
+{
+ if (context) {
+ dbus_context_disconnect (context);
+ g_free (context);
+ }
+}
+
+gboolean
+dbus_context_connect (MateNotificationDBusContext *context)
+{
+ GError *error = NULL;
+
+ if (!context)
+ return FALSE;
+
+ /* Clean up existing connection */
+ dbus_context_disconnect (context);
+
+ /* Create D-Bus proxy for notification daemon */
+ context->daemon_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL, /* GDBusInterfaceInfo */
+ NOTIFICATION_BUS_NAME,
+ NOTIFICATION_BUS_PATH,
+ "org.freedesktop.Notifications",
+ NULL, /* GCancellable */
+ &error);
+
+ if (error) {
+ g_warning ("Failed to connect to notification daemon: %s", error->message);
+ g_error_free (error);
+ context->daemon_available = FALSE;
+ return FALSE;
+ }
+
+ context->daemon_available = TRUE;
+ return TRUE;
+}
+
+void
+dbus_context_disconnect (MateNotificationDBusContext *context)
+{
+ if (!context)
+ return;
+
+ if (context->daemon_proxy) {
+ g_object_unref (context->daemon_proxy);
+ context->daemon_proxy = NULL;
+ }
+
+ context->daemon_available = FALSE;
+}
+
+gboolean
+dbus_context_is_available (MateNotificationDBusContext *context)
+{
+ return context && context->daemon_available && context->daemon_proxy;
+}
+
+guint
+dbus_context_get_notification_count (MateNotificationDBusContext *context)
+{
+ GVariant *result;
+ GError *error = NULL;
+ guint count = 0;
+
+ if (!dbus_context_is_available (context))
+ return 0;
+
+ result = g_dbus_proxy_call_sync (context->daemon_proxy,
+ "GetNotificationCount",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL, /* GCancellable */
+ &error);
+
+ if (error) {
+ g_warning ("Failed to get notification count: %s", error->message);
+ g_error_free (error);
+ context->daemon_available = FALSE;
+ } else if (result) {
+ g_variant_get (result, "(u)", &count);
+ g_variant_unref (result);
+ }
+
+ return count;
+}
+
+gboolean
+dbus_context_clear_notification_history (MateNotificationDBusContext *context)
+{
+ GVariant *result;
+ GError *error = NULL;
+
+ if (!dbus_context_is_available (context))
+ return FALSE;
+
+ result = g_dbus_proxy_call_sync (context->daemon_proxy,
+ "ClearNotificationHistory",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL, /* GCancellable */
+ &error);
+
+ if (error) {
+ g_warning ("Failed to clear notification history: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ if (result) {
+ g_variant_unref (result);
+ }
+
+ return TRUE;
+}
+
+gboolean
+dbus_context_mark_all_notifications_as_read (MateNotificationDBusContext *context)
+{
+ GVariant *result;
+ GError *error = NULL;
+
+ if (!dbus_context_is_available (context))
+ return FALSE;
+
+ result = g_dbus_proxy_call_sync (context->daemon_proxy,
+ "MarkAllNotificationsAsRead",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL, /* GCancellable */
+ &error);
+
+ if (error) {
+ g_warning ("Failed to mark all notifications as read: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ if (result) {
+ g_variant_unref (result);
+ }
+
+ return TRUE;
+}
+
+GVariant *
+dbus_context_get_notification_history (MateNotificationDBusContext *context)
+{
+ GVariant *result;
+ GError *error = NULL;
+
+ if (!dbus_context_is_available (context))
+ return NULL;
+
+ result = g_dbus_proxy_call_sync (context->daemon_proxy,
+ "GetNotificationHistory",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL, /* GCancellable */
+ &error);
+
+ if (error) {
+ g_warning ("Failed to get notification history: %s", error->message);
+ g_error_free (error);
+ return NULL;
+ }
+
+ return result; /* Caller owns this reference */
+}
diff --git a/src/capplet/mate-notification-applet-dbus.h b/src/capplet/mate-notification-applet-dbus.h
new file mode 100644
index 0000000..7f95bc3
--- /dev/null
+++ b/src/capplet/mate-notification-applet-dbus.h
@@ -0,0 +1,52 @@
+/* mate-notification-applet-dbus.h - MATE Notification Applet - D-Bus Context
+ *
+ * Copyright (C) 2025 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __MATE_NOTIFICATION_APPLET_DBUS_H__
+#define __MATE_NOTIFICATION_APPLET_DBUS_H__
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+/* D-Bus context structure for notification daemon communication */
+typedef struct {
+ GDBusProxy *daemon_proxy;
+ gboolean daemon_available;
+ guint watch_id;
+} MateNotificationDBusContext;
+
+/* Context creation/cleanup */
+MateNotificationDBusContext *dbus_context_new (void);
+void dbus_context_free (MateNotificationDBusContext *context);
+
+/* Connection management */
+gboolean dbus_context_connect (MateNotificationDBusContext *context);
+void dbus_context_disconnect (MateNotificationDBusContext *context);
+gboolean dbus_context_is_available (MateNotificationDBusContext *context);
+
+/* Notification daemon method calls */
+guint dbus_context_get_notification_count (MateNotificationDBusContext *context);
+gboolean dbus_context_clear_notification_history (MateNotificationDBusContext *context);
+gboolean dbus_context_mark_all_notifications_as_read (MateNotificationDBusContext *context);
+GVariant *dbus_context_get_notification_history (MateNotificationDBusContext *context);
+
+G_END_DECLS
+
+#endif /* __MATE_NOTIFICATION_APPLET_DBUS_H__ */
diff --git a/src/capplet/mate-notification-applet-history.c b/src/capplet/mate-notification-applet-history.c
new file mode 100644
index 0000000..4d762da
--- /dev/null
+++ b/src/capplet/mate-notification-applet-history.c
@@ -0,0 +1,421 @@
+/* mate-notification-applet.c - MATE Notification Applet - History
+ *
+ * Copyright (C) 2025 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "mate-notification-applet-history.h"
+#include "../common/constants.h"
+
+#define IMAGE_SIZE 48
+
+static GtkWidget *
+create_notification_icon (const gchar *icon_name)
+{
+ GdkPixbuf *pixbuf = NULL;
+ GtkWidget *image;
+
+ if (icon_name && *icon_name) {
+ if (g_path_is_absolute (icon_name)) {
+ pixbuf = gdk_pixbuf_new_from_file_at_scale (icon_name, IMAGE_SIZE, IMAGE_SIZE, TRUE, NULL);
+ } else {
+ GtkIconTheme *theme = gtk_icon_theme_get_default ();
+ pixbuf = gtk_icon_theme_load_icon (theme, icon_name, IMAGE_SIZE, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
+ }
+ }
+
+ if (pixbuf) {
+ image = gtk_image_new_from_pixbuf (pixbuf);
+ g_object_unref (pixbuf);
+ } else {
+ image = gtk_image_new_from_icon_name ("mate-notification-properties", GTK_ICON_SIZE_DIALOG);
+ }
+
+ gtk_widget_set_valign (image, GTK_ALIGN_CENTER);
+ return image;
+}
+
+static GtkWidget *
+create_popup_window (void)
+{
+ GtkWidget *popup = gtk_window_new (GTK_WINDOW_POPUP);
+ g_object_set (popup,
+ "type-hint", GDK_WINDOW_TYPE_HINT_POPUP_MENU,
+ "skip-taskbar-hint", TRUE,
+ "skip-pager-hint", TRUE,
+ "decorated", FALSE,
+ "resizable", FALSE,
+ NULL);
+ gtk_container_set_border_width (GTK_CONTAINER (popup), 1);
+ return popup;
+}
+
+static void
+popup_destroyed_cb (GtkWidget *popup,
+ MateNotificationHistoryContext *context)
+{
+ (void) popup;
+ context->history_popup = NULL;
+}
+
+static GtkWidget *
+create_notification_row (guint id, const gchar *app_name, const gchar *app_icon,
+ const gchar *summary, const gchar *body, gint64 timestamp)
+{
+ GtkWidget *row, *hbox, *icon_image, *content_box;
+ GtkWidget *title_label, *body_label, *time_label;
+ GDateTime *dt;
+ gchar *time_str, *markup;
+
+ /* Format timestamp */
+ dt = g_date_time_new_from_unix_local (timestamp / G_TIME_SPAN_SECOND);
+ time_str = g_date_time_format (dt, "%H:%M");
+ g_date_time_unref (dt);
+
+ /* Create row container for the entire notification */
+ row = gtk_list_box_row_new ();
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
+
+ icon_image = create_notification_icon (app_icon);
+
+ content_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
+
+ /* Title */
+ markup = g_markup_printf_escaped ("<b>%s</b>", summary ? summary : _("(No summary)"));
+ title_label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (title_label), markup);
+ gtk_widget_set_halign (title_label, GTK_ALIGN_START);
+ gtk_label_set_ellipsize (GTK_LABEL (title_label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_max_width_chars (GTK_LABEL (title_label), 40);
+ g_free (markup);
+
+ /* Body */
+ body_label = NULL;
+ if (body && *body) {
+ body_label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (body_label), body);
+ gtk_widget_set_halign (body_label, GTK_ALIGN_START);
+ gtk_label_set_ellipsize (GTK_LABEL (body_label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_max_width_chars (GTK_LABEL (body_label), 40);
+
+ /* Set tooltip in case the body overflows */
+ gchar *tooltip_text = g_strdup_printf ("%s\n%s", summary, body);
+ gtk_widget_set_tooltip_text (row, tooltip_text);
+ g_free (tooltip_text);
+ }
+
+ /* Time and app label */
+ markup = g_markup_printf_escaped ("<small>%s - %s</small>",
+ app_name ? app_name : _("Unknown"),
+ time_str);
+ time_label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (time_label), markup);
+ gtk_widget_set_halign (time_label, GTK_ALIGN_START);
+ g_free (markup);
+ g_free (time_str);
+
+ /* Pack content box */
+ gtk_box_pack_start (GTK_BOX (content_box), title_label, FALSE, FALSE, 0);
+ if (body_label)
+ gtk_box_pack_start (GTK_BOX (content_box), body_label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (content_box), time_label, FALSE, FALSE, 0);
+
+ /* Pack horizontal box */
+ gtk_box_pack_start (GTK_BOX (hbox), icon_image, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), content_box, TRUE, TRUE, 0);
+
+ gtk_container_add (GTK_CONTAINER (row), hbox);
+
+ return row;
+}
+
+static void
+clear_history (GtkWidget *button,
+ MateNotificationHistoryContext *context)
+{
+ (void) button;
+
+ /* Clear the notification history */
+ if (dbus_context_clear_notification_history (context->dbus_context)) {
+ /* Trigger count update after clearing */
+ if (context->count_update_callback) {
+ ((void (*)(gpointer)) context->count_update_callback) (context->count_update_user_data);
+ }
+ }
+
+ /* Close the popup */
+ if (context->history_popup) {
+ gtk_widget_destroy (context->history_popup);
+ }
+}
+
+static void
+dnd_toggle_clicked (GtkToggleButton *toggle,
+ MateNotificationHistoryContext *context)
+{
+ gboolean active = gtk_toggle_button_get_active (toggle);
+
+ if (context->settings) {
+ g_settings_set_boolean (context->settings, "do-not-disturb", active);
+ }
+}
+
+
+MateNotificationHistoryContext *
+history_context_new (MateNotificationDBusContext *dbus_context,
+ GtkWidget *main_widget,
+ GCallback count_update_callback,
+ gpointer count_update_user_data,
+ GSettings *settings)
+{
+ MateNotificationHistoryContext *context = g_new0 (MateNotificationHistoryContext, 1);
+ context->dbus_context = dbus_context;
+ context->main_widget = main_widget;
+ context->history_popup = NULL;
+ context->count_update_callback = count_update_callback;
+ context->count_update_user_data = count_update_user_data;
+ context->settings = settings;
+ return context;
+}
+
+void
+history_context_free (MateNotificationHistoryContext *context)
+{
+ if (context) {
+ if (context->history_popup) {
+ gtk_widget_destroy (context->history_popup);
+ }
+ g_free (context);
+ }
+}
+
+void
+history_context_update_dbus (MateNotificationHistoryContext *context,
+ MateNotificationDBusContext *dbus_context)
+{
+ if (context) {
+ context->dbus_context = dbus_context;
+ }
+}
+
+static void
+position_popup_window (GtkWidget *popup,
+ GtkWidget *reference_widget,
+ GdkScreen *screen,
+ gint popup_width,
+ gint popup_height)
+{
+ gint x, y;
+ GdkWindow *window;
+
+ window = gtk_widget_get_window (reference_widget);
+ if (!window) {
+ return;
+ }
+
+ gdk_window_get_origin (window, &x, &y);
+
+ /* Calculate popup dimensions */
+ gint applet_height = gtk_widget_get_allocated_height (reference_widget);
+
+ /* Get screen dimensions */
+ gint screen_width = gdk_screen_get_width (screen);
+ gint screen_height = gdk_screen_get_height (screen);
+
+ /* Calculate initial position below applet */
+ gint popup_x = x;
+ gint popup_y = y + applet_height;
+
+ /* Check if popup extends beyond screen boundaries and adjust */
+ if (popup_x + popup_width > screen_width) {
+ popup_x = screen_width - popup_width;
+ }
+ if (popup_x < 0) {
+ popup_x = 0;
+ }
+
+ /* If popup extends below screen, place it above the applet instead */
+ if (popup_y + popup_height > screen_height) {
+ popup_y = y - popup_height;
+ /* If it still doesn't fit above, center it vertically */
+ if (popup_y < 0) {
+ popup_y = (screen_height - popup_height) / 2;
+ if (popup_y < 0) popup_y = 0;
+ }
+ }
+
+ gtk_window_move (GTK_WINDOW (popup), popup_x, popup_y);
+}
+
+void
+show_notification_history (MateNotificationHistoryContext *context)
+{
+ GtkWidget *popup;
+ GtkWidget *vbox;
+ GtkWidget *scrolled_window;
+ GtkWidget *list_box;
+ GtkWidget *button_box;
+ GtkWidget *dnd_toggle;
+ GtkWidget *clear_button;
+ GtkWidget *close_button;
+ GVariant *result;
+ GVariantIter *iter;
+ guint id, urgency;
+ gchar *app_name, *app_icon, *summary, *body;
+ gint64 timestamp, closed_timestamp;
+ guint reason;
+ gboolean read;
+
+ if (!dbus_context_is_available (context->dbus_context)) {
+ g_warning ("Cannot show history: daemon not available");
+ 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);
+ context->history_popup = NULL;
+ return;
+ }
+
+ /* Get notification history from daemon */
+ result = dbus_context_get_notification_history (context->dbus_context);
+
+ if (!result) {
+ g_warning ("Failed to get notification history");
+ return;
+ }
+
+ /* Trigger count update since accessing history marks all as read */
+ if (context->count_update_callback) {
+ ((void (*)(gpointer)) context->count_update_callback) (context->count_update_user_data);
+ }
+
+ popup = create_popup_window ();
+
+ context->history_popup = popup;
+ g_signal_connect (popup, "destroy", G_CALLBACK (popup_destroyed_cb), context);
+
+ /* Create main container */
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+ gtk_container_add (GTK_CONTAINER (popup), vbox);
+
+ /* Create list box for all notifications */
+ list_box = gtk_list_box_new ();
+ gtk_list_box_set_selection_mode (GTK_LIST_BOX (list_box), GTK_SELECTION_NONE);
+
+ /* Get history data and add to list */
+ gint notification_count = 0;
+ if (result) {
+ g_variant_get (result, "(a(ussssxxuub))", &iter);
+
+ while (g_variant_iter_loop (iter, "(ussssxxuub)",
+ &id, &app_name, &app_icon, &summary, &body,
+ &timestamp, &closed_timestamp, &reason, &urgency, &read)) {
+ notification_count++;
+ /* Add each notification as a new row in the list */
+ GtkWidget *row = create_notification_row (id, app_name, app_icon, summary, body, timestamp);
+ gtk_list_box_insert (GTK_LIST_BOX (list_box), row, -1);
+ }
+
+ g_variant_iter_free (iter);
+ g_variant_unref (result);
+ }
+
+ /* Add message if list is empty */
+ if (gtk_list_box_get_row_at_index (GTK_LIST_BOX (list_box), 0) == NULL) {
+ GtkWidget *row = gtk_list_box_row_new ();
+ GtkWidget *label = gtk_label_new (_("No notifications"));
+ gtk_widget_set_sensitive (label, FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (row), 12);
+ gtk_container_add (GTK_CONTAINER (row), label);
+ gtk_list_box_insert (GTK_LIST_BOX (list_box), row, -1);
+ }
+
+ /* Add this window for the list of notifications */
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+
+ /* Calculate to ensure the popup is the right height:
+ * 80% of screen height, with some room for buttons */
+ GdkScreen *screen = gtk_widget_get_screen (context->main_widget);
+ gint max_content_height = (gdk_screen_get_height (screen) * 0.8) - 100;
+
+ gint content_height = 100; /* 100px minimum */
+ if (notification_count > 0)
+ content_height = MIN(notification_count * content_height, max_content_height);
+
+ /* Now force the scrollable window to be the calculated height */
+ gtk_scrolled_window_set_max_content_height (GTK_SCROLLED_WINDOW (scrolled_window), max_content_height);
+ gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (scrolled_window), content_height);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), list_box);
+
+ gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
+
+ /* Add a box for action buttons */
+ button_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (button_box), 6);
+
+ /* DND toggle first */
+ dnd_toggle = gtk_check_button_new_with_label (_("Do not disturb"));
+ gtk_widget_set_halign (dnd_toggle, GTK_ALIGN_START);
+
+ if (context->settings) {
+ gboolean dnd_enabled = g_settings_get_boolean (context->settings, "do-not-disturb");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dnd_toggle), dnd_enabled);
+ }
+
+ g_signal_connect (dnd_toggle, "toggled", G_CALLBACK (dnd_toggle_clicked), context);
+ gtk_box_pack_start (GTK_BOX (button_box), dnd_toggle, FALSE, FALSE, 0);
+
+ /* Spacer to push buttons to the right */
+ GtkWidget *spacer = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_start (GTK_BOX (button_box), spacer, TRUE, TRUE, 0);
+
+ /* Then the action buttons */
+ clear_button = gtk_button_new_with_label (_("Clear All"));
+ close_button = gtk_button_new_with_label (_("Close"));
+
+ g_signal_connect (clear_button, "clicked", G_CALLBACK (clear_history), context);
+ g_signal_connect_swapped (close_button, "clicked", G_CALLBACK (gtk_widget_destroy), popup);
+
+ gtk_box_pack_end (GTK_BOX (button_box), close_button, FALSE, FALSE, 0);
+ gtk_box_pack_end (GTK_BOX (button_box), clear_button, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), button_box, FALSE, FALSE, 0);
+
+ /* Position popup window with boundary checking */
+ position_popup_window (popup, context->main_widget, screen, 450, content_height + 100);
+
+ /* Set popup size based on content (with space for buttons) */
+ gtk_window_set_default_size (GTK_WINDOW (popup), 450, content_height + 100);
+ gtk_widget_show_all (popup);
+}
diff --git a/src/capplet/mate-notification-applet-history.h b/src/capplet/mate-notification-applet-history.h
new file mode 100644
index 0000000..37d0c31
--- /dev/null
+++ b/src/capplet/mate-notification-applet-history.h
@@ -0,0 +1,59 @@
+/* mate-notification-applet.c - MATE Notification Applet - History
+ *
+ * Copyright (C) 2025 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __MATE_NOTIFICATION_APPLET_HISTORY_H__
+#define __MATE_NOTIFICATION_APPLET_HISTORY_H__
+
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <mate-panel-applet.h>
+
+#include "mate-notification-applet-dbus.h"
+
+G_BEGIN_DECLS
+
+/* History context structure */
+typedef struct {
+ MateNotificationDBusContext *dbus_context;
+ GtkWidget *main_widget;
+ GtkWidget *history_popup;
+ GCallback count_update_callback;
+ gpointer count_update_user_data;
+ GSettings *settings;
+} MateNotificationHistoryContext;
+
+/* History popup functions */
+void show_notification_history (MateNotificationHistoryContext *context);
+
+/* Context creation/cleanup */
+MateNotificationHistoryContext *history_context_new (MateNotificationDBusContext *dbus_context,
+ GtkWidget *main_widget,
+ GCallback count_update_callback,
+ gpointer count_update_user_data,
+ GSettings *settings);
+void history_context_free (MateNotificationHistoryContext *context);
+
+/* Context update functions */
+void history_context_update_dbus (MateNotificationHistoryContext *context,
+ MateNotificationDBusContext *dbus_context);
+
+G_END_DECLS
+
+#endif /* __MATE_NOTIFICATION_APPLET_HISTORY_H__ */
diff --git a/src/capplet/mate-notification-applet-menu.xml b/src/capplet/mate-notification-applet-menu.xml
index cab30ac..9631114 100644
--- a/src/capplet/mate-notification-applet-menu.xml
+++ b/src/capplet/mate-notification-applet-menu.xml
@@ -1,3 +1,9 @@
<menuitem name="DoNotDisturb Item" action="DoNotDisturb" />
+<menuitem name="HistoryEnabled Item" action="HistoryEnabled" />
+<separator />
+<menuitem name="ShowHistory Item" action="ShowHistory" />
+<menuitem name="ClearHistory Item" action="ClearHistory" />
+<menuitem name="MarkAllRead Item" action="MarkAllRead" />
+<separator />
<menuitem name="Preferences Item" action="Preferences" />
<menuitem name="About Item" action="About" />
diff --git a/src/capplet/mate-notification-applet.c b/src/capplet/mate-notification-applet.c
index 7402707..dd2f4e1 100644
--- a/src/capplet/mate-notification-applet.c
+++ b/src/capplet/mate-notification-applet.c
@@ -25,20 +25,29 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <mate-panel-applet.h>
+#include <gio/gio.h>
#define MATE_DESKTOP_USE_UNSTABLE_API
#include <libmate-desktop/mate-desktop-utils.h>
#include "constants.h"
+#include "mate-notification-applet-dbus.h"
+#include "mate-notification-applet-history.h"
typedef struct
{
MatePanelApplet *applet;
- GtkWidget *image_on;
- GtkWidget *image_off;
+ GtkWidget *status_image;
+ GtkWidget *overlay;
+ GtkWidget *count_label;
GtkActionGroup *action_group;
GSettings *settings;
+ guint unread_count;
+ guint update_timer_id;
+
+ MateNotificationDBusContext *dbus_context;
+ MateNotificationHistoryContext *history_context;
} MateNotificationApplet;
static void
@@ -47,8 +56,43 @@ show_about (GtkAction *action,
static void
call_properties (GtkAction *action,
MateNotificationApplet *applet);
+static void
+call_show_history (GtkAction *action,
+ MateNotificationApplet *applet);
+void
+call_clear_history (GtkAction *action,
+ MateNotificationApplet *applet);
+static void
+call_mark_all_read (GtkAction *action,
+ MateNotificationApplet *applet);
+
+/* D-Bus and notification history functions */
+static void
+setup_daemon_connection (MateNotificationApplet *applet);
+static void
+update_unread_count (MateNotificationApplet *applet);
+static void
+update_applet_display (MateNotificationApplet *applet);
+static void
+update_count_badge (MateNotificationApplet *applet);
+static gboolean
+periodic_update_count (MateNotificationApplet *applet);
+
+/* Click handler functions */
+static gboolean
+applet_button_press_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ MateNotificationApplet *applet);
+static void
+toggle_do_not_disturb (MateNotificationApplet *applet);
static const GtkActionEntry applet_menu_actions [] = {
+ { "ShowHistory", "document-open-recent", N_("_Show History"),
+ NULL, NULL, G_CALLBACK (call_show_history) },
+ { "ClearHistory", "edit-clear", N_("_Clear History"),
+ NULL, NULL, G_CALLBACK (call_clear_history) },
+ { "MarkAllRead", "edit-select-all", N_("_Mark All as Read"),
+ NULL, NULL, G_CALLBACK (call_mark_all_read) },
{ "Preferences", "document-properties", N_("_Preferences"),
NULL, NULL, G_CALLBACK (call_properties) },
{ "About", "help-about", N_("_About"),
@@ -65,12 +109,54 @@ applet_destroy (MatePanelApplet *applet_widget,
{
g_assert (applet);
+ if (applet->update_timer_id > 0)
+ g_source_remove (applet->update_timer_id);
+
+ if (applet->dbus_context) {
+ dbus_context_free (applet->dbus_context);
+ }
+
+ if (applet->history_context) {
+ history_context_free (applet->history_context);
+ }
+
g_object_unref (applet->settings);
g_object_unref (applet->action_group);
g_free (applet);
}
static void
+call_show_history (GtkAction *action,
+ MateNotificationApplet *applet)
+{
+ (void) action;
+
+ if (applet->history_context)
+ show_notification_history (applet->history_context);
+}
+
+void
+call_clear_history (GtkAction *action,
+ MateNotificationApplet *applet)
+{
+ (void) action;
+
+ if (dbus_context_clear_notification_history (applet->dbus_context))
+ update_unread_count (applet);
+}
+
+static void
+call_mark_all_read (GtkAction *action,
+ MateNotificationApplet *applet)
+{
+ (void) action;
+
+ /* Update count after marking all as read */
+ if (dbus_context_mark_all_notifications_as_read (applet->dbus_context))
+ update_unread_count (applet);
+}
+
+static void
call_properties (GtkAction *action,
MateNotificationApplet *applet)
{
@@ -95,6 +181,7 @@ show_about (GtkAction *action,
MateNotificationApplet *applet)
{
static const char *authors[] = {
+ "MATE Developers",
"Robert Buj <[email protected]>",
NULL
};
@@ -102,10 +189,10 @@ show_about (GtkAction *action,
(void) applet;
gtk_show_about_dialog (NULL,
- "title", _("About Do Not Disturb"),
+ "title", _("About Notification Status"),
"version", VERSION,
"copyright", _("Copyright \xc2\xa9 2021 MATE developers"),
- "comments", _("Activate the do not disturb mode quickly."),
+ "comments", _("Monitor and control notification status."),
"authors", authors,
"translator-credits", _("translator-credits"),
"logo_icon_name", "mate-notification-properties",
@@ -114,13 +201,36 @@ show_about (GtkAction *action,
static void
set_status_image (MateNotificationApplet *applet,
- gboolean active)
+ gboolean dnd_active,
+ gboolean history_enabled)
{
+ const char *icon_name;
+ gint size, scale;
+ cairo_surface_t *surface;
+
+ if (dnd_active && history_enabled) {
+ icon_name = "user-busy";
+ } else if (dnd_active && !history_enabled) {
+ icon_name = "user-offline";
+ } else if (!dnd_active && !history_enabled) {
+ icon_name = "user-invisible";
+ } else {
+ icon_name = "user-available";
+ }
+
+ size = (gint) mate_panel_applet_get_size (applet->applet);
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (applet->applet));
+
+ surface = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
+ icon_name,
+ size, scale,
+ NULL, 0, NULL);
+ if (surface) {
+ gtk_image_set_from_surface (GTK_IMAGE (applet->status_image), surface);
+ cairo_surface_destroy (surface);
+ }
+
gtk_widget_show_all (GTK_WIDGET (applet->applet));
- if (active)
- gtk_widget_hide (applet->image_on);
- else
- gtk_widget_hide (applet->image_off);
}
static void
@@ -128,47 +238,146 @@ settings_changed (GSettings *settings,
gchar *key,
MateNotificationApplet *applet)
{
- if (g_strcmp0 (GSETTINGS_KEY_DO_NOT_DISTURB, key) == 0)
- set_status_image (applet,
- g_settings_get_boolean (settings, key));
+ if (g_strcmp0 (GSETTINGS_KEY_DO_NOT_DISTURB, key) == 0 ||
+ g_strcmp0 (GSETTINGS_KEY_HISTORY_ENABLED, key) == 0)
+ update_applet_display (applet);
}
static void
-applet_draw_icon (MatePanelApplet *applet_widget,
- int arg1,
- MateNotificationApplet *applet)
+applet_size_changed (MatePanelApplet *applet_widget,
+ int arg1,
+ MateNotificationApplet *applet)
{
- gint size, scale;
+ update_applet_display (applet);
+}
- g_assert (applet);
+static void
+setup_daemon_connection (MateNotificationApplet *applet)
+{
+ if (dbus_context_connect (applet->dbus_context)) {
+ update_unread_count (applet);
+ } else {
+ applet->unread_count = 0;
+ }
- size = (gint) mate_panel_applet_get_size (applet_widget);
- scale = gtk_widget_get_scale_factor (GTK_WIDGET (applet_widget));
+ /* Update history context with new daemon connection */
+ if (applet->history_context) {
+ history_context_update_dbus (applet->history_context, applet->dbus_context);
+ }
+}
+
+static void
+update_unread_count (MateNotificationApplet *applet)
+{
+ applet->unread_count = dbus_context_get_notification_count (applet->dbus_context);
+ update_applet_display (applet);
+}
+
+static void
+update_applet_display (MateNotificationApplet *applet)
+{
+ gchar *tooltip_text;
+ gboolean dnd_active;
+ gboolean history_enabled;
+
+ dnd_active = g_settings_get_boolean (applet->settings, GSETTINGS_KEY_DO_NOT_DISTURB);
+ history_enabled = g_settings_get_boolean (applet->settings, GSETTINGS_KEY_HISTORY_ENABLED);
+
+ /* Update tooltip based on number of unread notifications and user state */
+ if (!history_enabled)
+ tooltip_text = g_strdup (_("(privacy mode)"));
+ else if (applet->unread_count > 99)
+ tooltip_text = g_strdup (_("(99+ unread)"));
+ else if (applet->unread_count > 0)
+ tooltip_text = g_strdup_printf ("(%d unread)", applet->unread_count);
+ else
+ tooltip_text = g_strdup ("");
+
+ if (dnd_active)
+ tooltip_text = g_strdup_printf ("Do Not Disturb %s", tooltip_text);
+ else if (!dbus_context_is_available (applet->dbus_context))
+ tooltip_text = g_strdup (_("Notifications (daemon unavailable)"));
+ else
+ tooltip_text = g_strdup_printf ("Notifications %s", tooltip_text);
+
+ gtk_widget_set_tooltip_text (GTK_WIDGET (applet->applet), tooltip_text);
+ g_free (tooltip_text);
+
+ set_status_image (applet, dnd_active, history_enabled);
+ update_count_badge (applet);
+}
+
+static gboolean
+applet_button_press_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ MateNotificationApplet *applet)
+{
+ switch (event->button) {
+ case 1: /* Left click */
+ if (applet->history_context) {
+ show_notification_history (applet->history_context);
+ }
+ return TRUE;
+
+ case 2: /* Middle click */
+ toggle_do_not_disturb (applet);
+ return TRUE;
+
+ case 3: /* Right click handled by context menu */
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
+static void
+toggle_do_not_disturb (MateNotificationApplet *applet)
+{
+ gboolean current_state;
- cairo_surface_t *image_on = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
- "user-available",
- size, scale,
- NULL, 0, NULL);
- cairo_surface_t *image_off = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
- "user-invisible",
- size, scale,
- NULL, 0, NULL);
+ current_state = g_settings_get_boolean (applet->settings, GSETTINGS_KEY_DO_NOT_DISTURB);
+ g_settings_set_boolean (applet->settings, GSETTINGS_KEY_DO_NOT_DISTURB, !current_state);
+}
- gtk_image_set_from_surface (GTK_IMAGE (applet->image_on), image_on);
- gtk_image_set_from_surface (GTK_IMAGE (applet->image_off), image_off);
+static void
+update_count_badge (MateNotificationApplet *applet)
+{
+ gchar *count_text;
+ gboolean history_enabled = g_settings_get_boolean (applet->settings, GSETTINGS_KEY_HISTORY_ENABLED);
+
+ /* Only show count badges when history is enabled and there are notifications */
+ if (history_enabled && applet->unread_count > 0) {
+ if (applet->unread_count > 99) {
+ count_text = g_strdup ("99+");
+ } else {
+ count_text = g_strdup_printf ("%u", applet->unread_count);
+ }
+ gtk_label_set_text (GTK_LABEL (applet->count_label), count_text);
+ gtk_widget_show (applet->count_label);
+ g_free (count_text);
+ } else {
+ /* Hide badge when no unread notifications */
+ gtk_widget_hide (applet->count_label);
+ }
+}
- cairo_surface_destroy (image_on);
- cairo_surface_destroy (image_off);
+static gboolean
+periodic_update_count (MateNotificationApplet *applet)
+{
+ if (applet && dbus_context_is_available (applet->dbus_context)) {
+ update_unread_count (applet);
+ }
+ return TRUE; /* Continue periodic updates */
}
static MateNotificationApplet*
applet_main (MatePanelApplet *applet_widget)
{
MateNotificationApplet *applet;
- GtkWidget *box;
#ifndef ENABLE_IN_PROCESS
- g_set_application_name (_("Do Not Disturb"));
+ g_set_application_name (_("Notification Status"));
#endif
gtk_window_set_default_icon_name ("mate-notification-properties");
@@ -176,32 +385,67 @@ applet_main (MatePanelApplet *applet_widget)
applet->applet = applet_widget;
applet->settings = g_settings_new (GSETTINGS_SCHEMA);
+ /* Initialize D-Bus context and notification state */
+ applet->dbus_context = dbus_context_new ();
+ applet->unread_count = 0;
+ applet->update_timer_id = 0;
+
#ifndef ENABLE_IN_PROCESS
/* needed to clamp ourselves to the panel size */
- mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), MATE_PANEL_APPLET_EXPAND_MINOR);
+ mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet->applet), MATE_PANEL_APPLET_EXPAND_MINOR);
#endif
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-
- applet->image_on = gtk_image_new ();
- applet->image_off = gtk_image_new ();
- applet_draw_icon (applet_widget, 0, applet);
-
- gtk_widget_set_tooltip_text (applet->image_off, _("Do Not Disturb"));
- gtk_widget_set_tooltip_text (applet->image_on, _("Notifications Enabled"));
-
- gtk_box_pack_start (GTK_BOX (box), applet->image_on,
- TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (box), applet->image_off,
- TRUE, TRUE, 0);
- gtk_container_add (GTK_CONTAINER (applet_widget), box);
+ /* Create overlay for icons and count badge */
+ applet->overlay = gtk_overlay_new ();
+
+ /* Create status icon */
+ applet->status_image = gtk_image_new ();
+
+ /* Add status icon as main overlay child */
+ gtk_container_add (GTK_CONTAINER (applet->overlay), applet->status_image);
+
+ /* Create count badge label */
+ applet->count_label = gtk_label_new ("");
+ gtk_widget_set_name (applet->count_label, "notification-count-badge");
+ gtk_widget_set_halign (applet->count_label, GTK_ALIGN_END);
+ gtk_widget_set_valign (applet->count_label, GTK_ALIGN_END);
+ GtkCssProvider *css_provider = gtk_css_provider_new ();
+ const gchar *css_data =
+ "#notification-count-badge {"
+ " background-color: rgba(255,255,255,0.9);"
+ " color: #000000;"
+ " border-radius: 8px;"
+ " min-width: 12px;"
+ " min-height: 4px;"
+ " padding: 1px 1px;"
+ " font-size: 10px;"
+ " font-weight: bold;"
+ " text-shadow: none;"
+ " border: 1px solid rgba(0,0,0,0.1);"
+ "}";
+ gtk_css_provider_load_from_data (css_provider, css_data, -1, NULL);
+ gtk_style_context_add_provider (gtk_widget_get_style_context (applet->count_label),
+ GTK_STYLE_PROVIDER (css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (css_provider);
+
+ /* Add count label as overlay */
+ gtk_overlay_add_overlay (GTK_OVERLAY (applet->overlay), applet->count_label);
+
+ /* Add overlay to applet */
+ gtk_container_add (GTK_CONTAINER (applet_widget), applet->overlay);
set_status_image (applet,
- g_settings_get_boolean (applet->settings,
- GSETTINGS_KEY_DO_NOT_DISTURB));
+ g_settings_get_boolean (applet->settings, GSETTINGS_KEY_DO_NOT_DISTURB),
+ g_settings_get_boolean (applet->settings, GSETTINGS_KEY_HISTORY_ENABLED));
+
+ /* click handling */
+ gtk_widget_add_events (GTK_WIDGET (applet_widget), GDK_BUTTON_PRESS_MASK);
+ g_signal_connect (G_OBJECT (applet_widget), "button-press-event",
+ G_CALLBACK (applet_button_press_cb), applet);
/* set up context menu */
- applet->action_group = gtk_action_group_new ("Do Not Disturb Actions");
+ applet->action_group = gtk_action_group_new ("Notification Status Actions");
#ifdef ENABLE_NLS
gtk_action_group_set_translation_domain (applet->action_group, GETTEXT_PACKAGE);
#endif /* ENABLE_NLS */
@@ -215,6 +459,13 @@ applet_main (MatePanelApplet *applet_widget)
gtk_action_group_add_action (applet->action_group,
GTK_ACTION (do_not_disturb_toggle_action));
+ GtkToggleAction *history_toggle_action =
+ gtk_toggle_action_new ("HistoryEnabled", _("_Enable History"),
+ _("Enable/Disable notification history."), NULL);
+
+ gtk_action_group_add_action (applet->action_group,
+ GTK_ACTION (history_toggle_action));
+
mate_panel_applet_setup_menu_from_resource (applet->applet,
RESOURCE_PATH "menu.xml",
applet->action_group);
@@ -223,12 +474,31 @@ applet_main (MatePanelApplet *applet_widget)
do_not_disturb_toggle_action, "active",
G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (applet->settings, "history-enabled",
+ history_toggle_action, "active",
+ G_SETTINGS_BIND_DEFAULT);
+
g_signal_connect (G_OBJECT (applet->applet), "destroy",
G_CALLBACK (applet_destroy), applet);
- /* GSettings callback */
+ /* GSettings callbacks */
g_signal_connect (G_OBJECT (applet->settings), "changed::" GSETTINGS_KEY_DO_NOT_DISTURB,
G_CALLBACK (settings_changed), applet);
+ g_signal_connect (G_OBJECT (applet->settings), "changed::" GSETTINGS_KEY_HISTORY_ENABLED,
+ G_CALLBACK (settings_changed), applet);
+
+ /* Create new history context */
+ applet->history_context = history_context_new (applet->dbus_context,
+ GTK_WIDGET (applet->applet),
+ G_CALLBACK (update_unread_count),
+ applet,
+ applet->settings);
+
+ setup_daemon_connection (applet);
+
+ /* Set up periodic updates every few seconds */
+#define NOTIFICATION_UPDATE_COUNT 5
+ applet->update_timer_id = g_timeout_add_seconds (NOTIFICATION_UPDATE_COUNT, (GSourceFunc) periodic_update_count, applet);
return applet;
}
@@ -245,7 +515,7 @@ applet_factory (MatePanelApplet *applet_widget,
applet = applet_main (applet_widget);
g_signal_connect (G_OBJECT (applet_widget), "change_size",
- G_CALLBACK (applet_draw_icon),
+ G_CALLBACK (applet_size_changed),
(gpointer) applet);
return TRUE;
@@ -256,6 +526,6 @@ applet_factory (MatePanelApplet *applet_widget,
PANEL_APPLET_FACTORY ("MateNotificationAppletFactory",
PANEL_TYPE_APPLET,
- "Do Not Disturb Applet",
+ "Notification Status Applet",
applet_factory,
NULL)
diff --git a/src/capplet/mate-notification-properties.c b/src/capplet/mate-notification-properties.c
index d8ce983..f81dd2c 100644
--- a/src/capplet/mate-notification-properties.c
+++ b/src/capplet/mate-notification-properties.c
@@ -44,9 +44,14 @@ typedef struct {
GtkWidget* preview_button;
GtkWidget* active_checkbox;
GtkWidget* dnd_checkbox;
+ GtkWidget* history_checkbox;
GtkWidget* monitor_label;
+ GtkWidget* timeout_spin;
+ GtkWidget* persistence_checkbox;
+ GtkWidget* countdown_checkbox;
- NotifyNotification* preview;
+ NotifyNotification* preview1;
+ NotifyNotification* preview2;
} NotificationAppletDialog;
enum {
@@ -387,14 +392,19 @@ static void show_message(NotificationAppletDialog* dialog, const gchar* message)
static void notification_properties_dialog_preview_closed(NotifyNotification* preview, NotificationAppletDialog* dialog)
{
- if (preview == dialog->preview)
- {
- dialog->preview = NULL;
- }
+ if (preview == dialog->preview1)
+ dialog->preview1 = NULL;
+ else if (preview == dialog->preview2)
+ dialog->preview2 = NULL;
g_object_unref(preview);
}
+static gboolean notification_properties_dialog_preview_action(void *data) {
+ // @todo call notification_properties_dialog_preview_closed
+ return FALSE;
+}
+
static void notification_properties_dialog_preview(NotificationAppletDialog* dialog)
{
if (!notify_is_initted() && !notify_init("n-d"))
@@ -405,16 +415,35 @@ static void notification_properties_dialog_preview(NotificationAppletDialog* dia
GError* error = NULL;
- if (dialog->preview)
+ if (dialog->preview1)
+ {
+ notify_notification_close(dialog->preview1, NULL);
+ g_object_unref(dialog->preview1);
+ dialog->preview1 = NULL;
+ }
+ if (dialog->preview2)
+ {
+ notify_notification_close(dialog->preview2, NULL);
+ g_object_unref(dialog->preview2);
+ dialog->preview2 = NULL;
+ }
+
+ dialog->preview1 = notify_notification_new(_("Notification Test"), _("Just a test"), "dialog-information");
+ notify_notification_set_timeout (dialog->preview1, 50000);
+
+ if (!notify_notification_show(dialog->preview1, &error))
{
- notify_notification_close(dialog->preview, NULL);
- g_object_unref(dialog->preview);
- dialog->preview = NULL;
+ char* message = g_strdup_printf(_("Error while displaying notification: %s"), error->message);
+ show_message(dialog, message);
+ g_error_free(error);
+ g_free(message);
}
- dialog->preview = notify_notification_new(_("Notification Test"), _("Just a test"), "dialog-information");
+ dialog->preview2 = notify_notification_new(_("Notification Test"), _("Just a test"), "dialog-information");
+ notify_notification_add_action (dialog->preview2, "nothing", _("Close"), NOTIFY_ACTION_CALLBACK (notification_properties_dialog_preview_action), NULL, NULL);
+ notify_notification_set_timeout (dialog->preview2, 50000);
- if (!notify_notification_show(dialog->preview, &error))
+ if (!notify_notification_show(dialog->preview2, &error))
{
char* message = g_strdup_printf(_("Error while displaying notification: %s"), error->message);
show_message(dialog, message);
@@ -422,7 +451,8 @@ static void notification_properties_dialog_preview(NotificationAppletDialog* dia
g_free(message);
}
- g_signal_connect(dialog->preview, "closed", G_CALLBACK(notification_properties_dialog_preview_closed), dialog);
+ g_signal_connect(dialog->preview1, "closed", G_CALLBACK(notification_properties_dialog_preview_closed), dialog);
+ g_signal_connect(dialog->preview2, "closed", G_CALLBACK(notification_properties_dialog_preview_closed), dialog);
}
static void notification_properties_dialog_response(GtkWidget* widget, int response, NotificationAppletDialog* dialog)
@@ -467,7 +497,11 @@ 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"));
+ dialog->countdown_checkbox = GTK_WIDGET(gtk_builder_get_object(builder, "show_countdown_check"));
g_object_unref (builder);
@@ -478,6 +512,12 @@ 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);
+ g_settings_bind (dialog->gsettings, GSETTINGS_KEY_ENABLE_PERSISTENCE, dialog->persistence_checkbox, "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (dialog->gsettings, GSETTINGS_KEY_SHOW_COUNTDOWN, dialog->countdown_checkbox, "active", G_SETTINGS_BIND_DEFAULT);
notification_properties_dialog_setup_themes (dialog);
notification_properties_dialog_setup_positions (dialog);
@@ -491,7 +531,8 @@ static gboolean notification_properties_dialog_init(NotificationAppletDialog* di
gtk_widget_show_all(dialog->dialog);
- dialog->preview = NULL;
+ dialog->preview1 = NULL;
+ dialog->preview2 = NULL;
return TRUE;
}
@@ -504,11 +545,17 @@ static void notification_properties_dialog_finalize(NotificationAppletDialog* di
dialog->dialog = NULL;
}
- if (dialog->preview)
+ if (dialog->preview1)
+ {
+ notify_notification_close(dialog->preview1, NULL);
+ dialog->preview1 = NULL;
+ }
+ if (dialog->preview2)
{
- notify_notification_close(dialog->preview, NULL);
- dialog->preview = NULL;
+ notify_notification_close(dialog->preview2, NULL);
+ dialog->preview2 = NULL;
}
+
g_free (dialog);
}
diff --git a/src/capplet/mate-notification-properties.ui b/src/capplet/mate-notification-properties.ui
index d6dbfac..9b461bf 100644
--- a/src/capplet/mate-notification-properties.ui
+++ b/src/capplet/mate-notification-properties.ui
@@ -12,6 +12,13 @@
<property name="can_focus">False</property>
<property name="icon_name">window-close</property>
</object>
+ <object class="GtkAdjustment" id="timeout_adjustment">
+ <property name="lower">0</property>
+ <property name="upper">300000</property>
+ <property name="value">7000</property>
+ <property name="step_increment">1000</property>
+ <property name="page_increment">5000</property>
+ </object>
<object class="GtkDialog" id="dialog">
<property name="can_focus">False</property>
<property name="border_width">12</property>
@@ -211,6 +218,22 @@
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="history_enabled_check">
+ <property name="label" translatable="yes">Enable Notification History</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="draw_indicator">True</property>
+ <property name="tooltip_text" translatable="yes">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.</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</object>
</child>
</object>
@@ -232,6 +255,119 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkFrame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">_Timeout (ms):</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">timeout_spin</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="timeout_spin">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">timeout_adjustment</property>
+ <property name="climb_rate">1000</property>
+ <property name="digits">0</property>
+ <property name="numeric">True</property>
+ <property name="value">7000</property>
+ <property name="tooltip_text" translatable="yes">Default timeout for notifications in milliseconds. Use 0 for no timeout (persistent).</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="enable_persistence_check">
+ <property name="label" translatable="yes">Allow Persistent Notifications</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="draw_indicator">True</property>
+ <property name="tooltip_text" translatable="yes">Allow applications to create notifications that don't disappear automatically</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="show_countdown_check">
+ <property name="label" translatable="yes">Show Countdown Timer</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="draw_indicator">True</property>
+ <property name="tooltip_text" translatable="yes">Show countdown timer on all timed notifications (not just those with actions)</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Timeout &amp; Behavior</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
</child>
<action-widgets>