~ubuntuone-control-tower/ubuntuone-client/stable-13-10

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Rodney Dawes
  • Date: 2013-01-28 23:09:36 UTC
  • mfrom: (1378.1.5 no-pygtk)
  • Revision ID: tarmac-20130128230936-1k8aksvh4vlyzyi5
Remove most of the remaining support for older static glib bindings.

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-2012 Canonical Ltd.
 
1
# Copyright 2011-2013 Canonical Ltd.
6
2
#
7
3
# This program is free software: you can redistribute it and/or modify it
8
4
# under the terms of the GNU General Public License version 3, as published
33
29
# TODO: We may want to enable different notifiers. When none of them
34
30
# are available, we should fall back to silently discarding
35
31
# notifications.
36
 
 
37
 
import sys
38
 
 
39
 
NOTIFY_MODULE = None
40
 
 
41
 
if 'gi' in sys.modules and sys.modules['gi'] is not None:
42
 
    try:
43
 
        from gi.repository import Notify
44
 
        Notify  # pyflakes
45
 
        NOTIFY_MODULE = 'gi'
46
 
    except ImportError:
47
 
        pass
48
 
else:
49
 
    try:
50
 
        import pynotify as Notify
51
 
        NOTIFY_MODULE = 'pynotify'
52
 
    except ImportError:
53
 
        pass
 
32
USE_NOTIFY = False
 
33
 
 
34
try:
 
35
    from gi.repository import Notify
 
36
    USE_NOTIFY = True
 
37
except ImportError:
 
38
    pass
54
39
 
55
40
from ubuntuone.status.notification import AbstractNotification
56
41
 
69
54
 
70
55
    def send_notification(self, title, message, icon=ICON_NAME, append=False):
71
56
        """Send a notification using the underlying library."""
72
 
        if not NOTIFY_MODULE:
 
57
        if not USE_NOTIFY:
73
58
            return
74
59
 
75
60
        if self.notification is None:
76
61
            Notify.init(self.application_name)
77
 
            if NOTIFY_MODULE == 'gi':
78
 
                self.notification = Notify.Notification.new(title, message,
79
 
                    icon)
80
 
            else:
81
 
                self.notification = Notify.Notification(title, message, icon)
 
62
            self.notification = Notify.Notification.new(title, message,
 
63
                                                        icon)
82
64
        else:
83
65
            self.notification.update(title, message, icon)
84
66