Wednesday, March 30, 2011

gnocl::webkit

Added a pile of events handlers for this widget and uploaded to SF. Still having some problems with loading. These aren't Webkit problems but sure as hell don't see how I can stop the load process running smoothly without those nagging Bugzilla notifications!

Hey-ho!

gnocl::statusIcon docs

Just given the online docs a bit of attention. Basically there was no documentation of the signal handlers. Hopefully all is well.

Tuesday, March 29, 2011

gnocl::tickerTape

Added a new gnocl widget today tickertape. Basically its a wrap around the marquee widget included in Chapter 11 of Krause's 'Foundations of Gtk Development'. Here's as screenshot and testscript:





#!/usr/bin/sh
#\
exec tclsh "$0" "$@"
package require Gnocl


gnocl::window -child [gnocl::tickerTape \
    -baseFont {Sans 12 } \
    -background white \
    -speed 10 \
    -message "Gnocl 0.9.95 * Gnocl 0.9.95 * Gnocl 0.9.95 * Gnocl 0.9.95 *"]





Saturday, March 26, 2011

gnocl::webKit

In response to a post made to the Tcler's wiki earlier this week, todays TLC was given to the gnocl::webKit package. Ok, its all still pretty well early stuff but the core navigation controls are there. Looking at things, perhaps the name of the core command should be changed to gnocl::webView. There are no docs yet, but all the key implemented options  and commands are used in the following test script.

#---------------
# test-webkit.tcl
#---------------
# Created by William J Giddings
# 26-Mar-11
#---------------
# Description:
#
#---------------

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

package require Gnocl
package require GnoclWebKit

