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.

Saturday, July 25, 2015

Reworked the gnocl::dialog soucecode

With a few notable changes, the dialog.c module was legacy code which tried to do too much. In attempting to add stock icons and embedded buttons so many irreversible bugs had crept into the code which made it almost impossible to prevent an application crashing. A quick glance at the gtk style guide makes no mention to of the use of Stock icons in dialog buttons so,  the best way forward was to retire the inclusion of icons and predefined buttons in favour of something much simpler and far less prone to crashing. The following extract from the development documentation highlights the changes made.

-buttons
type: list (default: Ok)
List of buttons to be displayed consisting of a list of display strings with optional values.
Method 1) Simple Strings.

In this case the text string will be used as the basis of the returned value stripped of any percent string underscore markup.
-buttons "%__Yes %__No"
Clicking the "Yes" button will return "Yes" from the [gnocl::dialog] command or by substitution of the %v parameter in the -onResponse callback script..
Method 2) String and Value.

For more complex display strings the use of an associate value makes response parsing simpler.

Use underscore ("'_") to indicate accelerators, e.g.

-buttons [list [list  {%_P_ortable Document Format} pdf] [list  {%_O_pen Document Text ODT} odt]
As with method 1), clicking the "Portable Document Format " button will return "pdf" from the [gnocl::dialog] command or by substitution of the %v parameter in the -onResponse callback script..

Method 3) Default.

If the -buttons option is not specified then a single "Ok" button will be added to the dialog. This would be equivalent to using:

-buttons "%__Ok"
Note: The use of the %_ prefix is optional and retained for legacy.


To add previously created button widgets, use the -actionButtons option.




Thursday, June 04, 2015

Summary of Recent Progress

The current nightly build sees a range of enacements to Gnocl as a whole. A number of issues have been addressed as itemized in the extract from the NEWS document below. This nightly update sees the -name option taking on a greater role in the control of widgets. Ordinarily used for specifying ojects in a Gtk CSS file, or in a builder/glade XML file, using the name option will cause the interpretor to create a command for the widget using the string specified by the -name option. Ordinarily a widget instance would be created as follows:

set myButton [gnocl::button -text "Hello World"]

And modified with:

$myButton configure -onClicked { puts %w }

But now,  the following will produce similar results.

gnocl::button -text "Hell World" -name myButton

Modification can also be handled too,

myButton configure -onClicked {puts %w}

This approach provides a neat and efficient way of creating widgets as objects within namespaces. Using the same example the following could be used:

gnocl::button -text "Hell World" -name myprocs::myButton

The creation of widget with command names in this way does not eliminate the process of registering widgets with a unique id. Using the same example, to access this simply use:

[myprocs::myButton]

and the widget id will be returned.

Substitution strings also unclude the %g and %w parameters to extract the (glade) name and w(idget-id) of the object.

New Extract

2015-05:
    gnocl::notebook
        o added extra percentage subtitution strings to -onPageAdded, -onPageRemoved
                %l page label
    gnocl::comboBox/comboEntry added new sub-commands: get, set, prepend, append, insert and remove.
    gnocl::box/hBox/vBox fixed problem with cget -children
    gnocl::window, gnocl::expander, gnocl::fontSelection, gnocl::gammaCurve,
    gnocl::curve, gnocl::handleBox, gnocl::level, gnocl::popupEntry, gnocl::recentChooser
        o added -name
  

Thursday, May 07, 2015

Recent Modifications

Over the past few weeks a number of enhancements have be made to the gnocl package. Here's a brief overview of the changes:

2015-05:
    gnocl::menu, gnocl::menuRecentChooser, gnocl::statusBar
        o added -name, -data; implemented cget
        o added -name, -data; implemented cget
    gnocl::window
        o added -name
    added gnocl::application, a convience application megawidget
2015-04:
    added parent command to gnocl::volumeButton, gnocl::scale and gnocl::spinner
    gnocl::spinner
        o resolved problems with start and stop commands (same as using the -active options).
    gnocl::text
        o using the get widget command alone will return all text contents, i.e. same as "$wid get start end"
    gnocl::entry
        o wordList sub-commands "add", "clear", "delete" and "get" are now implemented.
        o enhanced the wordList subcommand with new option -split
            specifying this option will result in a string being treated as a space separated list
            of single words: e.g. "a red dog" becomes {{a} {red} {dog}}
        o enhanced the progress functionality, new options -range and -progressStep
            the command progress will increment the display by the fractions given by progressStep.
            Changing either -range or -progressStep will reset the progress display to 0.
            The use of the -progressFraction remains unaltered and is useful for resetting the progress to 0.
    gnocl::text
        o insert markup now works acceptably well, at present '            markup can only accept single, predefined options. Future
            versions may offer more, but this is probably adequate for
            most purposes requiring text pango markup.
        o renamed -markupTags to -useMarkup
    gnocl::toolBar
        checkItem/toggleButton
        o configure -data option and others now works
        o cget -iconSize now works properly
    gnocl::label
        bugfix:
            -textVariable setting now responds to the widget -useMarkup option


