Sunday, December 18, 2016

November Source Enhancements

The following enhancements were made to the gnocl core during November, expanding the ability to configure and extract settings from a number of key widgets.

        o added -textColor and -gridLines, available options: none, horizontal, vertical, or both.
        o added column options: -spacing, -sortIndicator, -expand, -fixedWidth, -sortId, -sortOrder
        o added cel options: -xAlign, -yAlign, -sensitive
    gnocl::tree / gnocl::list
        o added getRow subcommand, implemented cget -titles functionality.
        o new options -horizontalSeparator and -verticalSeparator
        o -title option now works correctly.
        o added -textColor, -textColour
        o new command: activate. Convenience function to emit 'activate' event.
        o added -insensitiveBaseColor / -insensitiveBaseColor, override style default.
        o added -heightGroup
        o added -baseFont, -heightGroup options

    -onButton* events
        o new substitution item %o, the bottom-left corner of the widget on screen, accurate placement of popups etc.

Tuesday, November 15, 2016

October Source Enhancements

During October the following areas of functionality were added to the development sources.  

    New commands: gnocl::buttonBox, gnocl::vButtonBox and gnocl::hButtonBox.
    gnocl::fontButton, gnocl::table
        o added -widthRequest, -heightRequest
        o calling cget -children now works if box -label options set (ie, box in a frame)
        o added -onDestroy, enable clearup on TCL side following widget destruction
        o added parent command

Saturday, October 01, 2016

Recent changes to the development sources

The last time the recent changes were posted was sometime during March this year.  So, to put matters right, here's a list of the recent changes. Mostly enhancements plus one or two bug fixes.

    gnocl::tree & gnocl::list
        o added -textColor and -textColour
        o new command, wordCount, return size of buffer in words.
        o new command, magnify. Increase/decrease basefont height by specified amount in pixels (e.g. 1 or -1), or "reset", to set to default.
    gnocl::box, gnocl::vBox, gnocl::hBox
        o new command, getPos. Returns postilion of child widget packed into box, or -1 if not found.
        o improved error checking to the -innerBorder option, a list of 4 integers must be supplied.
        o low priority command 'remove' renamed to 'subtract', this allows the 'remove' keyword to be used for removal of widgets embedded in a statusbar with the add command.
    gnocl::dialog, gnocl::fileChooserDialog
        o added -transient option
        o fixed (?) intermittent segmentation crash occurring during widget destruction.

        o modified -tabs options, set to spaces rather than pixels, based upon current -basefont. Apply after widget realized.
        o added -onPush, -onPop; unpack, messageArea
        o added -ellipsize, -baseFont, -ySpacing, -xSpacing,
        o added -steps to offer automation of the bar growth,
          prefined number of stages and advance progress with command "step".
        o added command "reset", same as using -fraction 0.0

        o new option -justification.
    gnocl::tree / gnocl::list
        o added %d substitution string to -onSelectionChanged callback.
        o module function insertRow renamed to appendRow
        o cget -titles now works
        o added options -labelWidget, -useMarkup, -labelFill

        o repaired some broken compilation dependencies.

        o added subcommand escape and options -all, -basic, -extended and -offtags.
    Added %d substitution string to the -onExpose option.
    New widget, gnocl::frame. Labelled container for a single object.
    Added "centre" to the list of alignment options.
        o the -text option will now accept markup strings.
        o new command getEntry, convert existing combo entry widget to a gnocl::entry object. Returns entry widget-id.
        o added option, -entryWidget. Replaces current combo widget with a new entry item.        
        o added subcommands: commands, options and commands   
        o fixed problem with setting the -useMarkup and -align options
        o option -linear default set at 1
        o added -licences and -wrapLicence synonyms.
        o bug fix, -backgroundImage now works without causing a fatal crash. 
        o added -textColor (textColour), set text default colour.
        o new subcommands, addChild and moveChild. Place widget in text at specified position, opts: -mark, -position and -coords.
          When creating widgets such as gnocl::list, use -widthRequest option to set child width.


The earlier version of the GnoclSpellCheck module as developed on my ancient 32-bit workstation running OpenSuse 11.2 (yes, I said that it was ancient). The problem arising from using legacy equipment is that when packages like Gnocl are developed, not only can various elements cease to work (i.e GtkSpell 2 does not run at all on a Gnome 3 desktop or under Ubuntu Mate) but later libraries such as GtkSpell 3 are complete re-writes and can, as I've found, have their own bugs! A new Gnome speller, gspell is under development but this requires the bleeding edge Gtk3 libraries which, apart from being incompatible with the Gtk+2 libraries against which Gnocl is built, these latest versions are not currently part of the stable releases. So, I thought, build my own. So, I did. Rather than using the C-api for either Ispell, Aspell or Hunspell, I've just used a simple data pipe. These three packages give varying suggestions for misspelt words so, the eventual front end will enable the user to pick which engine they want to use.

Here's a screen shot of the development program.  All the key elements are present: check as you type, errors are marked up, popup menus contain alternatives.  Just a little tweaking needed (if possible) to offset the error underline as the window manager doesn't seem to adequately refresh to layout to remove artefacts.

Currently working on a GUI for the full checker based upon the LibreOffice model.

Sunday, September 18, 2016

Hidden Bugs... The Real Nighmare!!!!

Have you every had to fix a leaking flat roof?

A strange question to ask on programming blog. But there's mileage in this simile. You see, when a flat root shows signs of leaking, its on the inside of the building, where the water comes out, not where it goes in. In other words, you can see the effect, but not the cause. Moreover, the effects of a leaky roof are cumulative, not immediate.

I've just fixed an intermittent crash in the gnocl core module when complex dialog layouts holding multiple buttons are closed. There was nothing wrong with the C code or Tcl scripts, each were grammatically correct, but still the crashes occur with the typical segmentation error being reported.

