Monday, March 15, 2010

NEW COMMAND: gnocl::inventory

Yesterday I put together some code to list the registered widgets and this morning I implemented the equivalent to display pixbufs. After assembling all the code together, it all looked a little clumsy, with two commands performing the same fundamental operations. So, I re-thought what was going on and created a new command, ‘inventory’ which then enables the script to specify registered types which, in this case, are ‘widget’ and ‘pixbuf’. This works fine. The general structure means that a framework exists for deeper gnocl introspection.

Whilst putting a test script together I noticed that another simple function was missing, the ability to get details regarding any existing pixBuf. So, I added a pixBuf ‘info’ sub-command. This is what one gets when development is ‘evolutionary’ rather than ‘ planned’.

Here's an illustrative script sample:

for {set i 1} {$i <12} {incr i} {
    gnocl::window -title "win $i"
    gnocl::pixBuf new {100 100 8}
}
foreach item [gnocl::inventry widget] {
    puts "$item is a [$item class]"
}
foreach item [gnocl::inventry pixBuf] {
    puts "$item [$item info]"
}

No comments: