Posts

Showing posts from January, 2013

Checking to see which entry has the active input focus.

Image
Gtk provides no simple way telling a calling program which entry widget contains the active keyboard focus. Specific widgets can be interrogated as to whether they possess keyboard input focus on either a global scale or simply within their own toplevel window. My own pet project is working on the translation of Chinese texts and the api of my translation editor will have multiple editable widgets on screen at any one time. Up till now I've used focus events to set a global variable identifying which widget has focus, but there are other ways. Today I just added the hasToplevelFocus and has hasGlobalFocus commands to the gnocl::text widget. There always was, of course the option to use cget -hasFocus. Here's my test script.

#---------------
# test-chinese-punct-toolbar.tcl
#---------------
#
#!/bin/sh
#\
exec tclsh "$0" "$@"

package require Gnocl

#---------------
# insert punc mark it currently active text
#---------------
proc do_chn_punc { mark } {

    foreach w $::te…

gnocl::cairo - moving forward

Image
Spent some time last night working on the proposed gnocl::cairo package. I've got most of the innards working now and the next step will be wrapping the gdk core api into the mixture. Cairo is certainly fast even on my old 32-bit workstation. By default, my development code wants always to work on bitmaps but, of course, Cairo will work on a variety of surfaces. Apart from pixbufs, the additional objects include svn, png, ps, pdf, some other windows, mac and X formats and gdk drawables such as windows. The code is expanding rapidly but, it's getting there!

Today's Added Functionality

Image
This is the summary of today's work on the Gnocl sourcecode.

2013-01:
    gnocl::winfo
        o new subcommand
            exists
    gnocl::notebook
        o new options
            -startWidget
            -endWidget
            -onDestroy
    gnocl::label
        o new option
            -onDestroy

Improving Notebook Tearoff Functionality

Image
The Gtk+ libraries provide the necessary support to detach notebook tabs in order to attach them to other notebooks in the same group or to place them in floating windows. This is fine. But, what happens when a floating palette is destroyed? Well, the notebook and any pages that it contains will be lost too. Unfortunately, the Gtk+ libs do not re-attach pages to any original note book when other notebooks in the group are deleted. In otherwords, pages will be lost and it up the application to create new instances. The following script shows how to do it. It relies upon the gnocl::winfo exists sub-command, which has only just been added. So, anyone trying out this script will need to use the nightly build dated 16-Jan-13 or later.

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

package require Gnocl

#---------------
# create notebook contents
#---------------
#
proc addStuff {} {

    set notebook1 [gnocl::notebook \
        -scrollable 1 \
        -tabPosition left…