From 182963242b57e91e40fe635847cf430a4b55bef9 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Sun, 8 Oct 2006 09:01:32 +0000
Subject: [PATCH] fix adjust_priority_with_status option: save when we change
 this option and correctly get autopriority_* values

---
 src/common/gajim.py | 12 +++++-------
 src/config.py       |  5 ++++-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/common/gajim.py b/src/common/gajim.py
index e9ef782258..6e6a79be85 100644
--- a/src/common/gajim.py
+++ b/src/common/gajim.py
@@ -120,10 +120,6 @@ status_before_autoaway = {}
 SHOW_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd',
 	'invisible']
 
-priority_dict = {}
-for status in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'):
-	priority_dict[status] = config.get('autopriority' + status)
-
 def get_nick_from_jid(jid):
 	pos = jid.find('@')
 	return jid[:pos]
@@ -333,7 +329,9 @@ def get_priority(account, show):
 	'''return the priority an account must have'''
 	if not show:
 		show = 'online'
-	if show in priority_dict and config.get_per('accounts', account,
-	'adjust_priority_with_status'):
-		return priority_dict[show]
+
+	if show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible') and \
+	config.get_per('accounts', account, 'adjust_priority_with_status'):
+		return config.get_per('accounts', account, 'autopriority_' + show)
+	print '1', config.get_per('accounts', account, 'priority')
 	return config.get_per('accounts', account, 'priority')
diff --git a/src/config.py b/src/config.py
index 97d6928f91..976a15bf85 100644
--- a/src/config.py
+++ b/src/config.py
@@ -1324,6 +1324,8 @@ class AccountModificationWindow:
 		config['password'] = self.xml.get_widget('password_entry').get_text().\
 			decode('utf-8')
 		config['resource'] = resource
+		config['adjust_priority_with_status'] = self.xml.get_widget(
+			'adjust_priority_with_status_checkbutton').get_active()
 		config['priority'] = self.xml.get_widget('priority_spinbutton').\
 																			get_value_as_int()
 		config['autoconnect'] = self.xml.get_widget('autoconnect_checkbutton').\
@@ -1451,7 +1453,8 @@ class AccountModificationWindow:
 			config['use_ft_proxies']:
 				gajim.connections[self.account].discover_ft_proxies()
 
-			if self.option_changed(config, 'priority'):
+			if self.option_changed(config, 'priority') or self.option_changed(
+			config, 'adjust_priority_with_status'):
 				resend_presence = True
 
 		for opt in config:
-- 
GitLab