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
|
# set image no matter if user wants at this time emoticons or not
|
||||||
# (so toggle works ok)
|
# (so toggle works ok)
|
||||||
img = self.xml.get_widget('emoticons_button_image')
|
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()
|
self.toggle_emoticons()
|
||||||
|
|
||||||
# Attach speller
|
# Attach speller
|
||||||
|
|
|
@ -80,7 +80,7 @@ class Config:
|
||||||
'sort_by_show': [ opt_bool, True, '', True ],
|
'sort_by_show': [ opt_bool, True, '', True ],
|
||||||
'use_speller': [ opt_bool, False, ],
|
'use_speller': [ opt_bool, False, ],
|
||||||
'print_time': [ opt_str, 'always' ],
|
'print_time': [ opt_str, 'always' ],
|
||||||
'useemoticons': [ opt_bool, True ],
|
'emoticons_theme': [opt_str, 'static', '', True ],
|
||||||
'ascii_formatting': [ opt_bool, True,
|
'ascii_formatting': [ opt_bool, True,
|
||||||
_('Treat * / _ pairs as possible formatting characters.'), True],
|
_('Treat * / _ pairs as possible formatting characters.'), True],
|
||||||
'show_ascii_formatting_chars': [ opt_bool, False , _('If True, do not '
|
'show_ascii_formatting_chars': [ opt_bool, False , _('If True, do not '
|
||||||
|
@ -235,9 +235,6 @@ class Config:
|
||||||
'statusmsg': ({
|
'statusmsg': ({
|
||||||
'message': [ opt_str, '' ],
|
'message': [ opt_str, '' ],
|
||||||
}, {}),
|
}, {}),
|
||||||
'emoticons': ({
|
|
||||||
'path': [ opt_str, '' ],
|
|
||||||
}, {}),
|
|
||||||
'soundevents': ({
|
'soundevents': ({
|
||||||
'enabled': [ opt_bool, True ],
|
'enabled': [ opt_bool, True ],
|
||||||
'path': [ opt_str, '' ],
|
'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 = {
|
statusmsg_default = {
|
||||||
_('Sleeping'): 'ZZZZzzzzzZZZZZ',
|
_('Sleeping'): 'ZZZZzzzzzZZZZZ',
|
||||||
_('Back soon'): _('Back in some minutes.'),
|
_('Back soon'): _('Back in some minutes.'),
|
||||||
|
|
|
@ -112,12 +112,26 @@ class PreferencesWindow:
|
||||||
self.xml.get_widget('show_status_msgs_in_roster_checkbutton').set_active(
|
self.xml.get_widget('show_status_msgs_in_roster_checkbutton').set_active(
|
||||||
st)
|
st)
|
||||||
|
|
||||||
# useemoticons
|
# emoticons
|
||||||
st = gajim.config.get('useemoticons')
|
emoticons_combobox = self.xml.get_widget('emoticons_combobox')
|
||||||
if st:
|
emoticons_list = os.listdir(os.path.join(gajim.DATA_DIR, 'emoticons'))
|
||||||
self.xml.get_widget('emoticons_combobox').set_active(1) # FIXME
|
renderer_text = gtk.CellRendererText()
|
||||||
else:
|
emoticons_combobox.pack_start(renderer_text, True)
|
||||||
self.xml.get_widget('emoticons_combobox').set_active(3) # FIXME
|
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
|
#iconset
|
||||||
iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets'))
|
iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets'))
|
||||||
|
@ -489,14 +503,12 @@ class PreferencesWindow:
|
||||||
|
|
||||||
def on_emoticons_combobox_changed(self, widget):
|
def on_emoticons_combobox_changed(self, widget):
|
||||||
active = widget.get_active()
|
active = widget.get_active()
|
||||||
if active == -1: # no active item
|
model = widget.get_model()
|
||||||
return
|
emot_theme = model[active][0].decode('utf-8')
|
||||||
elif active == 0: # animated
|
if emot_theme == _('Disabled'):
|
||||||
gajim.config.set('useemoticons', True) # FIXME
|
gajim.config.set('emoticons_theme', '')
|
||||||
elif active == 1: # static
|
else:
|
||||||
gajim.config.set('useemoticons', True) # FIXME
|
gajim.config.set('emoticons_theme', emot_theme)
|
||||||
else: # disabled
|
|
||||||
gajim.config.set('useemoticons', False)
|
|
||||||
|
|
||||||
gajim.interface.init_emoticons()
|
gajim.interface.init_emoticons()
|
||||||
gajim.interface.make_regexps()
|
gajim.interface.make_regexps()
|
||||||
|
@ -2094,6 +2106,7 @@ class ManageEmoticonsWindow:
|
||||||
|
|
||||||
def on_manage_emoticons_window_destroy(self, widget):
|
def on_manage_emoticons_window_destroy(self, widget):
|
||||||
gajim.interface.init_emoticons() # update emoticons
|
gajim.interface.init_emoticons() # update emoticons
|
||||||
|
gajim.interface.make_regexps()
|
||||||
# remove us from open windows
|
# remove us from open windows
|
||||||
del gajim.interface.instances['manage_emots']
|
del gajim.interface.instances['manage_emots']
|
||||||
|
|
||||||
|
@ -2128,9 +2141,14 @@ class ManageEmoticonsWindow:
|
||||||
def fill_emot_treeview(self):
|
def fill_emot_treeview(self):
|
||||||
model = self.emot_tree.get_model()
|
model = self.emot_tree.get_model()
|
||||||
model.clear()
|
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:
|
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))
|
iter = model.append((emot, file, None))
|
||||||
if not os.path.exists(file):
|
if not os.path.exists(file):
|
||||||
continue
|
continue
|
||||||
|
@ -2138,6 +2156,8 @@ class ManageEmoticonsWindow:
|
||||||
img.show()
|
img.show()
|
||||||
img.set_from_file(file)
|
img.set_from_file(file)
|
||||||
model.set(iter, 2, img)
|
model.set(iter, 2, img)
|
||||||
|
sys.path.remove(path)
|
||||||
|
del emots
|
||||||
|
|
||||||
def on_emot_cell_edited(self, cell, row, new_text):
|
def on_emot_cell_edited(self, cell, row, new_text):
|
||||||
emots = gajim.config.get_per('emoticons')
|
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_images = list()
|
||||||
self.emoticons = dict()
|
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:
|
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):
|
if not self.image_is_ok(emot_file):
|
||||||
continue
|
continue
|
||||||
# This avoids duplicated emoticons with the same image eg. :) and :-)
|
# This avoids duplicated emoticons with the same image eg. :) and :-)
|
||||||
if not emot_file in self.emoticons.values():
|
if not emot_file in self.emoticons.values():
|
||||||
pix = gtk.gdk.pixbuf_new_from_file(emot_file)
|
|
||||||
if emot_file.endswith('.gif'):
|
if emot_file.endswith('.gif'):
|
||||||
pix = gtk.gdk.PixbufAnimation(emot_file)
|
pix = gtk.gdk.PixbufAnimation(emot_file)
|
||||||
|
else:
|
||||||
|
pix = gtk.gdk.pixbuf_new_from_file(emot_file)
|
||||||
self.emoticons_images.append((emot, pix))
|
self.emoticons_images.append((emot, pix))
|
||||||
self.emoticons[emot.upper()] = emot_file
|
self.emoticons[emot.upper()] = emot_file
|
||||||
|
sys.path.remove(path)
|
||||||
|
del emots
|
||||||
|
|
||||||
def register_handlers(self):
|
def register_handlers(self):
|
||||||
self.handlers = {
|
self.handlers = {
|
||||||
|
@ -1562,12 +1570,6 @@ class Interface:
|
||||||
# Do not set gajim.verbose to False if -v option was given
|
# Do not set gajim.verbose to False if -v option was given
|
||||||
if gajim.config.get('verbose'):
|
if gajim.config.get('verbose'):
|
||||||
gajim.verbose = True
|
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
|
#add default status messages if there is not in the config file
|
||||||
if len(gajim.config.get_per('statusmsg')) == 0:
|
if len(gajim.config.get_per('statusmsg')) == 0:
|
||||||
for msg in gajim.config.statusmsg_default:
|
for msg in gajim.config.statusmsg_default:
|
||||||
|
|
|
@ -3798,9 +3798,6 @@ Per type</property>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkComboBox" id="emoticons_combobox">
|
<widget class="GtkComboBox" id="emoticons_combobox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="items" translatable="yes">Animated
|
|
||||||
Static
|
|
||||||
Disabled</property>
|
|
||||||
<property name="add_tearoffs">False</property>
|
<property name="add_tearoffs">False</property>
|
||||||
<property name="focus_on_click">True</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"/>
|
<signal name="changed" handler="on_emoticons_combobox_changed" last_modification_time="Sun, 05 Feb 2006 14:06:24 GMT"/>
|
||||||
|
|
Loading…
Reference in New Issue