Merge lp:~3v1n0/notify-osd/fix-notifications-replacing into lp:notify-osd

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: 506
Merged at revision: 504
Proposed branch: lp:~3v1n0/notify-osd/fix-notifications-replacing
Merge into: lp:notify-osd
Diff against target: 83 lines (+29/-8)
1 file modified
src/stack.c (+29/-8)
To merge this branch: bzr merge lp:~3v1n0/notify-osd/fix-notifications-replacing
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+291707@code.launchpad.net

Commit message

Stack: allow to replace a notification when the replace_id has been provided

This fixes the case where we want to replace a notification with a given
ID that is about to show or currently visible. As the NotifyOSD and Desktop
Notification protocols expect.

To post a comment you must log in.
506. By Marco Trevisan (Treviño)

Stack: indentation fix

Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/stack.c'
--- src/stack.c 2015-11-12 08:51:08 +0000
+++ src/stack.c 2016-04-13 05:32:07 +0000
@@ -388,8 +388,10 @@
388 if (!self || !IS_BUBBLE (bubble))388 if (!self || !IS_BUBBLE (bubble))
389 return -1;389 return -1;
390390
391 notification_id = bubble_get_id (bubble);
392
391 /* check if this is just an update */393 /* check if this is just an update */
392 if (find_bubble_by_id (self, bubble_get_id (bubble)))394 if (find_bubble_by_id (self, notification_id))
393 {395 {
394 bubble_start_timer (bubble, TRUE);396 bubble_start_timer (bubble, TRUE);
395 bubble_refresh (bubble);397 bubble_refresh (bubble);
@@ -400,11 +402,17 @@
400 if (stack_is_at_top_corner (self, sync_bubble))402 if (stack_is_at_top_corner (self, sync_bubble))
401 bubble_sync_with (sync_bubble, bubble);403 bubble_sync_with (sync_bubble, bubble);
402404
403 return bubble_get_id (bubble);405 return notification_id;
404 }406 }
405407
406 /* add bubble/id to stack */408 /* add bubble/id to stack */
407 notification_id = self->next_id++;409 if (notification_id == 0)
410 {
411 do
412 {
413 notification_id = self->next_id++;
414 } while (find_bubble_by_id (self, notification_id));
415 }
408416
409 // FIXME: migrate stack to use abstract notification object and don't417 // FIXME: migrate stack to use abstract notification object and don't
410 // keep heavy bubble objects around, at anyone time at max. only two418 // keep heavy bubble objects around, at anyone time at max. only two
@@ -582,6 +590,7 @@
582 gboolean new_bubble = FALSE;590 gboolean new_bubble = FALSE;
583 gboolean turn_into_dialog;591 gboolean turn_into_dialog;
584 guint real_id;592 guint real_id;
593 gchar *sender;
585594
586 // check max. allowed limit queue-size595 // check max. allowed limit queue-size
587 if (g_list_length (self->list) > MAX_STACK_SIZE)596 if (g_list_length (self->list) > MAX_STACK_SIZE)
@@ -620,22 +629,34 @@
620 return TRUE;629 return TRUE;
621 }630 }
622631
623 // check if a bubble exists with same id632 // check if a bubble exists with same id
624 bubble = find_bubble_by_id (self, id);633 bubble = find_bubble_by_id (self, id);
634 sender = dbus_g_method_get_sender (context);
635
636 if (bubble)
637 {
638 if (g_strcmp0 (bubble_get_sender (bubble), sender) != 0)
639 {
640 // Another sender is trying to replace a notification, let's block it!
641 id = 0;
642 bubble = NULL;
643 }
644 }
645
625 if (bubble == NULL)646 if (bubble == NULL)
626 {647 {
627 gchar *sender;
628 new_bubble = TRUE;648 new_bubble = TRUE;
629 bubble = bubble_new (self->defaults);649 bubble = bubble_new (self->defaults);
630 g_object_weak_ref (G_OBJECT (bubble),650 g_object_weak_ref (G_OBJECT (bubble),
631 _weak_notify_cb,651 _weak_notify_cb,
632 (gpointer) self);652 (gpointer) self);
633 653
634 sender = dbus_g_method_get_sender (context);
635 bubble_set_sender (bubble, sender);654 bubble_set_sender (bubble, sender);
636 g_free (sender);655 bubble_set_id (bubble, id);
637 }656 }
638657
658 g_free (sender);
659
639 if (new_bubble && hints)660 if (new_bubble && hints)
640 {661 {
641 data = (GValue*) g_hash_table_lookup (hints, "x-canonical-append");662 data = (GValue*) g_hash_table_lookup (hints, "x-canonical-append");

Subscribers

People subscribed via source and target branches