From ef8553031bce8bbae1acb204e76576d9e2d7ddb9 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Sun, 26 Nov 2006 09:28:12 +0000
Subject: [PATCH] [elrodeo] add a sound option when receiving gmail
 notifications. fixes #2697

---
 src/common/config.py | 1 +
 src/config.py        | 7 +++++++
 src/gajim.py         | 1 +
 3 files changed, 9 insertions(+)

diff --git a/src/common/config.py b/src/common/config.py
index 412024df50..43ba21203b 100644
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -375,6 +375,7 @@ class Config:
 		'message_sent': [ True, '../data/sounds/sent.wav' ],
 		'muc_message_highlight': [ True, '../data/sounds/gc_message1.wav', _('Sound to play when a group chat message contains one of the words in muc_highlight_words, or when a group chat message contains your nickname.')],
 		'muc_message_received': [ False, '../data/sounds/gc_message2.wav', _('Sound to play when any MUC message arrives.') ],
+		'gmail_received': [ False, '../data/sounds/message1.wav' ],
 	}
 
 	themes_default = {
diff --git a/src/config.py b/src/config.py
index 67ef76e6d5..86d189d401 100644
--- a/src/config.py
+++ b/src/config.py
@@ -1071,6 +1071,13 @@ def fill_sound_treeview(self):
 			'muc_message_highlight': _('Group Chat Message Highlight'),
 			'muc_message_received': _('Group Chat Message Received')
 		}
+
+		# In case of a GMail account we provide a sound notification option
+		for account in gajim.config.get_per('accounts'):
+			jid = gajim.get_jid_from_account(account)
+			if gajim.get_server_from_jid(jid) in gajim.gmail_domains:
+				sounds_dict['gmail_received'] = _('GMail Email Received')
+				break
 		
 		for sound_event_config_name, sound_ui_name in sounds_dict.items():
 			enabled = gajim.config.get_per('soundevents',
diff --git a/src/gajim.py b/src/gajim.py
index 5e56d094ba..02bb10cdf8 100755
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -1155,6 +1155,7 @@ def handle_event_gmail_notify(self, account, array):
 						{'from_address': gmessage['From']}
 					
 			path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
+			helpers.play_sound('gmail_received')
 			notify.popup(_('New E-mail'), jid, account, 'gmail',
 				path_to_image = path, title = title, text = text)
 
-- 
GitLab