Merge lp:~3v1n0/notify-osd/fix-empty-newlines-appending into lp:notify-osd

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: 507
Merged at revision: 505
Proposed branch: lp:~3v1n0/notify-osd/fix-empty-newlines-appending
Merge into: lp:notify-osd
Prerequisite: lp:~3v1n0/notify-osd/fix-notifications-replacing
Diff against target: 75 lines (+37/-1)
3 files modified
debian/changelog (+7/-0)
src/bubble.c (+30/-0)
src/stack.c (+0/-1)
To merge this branch: bzr merge lp:~3v1n0/notify-osd/fix-empty-newlines-appending
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+291964@code.launchpad.net

Commit message

Bubble: don't append new lines when receiving empty bodies

Delay the addition of new lines until there's some real content to append.

Description of the change

To be tested with something like

from gi.repository import Notify
from time import sleep

Notify.init("Test App")

for i in range(10):
    n = Notify.Notification.new("Title", "" if i % 3 else "test {}".format(i))
    n.set_hint_string("append", "true")
    n.show()
    sleep(1)

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

+1

review: Approve
508. By Marco Trevisan (Treviño)

Bubble: strip body text when adding it

509. By Marco Trevisan (Treviño)

Bubble: Indentation fixes

510. By Marco Trevisan (Treviño)

Merging changelog from landing silo

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-12-01 08:28:52 +0000
+++ debian/changelog 2016-04-15 11:52:53 +0000
@@ -1,3 +1,10 @@
1notify-osd (0.9.35+16.04.20160413-0ubuntu1) xenial; urgency=medium
2
3 * Stack: allow to replace a notification when the replace_id has been
4 provided (LP: #1569682)
5
6 -- Marco Trevisan (Treviño) <mail@3v1n0.net> Wed, 13 Apr 2016 05:36:20 +0000
7
1notify-osd (0.9.35+16.04.20151201-0ubuntu1) xenial; urgency=medium8notify-osd (0.9.35+16.04.20151201-0ubuntu1) xenial; urgency=medium
29
3 [ CI Train Bot ]10 [ CI Train Bot ]
411
=== modified file 'src/bubble.c'
--- src/bubble.c 2015-11-27 18:34:49 +0000
+++ src/bubble.c 2016-04-15 11:52:53 +0000
@@ -2323,6 +2323,7 @@
23232323
2324 // filter out any HTML/markup if possible2324 // filter out any HTML/markup if possible
2325 text = filter_text (body);2325 text = filter_text (body);
2326 g_strstrip (text);
23262327
2327 if (priv->message_body)2328 if (priv->message_body)
2328 if (g_strcmp0 (priv->message_body->str, text))2329 if (g_strcmp0 (priv->message_body->str, text))
@@ -3766,7 +3767,36 @@
37663767
3767 if (text)3768 if (text)
3768 {3769 {
3770 g_strstrip (text);
3771
3772 if (text[0] == '\0')
3773 {
3774 if (priv->message_body->len > 0 &&
3775 priv->message_body->str[priv->message_body->len-1] != '\n')
3776 {
3777 // This is a special combination, that allows us to remember that a
3778 // new empty body line has been requested, but we won't show this till
3779 // something visible will be appended.
3780 g_string_append_c (priv->message_body, '\0');
3781 g_string_append_c (priv->message_body, '\n');
3782 }
3783
3784 g_free (text);
3785 return;
3786 }
3787
3788 if (priv->message_body->len > 1)
3789 {
3790 if (priv->message_body->str[priv->message_body->len-1] == '\n' &&
3791 priv->message_body->str[priv->message_body->len-2] == '\0')
3792 {
3793 // A new message has been appended, let's remove the \0 we put before.
3794 g_string_erase (priv->message_body, priv->message_body->len-2, 1);
3795 }
3796 }
3797
3769 // append text to current message-body3798 // append text to current message-body
3799 g_string_append_c (priv->message_body, '\n');
3770 g_string_append (priv->message_body, text);3800 g_string_append (priv->message_body, text);
3771 priv->message_body_needs_refresh = TRUE;3801 priv->message_body_needs_refresh = TRUE;
37723802
37733803
=== modified file 'src/stack.c'
--- src/stack.c 2016-04-15 11:52:52 +0000
+++ src/stack.c 2016-04-15 11:52:53 +0000
@@ -682,7 +682,6 @@
682 g_object_unref(bubble);682 g_object_unref(bubble);
683 bubble = app_bubble;683 bubble = app_bubble;
684 if (body) {684 if (body) {
685 bubble_append_message_body (bubble, "\n");
686 bubble_append_message_body (bubble, body);685 bubble_append_message_body (bubble, body);
687 }686 }
688 }687 }

Subscribers

People subscribed via source and target branches