[gnome-db] GdaDataProxy



Hi,

I'm doing the folowing:
{
 GdaQuery *query;
 GdaDataModel *model;
 GtkWidget *form;
 GdaDict *dict = gda_dict_new();

 gda_dict_set_connection(dict,conn);
 gda_dict_update_dbms_meta_data(dict,0,NULL,NULL);

 query =
   gda_query_new_from_sql (dict,
               "SELECT id,name,job,department,office,rg,"
         "cpf,ctps,pis,address FROM employee",
               NULL);
 model = gda_data_model_query_new (query);
 g_object_unref (query);

 gda_data_model_query_set_modification_query (GDA_DATA_MODEL_QUERY (model),
                          "UPDATE employee SET "
                          "id=##[:name='+0' :type='gchararray'], "
                          "name=##[:name='+1' :type='gchararray'],"
                          "job=##[:name='+2' :type='gchararray'], "
                          "department=##[:name='+3' :type='gchararray'], "
                          "office=##[:name='+4' :type='gchararray'], "
                          "rg=##[:name='+5' :type='gchararray'], "
                          "cpf=##[:name='+6' :type='gchararray'], "
                          "ctps=##[:name='+7' :type='gchararray'], "
                          "pis=##[:name='+8' :type='gchararray'], "
                          "address=##[:name='+9' :type='gchararray'] "
                          "WHERE id=##[:name='-0' :type='gchararray']",
                          NULL);
 gda_data_model_query_set_modification_query (GDA_DATA_MODEL_QUERY (model),
"DELETE FROM employee WHERE id=##[:name='-0' :type='gchararray']",
                          NULL);
 gda_data_model_query_set_modification_query (GDA_DATA_MODEL_QUERY (model),
"INSERT INTO employee (id,name,job,department,office,rg,"
                "cpf,ctps,pis,address) "
                          "VALUES ("
                          "##[:name='+0' :type='gchararray'], "
                          "##[:name='+1' :type='gchararray'],"
                          "##[:name='+2' :type='gchararray'], "
                          "##[:name='+3' :type='gchararray'], "
                          "##[:name='+4' :type='gchararray'], "
                          "##[:name='+5' :type='gchararray'], "
                          "##[:name='+6' :type='gchararray'], "
                          "##[:name='+7' :type='gchararray'], "
                          "##[:name='+8' :type='gchararray'], "
                          "##[:name='+9' :type='gchararray'] "
                ")",
                          NULL);

 form = gnome_db_raw_form_new(model);
 g_object_unref (model);

 {
   GnomeDbFormLayoutSpec spec;
   spec.xml_object = xml;
   spec.root_element = "emp_form";
   spec.form_prefix = "emp_form_box";
   g_object_set(G_OBJECT(form),"layout_spec", &spec,NULL);
 }

   {
   GdaDataProxy *proxy;
   gboolean ok;
   GError *err = NULL;
   gint newrow;
   GdaDataModelIter *iter;
proxy = gnome_db_data_widget_get_proxy(GNOME_DB_DATA_WIDGET(form)); newrow = gda_data_model_get_n_rows(GDA_DATA_MODEL(proxy));
   g_print("ProxyNRows:%d\n",newrow);
iter = gnome_db_data_widget_get_current_data(GNOME_DB_DATA_WIDGET(form)); ok = gda_data_model_iter_is_valid(iter);
   g_print("Valid Iter:%d\n",ok);
newrow = gda_data_model_iter_get_row(iter);
   g_print("Iter Row:%d\n",newrow);
newrow = gda_data_proxy_get_proxied_model_n_rows(proxy);
   g_print("ProxyGetProxiedModelNRows:%d\n",newrow);
 }
}

(My table has one row)

This give me that the Iter is invalid = 0, and gda_data_model_iter_get_row give me -1, and gda_data_model_get_n_rows(GDA_DATA_MODEL(proxy)) = 0, gda_data_proxy_get_proxied_model_n_rows(proxy) = 1 But if I inspect this same values after a call gtk_main it gives me the right values.

My question is, what I need to do to initialize the proxy correctly?

Thank you





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]