#--------------
#
#--------------
proc gnocl::browser { {home webkit.org} } {

    # create container
    set bx [gnocl::box -orientation vertical]

    # global $bx.tbar
    global ${bx}.wk
    global ${bx}.tbar
    global ${bx}.ent

    global ${bx}.home

    set ${bx}.home $home

    # create key components, toolbar and browser
    set tbar [gnocl::toolBar]
    set wk [gnocl::webKit -transparent 1]

    set b [$tbar add item -icon %#GoBack -tooltip "Go Back"]
    set f [$tbar add item -icon %#GoForward  -tooltip "Go Forward"]
    set r [ $tbar add item -icon %#Refresh  -tooltip "Reload"]
    set s [$tbar add item -icon %#Cancel  -tooltip "Stop"]
    set h [$tbar add item -icon %#Home -tooltip "Home"]

    set ent [gnocl::entry -widthChars 85]
    $tbar add widget $ent

    # set toolbar behaviours
    $b configure -onClicked "$wk back"
    $f configure -onClicked "$wk forward"
    $r configure -onClicked "$wk reload"
    $s configure -onClicked "$wk stop"
    #$h configure -onClicked "$wk load http://$home"

    $h configure -onClicked  { set $browser.uri [loadPage $browser.wk [set $browser.home] ] }

    $ent configure \
        -onActivate { set $browser.uri [loadPage $browser.wk %t] } \
        -variable ${bx}.uri \


    # pack major components
    $bx add $tbar
    $bx add $wk -fill {1 1} -expand 1

    # create global access
    set ${bx}.wk $wk
    set ${bx}.tbar $tbar
    set ${bx}.ent $ent

    return $bx
}

#---------------
#
#---------------
proc loadPage {viewer page} {

    # string compare ?-nocase? ?-length int? string1 string2
    if { [string compare -length 7 "http://" $page] != 0 } {
        set page "http://$page"
    }

    [set $viewer] load $page

    return $page
}


set browser [gnocl::browser]

gnocl::window \
    -child $browser \
    -setSize 0.75 \
    -title "Gnocl WebKit Demo" \
    -onDestroy { exit }

gnocl::mainLoop

Tuesday, March 22, 2011

gnocl::asssistant

Just updated the docs page for this item. There's still much to do. This object is pretty complicated and so probably needs a tutorial page putting together too!

gnocl::accelarator -2

Module changes completed. Docs updated and NB refreshed.

gnocl::accelerator -1

Taking a look at this module. Now getting some TLC....

gnocl::action -2

Took another look at this code. Looking at what it does, its something of a legacy item from earlier versions and has is not integral to the overall gnocl widget set. Ok, the package will produce items, but this functionality is handled by other widget. The test code creates a menu item. Fine. That code binding already exists.  I'm certain that no-one has used the gnocl::action function, it hasn't been previously documented and, judging by the lack of functionality in the original code, there would have been feedback. So, I'll remove the module from the core.

gnocl::action -1

Did some more work on this module. But, I need some clearer idea of how this would be used in a script. Included for compatibility issues.

Monday, March 21, 2011

Updated DOCS -2

Updated the docs for the gnocl::aboutDialog. Some tidying up of the code was also needed too inoder to remove unwanted options inherited from the GtkWindow object. -Job Completed!

Sunday, March 20, 2011

Updated DOCS-1

Gave some of the 'pages in progress' the TCL they deserved today. With the abscence of a doc page, its so easy to assume that a feature isn't present. So, completed the docs for the gnocl::ruler, gnoc::volumeButton and gnocl::curve objects. More to follow...

gnocl::fileChooserButton and gnocl::folderChooserButton

Seeing as I recently used the folderChooser as part of my JukeBox script, I decide to tidy-up the code and documentation for these objects. So, that's done!

Friday, March 18, 2011

Packing mplayer into a gnocl::socket container.

Ok, got the JukBox. What about some vids? Here's a quick experiment with mplayer. Worked ok.

#!./bin sh
#\
exec tclsh "$0" "$@"

package require Gnocl

set socket [gnocl::socket]

set box [gnocl::box -orientation vertical]
$box add $socket -fill {1 1} -expand 1
gnocl::window -title "mplayer" -child $box -setSize 0.25

gnocl::update

eval exec "mplayer -wid [format "0x%x" [$socket getID]] mdia0003.asf"

Reworked JukeBox

Reworked the JukeBox earlier today. Now uses a list and not buttons along with the option to change directories.

Screenshot,




And, here's the revised code:

#---------------
# jukeBox.tcl
#---------------
#!/bin/sh
#\
exec tclsh "$0" "$@"

package require Gnocl

#---------------
# create playlist
#---------------
proc playList { dir {type ogg} } {
    global lst

    cd  $dir

    # clear the existing playlist
    $lst erase 0 end

    set tracks ""
    catch { set tracks [glob *.ogg] }

    if {$tracks == ""} {
        makeUI [gnocl::fileChooserDialog \
            -title "JukeBox: No tracks found. Select Collection Folder.." \
            -action openFolder \
            -currentFolder $dir ]
    }

    foreach track [lsort $tracks] {
        $lst add [list [list $track]]
        }
}

#---------------
# make ui
#---------------
proc makeUI {dir} {
    global lst

    cd $dir

    set cb [gnocl::folderChooserButton \
        -title "JukeBox: Select Collection Folder" \
        -onFileSet {playList %f}]

    set lst [gnocl::list \
        -titles {"Track"} \
        -types {string } \
        -onSelectionChanged {
            gnocl::sound [%w get %p 0 ]
            }]

    playList $dir

    set box [gnocl::box -orientation vertical]
    $box add $cb
    $box add $lst -expand 1 -fill {1 1}

    gnocl::window \
        -title "JukeBox (1.0)" \
        -child $box \
        -onDelete exit
}

#---------------
# use specified directory or pick a new one
#---------------
 if { $::argc > 0 } {
     makeUI $::argv
  } else {
    # select a directory
    makeUI [gnocl::fileChooserDialog \
        -title "JukeBox: Select Collection Folder" \
        -action openFolder \
        -currentFolder $::env(HOME)/Music ]
  }




Thursday, March 17, 2011

GtkStyles module

I've just taken a quick look at the doc packages for the gtk styles libs. These provide a way of painting widget elements to gtkwindows, the sort of sub-components required for making custom widgets. Right now, I'm not sure how bindings to this package would be used but they could be useful in the future. I'll add this to the "to do" list.

gnocl::entry undo

Started working on the undo/redo functionality for the entry widget. Looks as though it will be a cut-down and re-worked version of the code for the textview. The entry has only two signals and not four. Otherwise, it appears (?) straightforward enough.
 

Quick and easy gnocl based music jukebox

I don't like bloatware. I like things simple, like me. The media players that ship with our Distros are just too complicated and well, annoying. I wanted to listen to my favourite audio tracks whilst working this morning and was so fed up of fiddling with apps that I thought: "Gnocl has built-in sound playback, lets build a custom jukebox!". So, here it is.<br />

#---------------
# playOGG.tcl
#---------------
#!/bin/sh
#\
exec tclsh "$0" "$@"

package require Gnocl

set box [gnocl::box -orientation vertical]

set i 0
foreach track [lsort [glob *.ogg]] {
        set b($i) [gnocl::button \
                -icon %#Cdrom \
                -text $track \
                -onClicked "gnocl::sound \"$track\""]
        $box add $b($i)
        incr i
}

gnocl::window -child $box
gnocl::mainLoop

Friday, March 11, 2011

REVIEW Tcl/Tk 8.5 Programming Cookbook


When I received my review copy of the Tcl/Tk 8.5 Programming Cookbook I was half expecting a rewrite of the manual -lists of features and functionality with little indication of how and when to use specific resources. I was wrong. Let me explain. A cookbook is something to turn to when you’ve run out of ideas or perhaps are looking to find some new way of tackling an old problem. Alternatively, cookbooks are for beginners and novices, those people who need to know how do something effectively and quickly. In this area the ‘Cookbook’ score points in every chapter.

Turn to any page in the text and you will find a clear, structure on how to use Tcl/Tk to resolve particular issues. There is a task statement, such as 'Creating a List’ in which a particular requirement is identified followed by 'How to Do It’ code snippet and 'Why it Works’ explanation. For someone new to Tcl programming this is an excellent approach.

Overall, the ‘Cookbook’ is organised over thirteen chapters which cover all the key areas any novice Tcler needs to know. The flow of the book first introduces the reader to the key aspects of Tcl: the shell, program control, error handling, string manipulation, lists, dictionaries (particularly useful) and file operations. Following this it deals with the creation and configuration of GUIs using the Tk widget set and the use of in-built dialogs and the creation of menus. Finally, the issues and decisions surrounding the completion of a first Tcl/Tk project are examined in the form of an address book application.

Conclusion

The Tcl/Tk 8.5 Programming CookBook is exactly what it set out to be - a practical tutorial text. It doesn’t cover the advanced features of Tcl/Tk but this is intentional. Would I recommend this book to a Tcl/Tk newbie? Yes.

Thursday, March 03, 2011

gnocl::window docs ammended

Did some work upating the documentation to the gnocl::window command. Just a well that I did, even I had forgotten some the options available! Still a bit more work to do though.

Wednesday, March 02, 2011

Setting the Gnome Desktop background

Spent some time looking at directly setting the desktop background under script control rather than through gconf. The latter gives a gradual transition between images suitable for slide shows but I'm still interested in setting backgrounds to the contents of image buffers. This means that I could embed a clock dial or custom slide show, messages etc into the background layer itself. The documentation is pretty aweful and because the API is *UNSTABLE* its not in the expected libgnomeui libraries but secreted away in its own, obscure package.

So far, I managed to load the image, convert it to a pixmap and then set it as the bg image. This only occasionally works. The code will run but then nothing happens. Ok, I'm sure that the code is running, but there must be a daemon control the background which needs to be negotiated with. I think that the 'right route' might be to save the pixbuf as an image, add it to the list of background images and then write to that.


Tuesday, March 01, 2011

Docs Uploaded

The latest version of the developer documentation has now been uploaded to SourceForge and can be obtained from here:

http://sourceforge.net/projects/gnocl/files/Documentation/0.9.95/gnocl-0.9.95-DOC.tar.gz/download