17
17
# with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
"""Module that implements notification of the end user."""
20
# TODO: We may want to enable different notifiers. When none of them
21
# are available, we should fall back to silently discarding
22
30
from ubuntuone.status.notification import AbstractNotification
24
32
APPLICATION_NAME = 'Ubuntu One Client'
33
ICON_NAME = "ubuntuone"
27
36
class Notification(AbstractNotification):
28
37
"""Notification of the end user."""
39
# pylint: disable=W0231
30
40
def __init__(self, application_name=APPLICATION_NAME):
31
41
self.application_name = application_name
42
# pylint: enable=W0231
33
def send_notification(self, title, message, icon=None, append=False):
44
def send_notification(self, title, message, icon=ICON_NAME, append=False):
34
45
"""Send a notification using the underlying library."""
35
pynotify.init(self.application_name)
36
notification = pynotify.Notification(title, message, icon)
38
notification.set_hint_string('append', '')
47
pynotify.init(self.application_name)
48
notification = pynotify.Notification(title, message, icon)
50
notification.set_hint_string('x-canonical-append', '')
54
def update_notification(self, notification, new_title, new_message,
56
"""Update the notification with a new message body."""
58
notification.update(new_title, new_message, new_icon)