2012-02-20 23:55:36 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# gPodder - A media aggregator and podcast client
|
|
|
|
# Copyright (c) 2005-2011 Thomas Perl and the gPodder Team
|
|
|
|
#
|
|
|
|
# gPodder is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# gPodder is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Bernd Schlapsi <brot@gmx.info>; 2011-11-20
|
|
|
|
|
|
|
|
__title__ = 'Gtk+ Desktop Notifications'
|
|
|
|
__description__ = 'Display notification bubbles for different events.'
|
2012-11-18 19:26:02 +01:00
|
|
|
__category__ = 'desktop-integration'
|
2012-02-21 10:14:23 +01:00
|
|
|
__only_for__ = 'gtk'
|
2012-11-18 19:26:02 +01:00
|
|
|
__mandatory_in__ = 'gtk'
|
2012-12-22 12:19:28 +01:00
|
|
|
__disable_in__ = 'win32'
|
2012-02-20 23:55:36 +01:00
|
|
|
|
2018-07-24 11:08:10 +02:00
|
|
|
import logging
|
|
|
|
|
2012-02-20 23:55:36 +01:00
|
|
|
import gpodder
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
try:
|
2016-09-21 12:54:27 +02:00
|
|
|
import gi
|
|
|
|
gi.require_version('Notify', '0.7')
|
2016-09-25 14:31:58 +02:00
|
|
|
from gi.repository import Notify
|
2016-09-21 12:54:27 +02:00
|
|
|
pynotify = True
|
2012-02-20 23:55:36 +01:00
|
|
|
except ImportError:
|
|
|
|
pynotify = None
|
2016-10-02 19:30:40 +02:00
|
|
|
except ValueError:
|
|
|
|
pynotify = None
|
2012-02-20 23:55:36 +01:00
|
|
|
|
|
|
|
|
|
|
|
if pynotify is None:
|
|
|
|
class gPodderExtension(object):
|
|
|
|
def __init__(self, container):
|
|
|
|
logger.info('Could not find PyNotify.')
|
|
|
|
else:
|
|
|
|
class gPodderExtension(object):
|
|
|
|
def __init__(self, container):
|
2012-02-21 15:13:18 +01:00
|
|
|
self.container = container
|
|
|
|
|
|
|
|
def on_load(self):
|
2016-09-25 14:31:58 +02:00
|
|
|
Notify.init('gPodder')
|
2012-02-21 15:13:18 +01:00
|
|
|
|
|
|
|
def on_unload(self):
|
2016-09-25 14:31:58 +02:00
|
|
|
Notify.uninit()
|
2012-02-20 23:55:36 +01:00
|
|
|
|
|
|
|
def on_notification_show(self, title, message):
|
2012-03-11 10:24:25 +01:00
|
|
|
if not message and not title:
|
|
|
|
return
|
|
|
|
|
2016-09-21 12:54:27 +02:00
|
|
|
notify = Notify.Notification.new(title or '', message or '',
|
2012-03-11 10:24:25 +01:00
|
|
|
gpodder.icon_file)
|
2012-02-20 23:55:36 +01:00
|
|
|
|
|
|
|
try:
|
|
|
|
notify.show()
|
|
|
|
except:
|
|
|
|
# See http://gpodder.org/bug/966
|
|
|
|
pass
|