#####################################################
# Create the list menu for the "Alarm" button                               #
#####################################################


set alframe .ventana.editor.alarm_history
set aldescr $alframe.descr

proc display_alarm_history { } {

	global alframe
	global aldescr
	
	
	toplevel $alframe
	text $aldescr -width 35 -height 10
	
	scrollbar $alframe.scroll -command {$alframe.lb yview}
        listbox $alframe.lb -width 25 -height 10 -yscroll "$alframe.scroll set"

        #set astring [get_alarm_list]
 	set astring "the water|digital|analog|all of them"
 	set al_list [split $astring |]
 	
 	foreach item $al_list {
 	 	$alframe.lb insert end $item 	
 	
 	}


	
        bind $alframe.lb <ButtonRelease-1> {
        	
        	#destroy $aldescr
        	
        	# deleting the first line up to the 10th line (height of text widget)
        	$aldescr delete 1.0 10.0
        	set selected [selection get]
        	display_alarm_description $selected
	}

	# Creating a Close button
	button $alframe.close -text "Close" \
		-command {destroy $alframe; destroy $aldescr}
	
	#------------------#
	# Pack things up   #	
	#------------------#
	
	pack $alframe.close -side bottom
        pack $alframe.lb $alframe.scroll $aldescr -side left -fill y -expand 1



}

proc display_alarm_description {selected} {

	global aldescr
	if {$selected == "the water"} {
        		$aldescr insert end "water alarm is on, better watch out for that, blep blep blep"
 	}
 	if {$selected == "digital"} {
        		$aldescr insert end "something wrong with digital channelyr"
        	}


}
