Putting all the code from the current master branch of TWBlue

This commit is contained in:
2014-10-27 16:29:04 -06:00
parent 58c82e5486
commit 1af4a8b291
284 changed files with 58760 additions and 0 deletions

21
src/notifier/__init__.py Normal file
View File

@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
""" A cross platform notification system.
Under Linux, the wx.NotificationMessage does not show a notification on the taskbar, so we decided to use dbus for showing notifications for linux and wx for Windows."""
import platform
notify = None
def setup():
global notify
if platform.system() == "Windows":
import windows
notify = windows.notification()
elif platform.system() == "Linux":
import linux
notify = linux.notification()
def send(title, text):
global notify
if not notify or notify is None:
setup()
notify.notify(title, text)

25
src/notifier/linux.py Normal file
View File

@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
import dbus
import application
class notifications(object):
"""Supports notifications on Linux.
"""
def __init__(self):
super(notifications, self).__init__()
self.item = "org.freedesktop.Notifications"
self.path = "/org/freedesktop/Notifications"
self.interface = "org.freedesktop.Notifications"
self.app_name = application.name
self.id_num_to_replace = 0
self.icon = "/usr/share/icons/Tango/32x32/status/sunny.png"
def notify(self, title="", text=""):
actions_list = ''
hint = ''
time = 5000 # Use seconds x 1000
bus = dbus.SessionBus()
notif = bus.get_object(self.item, self.path)
notify = dbus.Interface(notif, self.interface)
notify.Notify(self.app_name, self.id_num_to_replace, self.icon, title, text, actions_list, hint, time)

7
src/notifier/windows.py Normal file
View File

@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
import wx
class notification(object):
def notify(self, title, text):
wx.NotificationMessage(title, text).Show()