# "emocpixs" Tkabber plugin -- Chat input menu with smiles. 
# Written by Renji <rejjin@jabber.dk>

package require msgcat
namespace eval emocpixs {
	::msgcat::mcload [file join [file dirname [info script]] msgs]
	proc egen {} {
		variable sms {}
		foreach im [array names ::plugins::emoticons::images] {
			lassign [split $im _] => sm
			lappend sms $im $sm
		}
	}
	hook::add finload_hook [namespace current]::egen
	proc  menu_gen {m w x y} {
		variable sms
		$m add cascade -label [msgcat::mc "Emoticons"] \
			-menu [menu $m.ems  -tearoff 0]
		$m add separator
		foreach {im s} $sms {
			$m.ems add command -image $im \
			-command [list $w insert insert $s]
		}
	}
	hook::add textinput_popup_menu_hook [namespace current]::menu_gen 10
}