## A small example

## Application presentation and context

This section presents a small example of how to use some powerful widgets provided with the libgnomedb library (the usage of the data dictionary is better seen in the source of the 'gnome-db-browser' application located in the extra/ directory). This small application will allow direct manipulation of data stored in a database representing a small company's shipments. Each shipment (order) is represented by an entry in the 'orders' table, and the corresponding's contents are listed as entries in the 'order_contents' table. Moreover, the customer the order is for is expressed as a link from the 'orders' table to the 'customers' table.

The sample application will allow to select a customer, will provide a tabular (grid) view of all the orders for that customers, and in another tabular (grid) view whill display the selected order's contents. The orders and the order's contents can be directly edited from the tabular views.

The following picture is a screenshot of the final sample application to be built. The resulting window allows to select a customer from a drop-down menu at the top ('Lew Bonito' in the example); the middle part shows the orders for the selected customer (which is of course updated everytime the selectec customer changes), and the bottom part shows the selected order's contents (one item in the example). Even though they are used, all the primary and foreign keys are hidden from the user.

The user is expected to select a customer from a popup list at the top of the application, and when done, the list of orders for that customers gets updated; when the selected order changes, the order's contents (details) is also updated as a dependency, as illustrated in the following picture:

This sample example is built using LibGlade, and avoids concentrating on the GTK specific layout code. The code is located in the `samples/SimpleExample` directory, the specific hand-written code being in the `example.c` file (there is also a simple `Makefile` to show how to compile).