Example #1
0
        try:
            import pynotify
        except ImportError:
            self.__notify = None
        else:
            self.__notify = pynotify
            self.__notify.init(data.name)

    def getName(self):
        return u'libnotify'

    def isAvailable(self):
        return self.__notify is not None

    def notify(self, title, summary, bitmap):
        # Libnotify needs a file, like Snarl.
        fd, filename = tempfile.mkstemp('.png')
        os.close(fd)
        bitmap.SaveFile(filename, wx.BITMAP_TYPE_PNG)
        try:
            n = self.__notify.Notification(title.encode('UTF-8'),
                                           summary.encode('UTF-8'),
                                           filename)
            n.show()
        finally:
            os.remove(filename)


AbstractNotifier.register(LibnotifyNotifier())
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
'''

from notifier import AbstractNotifier
import snarl, tempfile, os, wx


class SnarlNotifier(AbstractNotifier):
    def getName(self):
        return u'Snarl'

    def isAvailable(self):
        try:
            return bool(snarl.snGetVersion())
        except:
            return False

    def notify(self, title, summary, bitmap, **kwargs):
        # Hum. Snarl needs a file.
        fd, filename = tempfile.mkstemp('.png')
        os.close(fd)
        bitmap.SaveFile(filename, wx.BITMAP_TYPE_PNG)
        try:
            snarl.snShowMessage(title.encode('UTF-8'), summary.encode('UTF-8'), iconPath=filename)
        finally:
            os.remove(filename)


AbstractNotifier.register(SnarlNotifier())
Example #3
0
        super(KNotifyNotifier, self).__init__()

        self.__factory = None
        try:
            import pcop
            import pydcop
        except ImportError:
            pass
        else:
            if pydcop.anyAppCalled('knotify') is not None:
                self.__factory = pydcop.anyAppCalled

    def getName(self):
        return u'KNotify'

    def isAvailable(self):
        return self.__factory is not None

    def notify(self, title, summary, bitmap, **kwargs):
        # KNotify does not support icons

        coding = wx.Locale_GetSystemEncodingName()

        kn = self.__factory('knotify')
        kn.default.notify('reminder', title.encode(coding),
                          summary.encode(coding), '', '', 16, 0,
                          kwargs.get('windowId', 0))


AbstractNotifier.register(KNotifyNotifier())
    def __init__(self):
        super(GrowlNotifier, self).__init__()
        try:
            # pylint: disable=E1101
            self._notifier = Growl.GrowlNotifier(applicationName=meta.name, notifications=[u'Reminder'])
            self._notifier.register()
        except:
            self._available = False  # pylint: disable=W0702
        else:
            self._available = True

    def getName(self):
        return 'Growl'

    def isAvailable(self):
        return self._available

    def notify(self, title, summary, bitmap, **kwargs):
        # Not really efficient...
        fd, filename = tempfile.mkstemp('.png')
        os.close(fd)
        try:
            bitmap.SaveFile(filename, wx.BITMAP_TYPE_PNG)
            self._notifier.notify(noteType=u'Reminder', icon=file(filename, 'rb').read(), title=title, description=summary,
                                  sticky=True)
        finally:
            os.remove(filename)


AbstractNotifier.register(GrowlNotifier())
            NotificationCenter._instance = _NotificationCenter()
        return NotificationCenter._instance


class UniversalNotifier(AbstractNotifier):
    def getName(self):
        return 'Task Coach'

    def isAvailable(self):
        return True

    def notify(self, title, summary, bitmap, **kwargs):
        NotificationCenter().Notify(title, summary, icon=bitmap) # pylint: disable=E1101


AbstractNotifier.register(UniversalNotifier())


if __name__ == '__main__':
    class TestNotificationFrame(NotificationFrameBase):
        def AddInnerContent(self, sizer, panel):
            choice = wx.Choice(panel, wx.ID_ANY)
            choice.Append('One')
            choice.Append('Two')
            choice.Append('Three')
            sizer.Add(choice, 0, wx.ALL|wx.EXPAND, 5)

            hsz = wx.BoxSizer(wx.HORIZONTAL)
            hsz.Add(wx.Button(panel, wx.ID_ANY, u'OK'), 1, wx.ALL, 2)
            hsz.Add(wx.Button(panel, wx.ID_ANY, u'Cancel'), 1, wx.ALL, 2)
            sizer.Add(hsz, 0, wx.EXPAND|wx.ALL, 5)
Example #6
0
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
'''