For me, the most exciting prospect is the ability to use pango-like markup strings in conjunction with the the text widget. Additionally, the gnocl::application convenience function offers an extremely quick way of initializing a working application complete with menus, toolbars, main container and status bar. The following tests script shows how this new script can be used:

#---------------
# test-gnocl-appl.tcl
#---------------
#!/bin/sh
#\
exec tclsh "$0" "$@"

package require Gnocl

#~~~~~~~~~~~~~~~~~~~~~~~~~
# create the basic application
#~~~~~~~~~~~~~~~~~~~~~~~~~
array set app [gnocl::application -application "MyAPP" -version 1.0 -date 07/05/15 -filetypes *.tcb]

#~~~~~~~~~~~~~~~~~~~~~~~~~
# Configure the main toplevel settings
#~~~~~~~~~~~~~~~~~~~~~~~~~
$app(topLevel) configure -title "APPLICATION" -setSize 0.5 

#~~~~~~~~~~~~~~~~~~~~~~~~~
# Configure toolbars
#~~~~~~~~~~~~~~~~~~~~~~~~~
$app(toolBar,1) add item -icon "%#New" -text New -name AAAA
$app(toolBar,2) add item -icon "%#Open" -text Open -name BBB
$app(toolBar,2) configure -visible 0

#~~~~~~~~~~~~~~~~~~~~~~~~~
# Create and pack application specific resources
#~~~~~~~~~~~~~~~~~~~~~~~~~
set app(txt) [gnocl::text -wrapMode word -name "textEdit" -useMarkup 1]
$app(container) add $app(txt) -fill {1 1} -expand 1
$app(txt) lorem ;# a bit of dummy data

#~~~~~~~~~~~~~~~~~~~~~~~~~
# Show and go!
#~~~~~~~~~~~~~~~~~~~~~~~~~
$app(statusBar) push "Ready..."
$app(topLevel) show

#~~~~~~~~~~~~~~~~~~~~~~~~~
# GUI elements can now be modified
#~~~~~~~~~~~~~~~~~~~~~~~~~
$app(toolBar,2) add item -icon "%#Yes" -name CCC
$app(help,about) configure -onClicked {puts HIDIHI}
$app(file,quit) configure -onClicked {exit}
$app(file,recent_menu) configure -onClicked {puts "HODIHO %f"}

#~~~~~~~~~~~~~~~~~~~~~~~~~
# alternatively, use aliases based upon Gtk+ builder names
#~~~~~~~~~~~~~~~~~~~~~~~~~
if 1 {
    namespace eval myApp {}
    foreach item [gnocl::inventory widget $app(topLevel)] {
        set n [$item cget -name]
        if { $n != "" } { interp alias {} ::myApp::$n {} $item }
    }
    ::myApp::textEdit insert end "\nOm Mani Padme Hum Hrih"
}








Friday, February 13, 2015

Recent Enhacements


Here's a brief overiew of enhancements to the development distribution over the past month or so.The mix is consists of the inclusion of a number of convenience options and enhanced feedback.

    gnocl::notebook
        o added command nthPage, retrieve name of child widget on specified page. 
    gnocl::stringUtil
        o new command, provides additional convenience string functionality; particularly useful for
           string comparisons.
    gnocl::text
        o added -lineSpace convenience option. Valid options are "single", "1.5", double" or exact
           spacing in pixels.
    gnocl::label
        o added command getSelection (text only, markup not included)
    gnocl::window
        reduced -typeHint options to normal, popup and splashscreen.
    gnocl::toolbar menu button
        o added new option -data:
    gnocl::notebook
        o added command pageNum, retrive page number for specified child widget
            added extra percentage substitution strings to -onSwitchPage
                %c child
                %t label text
                %d data
    gnocl::eventBox
        o added specifc %c to -onButtonPress/Release list of substitution strings
        o add %d subsitution to -onButtonPress/Release list of substitution strings
    gnocl::fileName
        o new command, offers partial binding to the glib filename functions.

Tuesday, January 20, 2015

Cancellation of a 'Recent Items' Pull-Down Menu

Its been some time since support for 'recent file' operations was first added to the Gnocl sources. At the time I was quite pleased with its inclusion but there was always a annoying snag to it, something which is an inhereted feature from the API: if no selection if made, then the last file URI added to the list is always returned. This is not really a sign of anything lacking in the GTK sources, but the documentation does not suggest how to handle any need to CANCEL the menu by pressing the 'ESC' key.
 A quick gloss over the docs shows that there is a 'cancel' signal for the MENU-SHELL containing the recent items, but this automatically generates a 'selection-done' signal, the very signal that we want to avoid. The obvious solution for this is to set a boolean cancel flag and test for its TRUE or FALSE state during the execution of any 'selection-done' event handler.

For a TCL side solution it was first was necessary to implement a gnocl -onCancel option. So, this could added to any test script:

set cancel 0
set rc_menu [gnocl::menuRecentChooser \
...
-onCancel {  set cancel 1 } \
-onClicked {
     if { !$cancel } {
        set fname [string range %f 5 end]
        openFile $fname
        }
    set cancel 0
}

Works nicely, but it's better if this becomes invisible to the scripter.This of course, is not a problem to implement in C and so the relevant handlers have been modified to offer the benefit of this functionality.