[blarz] ability to load iconsets from ~/.gajim/iconsets. fixes #3339

This commit is contained in:
Yann Leboulanger 2007-08-05 22:57:04 +00:00
parent 85b4173e41
commit e906a096c9
7 changed files with 32 additions and 20 deletions

View File

@ -78,8 +78,10 @@ class ConfigPaths:
self.root = root self.root = root
# LOG is deprecated # LOG is deprecated
k = ( 'LOG', 'LOG_DB', 'VCARD', 'AVATAR', 'MY_EMOTS' ) k = ( 'LOG', 'LOG_DB', 'VCARD', 'AVATAR', 'MY_EMOTS',
v = (u'logs', u'logs.db', u'vcards', u'avatars', u'emoticons') 'MY_ICONSETS' )
v = (u'logs', u'logs.db', u'vcards', u'avatars', u'emoticons',
u'iconsets')
if os.name == 'nt': if os.name == 'nt':
v = map(lambda x: x.capitalize(), v) v = map(lambda x: x.capitalize(), v)

View File

@ -71,6 +71,7 @@ LOGPATH = gajimpaths['LOG'] # deprecated
VCARD_PATH = gajimpaths['VCARD'] VCARD_PATH = gajimpaths['VCARD']
AVATAR_PATH = gajimpaths['AVATAR'] AVATAR_PATH = gajimpaths['AVATAR']
MY_EMOTS_PATH = gajimpaths['MY_EMOTS'] MY_EMOTS_PATH = gajimpaths['MY_EMOTS']
MY_ICONSETS_PATH = gajimpaths['MY_ICONSETS']
TMP = gajimpaths['TMP'] TMP = gajimpaths['TMP']
DATA_DIR = gajimpaths['DATA'] DATA_DIR = gajimpaths['DATA']
HOME_DIR = gajimpaths['HOME'] HOME_DIR = gajimpaths['HOME']

View File

@ -1044,3 +1044,9 @@ def datetime_tuple(timestamp):
timestamp = timestamp.replace('-', '') timestamp = timestamp.replace('-', '')
from time import strptime from time import strptime
return strptime(timestamp, '%Y%m%dT%H:%M:%S') 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)

View File

@ -146,6 +146,8 @@ class PreferencesWindow:
# iconset # iconset
iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets')) 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 # new model, image in 0, string in 1
model = gtk.ListStore(gtk.Image, str) model = gtk.ListStore(gtk.Image, str)
renderer_image = cell_renderer_image.CellRendererImage(0, 0) renderer_image = cell_renderer_image.CellRendererImage(0, 0)
@ -158,7 +160,8 @@ class PreferencesWindow:
self.iconset_combobox.set_model(model) self.iconset_combobox.set_model(model)
l = [] l = []
for dir in iconsets_list: 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 continue
if dir != '.svn' and dir != 'transports': if dir != '.svn' and dir != 'transports':
l.append(dir) l.append(dir)
@ -167,9 +170,9 @@ class PreferencesWindow:
for i in xrange(len(l)): for i in xrange(len(l)):
preview = gtk.Image() preview = gtk.Image()
files = [] 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')) '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')) 'online.gif'))
for file in files: for file in files:
if os.path.exists(file): if os.path.exists(file):

View File

@ -1983,7 +1983,7 @@ class RosterWindow:
start_chat_menuitem.set_submenu(sub_menu) start_chat_menuitem.set_submenu(sub_menu)
iconset = gajim.config.get('iconset') 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: for c in contacts:
# icon MUST be different instance for every item # icon MUST be different instance for every item
state_images = self.load_iconset(path) state_images = self.load_iconset(path)
@ -2170,7 +2170,7 @@ class RosterWindow:
status_menuitems = gtk.Menu() status_menuitems = gtk.Menu()
send_custom_status_menuitem.set_submenu(status_menuitems) send_custom_status_menuitem.set_submenu(status_menuitems)
iconset = gajim.config.get('iconset') 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']: for s in ['online', 'chat', 'away', 'xa', 'dnd', 'offline']:
# icon MUST be different instance for every item # icon MUST be different instance for every item
state_images = self.load_iconset(path) state_images = self.load_iconset(path)
@ -2189,7 +2189,7 @@ class RosterWindow:
iconset = gajim.config.get('iconset') iconset = gajim.config.get('iconset')
if not iconset: if not iconset:
iconset = gajim.config.DEFAULT_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: for c in contacts:
# icon MUST be different instance for every item # icon MUST be different instance for every item
state_images = self.load_iconset(path) state_images = self.load_iconset(path)
@ -2668,7 +2668,7 @@ class RosterWindow:
status_menuitems = gtk.Menu() status_menuitems = gtk.Menu()
send_custom_status_menuitem.set_submenu(status_menuitems) send_custom_status_menuitem.set_submenu(status_menuitems)
iconset = gajim.config.get('iconset') 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']: for s in ['online', 'chat', 'away', 'xa', 'dnd', 'offline']:
# icon MUST be different instance for every item # icon MUST be different instance for every item
state_images = self.load_iconset(path) state_images = self.load_iconset(path)
@ -2860,7 +2860,7 @@ class RosterWindow:
# we have to create our own set of icons for the menu # we have to create our own set of icons for the menu
# using self.jabber_status_images is poopoo # using self.jabber_status_images is poopoo
iconset = gajim.config.get('iconset') 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) state_images = self.load_iconset(path)
if not gajim.config.get_per('accounts', account, 'is_zeroconf'): if not gajim.config.get_per('accounts', account, 'is_zeroconf'):
@ -3006,7 +3006,7 @@ class RosterWindow:
else: else:
menu = gtk.Menu() menu = gtk.Menu()
iconset = gajim.config.get('iconset') 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 accounts = [] # Put accounts in a list to sort them
for account in gajim.connections: for account in gajim.connections:
accounts.append(account) accounts.append(account)
@ -3603,7 +3603,7 @@ class RosterWindow:
except: except:
pass pass
iconset = gajim.config.get('iconset') 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'): if status in ('chat', 'away', 'xa', 'dnd', 'invisible', 'offline'):
status = status + '.png' status = status + '.png'
elif status == 'online': elif status == 'online':
@ -4300,7 +4300,7 @@ class RosterWindow:
def load_icon(self, icon_name): def load_icon(self, icon_name):
'''load an icon from the iconset in 16x16''' '''load an icon from the iconset in 16x16'''
iconset = gajim.config.get('iconset') 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) icon_list = self._load_icon_list([icon_name], path)
return icon_list[icon_name] return icon_list[icon_name]
@ -4335,16 +4335,16 @@ class RosterWindow:
'''initialise jabber_state_images dict''' '''initialise jabber_state_images dict'''
iconset = gajim.config.get('iconset') iconset = gajim.config.get('iconset')
if 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): if not os.path.exists(path):
iconset = gajim.config.DEFAULT_ICONSET iconset = gajim.config.DEFAULT_ICONSET
else: else:
iconset = gajim.config.DEFAULT_ICONSET 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) 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) self.jabber_state_images['16'] = self.load_iconset(path)
# try to find opened_meta.png file, else opened.png else nopixbuf merge # try to find opened_meta.png file, else opened.png else nopixbuf merge
path_opened = os.path.join(path, 'opened_meta.png') path_opened = os.path.join(path, 'opened_meta.png')

View File

@ -145,7 +145,7 @@ class Systray:
# We need our own set of status icons, let's make 'em! # We need our own set of status icons, let's make 'em!
iconset = gajim.config.get('iconset') 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) state_images = gajim.interface.roster.load_iconset(path)
if state_images.has_key('muc_active'): if state_images.has_key('muc_active'):

View File

@ -228,7 +228,7 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
iconset = gajim.config.get('iconset') iconset = gajim.config.get('iconset')
if not iconset: if not iconset:
iconset = 'dcraven' 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: for acct in accounts:
message = acct['message'] message = acct['message']
# before reducing the chars we should assure we send unicode, else # before reducing the chars we should assure we send unicode, else
@ -441,8 +441,8 @@ class RosterTooltip(NotificationAreaTooltip):
iconset = gajim.config.get('iconset') iconset = gajim.config.get('iconset')
if not iconset: if not iconset:
iconset = 'dcraven' iconset = 'dcraven'
file_path = os.path.join(gajim.DATA_DIR, file_path = os.path.join(helpers.get_iconset_path(iconsets),
'iconsets', iconset, '16x16') '16x16')
contact_keys = contacts_dict.keys() contact_keys = contacts_dict.keys()
contact_keys.sort() contact_keys.sort()