Saturday, October 19, 2013

gnocl::text tag rollover effects

Suprisingly, to me at least, tag rollover is not standard feature of the GtkTextTag. I've had Tcl a solution for some time now but always felt that this needed to be moved in to the package code itself. Whilst implementing rollover effects isn't difficult, matters would be made easier if the widget internals offered tag signals which tracked motion in and out of the tag rather than giving the simpler 'event' event binding. Well, its sorted now and the following test script illustrates how it works. There's a little more tweeking that can be done to the source code to allow similar changes to the rollover tag background colour. Finally,  runtime changes to the rollover colour setting (default = red) for the script will affect all instances of text widgets within a script.

# tagRollover.tcl

#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

package require Gnocl

set text [gnocl::text ]

$text configure -rollOverColor red

# whenever the pointer moves, clear any rollOver highlight
 $text configure -onMotion { #puts MOTION }


for {set j 0} {$j <= 5 } {incr j} {
 # create new, rollOver tag
 $text tag create _tag_rollOver_$j -rollOver 1 -fontWeight bold -foreground blue -onEvent {puts "HELLO!"}

 # use it
 $text insert end "This is "
 $text insert end "Gnocl tag $j" -tags _tag_rollOver_$j
 $text insert end "! \n"
}

gnocl::window -title "Text TagRollover Effects" -child $text -setSize 0.25
gnocl::mainLoop


Wednesday, August 28, 2013

gnocl::label -last of the signal bindings done!

Just added the last two signal bindings for this widget.
-onActivateCurrentLink
-onActivateLink
Nightly build updated.

Tuesday, August 27, 2013

gnocl::label -more options added

With the ability to copy text from the label widget being added, the widget can report a number of events. Those added today include: -onPopulatePopup, -onCopyClipboard, -onMoveCursor.

Available in today's 'nightly-build'.



Thursday, July 25, 2013

Running the Gnome 'yelp' Help System from Tcl/Gnocl applications.

I implemented some yelp help pages a while ago for my major app. After installing, however, the pages would load but not the graphics. When calling yelp all that needs to be passed is the directory containing all the pages, graphics, media etc. that are part of the help. To resolve this I resorted to launching a separate shell script to handle the help system. So, good-bye to:

set app(baseDir) $ENV(home)/help
exec yelp $app(baseDir)/help &


and hello to

exec my_yelp.sh &

Where my_yelp.sh is nothing more complex than

cd $HOME/help
yelp ./



Saturday, July 13, 2013

Its a lot of work!

Decided add to the ability to get more feedback from the gnocl package. The implementation of the cget command across the various widgets is still a little patchy and I've just added a new command, 'options' to all the widgets which will return a list of valid switches. With well over 50  modules to update this is a lot of work! Its taken me about 5hrs so far!
Following that I will add a similar command to obtain the valid widget and contents (e.g. text tags) sub-commands. For some widgets with just a handful of options and commands it something of an overkill but, then comes the task of updating the documentation.
I've completed most of the support in place for using pango markup strings in the text widget. The set of available tags is pre-defined, but quite extensive. Just a little more work in this area before the handling of <span.. </span> will work properly. Added this is a new toolbar with all the necessary buttons for the pango markup in place.


Monday, July 01, 2013

Dockable side toolbars

Gtk offers a dockable toolbar but this cannot be re-docked elsewhere on screen. The screenshot below shows a possible workaround using notebook groups. As the toolbar must be configured as either horizontal or vertical whenever a new page is dropped onto a notebook, then the toolbar will be automatically re-oriented. The accompanying script is basically for proof of principle rather than a realistic package.





proc addToolBarItems {tb} {
    foreach item {Open Close New Cut Paste Copy} {
        $tb add item -icon %#$item
    }
}


set container [gnocl::box]
set table [gnocl::table]
$container add $table -fill {1 1} -expand 1

set nb(1) [gnocl::notebook -groupId 1 -onPageAdded { %c configure -orientation %d } -data horizontal]
set nb(2) [gnocl::notebook -groupId 1 -tabPosition left -onPageAdded { %c configure -orientation %d } -data vertical]
set nb(3) [gnocl::notebook -groupId 1 -tabPosition right -onPageAdded { %c configure -orientation %d } -data vertical]
set nb(4) [gnocl::notebook -groupId 1 -onPageAdded { %c configure -orientation %d } -data horizontal]
set box(1) [gnocl::box -orientation vertical]

$table add $nb(1) 0 0 -columnSpan 3 -expand 0 -fill {1 0}
$table add $nb(2) 0 1 -expand 0 -fill {0 1}
$table add $box(1) 1 1  -expand 1 -fill {1 1}
$table add $nb(3)] 2 1 -expand 0 -fill {0 1}
$table add $nb(4) 0 2 -columnSpan 3 -expand 0 -fill {1 0}

$box(1) add [gnocl::text] -fill {1 1} -expand 1

set tb(1) [gnocl::toolBar -style icons]
set tb(2) [gnocl::toolBar -style icons -orientation vertical]
set tb(3) [gnocl::toolBar -style icons -orientation vertical]
set tb(4) [gnocl::toolBar -style icons]

addToolBarItems $tb(1)
addToolBarItems $tb(2)
addToolBarItems $tb(3)
addToolBarItems $tb(4)

$nb(1) addPage $tb(1) "TB1"
$nb(2) addPage $tb(2) "TB2"
$nb(3) addPage $tb(3) "TB3"
$nb(4) addPage $tb(4) "TB4"

gnocl::window \
    -child $container \
    -setSize 0.3 \
    -title test-side-toolbars
   

Recent Enhancements

Added the following enhancements to the nightly build code.

2013-07:
   gnocl::notebook
        o new options
            -data
        o added extra percentage subtitution strings to -onPageAdded, -onPageRemoved
            %c child
            %n page number
            %d data

2013-06:
    gnocl::toolBar
        o configure/cget -orientation now works

json_shell_utils.tcl