return ret;
}
+static GValue
+*_set_gvalue_stringify_from_datamodel (GdaExGridColumn *col, GValue *gval, GdaDataModel *dm, GdaDataModelIter *dm_iter, const gchar *field_name)
+{
+ GdaColumn *gda_col;
+ GType gda_col_gtype;
+
+ GDateTime *gdatetime;
+
+ gda_col = gda_data_model_describe_column (dm, gda_data_model_get_column_index (dm, field_name));
+ gda_col_gtype = gda_column_get_g_type (gda_col);
+
+ switch (gda_col_gtype)
+ {
+ case G_TYPE_STRING:
+ g_value_set_string (gval, _gettext (gdaex_data_model_iter_get_field_value_stringify_at (dm_iter, field_name)));
+ break;
+
+ case G_TYPE_BOOLEAN:
+ g_value_set_string (gval, gdaex_data_model_iter_get_field_value_boolean_at (dm_iter, field_name) ? "X" : "");
+ break;
+
+ case G_TYPE_INT:
+ case G_TYPE_FLOAT:
+ case G_TYPE_DOUBLE:
+ g_value_set_string (gval, gdaex_format_money (gdaex_data_model_iter_get_field_value_double_at (dm_iter, field_name),
+ gdaex_grid_column_get_decimals (col), FALSE));
+ break;
+
+ default:
+ if (gda_col_gtype == G_TYPE_DATE
+ || gda_col_gtype == G_TYPE_DATE_TIME
+ || gda_col_gtype == GDA_TYPE_TIMESTAMP)
+ {
+ gdatetime = gdaex_data_model_iter_get_field_value_gdatetime_at (dm_iter, field_name);
+ /* TODO find default format from locale */
+ g_value_set_string (gval, g_date_time_format (gdatetime, gda_col_gtype == G_TYPE_DATE ? "%d/%m/%Y" : "%d/%m/%Y %H.%M.%S"));
+ g_date_time_unref (gdatetime);
+ }
+ else
+ {
+ g_value_set_string (gval, _gettext (gdaex_data_model_iter_get_field_value_stringify_at (dm_iter, field_name)));
+ }
+ break;
+ }
+}
+
/**
* gdaex_grid_fill_from_datamodel_with_missing_func_with_sel:
* @grid: a #GdaExGrid object.
switch (col_gtype)
{
case G_TYPE_STRING:
- gda_col = gda_data_model_describe_column (dm, gda_data_model_get_column_index (dm, field_name));
- gda_col_gtype = gda_column_get_g_type (gda_col);
-
- switch (gda_col_gtype)
- {
- case G_TYPE_STRING:
- g_value_set_string (&gval, _gettext (gdaex_data_model_iter_get_field_value_stringify_at (dm_iter, field_name)));
- break;
-
- case G_TYPE_BOOLEAN:
- g_value_set_string (&gval, gdaex_data_model_iter_get_field_value_boolean_at (dm_iter, field_name) ? "X" : "");
- break;
-
- case G_TYPE_INT:
- case G_TYPE_FLOAT:
- case G_TYPE_DOUBLE:
- dval = gdaex_data_model_iter_get_field_value_double_at (dm_iter, field_name);
- g_value_set_string (&gval, gdaex_format_money (dval, gdaex_grid_column_get_decimals ((GdaExGridColumn *)g_ptr_array_index (priv->columns, col)), FALSE));
- break;
-
- default:
- if (gda_col_gtype == G_TYPE_DATE
- || gda_col_gtype == G_TYPE_DATE_TIME
- || gda_col_gtype == GDA_TYPE_TIMESTAMP)
- {
- gdatetime = gdaex_data_model_iter_get_field_value_gdatetime_at (dm_iter, field_name);
- /* TODO find default format from locale */
- g_value_set_string (&gval, g_date_time_format (gdatetime, gda_col_gtype == G_TYPE_DATE ? "%d/%m/%Y" : "%d/%m/%Y %H.%M.%S"));
- g_date_time_unref (gdatetime);
- }
- else
- {
- g_value_set_string (&gval, _gettext (gdaex_data_model_iter_get_field_value_stringify_at (dm_iter, field_name)));
- }
- break;
- }
-
+ _set_gvalue_stringify_from_datamodel((GdaExGridColumn *)g_ptr_array_index (priv->columns, col), &gval, dm, dm_iter, field_name);
break;
case G_TYPE_INT: