Friday, January 13, 2012

gnocl::dialog

Made some enhancements here today.  Added the Gtk "other" option  to the range of dialog types, i.e. no icon. But more significantly, implemented automatic setting of type to "other" if the -child option set.

Hiitherto, the gnocl::dialog was simply a means of giving yes/no feedback. Now, however, it's more useful for the setting of parameters and other forms of settings.

Here's a snippet from my current coding project which requires export to Abiword format. The following proc will build a dialog for the setting of vars. The code is not complete, but shows how the gnocl::dialog enhancements are working.

#---------------
# set file export properties
#---------------
# Args
#
# Return
#---------------
proc abi:properties {} {
    global metaData
    global pageSetup
   
    set nb [gnocl::notebook]

    # file metadata
    set box(1) [gnocl::box -orientation vertical]
    foreach name [lsort [array names metaData]] {
        $box(1) add [gnocl::labelEntry \
            -labelWidthChars 15 \
            -align left \
            -text [string totitle $name] ] \
            -fill {1 1} -expand 0
    }

    # page setup
    set box(2) [gnocl::box -orientation vertical]
    foreach name [lsort [array names pageSetup]] {
        $box(2) add [gnocl::labelEntry \
            -labelWidthChars 15 \
            -align left \
            -text [string totitle $name] ] \
            -fill {1 1} -expand 0
    }

    $nb addPage $box(1) "%__MetaData"
    $nb addPage $box(2) "%__Page Setup"

    set dlg [gnocl::dialog \
            -title "Abiword Export Properties" \
            -child $nb \
            -buttons "%#No  %#Yes" \
            -onResponse {
                puts %v
                } ]
}

No comments: