#!/usr/bin/ruby

require 'gtk2'
require 'socket'
require 'timeout'

$:.unshift "/mmt/scripts"
require 'MMTsocket.rb'

class	Clabel < Gtk::EventBox

	GREEN = Gdk::Color.new(0, 65535, 0)
	YELLOW = Gdk::Color.new(65535, 65535, 0)
	RED = Gdk::Color.new(65535, 0, 0)
	SKYBLUE =  Gdk::Color.new(34695, 52942, 60395)
	SKYBLUE1 =  Gdk::Color.new(34695, 52942, 65535)
	WHITE =  Gdk::Color.new(65535, 65535, 65535)

	def set_text ( text )
	    return if @text == text
	    @lab.set_text( "  " + text + "  " )
	    @text = text
	end

	def set_color ( color )
	    return if @color == color
	    @color = color
	    modify_bg( Gtk::STATE_NORMAL, color )
	end

	def initialize ( text, tag )
	    super()
	    set_color( WHITE )
	    @lab = Gtk::Label.new( text )
	    @text = text
	    add( @lab )
	    @tag = tag
	end

	def update ( vals )
	    newv = vals[@tag]
	    if newv
		@lab.set_text newv
	    else
		@lab.set_text "NA"
	    end
	end
end
