User interface activities
[Estron support library]


Detailed Description

API for handling user interface activities. "Actions" typically get run as a result of the GUI user clicking on a button or performing some other user interface activity. An action stores state information about what should happen when the button-click/signal/etc. occurs.

More precisely, actions are triggered by GTK signals issued from GTK widgets. The action stores the template of an SQL query that will be run when the signal is caught. Along with this, it stores the widgets that will be queried to fill in the blanks in the SQL statement.

The action also stores a list of reports that need to be refreshed when the SQL query is completed.

Not all actions need to perform SQL queries. Some (wtokey) cause data to be copied from the user interface widgets to the key-value pair tree. Others (wtoobj) copy the data to GLib-2.0 GObjects.


Functions

DuiAction * dui_action_new (const char *name)
void dui_action_destroy (DuiAction *)
const char * dui_action_get_name (DuiAction *)
void dui_action_set_interface (DuiAction *act, DuiInterface *)
void dui_action_add_resolver (DuiAction *, DuiResolverFieldFunc, gpointer user_data)
void dui_action_add_realizer (DuiAction *, DuiResolverRealizeFunc, gpointer user_data)
void dui_action_set_database_name (DuiAction *act, const char *dbname)
void dui_action_add_row (DuiAction *, DuiTxnQuery *qry)
DuiTxnQuery * dui_action_get_query (DuiAction *)
void dui_action_add_term (DuiAction *act, DuiFieldMap *fm)
void dui_action_set_report (DuiAction *, const char *name)
const char * dui_action_get_report (DuiAction *)
void dui_action_add_refresh (DuiAction *, const char *name)
void dui_action_rerun_last_query (DuiAction *act)
void dui_action_add_chain (DuiAction *act, const char *actionname)
void dui_action_do_realize (DuiAction *)
void dui_action_db_connect (DuiAction *act)
int dui_action_run (DuiAction *act)


Function Documentation

void dui_action_add_chain ( DuiAction *  act,
const char *  actionname 
)

Add a chained action

void dui_action_add_refresh ( DuiAction *  ,
const char *  name 
)

Add a window that needs to be refreshed when this action is performed

void dui_action_add_resolver ( DuiAction *  ,
DuiResolverFieldFunc  ,
gpointer  user_data 
)

Tell the action about how to convert names into actual objects

Definition at line 383 of file action.c.

00384 {
00385     if (!act) return;
00386     dui_resolver_add_resolver (act->resolver, fn, ud);
00387 }

void dui_action_add_row ( DuiAction *  ,
DuiTxnQuery *  qry 
)

Add a 'row' to the action. The row will typically hold a table widget, or possibly an object class name. If the row holds a table widget (e.g. gtklist, gtkctree, etc.), then the rows of the table will be used to formulate the SQL query. If the row holds an object class, then the action will find the matching instances of that class, and use those instances to formulate the query.

Definition at line 238 of file action.c.

00239 {
00240     if (!act || !qry) return;
00241 
00242     dui_txnquery_set_resolver (qry, act->resolver);
00243 
00244     /* XXX we should do something if this is called twice ... */
00245     if (act->query)
00246     {
00247         PERR ("There already is a query in this action");
00248     }
00249     act->query = qry;
00250 }

void dui_action_add_term ( DuiAction *  act,
DuiFieldMap *  fm 
)

Add a term, which may be an sql select, sql update, sql where matcher, or it might be a non-sql map

< Database table column

< match to database column

< Field with const value

Definition at line 260 of file action.c.

00261 {
00262     if (!act || !fm) return;
00263 
00264     if (DUI_FIELD_IS_TYPE(&fm->target, DUI_FIELD_SQL) ||
00265         DUI_FIELD_IS_TYPE(&fm->target, DUI_FIELD_WHERE) ||
00266         DUI_FIELD_IS_TYPE(&fm->target, DUI_FIELD_CONST))
00267     {
00268         if (NULL == act->query)
00269         {
00270             DuiTxnQuery *qry = dui_txnquery_new();
00271             dui_action_add_row (act, qry);
00272             act->query = qry;
00273         }
00274         dui_txnquery_add_term (act->query, fm);
00275     }
00276     else
00277     {
00278         dui_resolver_add_field (act->resolver, &fm->source);
00279         dui_resolver_add_field (act->resolver, &fm->target);
00280         act->non_table_targets = g_list_append (act->non_table_targets, fm);
00281     }
00282 }

