Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/osx/growler.py')
-rw-r--r--src/osx/growler.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/osx/growler.py b/src/osx/growler.py
new file mode 100644
index 000000000..c3ea320cf
--- /dev/null
+++ b/src/osx/growler.py
@@ -0,0 +1,63 @@
+import sys, os
+from growl.Growl import GrowlNotifier
+from common import gajim, helpers
+
+
+if sys.platform != "darwin":
+ raise ImportError("System platform is not OS/X")
+
+
+GENERIC_NOTIF = _('Generic')
+notifications = [
+ _('Contact Signed In'), _('Contact Signed Out'), _('New Message'),
+ _('New Single Message'), _('New Private Message'), _('New E-mail'),
+ _('File Transfer Request'), _('File Transfer Error'),
+ _('File Transfer Completed'), _('File Transfer Stopped'),
+ _('Groupchat Invitation'), _('Contact Changed Status'),
+ _('Connection Failed'), GENERIC_NOTIF
+ ]
+
+growler = None
+
+
+
+def init():
+ global growler, notifications
+ icon = file(os.path.join(gajim.DATA_DIR, "pixmaps", "gajim.icns"), "r")
+ growler = GrowlNotifier(applicationName = "Gajim",
+ notifications = notifications,
+ applicationIcon = icon.read(),
+ notify_cb = notifyCB)
+ growler.register()
+ return
+
+
+def notify(event_type, jid, account, msg_type, path_to_image, title, text):
+ global notifications
+ if not event_type in notifications:
+ event_type = GENERIC_NOTIF
+ if not text:
+ text = gajim.get_name_from_jid(account, jid) # default value of text
+ text = filterString(text)
+ if not title:
+ title = event_type
+ title = filterString(title)
+ if not path_to_image:
+ path_to_image = os.path.abspath(
+ os.path.join(gajim.DATA_DIR, 'pixmaps', 'events',
+ 'chat_msg_recv.png')) # img to display
+ icon = file(path_to_image, "r")
+ context = [account, jid, msg_type]
+ growler.notify(event_type, title, text, icon.read(), False, None,
+ context)
+ return
+
+
+def notifyCB(data):
+ gajim.interface.handle_event(data[0], data[1], data[2])
+
+
+def filterString(string):
+ string = string.replace(""", "'")
+ return string
+