HINTS, TIPS and COOKBOOK
------------------------
This document explains how to accomplish 'typical' tasks, such as
initializing windows, checking for null fields, using radio buttons,
and the like. Read on.
-- To initialize a form, treat it like a report. The following will
initialize an "widget one" with a blank and "widget two" with
the string "asdf":
-- To initialize the main window (so that it has values when the application
starts), treat it as a report (as described above), and use the "show"
signal on the main window widget to trigger the running of the report.
For example:
<... etc ... >
Note that in order for the above to work, you must use Glade to mark
the main window as "not visible", otherwise, the main window will be
shown before DWI has initialized, and thus, DWI will never catch the
"show" signal (and thus the report won't run).
-- To run a query when the app is started (e.g. to populate the main window)
use
Note, however, for this to work right, you *must* have the main
window marked as "not visible" (glade 'common' tab) ;
otherise the show signal will be delivered before dwi is initialized
(and thus won't be caught). Really. Not kidding. Re-read the above.
-- To have the app shut off when the app main window is closed, use
glade to add gtk_main_quit to the "destroy" signal of the app main
window. You can also use glade to hook this callback to any signal
on any widget. This can also be done within DWI, if desired.
For example, the following will hook up a menu item so that it
causes the gtk main loop to be exited:
Similarly, this will cause the main loop to exit when the main
window is closed:
-- A secion must have a section in it, even if empty.
Otherwise that window can't be the target of any actions (and will
not be instantiated!).
-- You can append to a previously defined section, merely by
refering to it by name. There is no technical reason that this
would ever be needed; however, its provided as a convenience.
For example:
....
....
....
-- How to get a form to 'remember' the last values entered:
To get a form to 'remember' the last values entered, one could,
of course, store them in the database, and then intialize the form
from the database. But there's an easier way that is more appropriate
for most applications, and that is to store the last values entered
in the global key-value-pair table. In the following example,
the widget's value is stored when the submit button is pressed.
Next time the form is initializzed, it will be initialized with
the stored value. The example:
-- How to check for blank or invalid fields:
When preparing a form, it is often useful to make sure that the user
entered a valid value for a field, before commiting that field to the
database. This can be done with chained forms in conjunction with
data filters. The example below shows how to do this.
-- How to use radio buttons:
First, initialize the data on *each* radio button when the form
is first created. For example, the following has a yes/no button:
Then copy from the widget data to the database. The form needs to
specify only one of the radio buttons to pick up the whole group.
The data from the selected button will be copied to the database.
-- How to use the file selection dialog:
In the example below, we have use a GtkEntry widget to allow the
user to type in a file name, and also use a GtkFileSelection widget
to allow the user to browse and pick a file. After browsing, the
user's selection will be copied into the GetEntry.
-- How to list the tables in a database:
Use the form type "tables". For example:
-- How to list the fields in a table:
Use the form type "fields". For example, the following picks
the name of a table out of a list:
========================== THAT'S ALL FOLKS =====================