From a8354e11323dc41bfa6e860ff27b441f282014d8 Mon Sep 17 00:00:00 2001
From: Jean-Marie Traissard <jim@lapin.org>
Date: Fri, 3 Nov 2006 19:52:39 +0000
Subject: [PATCH] Fixed totally broken trayicon_notification_on_new_messages
 behaviour, change name to trayicon_notification_on_events and do what's
 expected

---
 src/chat_control.py     | 11 ++++-------
 src/common/config.py    |  2 +-
 src/common/defs.py      |  2 +-
 src/common/optparser.py | 11 ++++++++++-
 src/notify.py           |  4 ++--
 5 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/chat_control.py b/src/chat_control.py
index a3aac70e2c..7bc85cb20f 100644
--- a/src/chat_control.py
+++ b/src/chat_control.py
@@ -560,7 +560,7 @@ class ChatControlBase(MessageControl):
 			gc_message = False
 			if self.type_id  == message_control.TYPE_GC:
 				gc_message = True
-			if self.notify_on_new_messages() or \
+			if not gc_message or \
 			(gc_message and other_tags_for_text == ['marked']):
 			# we want to have save this message in events list
 			# other_tags_for_text == ['marked'] --> highlighted gc message
@@ -580,11 +580,11 @@ class ChatControlBase(MessageControl):
 					gajim.interface.roster.draw_contact(self.contact.jid,
 						self.account)
 			self.parent_win.redraw_tab(self)
-			ctrl = gajim.interface.msg_win_mgr.get_control(full_jid,	self.account)
+			ctrl = gajim.interface.msg_win_mgr.get_control(full_jid, self.account)
 			if not self.parent_win.is_active():
-				self.parent_win.show_title(True, ctrl) # Enabled Urgent
+				self.parent_win.show_title(True, ctrl) # Enabled Urgent hint
 			else:
-				self.parent_win.show_title(False, ctrl) # Disabled Urgent
+				self.parent_win.show_title(False, ctrl) # Disabled Urgent hint
 
 	def toggle_emoticons(self):
 		'''hide show emoticons_button and make sure emoticons_menu is always there
@@ -899,9 +899,6 @@ class ChatControl(ChatControlBase):
 		# restore previous conversation
 		self.restore_conversation()
 
-	def notify_on_new_messages(self):
-		return gajim.config.get('trayicon_notification_on_new_messages')
-	
 	def on_avatar_eventbox_enter_notify_event(self, widget, event):
 		'''we enter the eventbox area so we under conditions add a timeout
 		to show a bigger avatar after 0.5 sec'''
diff --git a/src/common/config.py b/src/common/config.py
index bdd0b44446..1270f48f93 100644
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -165,7 +165,7 @@ class Config:
 		'roster_font': [opt_str, ''],
 		'use_kib_mib': [opt_bool, False, _('IEC standard says KiB = 1024 bytes, KB = 1000 bytes.')],
 		'notify_on_all_muc_messages': [opt_bool, False],
-		'trayicon_notification_on_new_messages': [opt_bool, True],
+		'trayicon_notification_on_events': [opt_bool, True, _('Notify of events in the system trayicon.')],
 		'last_save_dir': [opt_str, ''],
 		'last_send_dir': [opt_str, ''],
 		'last_emoticons_dir': [opt_str, ''],
diff --git a/src/common/defs.py b/src/common/defs.py
index ac47a8f102..9cd4f45d09 100644
--- a/src/common/defs.py
+++ b/src/common/defs.py
@@ -2,4 +2,4 @@ docdir = '../'
 
 datadir = '../'
 
-version = '0.10.1.6'
+version = '0.10.1.7'
diff --git a/src/common/optparser.py b/src/common/optparser.py
index fbb7fba994..c64446f904 100644
--- a/src/common/optparser.py
+++ b/src/common/optparser.py
@@ -151,6 +151,8 @@ class OptionsParser:
 			self.update_config_to_01015()
 		if old < [0, 10, 1, 6] and new >= [0, 10, 1, 6]:
 			self.update_config_to_01016()
+		if old < [0, 10, 1, 7] and new >= [0, 10, 1, 7]:
+			self.update_config_to_01017()
 
 		gajim.logger.init_vars()
 		gajim.config.set('version', new_version)
@@ -336,5 +338,12 @@ class OptionsParser:
 		gajim.config.get_per('soundevents', 'muc_message_received', 'enabled'):
 			gajim.config.set_per('soundevents',\
 				'muc_message_received', 'enabled', False)
-		
 		gajim.config.set('version', '0.10.1.6')
+
+	def update_config_to_01017(self):
+		'''trayicon_notification_on_new_messages ->
+		trayicon_notification_on_events '''
+		if self.old_values.has_key('trayicon_notification_on_new_messages'):
+			gajim.config.set('trayicon_notification_on_events',
+				 self.old_values['trayicon_notification_on_new_messages']) 
+		gajim.config.set('version', '0.10.1.7')
diff --git a/src/notify.py b/src/notify.py
index e4f34fbceb..ad4857ac37 100644
--- a/src/notify.py
+++ b/src/notify.py
@@ -54,14 +54,14 @@ def get_show_in_roster(event, account, contact):
 	return True
 
 def get_show_in_systray(event, account, contact):
-	'''Return True if this event must be shown in roster, else False'''
+	'''Return True if this event must be shown in systray, else False'''
 	num = get_advanced_notification(event, account, contact)
 	if num != None:
 		if gajim.config.get_per('notifications', str(num), 'systray') == 'yes':
 			return True
 		if gajim.config.get_per('notifications', str(num), 'systray') == 'no':
 			return False
-	return True
+	return gajim.config.get('trayicon_notification_on_events')
 
 def get_advanced_notification(event, account, contact):
 	'''Returns the number of the first (top most)
-- 
GitLab