~alecu/ubuntuone-client/fix-notification-parameters

« back to all changes in this revision

Viewing changes to ubuntuone/platform/linux/notification.py

  • Committer: Tarmac
  • Author(s): eric.casteleijn at canonical
  • Date: 2011-01-13 22:54:04 UTC
  • mfrom: (800.1.1 dr-frank-n-furter-i-presume)
  • Revision ID: tarmac-20110113225404-x3hz0v9l9t6i0fqk
This adds an abstract notification class that can be inherited from for different platforms/desktops, in order to send transient notifications to the user. An initial notify-osd implementation is included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ubuntuone.syncdaemon.platform.notification - User Notification
 
2
#
 
3
# Author: Eric Casteleijn <eric.casteleijn@canonical.com>
 
4
#
 
5
# Copyright 2011 Canonical Ltd.
 
6
#
 
7
# This program is free software: you can redistribute it and/or modify it
 
8
# under the terms of the GNU General Public License version 3, as published
 
9
# by the Free Software Foundation.
 
10
#
 
11
# This program is distributed in the hope that it will be useful, but
 
12
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
13
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
14
# PURPOSE.  See the GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License along
 
17
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
"""Module that implements notification of the end user."""
 
19
 
 
20
import pynotify
 
21
 
 
22
from ubuntuone.status.notification import AbstractNotification
 
23
 
 
24
APPLICATION_NAME = 'Ubuntu One Client'
 
25
 
 
26
 
 
27
class Notification(AbstractNotification):
 
28
    """Notification of the end user."""
 
29
 
 
30
    def __init__(self, application_name=APPLICATION_NAME):
 
31
        self.application_name = application_name
 
32
 
 
33
    def send_notification(self, title, message, icon=None, append=False):
 
34
        """Send a notification using the underlying library."""
 
35
        pynotify.init(self.application_name)
 
36
        notification = pynotify.Notification(title, message, icon)
 
37
        if append:
 
38
            notification.set_hint_string('append', '')
 
39
        notification.show()