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 \
        hawthorn.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
#
#!/bin/sh
#\
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.

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

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

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

Thursday, November 26, 2015

Recent Changes

The past couple of months have seen some inprovements to the core code, including an number of notable fixes. The most signfiicant, to my mind, is the a reliable implementation of text widget pango markup.

2015-11:
    gnocl::dialog
        o fixed problems with closing and deleting the dialog.
    gnocl::text
        o fixed problems with inserting pango markup strings containing non ASCII characters.
        o new options
            -balanceQuotes, handles matching double and single quotes along with apostrophe-s
            -swap, swap keyboard string sequences for items in a matched list (e.g --> swapped for right arrow graphic U+2192)
        o enhanced 'get' command to respond to the setting of the -useMarkup option, command getMarkup deprecated.


2015-10:
    gnocl::text
        o getMarkup subcommand now retrieves stable pango markup strings.
        o new option: -show
        o added: -rolloverMode, one of: non, foreground, background or both.
        o use of -rollOverFgColor and rollOverBgColor reinstated
        o resolved need to set -onMotion handler in order to engage rollover effect rendering.
    gnocl::entry
        o problems with getSelection fixed.
        o new sub-command: selectRegion.
    New widget, gnocl::acceleratorGroup


One of the major tasks ahead for me now is updating the documentation, and issuing an incremental release. At ths point plans need to be made regarding the migration to Gtk3+. Whilst the transition will certainly offer new resources to the Gnocl coder, a major overall of the sourcecode is anticipated, perhaps alongside the retirement of some widgets due to core deprecation.

Saturday, September 12, 2015

Summary of Changes for the Past Couple of Months


Haven't posted much to the Blog for the past couple of months but there has been a steady stream of enhancements put into the sources. Here's a brief summary of the changes over the past few weeks. Download the latest nightly build from Sourceforge.

2015-09:
    gnocl::box, gnocl::hBox, gnocl::vBox
        o added commands: show, hide
    gnocl::notebook
        o added commands hidePage, showPage
        o added options -tabAlign, -tabWidthChars, -tabUseMarkup
2015-08:
    new command, gnocl::keyName
2015-07:
    gnocl::accelarator module completely re-written.

A further area of development that I've been working on recently is providing a realiable framework for creating gnocl driven widgets and megawidgets. By widgets, the idea is the use of the drawing area object to create unique items, using internal scripting in order to drive cairo. To keep the Tcl side of the scripting to a minimum, a small number of utiltiy commands currently being tested will find their way into the main package module. More about this in the next posting.

json_shell_utils.tcl