Author: asterix
Date: 2007-08-06 00:57:04 +0200 (Mon, 06 Aug 2007)
New Revision: 8451
Modified:
trunk/src/common/configpaths.py
trunk/src/common/gajim.py
trunk/src/common/helpers.py
trunk/src/config.py
trunk/src/roster_window.py
trunk/src/systray.py
trunk/src/tooltips.py
Log:
[blarz] ability to load iconsets from ~/.gajim/iconsets. fixes #3339
Modified: trunk/src/common/configpaths.py
===================================================================
--- trunk/src/common/configpaths.py 2007-08-05 22:47:33 UTC (rev 8450)
+++ trunk/src/common/configpaths.py 2007-08-05 22:57:04 UTC (rev 8451)
@@ -78,8 +78,10 @@
self.root = root
# LOG is deprecated
- k = ( 'LOG', 'LOG_DB', 'VCARD', 'AVATAR', 'MY_EMOTS' )
- v = (u'logs', u'logs.db', u'vcards', u'avatars', u'emoticons')
+ k = ( 'LOG', 'LOG_DB', 'VCARD', 'AVATAR', 'MY_EMOTS',
+ 'MY_ICONSETS' )
+ v = (u'logs', u'logs.db', u'vcards', u'avatars', u'emoticons',
+ u'iconsets')
if os.name == 'nt':
v = map(lambda x: x.capitalize(), v)
Modified: trunk/src/common/gajim.py
===================================================================
--- trunk/src/common/gajim.py 2007-08-05 22:47:33 UTC (rev 8450)
+++ trunk/src/common/gajim.py 2007-08-05 22:57:04 UTC (rev 8451)
@@ -71,6 +71,7 @@
VCARD_PATH = gajimpaths['VCARD']
AVATAR_PATH = gajimpaths['AVATAR']
MY_EMOTS_PATH = gajimpaths['MY_EMOTS']
+MY_ICONSETS_PATH = gajimpaths['MY_ICONSETS']
TMP = gajimpaths['TMP']
DATA_DIR = gajimpaths['DATA']
HOME_DIR = gajimpaths['HOME']
Modified: trunk/src/common/helpers.py
===================================================================
--- trunk/src/common/helpers.py 2007-08-05 22:47:33 UTC (rev 8450)
+++ trunk/src/common/helpers.py 2007-08-05 22:57:04 UTC (rev 8451)
@@ -1044,3 +1044,9 @@
timestamp = timestamp.replace('-', '')
from time import strptime
return strptime(timestamp, '%Y%m%dT%H:%M:%S')
+
+def get_iconset_path(iconset):
+ if os.path.isdir(os.path.join(gajim.DATA_DIR, 'iconsets', iconset)):
+ return os.path.join(gajim.DATA_DIR, 'iconsets', iconset)
+ elif os.path.isdir(os.path.join(gajim.MY_ICONSETS_PATH, iconset)):
+ return os.path.join(gajim.MY_ICONSETS_PATH, iconset)
Modified: trunk/src/config.py
===================================================================
--- trunk/src/config.py 2007-08-05 22:47:33 UTC (rev 8450)
+++ trunk/src/config.py 2007-08-05 22:57:04 UTC (rev 8451)
@@ -146,6 +146,8 @@
# iconset
iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets'))
+ if os.path.isdir(gajim.MY_ICONSETS_PATH):
+ iconsets_list += os.listdir(gajim.MY_ICONSETS_PATH)
# new model, image in 0, string in 1
model = gtk.ListStore(gtk.Image, str)
renderer_image = cell_renderer_image.CellRendererImage(0, 0)
@@ -158,7 +160,8 @@
self.iconset_combobox.set_model(model)
l = []
for dir in iconsets_list:
- if not os.path.isdir(os.path.join(gajim.DATA_DIR, 'iconsets', dir)):
+ if not os.path.isdir(os.path.join(gajim.DATA_DIR, 'iconsets', dir)) \
+ and not os.path.isdir(os.path.join(gajim.MY_ICONSETS_PATH, dir)):
continue
if dir != '.svn' and dir != 'transports':
l.append(dir)
@@ -167,9 +170,9 @@
for i in xrange(len(l)):
preview = gtk.Image()
files = []
- files.append(os.path.join(gajim.DATA_DIR, 'iconsets', l[i], '16x16',
+ files.append(os.path.join(helpers.get_iconset_path(l[i]), '16x16',
'online.png'))
- files.append(os.path.join(gajim.DATA_DIR, 'iconsets', l[i], '16x16',
+ files.append(os.path.join(helpers.get_iconset_path(l[i]), '16x16',
'online.gif'))
for file in files:
if os.path.exists(file):
Modified: trunk/src/roster_window.py
===================================================================
--- trunk/src/roster_window.py 2007-08-05 22:47:33 UTC (rev 8450)
+++ trunk/src/roster_window.py 2007-08-05 22:57:04 UTC (rev 8451)
@@ -1983,7 +1983,7 @@
start_chat_menuitem.set_submenu(sub_menu)
iconset = gajim.config.get('iconset')
- path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
+ path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
for c in contacts:
# icon MUST be different instance for every item
state_images = self.load_iconset(path)
@@ -2170,7 +2170,7 @@
status_menuitems = gtk.Menu()
send_custom_status_menuitem.set_submenu(status_menuitems)
iconset = gajim.config.get('iconset')
- path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
+ path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
for s in ['online', 'chat', 'away', 'xa', 'dnd', 'offline']:
# icon MUST be different instance for every item
state_images = self.load_iconset(path)
@@ -2189,7 +2189,7 @@
iconset = gajim.config.get('iconset')
if not iconset:
iconset = gajim.config.DEFAULT_ICONSET
- path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
+ path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
for c in contacts:
# icon MUST be different instance for every item
state_images = self.load_iconset(path)
@@ -2668,7 +2668,7 @@
status_menuitems = gtk.Menu()
send_custom_status_menuitem.set_submenu(status_menuitems)
iconset = gajim.config.get('iconset')
- path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
+ path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
for s in ['online', 'chat', 'away', 'xa', 'dnd', 'offline']:
# icon MUST be different instance for every item
state_images = self.load_iconset(path)
@@ -2860,7 +2860,7 @@
# we have to create our own set of icons for the menu
# using self.jabber_status_images is poopoo
iconset = gajim.config.get('iconset')
- path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
+ path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
state_images = self.load_iconset(path)
if not gajim.config.get_per('accounts', account, 'is_zeroconf'):
@@ -3006,7 +3006,7 @@
else:
menu = gtk.Menu()
iconset = gajim.config.get('iconset')
- path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
+ path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
accounts = [] # Put accounts in a list to sort them
for account in gajim.connections:
accounts.append(account)
@@ -3603,7 +3603,7 @@
except:
pass
iconset = gajim.config.get('iconset')
- prefix = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '32x32')
+ prefix = os.path.join(helpers.get_iconset_path(iconset), '32x32')
if status in ('chat', 'away', 'xa', 'dnd', 'invisible', 'offline'):
status = status + '.png'
elif status == 'online':
@@ -4300,7 +4300,7 @@
def load_icon(self, icon_name):
'''load an icon from the iconset in 16x16'''
iconset = gajim.config.get('iconset')
- path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16'+ '/')
+ path = os.path.join(helpers.get_iconset_path(iconset), '16x16'+ '/')
icon_list = self._load_icon_list([icon_name], path)
return icon_list[icon_name]
@@ -4335,16 +4335,16 @@
'''initialise jabber_state_images dict'''
iconset = gajim.config.get('iconset')
if iconset:
- path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
+ path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
if not os.path.exists(path):
iconset = gajim.config.DEFAULT_ICONSET
else:
iconset = gajim.config.DEFAULT_ICONSET
- path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '32x32')
+ path = os.path.join(helpers.get_iconset_path(iconset), '32x32')
self.jabber_state_images['32'] = self.load_iconset(path)
- path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
+ path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
self.jabber_state_images['16'] = self.load_iconset(path)
# try to find opened_meta.png file, else opened.png else nopixbuf merge
path_opened = os.path.join(path, 'opened_meta.png')
Modified: trunk/src/systray.py
===================================================================
--- trunk/src/systray.py 2007-08-05 22:47:33 UTC (rev 8450)
+++ trunk/src/systray.py 2007-08-05 22:57:04 UTC (rev 8451)
@@ -145,7 +145,7 @@
# We need our own set of status icons, let's make 'em!
iconset = gajim.config.get('iconset')
- path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
+ path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
state_images = gajim.interface.roster.load_iconset(path)
if state_images.has_key('muc_active'):
Modified: trunk/src/tooltips.py
===================================================================
--- trunk/src/tooltips.py 2007-08-05 22:47:33 UTC (rev 8450)
+++ trunk/src/tooltips.py 2007-08-05 22:57:04 UTC (rev 8451)
@@ -228,7 +228,7 @@
iconset = gajim.config.get('iconset')
if not iconset:
iconset = 'dcraven'
- file_path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
+ file_path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
for acct in accounts:
message = acct['message']
# before reducing the chars we should assure we send unicode, else
@@ -441,8 +441,8 @@
iconset = gajim.config.get('iconset')
if not iconset:
iconset = 'dcraven'
- file_path = os.path.join(gajim.DATA_DIR,
- 'iconsets', iconset, '16x16')
+ file_path = os.path.join(helpers.get_iconset_path(iconsets),
+ '16x16')
contact_keys = contacts_dict.keys()
contact_keys.sort()