Re: [gtk-list] Re: text-entry retrieval



>>>>> "Tom" == Tom Vogt <tom@lemuria.org> writes:

Tom> Dave Cole <dave@dccs.com.au> wrote:
>> I have built a layer on top of a few of the Gtk widgets so I can
>> capture user entry in my persistent storage transparently.  Once
>> the widget has been attached to the data, all updates to the data
>> by the user, or other code are automatically propagated to any
>> widget attached to the data.

Tom> can you elaborate on the later? I'll need that soon - load some
Tom> data and update some 50 widgets. how do I do this best?

The idea behind the whole method that I store my persistent data in a
tree structured format like XML.  I was lazy and wrote a yacc grammar
that was easier to parse than XML.  The loading and storing of the
data is done without understanding anything more about the data than
the meta-format.

In the application I am writing, there is a large amount of data that
is highly structured and well suited to being stored in a tree - much
like the windows registry.  I figured that if I leave it in a tree,
then attach widgets to nodes in the tree, then I could write some
general purpose code that managed the interface between the widgets
and the tree.

Two of the basic operations I have is copy/merge subtree.  These
operations are ideal for complex dialogs with large amounts of user
input.  When the dialog is opened, the subtree that is relevant to
that dialog is copied as an "edit session" and attached to the widgets
in the dialog.  When the user completes the edit and presses OK, the
copy tree is merged with the original.  If the user presses Cancel,
the copy tree is discarded.

The tree structure supports linkages between tree nodes.  This is used
so that the program can implicitly know which parts of the data tree
are being used (referenced) by other parts of the data.

Another primitive behaviour of the tree is a callback mechanism
whenever certain changes are made to the tree.  This allows the GUI
layer to attach to a node and monitor changes to that node; this
includes child add, child move, child delete, node rename, node value
change.  This is very useful for displaying lists and trees.  All I
have to do is attach a parent node to a GtkCList.  It then scans all
child nodes (1 level down) and adds an entry for each child.  By
providing a path for the data in each column (similar to DOM) from the
current child to the data to be displayed, the list is automatically
filled and attached to the data tree.  If another part of my program
modifies the data tree, the callback mechanism notifies the list which
automatically displays the results of the change.

By using the data tree as the central part of my GUI, I can build
dialogs that modify data without regard to where else it is displayed.
By simply merging the data back into the main tree, the data will be
updated in all other places where it is attached to the GUI.  The
linkage mechanism greatly simplifies things as I do not have to write
application code that understands how, if, and when a piece of data is
used, I simply ask the tree.

- Dave

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS dpu s-:+ a C++$ ULS++$ P+++$>++++ L++>+++$ E+>++ W N++ !o K w++$ O !M-
!V(-) PS+ PE- Y+ PGP !t-- 5++ X R tv b+ DI+++ D G e++ h--- r+++ y++++
------END GEEK CODE BLOCK------



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]