we now have emoticons themes. Fixes #1182
TODO: fill animated folder with his emoticons file
This commit is contained in:
parent
7cd6cf3994
commit
b4ed754b51
|
@ -123,7 +123,8 @@ class ChatControlBase(MessageControl):
|
|||
# set image no matter if user wants at this time emoticons or not
|
||||
# (so toggle works ok)
|
||||
img = self.xml.get_widget('emoticons_button_image')
|
||||
img.set_from_file(os.path.join(gajim.DATA_DIR, 'emoticons', 'smile.png'))
|
||||
img.set_from_file(os.path.join(gajim.DATA_DIR, 'emoticons', 'static',
|
||||
'smile.png'))
|
||||
self.toggle_emoticons()
|
||||
|
||||
# Attach speller
|
||||
|
|
|
@ -80,7 +80,7 @@ class Config:
|
|||
'sort_by_show': [ opt_bool, True, '', True ],
|
||||
'use_speller': [ opt_bool, False, ],
|
||||
'print_time': [ opt_str, 'always' ],
|
||||
'useemoticons': [ opt_bool, True ],
|
||||
'emoticons_theme': [opt_str, 'static', '', True ],
|
||||
'ascii_formatting': [ opt_bool, True,
|
||||
_('Treat * / _ pairs as possible formatting characters.'), True],
|
||||
'show_ascii_formatting_chars': [ opt_bool, False , _('If True, do not '
|
||||
|
@ -235,9 +235,6 @@ class Config:
|
|||
'statusmsg': ({
|
||||
'message': [ opt_str, '' ],
|
||||
}, {}),
|
||||
'emoticons': ({
|
||||
'path': [ opt_str, '' ],
|
||||
}, {}),
|
||||
'soundevents': ({
|
||||
'enabled': [ opt_bool, True ],
|
||||
'path': [ opt_str, '' ],
|
||||
|
@ -286,72 +283,6 @@ class Config:
|
|||
}, {}),
|
||||
}
|
||||
|
||||
emoticons_default = {
|
||||
':-)': '../data/emoticons/smile.png',
|
||||
'(@)': '../data/emoticons/pussy.png',
|
||||
'8)': '../data/emoticons/coolglasses.png',
|
||||
':(': '../data/emoticons/unhappy.png',
|
||||
':)': '../data/emoticons/smile.png',
|
||||
':/': '../data/emoticons/frowning.png',
|
||||
'(})': '../data/emoticons/hugleft.png',
|
||||
':$': '../data/emoticons/blush.png',
|
||||
'(Y)': '../data/emoticons/yes.png',
|
||||
':-@': '../data/emoticons/angry.png',
|
||||
':-D': '../data/emoticons/biggrin.png',
|
||||
'(U)': '../data/emoticons/brheart.png',
|
||||
'(F)': '../data/emoticons/flower.png',
|
||||
':-[': '../data/emoticons/bat.png',
|
||||
':>': '../data/emoticons/biggrin.png',
|
||||
'(T)': '../data/emoticons/phone.png',
|
||||
':-S': '../data/emoticons/frowning.png',
|
||||
':-P': '../data/emoticons/tongue.png',
|
||||
'(H)': '../data/emoticons/coolglasses.png',
|
||||
'(D)': '../data/emoticons/drink.png',
|
||||
':-O': '../data/emoticons/oh.png',
|
||||
'(C)': '../data/emoticons/coffee.png',
|
||||
'({)': '../data/emoticons/hugright.png',
|
||||
'(*)': '../data/emoticons/star.png',
|
||||
'B-)': '../data/emoticons/coolglasses.png',
|
||||
'(Z)': '../data/emoticons/boy.png',
|
||||
'(E)': '../data/emoticons/mail.png',
|
||||
'(N)': '../data/emoticons/no.png',
|
||||
'(P)': '../data/emoticons/photo.png',
|
||||
'(K)': '../data/emoticons/kiss.png',
|
||||
':-*': '../data/emoticons/kiss.png',
|
||||
':*': '../data/emoticons/kiss.png',
|
||||
'(R)': '../data/emoticons/rainbow.png',
|
||||
':-|': '../data/emoticons/stare.png',
|
||||
';-)': '../data/emoticons/wink.png',
|
||||
';-(': '../data/emoticons/cry.png',
|
||||
'(6)': '../data/emoticons/devil.png',
|
||||
'>:)': '../data/emoticons/devil.png',
|
||||
'>:-)': '../data/emoticons/devil.png',
|
||||
'(L)': '../data/emoticons/heart.png',
|
||||
'<3': '../data/emoticons/heart.png',
|
||||
'(W)': '../data/emoticons/brflower.png',
|
||||
':|': '../data/emoticons/stare.png',
|
||||
':O': '../data/emoticons/oh.png',
|
||||
';)': '../data/emoticons/wink.png',
|
||||
';(': '../data/emoticons/cry.png',
|
||||
':S': '../data/emoticons/frowning.png',
|
||||
';\'-(': '../data/emoticons/cry.png',
|
||||
':-(': '../data/emoticons/unhappy.png',
|
||||
'8-)': '../data/emoticons/coolglasses.png',
|
||||
'(B)': '../data/emoticons/beer.png',
|
||||
':D': '../data/emoticons/biggrin.png',
|
||||
'(8)': '../data/emoticons/music.png',
|
||||
':@': '../data/emoticons/angry.png',
|
||||
'B)': '../data/emoticons/coolglasses.png',
|
||||
':-$': '../data/emoticons/blush.png',
|
||||
':\'(': '../data/emoticons/cry.png',
|
||||
':->': '../data/emoticons/biggrin.png',
|
||||
':[': '../data/emoticons/bat.png',
|
||||
'(I)': '../data/emoticons/lamp.png',
|
||||
':P': '../data/emoticons/tongue.png',
|
||||
'(%)': '../data/emoticons/cuffs.png',
|
||||
'(S)': '../data/emoticons/moon.png',
|
||||
}
|
||||
|
||||
statusmsg_default = {
|
||||
_('Sleeping'): 'ZZZZzzzzzZZZZZ',
|
||||
_('Back soon'): _('Back in some minutes.'),
|
||||
|
|
|
@ -112,12 +112,26 @@ class PreferencesWindow:
|
|||
self.xml.get_widget('show_status_msgs_in_roster_checkbutton').set_active(
|
||||
st)
|
||||
|
||||
# useemoticons
|
||||
st = gajim.config.get('useemoticons')
|
||||
if st:
|
||||
self.xml.get_widget('emoticons_combobox').set_active(1) # FIXME
|
||||
else:
|
||||
self.xml.get_widget('emoticons_combobox').set_active(3) # FIXME
|
||||
# emoticons
|
||||
emoticons_combobox = self.xml.get_widget('emoticons_combobox')
|
||||
emoticons_list = os.listdir(os.path.join(gajim.DATA_DIR, 'emoticons'))
|
||||
renderer_text = gtk.CellRendererText()
|
||||
emoticons_combobox.pack_start(renderer_text, True)
|
||||
emoticons_combobox.add_attribute(renderer_text, 'text', 0)
|
||||
model = gtk.ListStore(str)
|
||||
emoticons_combobox.set_model(model)
|
||||
l = ['Disabled']
|
||||
for dir in emoticons_list:
|
||||
if dir != '.svn':
|
||||
l.append(dir)
|
||||
print l
|
||||
for i in xrange(len(l)):
|
||||
print l[i]
|
||||
model.append([l[i]])
|
||||
if gajim.config.get('emoticons_theme') == l[i]:
|
||||
emoticons_combobox.set_active(i)
|
||||
if not gajim.config.get('emoticons_theme'):
|
||||
emoticons_combobox.set_active(0)
|
||||
|
||||
#iconset
|
||||
iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets'))
|
||||
|
@ -489,14 +503,12 @@ class PreferencesWindow:
|
|||
|
||||
def on_emoticons_combobox_changed(self, widget):
|
||||
active = widget.get_active()
|
||||
if active == -1: # no active item
|
||||
return
|
||||
elif active == 0: # animated
|
||||
gajim.config.set('useemoticons', True) # FIXME
|
||||
elif active == 1: # static
|
||||
gajim.config.set('useemoticons', True) # FIXME
|
||||
else: # disabled
|
||||
gajim.config.set('useemoticons', False)
|
||||
model = widget.get_model()
|
||||
emot_theme = model[active][0].decode('utf-8')
|
||||
if emot_theme == _('Disabled'):
|
||||
gajim.config.set('emoticons_theme', '')
|
||||
else:
|
||||
gajim.config.set('emoticons_theme', emot_theme)
|
||||
|
||||
gajim.interface.init_emoticons()
|
||||
gajim.interface.make_regexps()
|
||||
|
@ -2094,6 +2106,7 @@ class ManageEmoticonsWindow:
|
|||
|
||||
def on_manage_emoticons_window_destroy(self, widget):
|
||||
gajim.interface.init_emoticons() # update emoticons
|
||||
gajim.interface.make_regexps()
|
||||
# remove us from open windows
|
||||
del gajim.interface.instances['manage_emots']
|
||||
|
||||
|
@ -2128,9 +2141,14 @@ class ManageEmoticonsWindow:
|
|||
def fill_emot_treeview(self):
|
||||
model = self.emot_tree.get_model()
|
||||
model.clear()
|
||||
emots = gajim.config.get_per('emoticons')
|
||||
emot_theme = gajim.config.get('emoticons_theme')
|
||||
if not emot_theme:
|
||||
return
|
||||
path = os.path.join(gajim.DATA_DIR, 'emoticons', emot_theme)
|
||||
sys.path.append(path)
|
||||
from emoticons import emoticons as emots
|
||||
for emot in emots:
|
||||
file = gajim.config.get_per('emoticons', emot, 'path')
|
||||
file = os.path.join(path, emots[emot])
|
||||
iter = model.append((emot, file, None))
|
||||
if not os.path.exists(file):
|
||||
continue
|
||||
|
@ -2138,6 +2156,8 @@ class ManageEmoticonsWindow:
|
|||
img.show()
|
||||
img.set_from_file(file)
|
||||
model.set(iter, 2, img)
|
||||
sys.path.remove(path)
|
||||
del emots
|
||||
|
||||
def on_emot_cell_edited(self, cell, row, new_text):
|
||||
emots = gajim.config.get_per('emoticons')
|
||||
|
|
20
src/gajim.py
20
src/gajim.py
|
@ -1415,18 +1415,26 @@ class Interface:
|
|||
self.emoticons_images = list()
|
||||
self.emoticons = dict()
|
||||
|
||||
emots = gajim.config.get_per('emoticons')
|
||||
emot_theme = gajim.config.get('emoticons_theme')
|
||||
if not emot_theme:
|
||||
return
|
||||
path = os.path.join(gajim.DATA_DIR, 'emoticons', emot_theme)
|
||||
sys.path.append(path)
|
||||
from emoticons import emoticons as emots
|
||||
for emot in emots:
|
||||
emot_file = gajim.config.get_per('emoticons', emot, 'path')
|
||||
emot_file = os.path.join(path, emots[emot])
|
||||
if not self.image_is_ok(emot_file):
|
||||
continue
|
||||
# This avoids duplicated emoticons with the same image eg. :) and :-)
|
||||
if not emot_file in self.emoticons.values():
|
||||
pix = gtk.gdk.pixbuf_new_from_file(emot_file)
|
||||
if emot_file.endswith('.gif'):
|
||||
pix = gtk.gdk.PixbufAnimation(emot_file)
|
||||
else:
|
||||
pix = gtk.gdk.pixbuf_new_from_file(emot_file)
|
||||
self.emoticons_images.append((emot, pix))
|
||||
self.emoticons[emot.upper()] = emot_file
|
||||
sys.path.remove(path)
|
||||
del emots
|
||||
|
||||
def register_handlers(self):
|
||||
self.handlers = {
|
||||
|
@ -1562,12 +1570,6 @@ class Interface:
|
|||
# Do not set gajim.verbose to False if -v option was given
|
||||
if gajim.config.get('verbose'):
|
||||
gajim.verbose = True
|
||||
#add default emoticons if there is not in the config file
|
||||
if len(gajim.config.get_per('emoticons')) == 0:
|
||||
for emot in gajim.config.emoticons_default:
|
||||
gajim.config.add_per('emoticons', emot)
|
||||
gajim.config.set_per('emoticons', emot, 'path',
|
||||
gajim.config.emoticons_default[emot])
|
||||
#add default status messages if there is not in the config file
|
||||
if len(gajim.config.get_per('statusmsg')) == 0:
|
||||
for msg in gajim.config.statusmsg_default:
|
||||
|
|
|
@ -3798,9 +3798,6 @@ Per type</property>
|
|||
<child>
|
||||
<widget class="GtkComboBox" id="emoticons_combobox">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">Animated
|
||||
Static
|
||||
Disabled</property>
|
||||
<property name="add_tearoffs">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="changed" handler="on_emoticons_combobox_changed" last_modification_time="Sun, 05 Feb 2006 14:06:24 GMT"/>
|
||||
|
|
Loading…
Reference in New Issue