| GdaBrowser hacking manual | ||||
|---|---|---|---|---|
| Top | Description | Object Hierarchy | Properties | Signals | ||||
BrowserConnectionPrivate; BrowserConnection; BrowserConnection * browser_connection_new (GdaConnection *cnc); const gchar * browser_connection_get_name (BrowserConnection *bcnc); const GdaDsnInfo * browser_connection_get_information (BrowserConnection *bcnc); gboolean browser_connection_is_busy (BrowserConnection *bcnc,gchar **out_reason); void browser_connection_update_meta_data (BrowserConnection *bcnc); void browser_connection_meta_data_changed (BrowserConnection *bcnc); GdaMetaStruct * browser_connection_get_meta_struct (BrowserConnection *bcnc); GdaMetaStore * browser_connection_get_meta_store (BrowserConnection *bcnc); const gchar * browser_connection_get_dictionary_file (BrowserConnection *bcnc); BrowserFavorites * browser_connection_get_favorites (BrowserConnection *bcnc); gchar ** browser_connection_get_completions (BrowserConnection *bcnc,const gchar *sql,gint start,gint end); GdaSqlParser * browser_connection_create_parser (BrowserConnection *bcnc); gchar * browser_connection_render_pretty_sql (BrowserConnection *bcnc,GdaStatement *stmt); guint browser_connection_execute_statement (BrowserConnection *bcnc,GdaStatement *stmt,GdaSet *params,GdaStatementModelUsage model_usage,gboolean need_last_insert_row,GError **error); GObject * browser_connection_execution_get_result (BrowserConnection *bcnc,guint exec_id,GdaSet **last_insert_row,GError **error); void (*BrowserConnectionExecuteCallback) (BrowserConnection *bcnc,guint exec_id,GObject *out_result,GdaSet *out_last_inserted_row,GError *error,gpointer data); guint browser_connection_execute_statement_cb (BrowserConnection *bcnc,GdaStatement *stmt,GdaSet *params,GdaStatementModelUsage model_usage,gboolean need_last_insert_row,BrowserConnectionExecuteCallback callback,gpointer data,GError **error); gboolean browser_connection_normalize_sql_statement (BrowserConnection *bcnc,GdaSqlStatement *sqlst,GError **error); gboolean browser_connection_check_sql_statement_validify (BrowserConnection *bcnc,GdaSqlStatement *sqlst,GError **error); guint browser_connection_rerun_select (BrowserConnection *bcnc,GdaDataModel *model,GError **error); guint browser_connection_rerun_select_cb (BrowserConnection *bcnc,GdaDataModel *model,BrowserConnectionExecuteCallback callback,gpointer data,GError **error); gboolean browser_connection_begin (BrowserConnection *bcnc,GError **error); gboolean browser_connection_commit (BrowserConnection *bcnc,GError **error); gboolean browser_connection_rollback (BrowserConnection *bcnc,GError **error); GdaTransactionStatus * browser_connection_get_transaction_status (BrowserConnection *bcnc); gboolean browser_connection_set_table_column_attribute (BrowserConnection *bcnc,GdaMetaTable *table,GdaMetaTableColumn *column,const gchar *attr_name,const gchar *value,GError **error); gchar * browser_connection_get_table_column_attribute (BrowserConnection *bcnc,GdaMetaTable *table,GdaMetaTableColumn *column,const gchar *attr_name,GError **error); void browser_connection_define_ui_plugins_for_batch (BrowserConnection *bcnc,GdaBatch *batch,GdaSet *params); void browser_connection_define_ui_plugins_for_stmt (BrowserConnection *bcnc,GdaStatement *stmt,GdaSet *params); void browser_connection_keep_variables (BrowserConnection *bcnc,GdaSet *set); void browser_connection_load_variables (BrowserConnection *bcnc,GdaSet *set);
"busy" :Run First"favorites-changed" :Run First"meta-changed" :Run First"table-column-pref-changed" :Run First"transaction-status-changed" :Run First
The BrowserConnection object wraps a GdaConnection with some additionnal features. The wrapped GdaConnection is only accessible from within the BrowserConnection object, so to use a connection, you have to use the BrowserConnection's methods.
typedef struct {
GdaThreadWrapper *wrapper;
GSList *wrapper_jobs;
guint wrapper_results_timer;
gboolean long_timer;
gint nb_no_job_waits; /* number of times check_for_wrapper_result() has been
called without any job */
GHashTable *executed_statements; /* key = guint exec ID, value = a StatementResult pointer */
gulong meta_store_signal;
gulong transaction_status_signal;
gchar *name;
GdaConnection *cnc;
gchar *dict_file_name;
GdaSqlParser *parser;
GdaDsnInfo dsn_info;
GMutex *p_mstruct_mutex;
GSList *p_mstruct_list; /* private GdaMetaStruct list: while they are being created */
GdaMetaStruct *c_mstruct; /* last GdaMetaStruct up to date, ready to be passed as @mstruct */
GdaMetaStruct *mstruct; /* public GdaMetaStruct: once it has been created and is no more modified */
BrowserFavorites *bfav;
gboolean busy;
gchar *busy_reason;
GdaConnection *store_cnc;
GdaSet *variables;
GSList *results_list; /* list of #ExecCallbackData pointers */
gulong results_timer_id;
} BrowserConnectionPrivate;
BrowserConnection * browser_connection_new (GdaConnection *cnc);
Creates a new BrowserConnection object wrapping cnc. The browser_core_take_connection() method
must be called on the new object to mahe it managed by the browser.
To close the new connection, use browser_core_close_connection().
|
a GdaConnection |
Returns : |
a new object |
const gchar * browser_connection_get_name (BrowserConnection *bcnc);
|
a BrowserConnection |
Returns : |
bcnc's name |
const GdaDsnInfo * browser_connection_get_information (BrowserConnection *bcnc);
Get some information about the connection
|
a BrowserConnection |
Returns : |
a pointer to the associated GdaDsnInfo |
gboolean browser_connection_is_busy (BrowserConnection *bcnc,gchar **out_reason);
Tells if bcnc is currently busy or not.
|
a BrowserConnection |
|
a pointer to store a copy of the reason bcnc is busy (will be set
to NULL if bcnc is not busy), or NULL
|
Returns : |
TRUE if bcnc is busy |
void browser_connection_update_meta_data (BrowserConnection *bcnc);
Make bcnc update its meta store in the background.
|
a BrowserConnection |
void browser_connection_meta_data_changed
(BrowserConnection *bcnc);
Call this function if the meta data has been changed directly (ie. for example after declaring or undeclaring a foreign key). This call creates a new GdaMetaStruct internally used.
|
a BrowserConnection |
GdaMetaStruct * browser_connection_get_meta_struct (BrowserConnection *bcnc);
Get the GdaMetaStruct maintained up to date by bcnc.
|
a BrowserConnection |
Returns : |
a GdaMetaStruct, the caller does not have any reference to it. |
GdaMetaStore * browser_connection_get_meta_store (BrowserConnection *bcnc);
|
a BrowserConnection |
Returns : |
bcnc's GdaMetaStore, the caller does not have any reference to it. |
const gchar * browser_connection_get_dictionary_file
(BrowserConnection *bcnc);
|
a BrowserConnection |
Returns : |
the dictionary file name used by bcnc, or NULL
|
BrowserFavorites * browser_connection_get_favorites (BrowserConnection *bcnc);
Get bcnc's favorites handler
|
a BrowserConnection |
Returns : |
the BrowserFavorites used by bcnc
|
gchar ** browser_connection_get_completions (BrowserConnection *bcnc,const gchar *sql,gint start,gint end);
|
a BrowserConnection |
Returns : |
a new array of strings, or NULL (use g_strfreev() to free the returned array) |
GdaSqlParser * browser_connection_create_parser (BrowserConnection *bcnc);
Get a new GdaSqlParser object for bcnc
|
a BrowserConnection |
Returns : |
a new GdaSqlParser |
gchar * browser_connection_render_pretty_sql (BrowserConnection *bcnc,GdaStatement *stmt);
Renders stmt as SQL well indented
|
a BrowserConnection |
|
a GdaStatement |
Returns : |
a new string |
guint browser_connection_execute_statement (BrowserConnection *bcnc,GdaStatement *stmt,GdaSet *params,GdaStatementModelUsage model_usage,gboolean need_last_insert_row,GError **error);
Executes stmt by bcnc. Unless specific requirements, it's easier to use
browser_connection_execute_statement_cb().
|
a BrowserConnection |
|
a GdaStatement |
|
a GdaSet as parameters, or NULL
|
|
how the returned data model (if any) will be used |
|
TRUE if the values of the last interted row must be computed |
|
a place to store errors, or NULL
|
Returns : |
a job ID, to be used with browser_connection_execution_get_result(), or 0 if an
error occurred |
GObject * browser_connection_execution_get_result (BrowserConnection *bcnc,guint exec_id,GdaSet **last_insert_row,GError **error);
Pick up the result of the exec_id's execution.
|
a BrowserConnection |
|
the ID of the excution |
|
a place to store the last inserted row, if any, or NULL
|
|
a place to store errors, or NULL
|
Returns : |
the execution result, or NULL if either an error occurred or the result is not yet ready |
void (*BrowserConnectionExecuteCallback) (BrowserConnection *bcnc,guint exec_id,GObject *out_result,GdaSet *out_last_inserted_row,GError *error,gpointer data);
Callback function called by browser_connection_execute_statement_cb(). If you need to keep
some of the arguments for a later usage, you need to ref/copy them.
None of the passed arguments must not be modified
guint browser_connection_execute_statement_cb (BrowserConnection *bcnc,GdaStatement *stmt,GdaSet *params,GdaStatementModelUsage model_usage,gboolean need_last_insert_row,BrowserConnectionExecuteCallback callback,gpointer data,GError **error);
Executes stmt by bcnc and calls callback when done. This occurs in the UI thread and avoids
having to set up a waiting mechanism to call browser_connection_execution_get_result()
repeatedly.
|
a BrowserConnection |
|
a GdaStatement |
|
a GdaSet as parameters, or NULL
|
|
how the returned data model (if any) will be used |
|
TRUE if the values of the last interted row must be computed |
|
the function to call when statement has been executed |
|
data to pass to callback, or NULL
|
|
a place to store errors, or NULL
|
Returns : |
a job ID, or 0 if an error occurred |
gboolean browser_connection_normalize_sql_statement (BrowserConnection *bcnc,GdaSqlStatement *sqlst,GError **error);
See gda_sql_statement_normalize().
|
a BrowserConnection |
|
a GdaSqlStatement |
|
a place to store errors, or NULL
|
Returns : |
TRUE if no error occurred |
gboolean browser_connection_check_sql_statement_validify (BrowserConnection *bcnc,GdaSqlStatement *sqlst,GError **error);
guint browser_connection_rerun_select (BrowserConnection *bcnc,GdaDataModel *model,GError **error);
Re-execute model
|
a BrowserConnection object |
|
a GdaDataModel, which has to ba a GdaDataSelect |
|
a place to store errors, or NULL
|
Returns : |
a job ID, or 0 if an error occurred |
guint browser_connection_rerun_select_cb (BrowserConnection *bcnc,GdaDataModel *model,BrowserConnectionExecuteCallback callback,gpointer data,GError **error);
Re-execute model.
Warning: gda_data_model_freeze() and gda_data_model_thaw() should be used
before and after this call since the model will signal its changes in a thread
which is not the GUI thread.
|
a BrowserConnection object |
|
a GdaDataModel, which has to ba a GdaDataSelect |
|
the function to call when statement has been executed |
|
data to pass to callback, or NULL
|
|
a place to store errors, or NULL
|
Returns : |
a job ID, or 0 if an error occurred |
gboolean browser_connection_begin (BrowserConnection *bcnc,GError **error);
Begins a transaction
|
a BrowserConnection |
|
a place to store errors, or NULL
|
gboolean browser_connection_commit (BrowserConnection *bcnc,GError **error);
Commits a transaction
|
a BrowserConnection |
|
a place to store errors, or NULL
|
gboolean browser_connection_rollback (BrowserConnection *bcnc,GError **error);
Rolls back a transaction
|
a BrowserConnection |
|
a place to store errors, or NULL
|
GdaTransactionStatus * browser_connection_get_transaction_status
(BrowserConnection *bcnc);
Retuns: the GdaTransactionStatus of the connection, or NULL
|
a BrowserConnection |
gboolean browser_connection_set_table_column_attribute (BrowserConnection *bcnc,GdaMetaTable *table,GdaMetaTableColumn *column,const gchar *attr_name,const gchar *value,GError **error);
gchar * browser_connection_get_table_column_attribute (BrowserConnection *bcnc,GdaMetaTable *table,GdaMetaTableColumn *column,const gchar *attr_name,GError **error);
void browser_connection_define_ui_plugins_for_batch (BrowserConnection *bcnc,GdaBatch *batch,GdaSet *params);
Calls browser_connection_define_ui_plugins_for_stmt() for each statement in batch
|
a BrowserConnection object |
|
a GdaBatch |
|
a GdaSet (usually created with gda_batch_get_parameters()) |
void browser_connection_define_ui_plugins_for_stmt (BrowserConnection *bcnc,GdaStatement *stmt,GdaSet *params);
Analyses stmt and assign plugins to each GdaHolder in params according to the preferences stored
for each table's field, defined at some point using browser_connection_set_table_column_attribute().
|
a BrowserConnection object |
|
a GdaStatement |
|
a GdaSet (usually created with gda_statement_get_parameters()) |
void browser_connection_keep_variables (BrowserConnection *bcnc,GdaSet *set);
Makes a copy of the variables in set and keep them in bcnc. Retreive them
using browser_connection_load_variables()
|
a BrowserConnection object |
|
a GdaSet containing variables for which a copy has to be done |
void browser_connection_load_variables (BrowserConnection *bcnc,GdaSet *set);
For each GdaHolder in set, set the value if one is available in bcnc.
|
a BrowserConnection object |
|
a GdaSet which will in the end contain (if any) variables stored in bcnc
|
"gda-connection" property"gda-connection" GdaConnection* : Write / Construct Only
Connection to use.
"busy" signalvoid user_function (BrowserConnection *browserconnection,
gboolean arg1,
gchar *arg2,
gpointer user_data) : Run First
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"favorites-changed" signalvoid user_function (BrowserConnection *browserconnection,
gpointer user_data) : Run First
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"meta-changed" signalvoid user_function (BrowserConnection *browserconnection,
GdaMetaStruct *arg1,
gpointer user_data) : Run First
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"table-column-pref-changed" signalvoid user_function (BrowserConnection *browserconnection,
gpointer arg1,
gpointer arg2,
gchar *arg3,
gchar *arg4,
gpointer user_data) : Run First
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"transaction-status-changed" signalvoid user_function (BrowserConnection *browserconnection,
gpointer user_data) : Run First
|
the object which received the signal. |
|
user data set when the signal handler was connected. |