summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--data/org.mate.applets.MateNotificationApplet.desktop.in.in4
-rw-r--r--src/capplet/mate-notification-applet-history.c59
-rw-r--r--src/capplet/mate-notification-applet-menu.xml1
-rw-r--r--src/capplet/mate-notification-applet.c129
5 files changed, 126 insertions, 68 deletions
diff --git a/NEWS b/NEWS
index 8adff39..ba1a19e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
### mate-notification-daemon 1.29.0
+ * update translations
* daemon: Fix use-after-free crash in idle reposition timeout
* daemon: Fix crash when monitor is disconnected
* history: Add enable/disable toggle
diff --git a/data/org.mate.applets.MateNotificationApplet.desktop.in.in b/data/org.mate.applets.MateNotificationApplet.desktop.in.in
index 5b7c538..a335cf7 100644
--- a/data/org.mate.applets.MateNotificationApplet.desktop.in.in
+++ b/data/org.mate.applets.MateNotificationApplet.desktop.in.in
@@ -6,8 +6,8 @@ Name=Mate Notification Applet Factory
Description=Mate Notification Applet Factory
[MateNotificationApplet]
-Name=Do Not Disturb
-Description=Activate the do not disturb mode.
+Name=Notification Status
+Description=Monitor and control notification status.
# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
Icon=mate-notification-properties
MateComponentId=OAFIID:MATE_Panel_Notification_Applet
diff --git a/src/capplet/mate-notification-applet-history.c b/src/capplet/mate-notification-applet-history.c
index ce38a6f..4d762da 100644
--- a/src/capplet/mate-notification-applet-history.c
+++ b/src/capplet/mate-notification-applet-history.c
@@ -219,6 +219,55 @@ history_context_update_dbus (MateNotificationHistoryContext *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)
{
@@ -237,8 +286,6 @@ show_notification_history (MateNotificationHistoryContext *context)
gint64 timestamp, closed_timestamp;
guint reason;
gboolean read;
- gint x, y;
- GdkWindow *window;
if (!dbus_context_is_available (context->dbus_context)) {
g_warning ("Cannot show history: daemon not available");
@@ -365,12 +412,8 @@ show_notification_history (MateNotificationHistoryContext *context)
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);
- /* Place popup window below the applet */
- window = gtk_widget_get_window (context->main_widget);
- if (window) {
- gdk_window_get_origin (window, &x, &y);
- gtk_window_move (GTK_WINDOW (popup), x, y + gtk_widget_get_allocated_height (context->main_widget));
- }
+ /* 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);
diff --git a/src/capplet/mate-notification-applet-menu.xml b/src/capplet/mate-notification-applet-menu.xml
index 4b41d57..9631114 100644
--- a/src/capplet/mate-notification-applet-menu.xml
+++ b/src/capplet/mate-notification-applet-menu.xml
@@ -1,4 +1,5 @@
<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" />
diff --git a/src/capplet/mate-notification-applet.c b/src/capplet/mate-notification-applet.c
index 56a03b9..dd2f4e1 100644
--- a/src/capplet/mate-notification-applet.c
+++ b/src/capplet/mate-notification-applet.c
@@ -38,8 +38,7 @@ typedef struct
{
MatePanelApplet *applet;
- GtkWidget *image_on;
- GtkWidget *image_off;
+ GtkWidget *status_image;
GtkWidget *overlay;
GtkWidget *count_label;
GtkActionGroup *action_group;
@@ -190,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",
@@ -202,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
@@ -216,36 +238,17 @@ settings_changed (GSettings *settings,
gchar *key,
MateNotificationApplet *applet)
{
- if (g_strcmp0 (GSETTINGS_KEY_DO_NOT_DISTURB, key) == 0)
+ 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;
-
- g_assert (applet);
-
- size = (gint) mate_panel_applet_get_size (applet_widget);
- scale = gtk_widget_get_scale_factor (GTK_WIDGET (applet_widget));
-
- 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);
-
- gtk_image_set_from_surface (GTK_IMAGE (applet->image_on), image_on);
- gtk_image_set_from_surface (GTK_IMAGE (applet->image_off), image_off);
-
- cairo_surface_destroy (image_on);
- cairo_surface_destroy (image_off);
+ update_applet_display (applet);
}
static void
@@ -275,11 +278,15 @@ 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 (applet->unread_count > 99)
+ 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);
@@ -296,7 +303,7 @@ update_applet_display (MateNotificationApplet *applet)
gtk_widget_set_tooltip_text (GTK_WIDGET (applet->applet), tooltip_text);
g_free (tooltip_text);
- set_status_image (applet, dnd_active);
+ set_status_image (applet, dnd_active, history_enabled);
update_count_badge (applet);
}
@@ -337,9 +344,10 @@ static void
update_count_badge (MateNotificationApplet *applet)
{
gchar *count_text;
+ gboolean history_enabled = g_settings_get_boolean (applet->settings, GSETTINGS_KEY_HISTORY_ENABLED);
- if (applet->unread_count > 0) {
- /* Show badge with count */
+ /* 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 {
@@ -367,10 +375,9 @@ 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");
@@ -385,24 +392,17 @@ applet_main (MatePanelApplet *applet_widget)
#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
/* Create overlay for icons and count badge */
applet->overlay = gtk_overlay_new ();
- /* Create container for the two state icons */
- 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_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);
+ /* Create status icon */
+ applet->status_image = gtk_image_new ();
- /* Add icon box as main overlay child */
- gtk_container_add (GTK_CONTAINER (applet->overlay), box);
+ /* 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 ("");
@@ -436,8 +436,8 @@ applet_main (MatePanelApplet *applet_widget)
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);
@@ -445,7 +445,7 @@ applet_main (MatePanelApplet *applet_widget)
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 */
@@ -459,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);
@@ -467,12 +474,18 @@ 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,
@@ -502,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;
@@ -513,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)