void dui_action_db_connect ( DuiAction *  act  ) 

Force the db to connect. This will cause any connect errors to be reported.

Definition at line 410 of file action.c.

00411 {
00412     if (!act) return;
00413     dui_txnquery_connect (act->query);
00414 }

void dui_action_do_realize ( DuiAction *   ) 

Resolve stuff; the book/window/interface must be set before calling this. The action must be realized before it can be run.

Definition at line 397 of file action.c.

00398 {
00399     if (!act) return;
00400 
00401     ENTER ("(act=%p)", act);
00402     final_setup (act);
00403     dui_resolver_realize (act->resolver);
00404     LEAVE ("(act=%p)", act);
00405 }

void dui_action_rerun_last_query ( DuiAction *  act  ) 

Rerun the last query (and display it in a report). this routine is used to refresh a window.

Definition at line 473 of file action.c.

00474 {
00475     DuiDBRecordSet *recs = NULL;
00476 
00477     if (!act) return;
00478 
00479     ENTER ("(act=%p \'%s\')", act, dui_action_get_name (act));
00480 
00481     /* Issue same query as before, and display the results */
00482     recs = dui_txnquery_rerun_last_query (act->query);
00483     dui_report_show_data (act->report, recs);
00484     dui_recordset_free (recs);
00485 
00486     LEAVE ("(act=%p \'%s\')", act, dui_action_get_name (act));
00487 }

int dui_action_run ( DuiAction *  act  ) 

Cause the indicated action to be run.

Definition at line 419 of file action.c.

00420 {
00421     DuiDBRecordSet *recs = NULL;
00422     GList *node;
00423     gint rc = 0;
00424 
00425     if (!act) return 0;
00426     ENTER ("(act=%p \'%s\')", act, dui_action_get_name (act));
00427     final_setup (act);
00428 
00429     /* We need to resolve the widgets again, because the action window
00430      * may have been closed. When it is re-realized, there will be all
00431      * new widgets for the thing.  It would probably be more efficient
00432      * (and more complex) to catch the window-close signal. Oh well. */
00433     resolve_widget_again (act);
00434 
00435     /* Loop over chained actions; quit if one of them handled things */
00436     for (node=act->check_list; node; node=node->next)
00437     {
00438         DuiCheck *chk = node->data;
00439         rc = dui_action_run (chk->action);
00440         if (rc) return rc;
00441     }
00442 
00443     /* Loop over list of field maps that don't involve any SQL tables,
00444      * and move the data from the source to the target. */
00445     for (node = act->non_table_targets; node; node=node->next)
00446     {
00447         DuiFieldMap *fm = node->data;
00448         dui_field_map_transfer_data (fm);
00449     }
00450 
00451     recs = dui_txnquery_run (act->query);
00452 
00453     /* Now report the results. */
00454     dui_report_set_last_action (act->report, act);
00455     rc = dui_report_show_data (act->report, recs);
00456 
00457     /* Don't need it no more */
00458     dui_recordset_free (recs);
00459 
00460     /* Refresh all windows that show data modified by this query */
00461     for (node=act->refresh_list; node; node=node->next)
00462     {
00463         DuiRefresh *rsh = node->data;
00464         dui_report_refresh (rsh->report);
00465     }
00466     LEAVE ("(act=%p \'%s\') rc=%d", act, dui_action_get_name (act), rc);
00467     return rc;
00468 }

void dui_action_set_database_name ( DuiAction *  act,
const char *  dbname 
)

Set the name of the database connection that will be used to perform queries on

void dui_action_set_interface ( DuiAction *  act,
DuiInterface *   
)

Tell the action about where to find the 'global' objects, such as kvp trees, gobjects etc.

Definition at line 376 of file action.c.

00377 {
00378     if (!act) return;
00379     act->interface = iface;
00380 }

void dui_action_set_report ( DuiAction *  ,
const char *  name 
)

Cross-reference to the reports that will show the results.


Generated on Tue Apr 29 21:27:54 2008 for estron by  doxygen 1.5.5