Skip to main content

Posts

Showing posts from May, 2012

Working with application preferences using gnocl::keyFile

Its easy enough to load/save script settings as some form of serialization on an array, but what if we want to conform to Gtk+ standards and save settings as an *.ini file? The following script shows how this can be done. #--------------- # test-keyfile.tcl #--------------- # William J Giddings, 19/05/2012 #--------------- #!/bin/sh #\ exec tclsh "$0" "$@" package require Gnocl #--------------- # manipulate application preferences #--------------- # preferences stored in global two-dimensional array name "prefs" # array names are equivalent to the group/key pairings required for keyFile #--------------- # args #    cmd        one of load, edit, save #    keyfile    name of keyfile to load/save, ignored for edit # returns #   none #--------------- proc preferences {cmd {keyFile {} } } {  global prefs  switch $cmd {     load {         set kf [gnocl::keyFile load $keyFile]         set prefs(comment) [$kf get comment]                 foreach group [$kf get

pango markup functionality

The arrangement for creating markup strings from the contents of text widget is almost complete. I've just got to add some extra toolbar buttons for the remaining settings and then the job will be done! Here's a screenshot.

gnocl::toolbar cget

Did a little more work on the gnocl::toolbar to implement the cget function. Not fully implemented as any cget implementation needs a lots of wrapping to get the job done! All changes posted to SF in today's NB.

gnocl::text pango markup

Getting closer towards some working code. I've expanded the list of automatically created pango style text tags to include those which are possible using the GtkTextView widget. One nice feature in pango, ie using unique strikethrough colours isn't available as a text tag attribute. The fg/bg colours are restricted at the moment to red, green, blue, cyan, magenta, yellow, black, gray and white. Apart from the default theme font, the other two settings are serif and sans. Setting unique values for these would not be an impossibility, but these can be created on the fly as normal text tags in a Tcl script.