#
# $RCSfile: menustate.itcl,v $ --
#
#      This file contains ...
#
# Copyright (c) 2004  Anton Kokalj   Email: tone.kokalj@ijs.si
#
#
# This file is distributed under the terms of the GNU General Public
# License. See the file `COPYING' in the root directory of the present
# distribution, or http://www.gnu.org/copyleft/gpl.txt .
#
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# ANTON KOKALJ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
#
# $Id: menustate.itcl,v 1.4 2009-07-16 16:58:45 kokalj Exp $ 
#

proc ::pwscf::menustate::editable {obj moduleIdent} {
    ::tclu::DEBUG editable: moduleIdent = $moduleIdent

    if { $moduleIdent == "" } {
	return disabled
    } else {
	return normal
    }
}


proc ::pwscf::menustate::xcrysden {obj moduleIdent} {
    global env

    ::tclu::DEBUG xcrysden: moduleIdent = $moduleIdent
    if { [auto_execok xcrysden] != "" && ! [info exists env(XCRYSDEN_TOPDIR)] } {
    }
    
    if { ( ! [info exists env(XCRYSDEN_TOPDIR)] && [auto_execok xcrysden] == "" ) || ! [string match *pw $moduleIdent] } {
	return disabled
    } else {
	return normal
    }
}


proc ::pwscf::menustate::runnable {obj moduleIdent} {

    ::tclu::DEBUG runnable: moduleIdent = $moduleIdent

    if { [regexp {(pw|ph|pp|pr|d3|atomic)} $moduleIdent] } {
	return normal
    } else {
	return disabled
    }
}


proc ::pwscf::menustate::runnableXC {obj moduleIdent} {
    global env

    ::tclu::DEBUG runnable: moduleIdent = $moduleIdent

    if { [regexp {(pw|pp)} $moduleIdent] && [info exists env(XCRYSDEN_TOPDIR)] } {
	return normal
    } else {
	return disabled
    }
}

