home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 December
/
PCWorld_2000-12_cd.bin
/
Komunikace
/
Comanche
/
plugins
/
manager
/
manager.tcl
< prev
Wrap
Text File
|
2000-11-02
|
5KB
|
153 lines
# manager.tcl --
# managerPlugIn --
# Collects and displays information about installed plugins such as name,
# version, description.
#
# It is also responsoble for creating the big categories
#
# TO-DO: When the plugin API is more advanced, provide functionality to
# load/unload plugins on demand.
class managerPlugIn {
inherit basePlugIn
variable managerXuiPP
variable managerEntry
variable managerNodeId
variable networkServicesNodeId
variable systemNodeId
variable modulesInfo
constructor {} {
array set modulesInfo {}
set managerXuiPP [xuiPropertyPage ::#auto]
$managerXuiPP configure -icon moduleManager
$managerXuiPP setLabel [mesg::get plugin_manager]
$managerXuiPP setName managerPP
set managerEntry [xuiString ::#auto]
$managerEntry setLabel "manager"
$managerEntry setName manager
$managerXuiPP addComponent $managerEntry
}
method init { args }
method _inquiryForRightPaneContent { node }
method _inquiryForPropertyPages { node }
method _receivedPropertyPages { node xuiPropertyPages}
}
# args contains the options that are passed to the plugIn at initialization
# time.
#
# -namespace contains the name of the name space server
body managerPlugIn::init {args} {
# We are hooking to the root node
# The ::plugInUtils::addNode syntaxis is the following
# ::plugInUtils::addNode caller namespace parentNode
# where
# caller: Name of the object that is adding the node (the plugIn object)
# namespace: Namespace where we are adding the node
# parentNode: Parent node
#
# The list of available icons is in view/images.tcl
array set options $args
set namespace $options(-namespace)
set parentNode [[ $namespace getRootNode] getId]
set managerNode [::plugInUtils::addNode $this $namespace $parentNode \
-classes {manager leaf} \
-openIcon moduleManager \
-closedIcon moduleManager \
-label [mesg::get plugin_management] ]
set networkServices [::plugInUtils::addNode $this $namespace $parentNode \
-classes {networkServices container} \
-openIcon network \
-closedIcon network \
-label [mesg::get network_services] ]
set networkServicesNodeId [$networkServices getId]
set system [::plugInUtils::addNode $this $namespace $parentNode \
-classes {system container} \
-openIcon smallWheel \
-closedIcon smallWheel \
-label [mesg::get System]]
set systemNodeId [$system getId]
set managerNodeId [$managerNode getId]
# Now we iterate over all modules, keeping track of the options, for
# further display.
# Get all module directories.
set moduleDir $options(-moduledirectory)
set directoryList [glob [file join $moduleDir .. *]]
# Somebody with a Mac can tell me if the above works?
# Load all modules.
foreach directory $directoryList {
set rootname [file tail [file rootname $directory ]]
switch $rootname {
manager - CVS - test {
# Do nothing, it is us! :)
# also in development, we do not want CVS
} default {
source [file join $directory init.tcl]
splash::add "Loading [file tail $directory]"
${rootname}_init -namespace $namespace \
-moduledirectory $directory
# (TO-DO) Move this into registerPlugInProperties
# (for plugIns written in other languages)
set modulesInfo($rootname) [${rootname}_info]
}
}
}
}
body managerPlugIn::_inquiryForRightPaneContent { node } {
switch $node [ list $managerNodeId {
set result [mesg::get manager_right_pane]
foreach {module info} [array get modulesInfo] {
catch {unset infoArray}
array set infoArray $info
append result "<br><img src=\"$infoArray(icon)\">"
append result "<b>$infoArray(name) - $infoArray(version)</b>"
append result "<hr>"
append result $infoArray(description)
append result "<br>"
}
} $systemNodeId {
set result [mesg::get system_right_pane]
} $networkServicesNodeId {
set result [mesg::get network_services__right_pane]
} default {
set result {}
} ]
return $result
}
body managerPlugIn::_inquiryForPropertyPages { node } {
return
if ![string compare $node $managerNodeId ] {
return $managerXuiPP
} else {
return
}
}
body managerPlugIn::_receivedPropertyPages { node xuiPropertyPages } {
# set pp [$xuiPropertyPages getComponentByName managerPP]
# set newmanager [[$pp getComponentByName manager] getValue]
# catch {exec manager $newmanager}
}