Hello everyone!
I assume that you have already followed previous howto section. This is an informal tutotual page. I will show you some of the code I've written.
When we build a BOND application, we use Glade to design its user interface,
NOT to generate the code to draw GUI. Glade's "build code" is only useful to generate
callbacks.c
. Keep in mind that drawing GUI elements such as forms (generally windows),
buttons, listbox, etc. are handled by BOND. The rest files such as main.c,
interface.c, interface.h, support.c, support.h
are not required at all.
However, "build code" can be useful when you want to generate the template
callbacks.c
. This in the only time you may want to use "build code".
After that, you should not try again because it may override your
callbacks.c
. So don't do that unless you haven't written any callbacks.
It is very important to understand that the model of BOND application. I will discuss brief BOND application model later.
(form) +-----------+ | | (map to) +---------+ | | --------> | | | | +---------+ | | | | +-----------+
#ifdef HAVE_CONFIG_H # include config.h #endif #include bond/bond.h #include bond/ui.h #include "callbacks.h" int main (int argc, char *argv[]) { bond_init(argc, argv); bond_main(); bond_cleanup(); return 0; } |
As you can see, the main.c
is too simple and rather dull.
Moreover, this code doesn't include any of your specific application feature, strange, huh?
In most cases, you main code will look like above. Writing a BOND application is actually writing the callback functions.
#ifdef HAVE_CONFIG_H # include config.h #endif #include gtk/gtk.h #include "callbacks.h" void on_customer_tool_add_clicked (GtkButton *button, gpointer user_data) { int retval; retval = bond_formadd("customer"); /* ASPECT: error */ if (retval < 0) { puts("Ouch!!!\n"); } } void on_customer_tool_save_clicked (GtkButton *button, gpointer user_data) { int retval; retval = bond_formsave("customer"); retval = bond_flushall(); /* ASPECT: error */ if (retval < 0) { } } |
If you want quit, the whole BOND application, in a callback function
call bond_mainquit()
. This function post quit message to
the message queue in GTK/wxWindows case, and the control of your application
will go back to the main (Code 1.1) function and subsequentially,
bond_cleanup()
will be called.
If you need to flush cache right now, call bond_formsave("formname")
first,
then bond_flushall()
. If you call only bond_flushall()
, the immediate
update will not be reflected on your form.
If you want to show
CREATE TABLE "product_type" ( id INTEGER PRIMARY KEY, name CHARACTER(20) ); CREATE TABLE "product" ( id INTEGER PRIMARY KEY, name CHARACTER(20), description CHARACTER(200), producttypeid INTEGER REFERENCES product_type(id) ); INSERT INTO product_type(id, name) VALUES(1, 'Heavy Weight'); INSERT INTO product_type(id, name) VALUES(2, 'Light Weight'); |
francis@crackle:~/private/proj/tutbond/apptemplate/tut/src$ createdb -h nikita -U francis tut CREATE DATABASE francis@crackle:~/private/proj/tutbond/apptemplate/tut/src$ psql -f tut.sql -h nikita -U francis tut
Sometimes using Notebook (i.e. ) is extremly useful from escaping so many windows to reduce number of windows and grouping related things together.
So how do we map a database table to a notebook? Based on assumption that all Notebook GUI component has a label for each page, name the label of the page to database table name.BOND provides a set of APIs to search a row in database. When you name a field name of search input form, use can specify '*' to at end of the field name. For example, name to name* means typing "a" in the name field will return "andru" "andrew", etc. However, it will not return "bart" because it does not start with 'a' although it contains 'a'.
![]() |
![]() |