from notifier import AbstractNotifier
import snarl, tempfile, os, wx


class SnarlNotifier(AbstractNotifier):
    def getName(self):
        return u'Snarl'

    def isAvailable(self):
        return bool(snarl.snGetVersion())

    def notify(self, title, summary, bitmap, **kwargs):
        # Hum. Snarl needs a file.
        fd, filename = tempfile.mkstemp('.png')
        os.close(fd)
        bitmap.SaveFile(filename, wx.BITMAP_TYPE_PNG)
        try:
            snarl.snShowMessage(title.encode('UTF-8'),
                                summary.encode('UTF-8'),
                                iconPath=filename)
        finally:
            os.remove(filename)


AbstractNotifier.register(SnarlNotifier())
Example #7
0
        self.__factory = None
        try:
            import pcop
            import pydcop
        except ImportError:
            pass
        else:
            if pydcop.anyAppCalled('knotify') is not None:
                self.__factory = pydcop.anyAppCalled

    def getName(self):
        return u'KNotify'

    def isAvailable(self):
        return self.__factory is not None

    def notify(self, title, summary, bitmap, **kwargs):
        # KNotify does not support icons

        coding = wx.Locale_GetSystemEncodingName()

        kn = self.__factory('knotify')
        kn.default.notify('reminder',
                          title.encode(coding),
                          summary.encode(coding),
                          '', '',
                          16, 0, kwargs.get('windowId', 0))


AbstractNotifier.register(KNotifyNotifier())
Example #8
0
            self._notifier = Growl.GrowlNotifier(applicationName=meta.name,
                                                 notifications=[u'Reminder'])
            self._notifier.register()
        except:
            self._available = False  # pylint: disable=W0702
        else:
            self._available = True

    def getName(self):
        return 'Growl'

    def isAvailable(self):
        return self._available

    def notify(self, title, summary, bitmap, **kwargs):
        # Not really efficient...
        fd, filename = tempfile.mkstemp('.png')
        os.close(fd)
        try:
            bitmap.SaveFile(filename, wx.BITMAP_TYPE_PNG)
            self._notifier.notify(noteType=u'Reminder',
                                  icon=file(filename, 'rb').read(),
                                  title=title,
                                  description=summary,
                                  sticky=True)
        finally:
            os.remove(filename)


AbstractNotifier.register(GrowlNotifier())
            NotificationCenter._instance = _NotificationCenter()
        return NotificationCenter._instance


class UniversalNotifier(AbstractNotifier):
    def getName(self):
        return 'Task Coach'

    def isAvailable(self):
        return True

    def notify(self, title, summary, bitmap):
        NotificationCenter().Notify(title, summary, icon=bitmap)


AbstractNotifier.register(UniversalNotifier())


if __name__ == '__main__':
    class TestNotificationFrame(NotificationFrameBase):
        def AddInnerContent(self, sizer, panel):
            choice = wx.Choice(panel, wx.ID_ANY)
            choice.Append('One')
            choice.Append('Two')
            choice.Append('Three')
            sizer.Add(choice, 0, wx.ALL|wx.EXPAND, 5)

            hsz = wx.BoxSizer(wx.HORIZONTAL)
            hsz.Add(wx.Button(panel, wx.ID_ANY, u'OK'), 1, wx.ALL, 2)
            hsz.Add(wx.Button(panel, wx.ID_ANY, u'Cancel'), 1, wx.ALL, 2)
            sizer.Add(hsz, 0, wx.EXPAND|wx.ALL, 5)
Example #10
0
        super(LibnotifyNotifier, self).__init__()

        try:
            import pynotify
        except ImportError:
            self.__notify = None
        else:
            self.__notify = pynotify
            self.__notify.init(data.name)

    def getName(self):
        return u'libnotify'

    def isAvailable(self):
        return self.__notify is not None

    def notify(self, title, summary, bitmap, **kwargs):
        # Libnotify needs a file, like Snarl.
        fd, filename = tempfile.mkstemp('.png')
        os.close(fd)
        bitmap.SaveFile(filename, wx.BITMAP_TYPE_PNG)
        try:
            n = self.__notify.Notification(title.encode('UTF-8'),
                                           summary.encode('UTF-8'), filename)
            n.show()
        finally:
            os.remove(filename)


AbstractNotifier.register(LibnotifyNotifier())