optimize emoticons-related code and add better image for emoticons_button
This commit is contained in:
		
							parent
							
								
									c3ce9560f7
								
							
						
					
					
						commit
						377e5a416f
					
				
					 2 changed files with 24 additions and 23 deletions
				
			
		
							
								
								
									
										29
									
								
								src/chat.py
									
										
									
									
									
								
							
							
						
						
									
										29
									
								
								src/chat.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -23,6 +23,7 @@ import pango
 | 
			
		|||
import gobject
 | 
			
		||||
import time
 | 
			
		||||
import math
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
import dialogs
 | 
			
		||||
import history_window
 | 
			
		||||
| 
						 | 
				
			
			@ -98,14 +99,19 @@ class Chat:
 | 
			
		|||
		self.muc_attentions = []
 | 
			
		||||
 | 
			
		||||
	def toggle_emoticons(self):
 | 
			
		||||
		'''hide show emoticons_button and make sure emoticons_menu is always there
 | 
			
		||||
		when needed'''
 | 
			
		||||
		if gajim.config.get('useemoticons'):
 | 
			
		||||
			self.emoticons_menu = self.prepare_emoticons_menu()
 | 
			
		||||
		
 | 
			
		||||
		for jid in self.xmls:
 | 
			
		||||
			emoticons_button = self.xmls[jid].get_widget('emoticons_button')
 | 
			
		||||
			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)
 | 
			
		||||
				self.emoticons_menu = self.prepare_emoticons_menu()
 | 
			
		||||
				emoticons_button.show()
 | 
			
		||||
				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)
 | 
			
		||||
				emoticons_button.hide()
 | 
			
		||||
				emoticons_button.set_no_show_all(True)
 | 
			
		||||
 | 
			
		||||
	def update_font(self):
 | 
			
		||||
		font = pango.FontDescription(gajim.config.get('conversation_font'))
 | 
			
		||||
| 
						 | 
				
			
			@ -704,12 +710,17 @@ 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)
 | 
			
		||||
		
 | 
			
		||||
		emoticons_button = self.xmls[jid].get_widget('emoticons_button')
 | 
			
		||||
		# set image no matter if user wants at this time emoticons or not
 | 
			
		||||
		# (so toggle works ok)
 | 
			
		||||
		img = self.xmls[jid].get_widget('emoticons_button_image')
 | 
			
		||||
		img.set_from_file(os.path.join(gajim.DATA_DIR, 'emoticons', 'smile.png'))
 | 
			
		||||
		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)
 | 
			
		||||
			emoticons_button.show()
 | 
			
		||||
			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)
 | 
			
		||||
			emoticons_button.hide()
 | 
			
		||||
			emoticons_button.set_no_show_all(True)
 | 
			
		||||
 | 
			
		||||
		conv_textview.modify_font(font)
 | 
			
		||||
		conv_buffer = conv_textview.get_buffer()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9797,16 +9797,11 @@ topic</property>
 | 
			
		|||
		      <property name="can_focus">True</property>
 | 
			
		||||
		      <property name="relief">GTK_RELIEF_NORMAL</property>
 | 
			
		||||
		      <property name="focus_on_click">True</property>
 | 
			
		||||
		      <accessibility>
 | 
			
		||||
			<atkproperty name="AtkObject::accessible_name" translatable="yes">Emoticons</atkproperty>
 | 
			
		||||
		      </accessibility>
 | 
			
		||||
		      <signal name="clicked" handler="on_emoticons_button_clicked" last_modification_time="Wed, 14 Sep 2005 15:16:41 GMT"/>
 | 
			
		||||
		      <signal name="clicked" handler="on_emoticons_button_clicked" last_modification_time="Thu, 17 Nov 2005 18:06:37 GMT"/>
 | 
			
		||||
 | 
			
		||||
		      <child>
 | 
			
		||||
			<widget class="GtkImage" id="image1239">
 | 
			
		||||
			<widget class="GtkImage" id="emoticons_button_image">
 | 
			
		||||
			  <property name="visible">True</property>
 | 
			
		||||
			  <property name="stock">gtk-about</property>
 | 
			
		||||
			  <property name="icon_size">4</property>
 | 
			
		||||
			  <property name="xalign">0.5</property>
 | 
			
		||||
			  <property name="yalign">0.5</property>
 | 
			
		||||
			  <property name="xpad">0</property>
 | 
			
		||||
| 
						 | 
				
			
			@ -11356,16 +11351,11 @@ Status message</property>
 | 
			
		|||
		      <property name="can_focus">True</property>
 | 
			
		||||
		      <property name="relief">GTK_RELIEF_NORMAL</property>
 | 
			
		||||
		      <property name="focus_on_click">True</property>
 | 
			
		||||
		      <accessibility>
 | 
			
		||||
			<atkproperty name="AtkObject::accessible_name" translatable="yes">Emoticons</atkproperty>
 | 
			
		||||
		      </accessibility>
 | 
			
		||||
		      <signal name="clicked" handler="on_emoticons_button_clicked" last_modification_time="Wed, 14 Sep 2005 15:16:41 GMT"/>
 | 
			
		||||
		      <signal name="clicked" handler="on_emoticons_button_clicked" last_modification_time="Thu, 17 Nov 2005 18:04:40 GMT"/>
 | 
			
		||||
 | 
			
		||||
		      <child>
 | 
			
		||||
			<widget class="GtkImage" id="image1239">
 | 
			
		||||
			<widget class="GtkImage" id="emoticons_button_image">
 | 
			
		||||
			  <property name="visible">True</property>
 | 
			
		||||
			  <property name="stock">gtk-about</property>
 | 
			
		||||
			  <property name="icon_size">4</property>
 | 
			
		||||
			  <property name="xalign">0.5</property>
 | 
			
		||||
			  <property name="yalign">0.5</property>
 | 
			
		||||
			  <property name="xpad">0</property>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue