Extensions: Various fixes and clean-ups from review
[gpodder.git] / share / gpodder / extensions / notification.py
blobdebe18d88b5ecd7c0e450f0d5b29cbc5548fb73f
1 # -*- coding: utf-8 -*-
3 # gPodder - A media aggregator and podcast client
4 # Copyright (c) 2005-2011 Thomas Perl and the gPodder Team
6 # gPodder is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # gPodder is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # Bernd Schlapsi <brot@gmx.info>; 2011-11-20
22 __title__ = 'Gtk+ Desktop Notifications'
23 __description__ = 'Display notification bubbles for different events.'
24 __only_for__ = 'gtk'
26 import gpodder
28 import logging
29 logger = logging.getLogger(__name__)
31 try:
32 import pynotify
33 except ImportError:
34 pynotify = None
37 if pynotify is None:
38 class gPodderExtension(object):
39 def __init__(self, container):
40 logger.info('Could not find PyNotify.')
41 else:
42 class gPodderExtension(object):
43 def __init__(self, container):
44 self.container = container
46 def on_load(self):
47 pynotify.init('gPodder')
49 def on_unload(self):
50 pynotify.uninit()
52 def on_notification_show(self, title, message):
53 notify = pynotify.Notification(title, message, gpodder.icon_file)
55 try:
56 notify.show()
57 except:
58 # See http://gpodder.org/bug/966
59 pass