This is indicative of the free() function attempting to release unused memory but the code uses g_free() which has some built in protection, i.e. it returns if the memory pointer is NULL.

The problem was resolved by commented out one of the g_free lines in the button.c module buttonDestroyFunc. It would suggest that something bizarre was happening in the compile process, perhaps some side-effect of optimization which had gone wrong.

Anyway, big relief this bug has been squashed, zapped, splattered! -GONE!!!

Thursday, August 11, 2016

Simplifying the use of the Progress Bar.

The basic implementation of the progressBar widget allows the setting of the "fraction" property of the GtkProgressBar but using this options requires more on the Tcl-side than it needs to.

Combination of the new options -range and -steps along with the new sub-commands step, incr and reset help to simplify matters.

For simple lists use the step subcommand along with the the -steps option to indicate the progress of a small, known number of steps where feedback on the completion of each step is required. Setting the -steps option to 10, for example, will set the widget "fraction" property to 0.1 (1/10, i.e. 10%). Following this each time the step sub-command is called, the widget bar will expand in length by 10% until it reaches 100%. The step sub-command accepts an additional argument which will set the text content of the bar.

    set modules [list \
        apple.tcl \
        blackberry.tcl \
        cherry.tcl \
        damson.tcl \
        elderberry.tcl \
        fig.tcl \
        gooseberry.tcl \
    proc do_progress { box modules } {
    set steps [llength $modules]

    set pb [gnocl::progressBar]
    $pb configure -steps $steps -showText 1
    $box add $pb
    $pb reset
    for {set i 0} {$i <= $steps} {incr i} {
        after 300
        $pb step [lindex $modules $i]
    if ( [$box class] == statusBar ) {
        $box unpack $pb
    } else {
        $box remove $pb

In the above example, the reset subcommand was used to set the display fraction to 0.0 and text to and empty string.

More complicated operations, such as sifting through a large number of database records, may only need indication of relative progress. In other words, specific feedback on each increment in the batch process is not required. In this case the incr sub-command should be used. As with step above, an optional string can be specified, but if this field is left empty and the widget -showText option set to 1, the percentage completion of the bar will be displayed.

set range [ expr 1000 + round (rand() * 10000) ]
set steps 20
$pb3 configure -steps $steps -range $range -showText 1

for {set i 0 } {$i < $range} {incr i} {
    # do something or delay
    after 1
    $pb3 incr

Saturday, May 28, 2016

gnocl::toolPalette -now implemented

I'm pleased to announce that, after much frustration, the gnocl binding to the GtkToolPalette is now complete. To try it out, download and compile the latest nightly build from Sourceforge.

And here's the test script:

# test-toolPalette.tcl
# Created by Dr. William J Giddings, 2016
exec tclsh "$0" "$@"
package require Gnocl

set tp [gnocl::toolPalette -tooltip TOOL-PALETTE -orientation vertical]

puts >[$tp commands]
puts >[$tp options]

set ig(1) [$tp addGroup -label MyGroup1]

puts >>[$ig(1) commands]
puts >>[$ig(1) options]

$ig(1) addItem -icon %#New -text XXX -tooltip YYY -data £££ -onClicked {puts "Hello from %w %d"}
$ig(1) addItem -icon %#Cut -text ABC -tooltip ZZZ -onClicked {puts "Hello from %w"}
$ig(1) addItem -icon %#Copy -tooltip WWW -onClicked {puts "Hello from %w"}

set pi [$ig(1) addItem -icon %#Paste -tooltip AAA -onClicked {puts pi} ]
puts ....$pi....
puts "class = [$pi class]"
puts >>>[$pi commands]
puts >>>[$pi options]

$pi configure -onClicked { puts "BOING! BOINGG!" } -icon %#Stop

if 1 {
set ig(2) [$tp addGroup -label MyGroup2 -collapsed 1 -sensitive 0]

$ig(2) addItem -icon %#New -text XXX -tooltip YYY -onClicked {puts "Hello from %w"}
$ig(2) addItem -icon %#Cut -text ABC
$ig(2) addItem -icon %#Copy
$ig(2) addItem -icon %#Paste

parray ig

gnocl::window -child $tp -width 200 -height 400

Tuesday, May 17, 2016

Gnocl for Raspberry PI

After a couple of hours work this evening (largely fixing errors in the distribution makefile) I successfully compiled Gnocl to run on my newly acquired Raspberry PI3. It was much, much easier than expected. No changes to the source code whatsoever.

I now need to create a download page from Sourceforge. Currently running Ubuntu Mate on my Pi. Very nice, very pleased. Much faster than my sturdy old 32-bit workhorse.

Here's a snippet from a screenshot.

Sunday, March 27, 2016

A Few Recent Enhancements...

Time has flown very quickly over the past few months, with much of my coding time dedicated to working on other projects. These have identified a the need for a few modifications to the Gnocl code which make GUI composition easier such as explicit order placement of child widgets in boxes and the harmonization of value extraction for text entry widgets.
Here is a summary of changes since the previous blog posting.

    gnocl::box, gnocl::hBox, gnocl::vBox
        o added -position option to the "add" subcommand.

        o added commands: 'selectionBounds', 'insert', and 'erase' (remove specified range of characters from entry buffer).
        o fixed problems arising from using the "delete" command.
        o added -nomarkup switch to the "get" command to override return of formatting markup.

        o problem with very slow internal update of the GTK 'text' property worked around, value set explicitly in widget configure function.
        o added 'select' as synonym for 'selectRegion', harmonizes with text commands.
        o added 'start' and 'end' keywords to the 'select'/'selectRegion' commands.