[blarz] ability to load iconsets from ~/.gajim/iconsets. fixes #3339
This commit is contained in:
parent
85b4173e41
commit
e906a096c9
|
@ -78,8 +78,10 @@ class ConfigPaths:
|
|||
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)
|
||||
|
|
|
@ -71,6 +71,7 @@ LOGPATH = gajimpaths['LOG'] # deprecated
|
|||
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']
|
||||
|
|
|
@ -1044,3 +1044,9 @@ def datetime_tuple(timestamp):
|
|||
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)
|
||||
|
|
|
@ -146,6 +146,8 @@ class PreferencesWindow:
|
|||
|
||||
# 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 @@ class PreferencesWindow:
|
|||
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 @@ class PreferencesWindow:
|
|||
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):
|
||||
|
|
|
@ -1983,7 +1983,7 @@ class RosterWindow:
|
|||
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 @@ class RosterWindow:
|
|||
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 @@ class RosterWindow:
|
|||
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 @@ class RosterWindow:
|
|||
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 @@ class RosterWindow:
|
|||
# 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 @@ class RosterWindow:
|
|||
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 @@ class RosterWindow:
|
|||
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 @@ class RosterWindow:
|
|||
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 @@ class RosterWindow:
|
|||
'''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')
|
||||
|
|
|
@ -145,7 +145,7 @@ class Systray:
|
|||
|
||||
# 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'):
|
||||
|
|
|
@ -228,7 +228,7 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
|
|||
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 @@ class RosterTooltip(NotificationAreaTooltip):
|
|||
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()
|
||||
|
|
Loading…
Reference in New Issue