diff --git a/src/chat.py b/src/chat.py
index 121e81791..b7771af49 100644
--- a/src/chat.py
+++ b/src/chat.py
@@ -22,6 +22,7 @@ import gtk.glade
import pango
import gobject
import time
+import math
import dialogs
import history_window
@@ -89,10 +90,22 @@ class Chat:
self.notebook.set_show_tabs(gajim.config.get('tabs_always_visible'))
self.notebook.set_show_border(gajim.config.get('tabs_border'))
+ if gajim.config.get('useemoticons'):
+ self.emoticons_menu = self.emoticons_menu()
+
# muc attention states (when we are mentioned in a muc)
# if the room jid is in the list, the room has mentioned us
self.muc_attentions = []
+ def update_emoticons_button(self):
+ for jid in self.xmls:
+ if gajim.config.get('useemoticons'):
+ self.xmls[jid].get_widget('emoticons_button').show()
+ self.xmls[jid].get_widget('emoticons_button').set_no_show_all(False)
+ else:
+ self.xmls[jid].get_widget('emoticons_button').hide()
+ self.xmls[jid].get_widget('emoticons_button').set_no_show_all(True)
+
def update_font(self):
font = pango.FontDescription(gajim.config.get('conversation_font'))
for jid in self.xmls:
@@ -353,6 +366,10 @@ class Chat:
menu.popup(None, None, self.position_actions_menu, 1, 0)
menu.show_all()
+ def on_emoticons_button_clicked(self, widget):
+ '''popup emoticons menu'''
+ self.emoticons_menu.popup(None, None, None, 1, 0)
+
def position_actions_menu(self, menu):
# here I get the coordinates of the button relative to
# window (self.window)
@@ -425,6 +442,35 @@ class Chat:
return menu
+ def emoticons_menu(self):
+ menu = gtk.Menu()
+
+ def append_emoticon(w, d):
+ jid = self.get_active_jid()
+ message_textview = self.message_textviews[jid]
+ message_textview.get_buffer().insert_at_cursor(" %s " % d)
+ message_textview.grab_focus()
+
+ counter = 0
+ # Calculate the side lenght of the popup to make it a square
+ size = int(round(math.sqrt(len(gajim.interface.emoticons_images))))
+ for image in gajim.interface.emoticons_images:
+ item = gtk.MenuItem()
+ img = gtk.Image()
+ if type(image[1]) == gtk.gdk.PixbufAnimation:
+ img.set_from_animation(image[1])
+ else:
+ img.set_from_pixbuf(image[1])
+ item.add(img)
+ item.connect('activate', append_emoticon, image[0])
+ #FIXME: add tooltip with ascii
+ menu.attach(item,
+ counter % size, counter % size + 1,
+ counter / size, counter / size + 1)
+ counter += 1
+ menu.show_all()
+ return menu
+
def popup_menu(self, event):
menu = self.prepare_context_menu()
# common menuitems (tab switches)
@@ -645,6 +691,13 @@ class Chat:
dialogs.ErrorDialog(unicode(msg), _('If that is not your language for which you want to highlight misspelled words, then please set your $LANG as appropriate. Eg. for French do export LANG=fr_FR or export LANG=fr_FR.UTF-8 in ~/.bash_profile or to make it global in /etc/profile.\n\nHighlighting misspelled words feature will not be used')).get_response()
gajim.config.set('use_speller', False)
+ if gajim.config.get('useemoticons'):
+ self.xmls[jid].get_widget('emoticons_button').show()
+ self.xmls[jid].get_widget('emoticons_button').set_no_show_all(False)
+ else:
+ self.xmls[jid].get_widget('emoticons_button').hide()
+ self.xmls[jid].get_widget('emoticons_button').set_no_show_all(True)
+
conv_textview.modify_font(font)
conv_buffer = conv_textview.get_buffer()
end_iter = conv_buffer.get_end_iter()
@@ -744,6 +797,16 @@ class Chat:
elif event.keyval == gtk.keysyms.c and \
(event.state & gtk.gdk.MOD1_MASK): # alt + C toggles compact view
self.set_compact_view(not self.compact_view_current_state)
+ elif event.keyval == gtk.keysyms.e and \
+ (event.state & gtk.gdk.MOD1_MASK): # alt + E opens emoticons menu
+ if gajim.config.get('useemoticons'):
+ parent = self.message_textviews[jid]
+ def set_emoticons_menu_position(w, parent=parent):
+ window = parent.get_window(gtk.TEXT_WINDOW_WIDGET)
+ origin = window.get_origin()
+ size = window.get_size()
+ return (origin[0], origin[1] + size[1], 0)
+ self.emoticons_menu.popup(None, None, set_emoticons_menu_position, 1, 0)
elif event.keyval == gtk.keysyms.Page_Down:
if event.state & gtk.gdk.SHIFT_MASK: # SHIFT + PAGE DOWN
conv_textview = self.conversation_textviews[jid]
diff --git a/src/config.py b/src/config.py
index 2e13dc1f5..d88851e8c 100644
--- a/src/config.py
+++ b/src/config.py
@@ -501,7 +501,19 @@ class PreferencesWindow:
def on_use_emoticons_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'useemoticons',
[self.xml.get_widget('add_remove_emoticons_button')])
-
+ self.update_emoticons_button()
+
+ def update_emoticons_button(self):
+ '''Update emoticons button in Opened Chat Windows'''
+ for a in gajim.connections:
+ for kind in ('chats', 'gc'):
+ windows = gajim.interface.instances[a][kind]
+ if windows.has_key('tabbed'):
+ windows['tabbed'].update_emoticons_button()
+ else:
+ for jid in windows.keys():
+ windows[jid].update_emoticons_button()
+
def on_add_remove_emoticons_button_clicked(self, widget):
if gajim.interface.instances.has_key('manage_emots'):
gajim.interface.instances['manage_emots'].window.present()
@@ -1947,7 +1959,7 @@ class ManageEmoticonsWindow:
self.xml.signal_autoconnect(self)
def on_manage_emoticons_window_destroy(self, widget):
- gajim.interface.init_regexp() # update regexp [emoticons included]
+ gajim.interface.init_emoticons() # update emoticons
# remove us from open windows
del gajim.interface.instances['manage_emots']
diff --git a/src/gajim.py b/src/gajim.py
index 17c1a2755..b8ae31c8e 100755
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -1064,16 +1064,17 @@ class Interface:
basic_pattern = links + mail + formatting
self.basic_pattern_re = sre.compile(basic_pattern, sre.IGNORECASE)
- # When an emoticon is bordered by an alpha-numeric character it is NOT
- # expanded. e.g., foo:) NO, foo :) YES, (brb) NO, (:)) YES, etc.
- emoticons_pattern = '(?
False
6
+
+
+
+ True
+ Click to insert an emoticon
+ True
+ GTK_RELIEF_NORMAL
+ True
+
+ Emoticons
+
+
+
+
+
+ True
+ gtk-about
+ 4
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+
+
+ 0
+ False
+ False
+
+
+
True
@@ -11318,6 +11350,37 @@ Status message
False
6
+
+
+ True
+ Click to insert an emoticon
+ True
+ GTK_RELIEF_NORMAL
+ True
+
+ Emoticons
+
+
+
+
+
+ True
+ gtk-about
+ 4
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+
+
+ 0
+ False
+ False
+
+
+
True