...
 
Commits (3)
...@@ -760,7 +760,7 @@ run_context_push_with_stmt (GdaReportEngine *engine, RunContext *context, GdaCon ...@@ -760,7 +760,7 @@ run_context_push_with_stmt (GdaReportEngine *engine, RunContext *context, GdaCon
GdaHolder *param; GdaHolder *param;
GValue *value; GValue *value;
gchar *name; gchar *name;
param = gda_holder_new (G_TYPE_INT); param = gda_holder_new (G_TYPE_INT, "id");
value = gda_value_new (G_TYPE_INT); value = gda_value_new (G_TYPE_INT);
g_value_set_int (value, gda_data_model_get_n_rows (model)); g_value_set_int (value, gda_data_model_get_n_rows (model));
if (! gda_holder_set_value (param, value, error)) { if (! gda_holder_set_value (param, value, error)) {
......
...@@ -500,12 +500,10 @@ paramlist_param_attr_changed_cb (G_GNUC_UNUSED GdaSet *paramlist, GdaHolder *par ...@@ -500,12 +500,10 @@ paramlist_param_attr_changed_cb (G_GNUC_UNUSED GdaSet *paramlist, GdaHolder *par
attrs |= toset ? 0 : GDA_VALUE_ATTR_CAN_BE_NULL; attrs |= toset ? 0 : GDA_VALUE_ATTR_CAN_BE_NULL;
mask |= GDA_VALUE_ATTR_CAN_BE_NULL; mask |= GDA_VALUE_ATTR_CAN_BE_NULL;
defv = gda_holder_get_attribute (param, GDA_ATTRIBUTE_IS_DEFAULT); if (gda_holder_value_is_default (param)) {
if (defv && (G_VALUE_TYPE (defv) == G_TYPE_BOOLEAN) && g_value_get_boolean (defv)) {
attrs |= GDA_VALUE_ATTR_IS_DEFAULT; attrs |= GDA_VALUE_ATTR_IS_DEFAULT;
mask |= GDA_VALUE_ATTR_IS_DEFAULT; mask |= GDA_VALUE_ATTR_IS_DEFAULT;
} }
g_signal_handlers_block_by_func (G_OBJECT (entry), g_signal_handlers_block_by_func (G_OBJECT (entry),
G_CALLBACK (entry_contents_modified), sentry); G_CALLBACK (entry_contents_modified), sentry);
gdaui_data_entry_set_attributes (GDAUI_DATA_ENTRY (entry), attrs, mask); gdaui_data_entry_set_attributes (GDAUI_DATA_ENTRY (entry), attrs, mask);
...@@ -912,14 +910,7 @@ create_entry_widget (SingleEntry *sentry) ...@@ -912,14 +910,7 @@ create_entry_widget (SingleEntry *sentry)
value = default_val; value = default_val;
/* create entry */ /* create entry */
plugin_val = gda_holder_get_attribute (param, GDAUI_ATTRIBUTE_PLUGIN); g_object_get (param, "plugin", &plugin, NULL);
if (plugin_val) {
if (G_VALUE_TYPE (plugin_val) == G_TYPE_STRING)
plugin = g_value_get_string (plugin_val);
else
g_warning (_("The '%s' attribute should be a G_TYPE_STRING value"),
GDAUI_ATTRIBUTE_PLUGIN);
}
entry = GTK_WIDGET (gdaui_new_data_entry (type, plugin)); entry = GTK_WIDGET (gdaui_new_data_entry (type, plugin));
sentry->entry = GDAUI_DATA_ENTRY (entry); sentry->entry = GDAUI_DATA_ENTRY (entry);
...@@ -1300,8 +1291,7 @@ load_xml_layout_column (GdauiBasicForm *form, xmlNodePtr box_node) ...@@ -1300,8 +1291,7 @@ load_xml_layout_column (GdauiBasicForm *form, xmlNodePtr box_node)
if (plugin && sentry->single_param) { if (plugin && sentry->single_param) {
GValue *value; GValue *value;
value = gda_value_new_from_string ((gchar*) plugin, G_TYPE_STRING); value = gda_value_new_from_string ((gchar*) plugin, G_TYPE_STRING);
gda_holder_set_attribute_static (sentry->single_param, g_object_set (sentry->single_param, "plugin", value, NULL);
GDAUI_ATTRIBUTE_PLUGIN, value);
gda_value_free (value); gda_value_free (value);
} }
if (plugin) if (plugin)
......
...@@ -55,6 +55,7 @@ catch_css_parsing_errors (GtkCssProvider *provider, ...@@ -55,6 +55,7 @@ catch_css_parsing_errors (GtkCssProvider *provider,
g_warning (_("Error parsing CSS: %s"), error->message); g_warning (_("Error parsing CSS: %s"), error->message);
} }
extern void _gdaui_register_resource (void);
/** /**
* gdaui_init: * gdaui_init:
* *
......
...@@ -707,14 +707,7 @@ create_columns_data (GdauiRawGrid *grid) ...@@ -707,14 +707,7 @@ create_columns_data (GdauiRawGrid *grid)
if (!title) if (!title)
title = g_strdup (_("No title")); title = g_strdup (_("No title"));
plugin_val = gda_holder_get_attribute (param, GDAUI_ATTRIBUTE_PLUGIN); g_object_get (param, "plugin", &plugin, NULL);
if (plugin_val) {
if (G_VALUE_TYPE (plugin_val) == G_TYPE_STRING)
plugin = g_value_get_string (plugin_val);
else
g_warning (_("The '%s' attribute should be a G_TYPE_STRING value"),
GDAUI_ATTRIBUTE_PLUGIN);
}
renderer = _gdaui_new_cell_renderer (g_type, plugin); renderer = _gdaui_new_cell_renderer (g_type, plugin);
cdata->data_cell = GTK_CELL_RENDERER (g_object_ref_sink ((GObject*) renderer)); cdata->data_cell = GTK_CELL_RENDERER (g_object_ref_sink ((GObject*) renderer));
g_hash_table_insert (priv->columns_hash, renderer, cdata); g_hash_table_insert (priv->columns_hash, renderer, cdata);
...@@ -856,8 +849,7 @@ reset_columns_in_xml_layout (GdauiRawGrid *grid, xmlNodePtr grid_node) ...@@ -856,8 +849,7 @@ reset_columns_in_xml_layout (GdauiRawGrid *grid, xmlNodePtr grid_node)
if (plugin && cdata->single_param) { if (plugin && cdata->single_param) {
GValue *value; GValue *value;
value = gda_value_new_from_string ((gchar*) plugin, G_TYPE_STRING); value = gda_value_new_from_string ((gchar*) plugin, G_TYPE_STRING);
gda_holder_set_attribute_static (cdata->single_param, g_object_set (cdata->single_param, "plugin", value, NULL);
GDAUI_ATTRIBUTE_PLUGIN, value);
gda_value_free (value); gda_value_free (value);
} }
if (plugin) if (plugin)
......
...@@ -1954,8 +1954,8 @@ create_internal_provider (const gchar *path, ...@@ -1954,8 +1954,8 @@ create_internal_provider (const gchar *path,
GValue *value; GValue *value;
#define GDAUI_ATTRIBUTE_PLUGIN "__gdaui_attr_plugin" #define GDAUI_ATTRIBUTE_PLUGIN "__gdaui_attr_plugin"
value = gda_value_new_from_string ("string:HIDDEN=true", G_TYPE_STRING); value = gda_value_new_from_string ("string:HIDDEN=true", G_TYPE_STRING);
gda_holder_set_attribute_static (h, GDAUI_ATTRIBUTE_PLUGIN, value); g_object_set (h, "plugin", value, NULL);
gda_value_free (value); gda_value_free (value);
} }
info->icon_id = icon_id ? g_strdup (icon_id) : g_strdup (prov_name); info->icon_id = icon_id ? g_strdup (icon_id) : g_strdup (prov_name);
......
...@@ -40,7 +40,7 @@ extern GdaAttributesManager *gda_holder_attributes_manager; ...@@ -40,7 +40,7 @@ extern GdaAttributesManager *gda_holder_attributes_manager;
/* private structure */ /* private structure */
typedef struct typedef struct
{ {
GdaDataModel *data_model; /* may be %NULL because there is only a weak ref on it */ GWeakRef data_model; /* may be %NULL because there is only a weak ref on it */
gulong model_changes_signals[3]; gulong model_changes_signals[3];
gboolean keep_param_changes; gboolean keep_param_changes;
gint row; /* -1 if row is unknown */ gint row; /* -1 if row is unknown */
...@@ -180,7 +180,7 @@ static void ...@@ -180,7 +180,7 @@ static void
gda_data_model_iter_init (GdaDataModelIter *iter) gda_data_model_iter_init (GdaDataModelIter *iter)
{ {
GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter); GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter);
priv->data_model = NULL; g_weak_ref_set (&priv->data_model, NULL);
priv->row = -1; priv->row = -1;
priv->model_changes_signals[0] = 0; priv->model_changes_signals[0] = 0;
priv->model_changes_signals[1] = 0; priv->model_changes_signals[1] = 0;
...@@ -191,9 +191,24 @@ gda_data_model_iter_init (GdaDataModelIter *iter) ...@@ -191,9 +191,24 @@ gda_data_model_iter_init (GdaDataModelIter *iter)
static void static void
model_row_updated_cb (GdaDataModel *model, gint row, GdaDataModelIter *iter) model_row_updated_cb (GdaDataModel *model, gint row, GdaDataModelIter *iter)
{ {
g_return_if_fail (model != NULL);
g_return_if_fail (GDA_IS_DATA_MODEL (model));
g_return_if_fail (iter != NULL);
g_return_if_fail (GDA_IS_DATA_MODEL_ITER (iter));
GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter); GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter);
g_assert (model == priv->data_model);
GdaDataModel *obj = g_weak_ref_get (&priv->data_model);
if (obj == NULL) {
g_warning (_("Iter has an invalid/non-existent reference to a data model"));
return;
}
if (model != obj) {
g_warning (_("Referenced data model in iterator doesn't belong to given data model"));
g_object_unref (obj);
return;
}
g_object_unref (obj);
/* sync parameters with the new values in row */ /* sync parameters with the new values in row */
if (priv->row == row) { if (priv->row == row) {
priv->keep_param_changes = TRUE; priv->keep_param_changes = TRUE;
...@@ -205,6 +220,11 @@ model_row_updated_cb (GdaDataModel *model, gint row, GdaDataModelIter *iter) ...@@ -205,6 +220,11 @@ model_row_updated_cb (GdaDataModel *model, gint row, GdaDataModelIter *iter)
static void static void
model_row_removed_cb (G_GNUC_UNUSED GdaDataModel *model, gint row, GdaDataModelIter *iter) model_row_removed_cb (G_GNUC_UNUSED GdaDataModel *model, gint row, GdaDataModelIter *iter)
{ {
g_return_if_fail (model != NULL);
g_return_if_fail (GDA_IS_DATA_MODEL (model));
g_return_if_fail (iter != NULL);
g_return_if_fail (GDA_IS_DATA_MODEL_ITER (iter));
GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter); GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter);
if (priv->row < 0) if (priv->row < 0)
...@@ -227,6 +247,11 @@ model_row_removed_cb (G_GNUC_UNUSED GdaDataModel *model, gint row, GdaDataModelI ...@@ -227,6 +247,11 @@ model_row_removed_cb (G_GNUC_UNUSED GdaDataModel *model, gint row, GdaDataModelI
static void static void
define_holder_for_data_model_column (GdaDataModel *model, gint col, GdaDataModelIter *iter) define_holder_for_data_model_column (GdaDataModel *model, gint col, GdaDataModelIter *iter)
{ {
g_return_if_fail (model != NULL);
g_return_if_fail (GDA_IS_DATA_MODEL (model));
g_return_if_fail (iter != NULL);
g_return_if_fail (GDA_IS_DATA_MODEL_ITER (iter));
gchar *str; gchar *str;
GdaHolder *param; GdaHolder *param;
GdaColumn *column; GdaColumn *column;
...@@ -297,6 +322,11 @@ define_holder_for_data_model_column (GdaDataModel *model, gint col, GdaDataModel ...@@ -297,6 +322,11 @@ define_holder_for_data_model_column (GdaDataModel *model, gint col, GdaDataModel
static void static void
model_reset_cb (GdaDataModel *model, GdaDataModelIter *iter) model_reset_cb (GdaDataModel *model, GdaDataModelIter *iter)
{ {
g_return_if_fail (model != NULL);
g_return_if_fail (GDA_IS_DATA_MODEL (model));
g_return_if_fail (iter != NULL);
g_return_if_fail (GDA_IS_DATA_MODEL_ITER (iter));
gint row; gint row;
row = gda_data_model_iter_get_row (iter); row = gda_data_model_iter_get_row (iter);
...@@ -368,10 +398,13 @@ validate_holder_change_cb (GdaSet *paramlist, GdaHolder *param, const GValue *ne ...@@ -368,10 +398,13 @@ validate_holder_change_cb (GdaSet *paramlist, GdaHolder *param, const GValue *ne
iter = GDA_DATA_MODEL_ITER (paramlist); iter = GDA_DATA_MODEL_ITER (paramlist);
GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter); GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter);
GdaDataModel *model = g_weak_ref_get (&priv->data_model);
g_return_val_if_fail (priv->data_model != NULL, NULL); if (model == NULL) {
g_set_error (&error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_INVALID,
g_return_val_if_fail (GDA_IS_DATA_MODEL (priv->data_model), NULL); _("Invalid data model. Can't validate holder"));
return error;
}
if (new_value) if (new_value)
nvalue = (GValue*) new_value; nvalue = (GValue*) new_value;
...@@ -379,9 +412,9 @@ validate_holder_change_cb (GdaSet *paramlist, GdaHolder *param, const GValue *ne ...@@ -379,9 +412,9 @@ validate_holder_change_cb (GdaSet *paramlist, GdaHolder *param, const GValue *ne
nvalue = gda_value_new_null(); nvalue = gda_value_new_null();
iter = (GdaDataModelIter *) paramlist; iter = (GdaDataModelIter *) paramlist;
if (!priv->keep_param_changes && (priv->row >= 0) && (GDA_IS_DATA_MODEL (priv->data_model))) { if (!priv->keep_param_changes && (priv->row >= 0) && (GDA_IS_DATA_MODEL (model))) {
g_signal_handler_block (priv->data_model, priv->model_changes_signals [0]); g_signal_handler_block (model, priv->model_changes_signals [0]);
g_signal_handler_block (priv->data_model, priv->model_changes_signals [1]); g_signal_handler_block (model, priv->model_changes_signals [1]);
/* propagate the value update to the data model */ /* propagate the value update to the data model */
col = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (param), "model_col")) - 1; col = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (param), "model_col")) - 1;
...@@ -395,18 +428,22 @@ validate_holder_change_cb (GdaSet *paramlist, GdaHolder *param, const GValue *ne ...@@ -395,18 +428,22 @@ validate_holder_change_cb (GdaSet *paramlist, GdaHolder *param, const GValue *ne
} }
else { else {
g_print ("using Data Model default set_value_at\n"); g_print ("using Data Model default set_value_at\n");
gda_data_model_set_value_at ((GdaDataModel *) priv->data_model, col, priv->row, nvalue, &error); gda_data_model_set_value_at (model, col, priv->row, nvalue, &error);
} }
g_signal_handler_unblock (priv->data_model, priv->model_changes_signals [0]); g_signal_handler_unblock (model, priv->model_changes_signals [0]);
g_signal_handler_unblock (priv->data_model, priv->model_changes_signals [1]); g_signal_handler_unblock (model, priv->model_changes_signals [1]);
} }
if (!new_value) if (!new_value)
gda_value_free (nvalue); gda_value_free (nvalue);
if (!error && GDA_SET_CLASS(gda_data_model_iter_parent_class)->validate_holder_change) if (!error && GDA_SET_CLASS(gda_data_model_iter_parent_class)->validate_holder_change) {
g_object_unref (model);
/* for the parent class */ /* for the parent class */
return (GDA_SET_CLASS(gda_data_model_iter_parent_class))->validate_holder_change (paramlist, param, new_value); return (GDA_SET_CLASS(gda_data_model_iter_parent_class))->validate_holder_change (paramlist, param, new_value);
}
g_object_unref (model);
return error; return error;
} }
...@@ -430,13 +467,21 @@ holder_attr_changed_cb (GdaSet *paramlist, GdaHolder *param, const gchar *att_na ...@@ -430,13 +467,21 @@ holder_attr_changed_cb (GdaSet *paramlist, GdaHolder *param, const gchar *att_na
GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter); GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter);
if (!GDA_IS_DATA_PROXY (priv->data_model)) GdaDataModel *model = g_weak_ref_get (&priv->data_model);
if (model == NULL) {
return; return;
}
if (!GDA_IS_DATA_PROXY (model)) {
g_object_unref (model);
return;
}
if (!strcmp (att_name, GDA_ATTRIBUTE_IS_DEFAULT) && if (!strcmp (att_name, GDA_ATTRIBUTE_IS_DEFAULT) &&
!priv->keep_param_changes && (priv->row >= 0)) { !priv->keep_param_changes && (priv->row >= 0)) {
g_signal_handler_block (priv->data_model, priv->model_changes_signals [0]); g_signal_handler_block (model, priv->model_changes_signals [0]);
g_signal_handler_block (priv->data_model, priv->model_changes_signals [1]); g_signal_handler_block (model, priv->model_changes_signals [1]);
/* propagate the value update to the data model */ /* propagate the value update to the data model */
col = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (param), "model_col")) - 1; col = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (param), "model_col")) - 1;
...@@ -445,17 +490,19 @@ holder_attr_changed_cb (GdaSet *paramlist, GdaHolder *param, const gchar *att_na ...@@ -445,17 +490,19 @@ holder_attr_changed_cb (GdaSet *paramlist, GdaHolder *param, const gchar *att_na
if (att_value && g_value_get_boolean (att_value)) if (att_value && g_value_get_boolean (att_value))
toset = TRUE; toset = TRUE;
if (toset && gda_holder_get_default_value (param)) if (toset && gda_holder_get_default_value (param))
gda_data_proxy_alter_value_attributes (GDA_DATA_PROXY (priv->data_model), gda_data_proxy_alter_value_attributes (GDA_DATA_PROXY (model),
priv->row, col, priv->row, col,
GDA_VALUE_ATTR_CAN_BE_DEFAULT | GDA_VALUE_ATTR_IS_DEFAULT); GDA_VALUE_ATTR_CAN_BE_DEFAULT | GDA_VALUE_ATTR_IS_DEFAULT);
g_signal_handler_unblock (priv->data_model, priv->model_changes_signals [0]); g_signal_handler_unblock (model, priv->model_changes_signals [0]);
g_signal_handler_unblock (priv->data_model, priv->model_changes_signals [1]); g_signal_handler_unblock (model, priv->model_changes_signals [1]);
} }
/* for the parent class */ /* for the parent class */
if ((GDA_SET_CLASS(gda_data_model_iter_parent_class))->holder_attr_changed) if ((GDA_SET_CLASS(gda_data_model_iter_parent_class))->holder_attr_changed)
(GDA_SET_CLASS(gda_data_model_iter_parent_class))->holder_attr_changed (paramlist, param, att_name, att_value); (GDA_SET_CLASS(gda_data_model_iter_parent_class))->holder_attr_changed (paramlist, param, att_name, att_value);
g_object_unref (model);
} }
static void static void
...@@ -468,13 +515,12 @@ gda_data_model_iter_finalize (GObject *object) ...@@ -468,13 +515,12 @@ gda_data_model_iter_finalize (GObject *object)
iter = GDA_DATA_MODEL_ITER (object); iter = GDA_DATA_MODEL_ITER (object);
GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter); GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter);
if (priv->data_model) { GdaDataModel *model = g_weak_ref_get (&priv->data_model);
g_signal_handler_disconnect (priv->data_model, priv->model_changes_signals [0]); if (model != NULL) {
g_signal_handler_disconnect (priv->data_model, priv->model_changes_signals [1]); g_signal_handler_disconnect (model, priv->model_changes_signals [0]);
g_signal_handler_disconnect (priv->data_model, priv->model_changes_signals [2]); g_signal_handler_disconnect (model, priv->model_changes_signals [1]);
g_object_remove_weak_pointer (G_OBJECT (priv->data_model), g_signal_handler_disconnect (model, priv->model_changes_signals [2]);
(gpointer*) &(priv->data_model)); g_object_unref (model);
priv->data_model = NULL;
} }
/* parent class */ /* parent class */
...@@ -496,25 +542,26 @@ gda_data_model_iter_set_property (GObject *object, ...@@ -496,25 +542,26 @@ gda_data_model_iter_set_property (GObject *object,
case PROP_DATA_MODEL: { case PROP_DATA_MODEL: {
GdaDataModel *model; GdaDataModel *model;
GObject* ptr = g_value_get_object (value); GObject* ptr = g_value_dup_object (value);
g_return_if_fail (ptr && GDA_IS_DATA_MODEL (ptr)); if (!GDA_IS_DATA_MODEL (ptr)) {
g_object_unref (ptr);
g_warning (_("Invalid data model object. Can't set property"));
return;
}
model = GDA_DATA_MODEL (ptr); model = GDA_DATA_MODEL (ptr);
if (priv->data_model) { GdaDataModel *current = g_weak_ref_get (&priv->data_model);
if (priv->data_model == model) if (current != NULL) {
if (current == model)
return; return;
g_signal_handler_disconnect (priv->data_model, g_signal_handler_disconnect (current,
priv->model_changes_signals [0]); priv->model_changes_signals [0]);
g_signal_handler_disconnect (priv->data_model, g_signal_handler_disconnect (current,
priv->model_changes_signals [1]); priv->model_changes_signals [1]);
g_signal_handler_disconnect (priv->data_model, g_signal_handler_disconnect (current,
priv->model_changes_signals [2]); priv->model_changes_signals [2]);
g_object_remove_weak_pointer (G_OBJECT (priv->data_model),
(gpointer*) &(priv->data_model));
} }
priv->data_model = model; g_weak_ref_set (&priv->data_model, model);
g_object_add_weak_pointer (G_OBJECT (priv->data_model),
(gpointer*) &(priv->data_model));
priv->model_changes_signals [0] = g_signal_connect (G_OBJECT (model), "row-updated", priv->model_changes_signals [0] = g_signal_connect (G_OBJECT (model), "row-updated",
G_CALLBACK (model_row_updated_cb), G_CALLBACK (model_row_updated_cb),
...@@ -525,6 +572,7 @@ gda_data_model_iter_set_property (GObject *object, ...@@ -525,6 +572,7 @@ gda_data_model_iter_set_property (GObject *object,
priv->model_changes_signals [2] = g_signal_connect (G_OBJECT (model), "reset", priv->model_changes_signals [2] = g_signal_connect (G_OBJECT (model), "reset",
G_CALLBACK (model_reset_cb), iter); G_CALLBACK (model_reset_cb), iter);
model_reset_cb (GDA_DATA_MODEL (ptr), iter); model_reset_cb (GDA_DATA_MODEL (ptr), iter);
g_object_unref (ptr);
break; break;
} }
case PROP_FORCED_MODEL: { case PROP_FORCED_MODEL: {
...@@ -561,11 +609,23 @@ gda_data_model_iter_get_property (GObject *object, ...@@ -561,11 +609,23 @@ gda_data_model_iter_get_property (GObject *object,
if (priv) { if (priv) {
switch (param_id) { switch (param_id) {
case PROP_DATA_MODEL: case PROP_DATA_MODEL:
g_value_set_object (value, G_OBJECT (priv->data_model)); {
GObject *obj = g_weak_ref_get (&priv->data_model);
g_value_set_object (value, obj);
if (obj != NULL) {
g_object_unref (obj);
}
}
break; break;
case PROP_FORCED_MODEL: case PROP_FORCED_MODEL:
g_warning ("Deprecated property, not to be used"); {
g_value_set_object (value, G_OBJECT (priv->data_model)); g_warning ("Deprecated property, not to be used");
GObject *obj = g_weak_ref_get (&priv->data_model);
g_value_set_object (value, obj);
if (obj != NULL) {
g_object_unref (obj);
}
}
break; break;
case PROP_CURRENT_ROW: case PROP_CURRENT_ROW:
g_value_set_int (value, priv->row); g_value_set_int (value, priv->row);
...@@ -624,12 +684,14 @@ real_gda_data_model_iter_move_to_row (GdaDataModelIter *iter, gint row) ...@@ -624,12 +684,14 @@ real_gda_data_model_iter_move_to_row (GdaDataModelIter *iter, gint row)
g_return_val_if_fail (GDA_IS_DATA_MODEL_ITER (iter), FALSE); g_return_val_if_fail (GDA_IS_DATA_MODEL_ITER (iter), FALSE);
GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter); GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter);
GdaDataModel *model; GdaDataModel *model = g_weak_ref_get (&priv->data_model);
gboolean ret = FALSE;
model = priv->data_model;
g_return_val_if_fail (model, FALSE);
return gda_data_model_iter_move_to_row_default (model, iter, row); ret = gda_data_model_iter_move_to_row_default (model, iter, row);
if (model != NULL) {
g_object_unref (model);
}
return ret;
} }
static void static void
...@@ -744,12 +806,15 @@ real_gda_data_model_iter_move_next (GdaDataModelIter *iter) ...@@ -744,12 +806,15 @@ real_gda_data_model_iter_move_next (GdaDataModelIter *iter)
g_return_val_if_fail (GDA_IS_DATA_MODEL_ITER (iter), FALSE); g_return_val_if_fail (GDA_IS_DATA_MODEL_ITER (iter), FALSE);
GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter); GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter);
gboolean ret = FALSE;
g_return_val_if_fail (priv, FALSE); model = g_weak_ref_get (&priv->data_model);
g_return_val_if_fail (priv->data_model, FALSE);
model = priv->data_model; ret = gda_data_model_iter_move_next_default (model, iter);
return gda_data_model_iter_move_next_default (model, iter); if (model != NULL) {
g_object_unref (model);
}
return ret;
} }
/** /**
...@@ -849,13 +914,15 @@ real_gda_data_model_iter_move_prev (GdaDataModelIter *iter) ...@@ -849,13 +914,15 @@ real_gda_data_model_iter_move_prev (GdaDataModelIter *iter)
g_return_val_if_fail (GDA_IS_DATA_MODEL_ITER (iter), FALSE); g_return_val_if_fail (GDA_IS_DATA_MODEL_ITER (iter), FALSE);
GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter); GdaDataModelIterPrivate *priv = gda_data_model_iter_get_instance_private (iter);
gboolean ret = FALSE;
g_return_val_if_fail (priv, FALSE); model = g_weak_ref_get (&priv->data_model);
g_return_val_if_fail (priv->data_model, FALSE);
model = priv->data_model;
/* default method */ /* default method */
return gda_data_model_iter_move_prev_default (model, iter); ret = gda_data_model_iter_move_prev_default (model, iter);
if (model != NULL) {
g_object_unref (model);
}
return ret;
} }
/** /**
......
...@@ -91,6 +91,7 @@ typedef enum { ...@@ -91,6 +91,7 @@ typedef enum {
GDA_DATA_MODEL_XML_FORMAT_ERROR, GDA_DATA_MODEL_XML_FORMAT_ERROR,
GDA_DATA_MODEL_TRUNCATED_ERROR, GDA_DATA_MODEL_TRUNCATED_ERROR,
GDA_DATA_MODEL_INVALID,
GDA_DATA_MODEL_OTHER_ERROR GDA_DATA_MODEL_OTHER_ERROR
} GdaDataModelError; } GdaDataModelError;
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "gda-marshal.h" #include "gda-marshal.h"
#include "gda-util.h" #include "gda-util.h"
#include <libgda.h> #include <libgda.h>
#include <libgda/gda-attributes-manager.h>
#include <libgda/gda-custom-marshal.h> #include <libgda/gda-custom-marshal.h>
/* /*
...@@ -65,19 +64,16 @@ static void bound_holder_changed_cb (GdaHolder *alias_of, GdaHolder *holder); ...@@ -65,19 +64,16 @@ static void bound_holder_changed_cb (GdaHolder *alias_of, GdaHolder *holder);
static void full_bound_holder_changed_cb (GdaHolder *alias_of, GdaHolder *holder); static void full_bound_holder_changed_cb (GdaHolder *alias_of, GdaHolder *holder);
static void gda_holder_set_full_bind (GdaHolder *holder, GdaHolder *alias_of); static void gda_holder_set_full_bind (GdaHolder *holder, GdaHolder *alias_of);
GdaAttributesManager *gda_holder_attributes_manager;
/* signals */ /* signals */
enum enum
{ {
CHANGED, CHANGED,
SOURCE_CHANGED, SOURCE_CHANGED,
VALIDATE_CHANGE, VALIDATE_CHANGE,
ATT_CHANGED, LAST_SIGNAL
LAST_SIGNAL
}; };
static gint gda_holder_signals[LAST_SIGNAL] = { 0, 0, 0, 0 }; static gint gda_holder_signals[LAST_SIGNAL] = { 0, 0, 0 };
/* properties */ /* properties */
...@@ -93,7 +89,8 @@ enum ...@@ -93,7 +89,8 @@ enum
PROP_SOURCE_COLUMN, PROP_SOURCE_COLUMN,
PROP_GDA_TYPE, PROP_GDA_TYPE,
PROP_NOT_NULL, PROP_NOT_NULL,
PROP_VALIDATE_CHANGES PROP_VALIDATE_CHANGES,
PROP_PLUGIN
}; };
...@@ -121,6 +118,9 @@ typedef struct { ...@@ -121,6 +118,9 @@ typedef struct {
GRecMutex mutex; GRecMutex mutex;
gboolean validate_changes; gboolean validate_changes;
gchar *name;
gchar *desc;
gchar *plugin;
} GdaHolderPrivate; } GdaHolderPrivate;
G_DEFINE_TYPE_WITH_CODE (GdaHolder, gda_holder, G_TYPE_OBJECT, G_DEFINE_TYPE_WITH_CODE (GdaHolder, gda_holder, G_TYPE_OBJECT,
G_ADD_PRIVATE (GdaHolder) G_ADD_PRIVATE (GdaHolder)
...@@ -154,13 +154,6 @@ m_validate_change (G_GNUC_UNUSED GdaHolder *holder, G_GNUC_UNUSED const GValue * ...@@ -154,13 +154,6 @@ m_validate_change (G_GNUC_UNUSED GdaHolder *holder, G_GNUC_UNUSED const GValue *
return NULL; return NULL;
} }
static void
holder_attribute_set_cb (GObject *obj, const gchar *att_name, const GValue *value,
G_GNUC_UNUSED gpointer data)
{
g_signal_emit (obj, gda_holder_signals[ATT_CHANGED], 0, att_name, value);
}
static void static void
gda_holder_class_init (GdaHolderClass *class) gda_holder_class_init (GdaHolderClass *class)
{ {
...@@ -192,22 +185,6 @@ gda_holder_class_init (GdaHolderClass *class) ...@@ -192,22 +185,6 @@ gda_holder_class_init (GdaHolderClass *class)
G_STRUCT_OFFSET (GdaHolderClass, changed), G_STRUCT_OFFSET (GdaHolderClass, changed),
NULL, NULL, NULL, NULL,
_gda_marshal_VOID__VOID, G_TYPE_NONE, 0); _gda_marshal_VOID__VOID, G_TYPE_NONE, 0);
/**
* GdaHolder::attribute-changed:
* @holder: the #GdaHolder
* @att_name: attribute's name
* @att_value: attribute's value
*
* Gets emitted when any @holder's attribute has changed
*/
gda_holder_signals[ATT_CHANGED] =
g_signal_new ("attribute-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaHolderClass, att_changed),
NULL, NULL,
_gda_marshal_VOID__STRING_VALUE, G_TYPE_NONE, 2,
G_TYPE_STRING, G_TYPE_VALUE);
/** /**
* GdaHolder::validate-change: * GdaHolder::validate-change:
...@@ -276,6 +253,9 @@ gda_holder_class_init (GdaHolderClass *class) ...@@ -276,6 +253,9 @@ gda_holder_class_init (GdaHolderClass *class)
"with the source-model property", "with the source-model property",
0, G_MAXINT, 0, 0, G_MAXINT, 0,
(G_PARAM_READABLE | G_PARAM_WRITABLE))); (G_PARAM_READABLE | G_PARAM_WRITABLE)));
g_object_class_install_property (object_class, PROP_PLUGIN,
g_param_spec_string ("plugin", NULL, "Holder's plugin", NULL,
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
/** /**
* GdaHolder:validate-changes: * GdaHolder:validate-changes:
...@@ -288,9 +268,6 @@ gda_holder_class_init (GdaHolderClass *class) ...@@ -288,9 +268,6 @@ gda_holder_class_init (GdaHolderClass *class)
g_object_class_install_property (object_class, PROP_VALIDATE_CHANGES, g_object_class_install_property (object_class, PROP_VALIDATE_CHANGES,
g_param_spec_boolean ("validate-changes", NULL, "Defines if the validate-change signal is emitted on value change", TRUE, g_param_spec_boolean ("validate-changes", NULL, "Defines if the validate-change signal is emitted on value change", TRUE,
(G_PARAM_READABLE | G_PARAM_WRITABLE))); (G_PARAM_READABLE | G_PARAM_WRITABLE)));
/* extra */
gda_holder_attributes_manager = gda_attributes_manager_new (TRUE, holder_attribute_set_cb, NULL);
} }
static void static void
...@@ -306,7 +283,7 @@ gda_holder_init (GdaHolder *holder) ...@@ -306,7 +283,7 @@ gda_holder_init (GdaHolder *holder)
{ {
GdaHolderPrivate *priv = gda_holder_get_instance_private (holder); GdaHolderPrivate *priv = gda_holder_get_instance_private (holder);
priv->id = NULL; priv->id = g_strdup ("id");
priv->g_type = GDA_TYPE_NULL; priv->g_type = GDA_TYPE_NULL;
priv->full_bind = NULL; priv->full_bind = NULL;
...@@ -328,20 +305,25 @@ gda_holder_init (GdaHolder *holder) ...@@ -328,20 +305,25 @@ gda_holder_init (GdaHolder *holder)
g_rec_mutex_init (& (priv->mutex)); g_rec_mutex_init (& (priv->mutex));
priv->validate_changes = TRUE; priv->validate_changes = TRUE;
priv->name = NULL;
priv->desc = NULL;
priv->plugin = NULL;
} }
/** /**
* gda_holder_new: * gda_holder_new:
* @type: the #GType requested * @type: the #GType requested
* @id: an identifiation
* *
* Creates a new holder of type @type * Creates a new holder of type @type
* *
* Returns: a new #GdaHolder object * Returns: a new #GdaHolder object
*/ */
GdaHolder * GdaHolder *
gda_holder_new (GType type) gda_holder_new (GType type, const gchar *id)
{ {
return (GdaHolder*) g_object_new (GDA_TYPE_HOLDER, "g-type", type, NULL); g_return_val_if_fail (id != NULL, NULL);
return (GdaHolder*) g_object_new (GDA_TYPE_HOLDER, "g-type", type, "id", id, NULL);
} }
/** /**
...@@ -372,6 +354,12 @@ gda_holder_copy (GdaHolder *orig) ...@@ -372,6 +354,12 @@ gda_holder_copy (GdaHolder *orig)
if (priv->id) if (priv->id)
cpriv->id = g_strdup (priv->id); cpriv->id = g_strdup (priv->id);
if (priv->name)
cpriv->name = g_strdup (priv->name);
if (priv->desc)
cpriv->desc = g_strdup (priv->desc);
if (priv->plugin)
cpriv->plugin = g_strdup (priv->plugin);
if (priv->full_bind) if (priv->full_bind)
gda_holder_set_full_bind (holder, priv->full_bind); gda_holder_set_full_bind (holder, priv->full_bind);
...@@ -397,13 +385,6 @@ gda_holder_copy (GdaHolder *orig) ...@@ -397,13 +385,6 @@ gda_holder_copy (GdaHolder *orig)
if (priv->default_value) if (priv->default_value)
cpriv->default_value = gda_value_copy (priv->default_value); cpriv->default_value = gda_value_copy (priv->default_value);
cpriv->not_null = priv->not_null; cpriv->not_null = priv->not_null;
gda_attributes_manager_copy (gda_holder_attributes_manager, (gpointer) orig, gda_holder_attributes_manager, (gpointer) holder);
GValue *att_value;
g_value_set_boolean ((att_value = gda_value_new (G_TYPE_BOOLEAN)), cpriv->default_forced);
gda_holder_set_attribute_static (holder, GDA_ATTRIBUTE_IS_DEFAULT, att_value);
gda_value_free (att_value);
gda_holder_unlock ((GdaLockable*) orig); gda_holder_unlock ((GdaLockable*) orig);
return holder; return holder;
...@@ -438,22 +419,23 @@ gda_holder_new_inline (GType type, const gchar *id, ...) ...@@ -438,22 +419,23 @@ gda_holder_new_inline (GType type, const gchar *id, ...)
static GMutex serial_mutex; static GMutex serial_mutex;
static guint serial = 0; static guint serial = 0;
const gchar *idm = NULL;
g_print ("Creating inline: %s", id);
holder = gda_holder_new (type); if (id != NULL) {
idm = id;
} else {
idm = g_strdup_printf ("%d", serial++);
}
holder = gda_holder_new (type, idm);
GdaHolderPrivate *priv = gda_holder_get_instance_private (holder); GdaHolderPrivate *priv = gda_holder_get_instance_private (holder);
if (holder) { if (holder) {
GValue *value; GValue *value;
va_list ap; va_list ap;
GError *lerror = NULL; GError *lerror = NULL;
if (id)
priv->id = g_strdup (id);
else {
g_mutex_lock (&serial_mutex);
priv->id = g_strdup_printf ("%d", serial++);
g_mutex_unlock (&serial_mutex);
}
va_start (ap, id); va_start (ap, id);
value = gda_value_new (type); value = gda_value_new (type);
if (type == G_TYPE_BOOLEAN) if (type == G_TYPE_BOOLEAN)
...@@ -565,7 +547,22 @@ gda_holder_finalize (GObject * object) ...@@ -565,7 +547,22 @@ gda_holder_finalize (GObject * object)
holder = GDA_HOLDER (object); holder = GDA_HOLDER (object);
GdaHolderPrivate *priv = gda_holder_get_instance_private (holder); GdaHolderPrivate *priv = gda_holder_get_instance_private (holder);
g_free (priv->id); if (priv->id != NULL) {
g_free (priv->id);
priv->id = NULL;
}
if (priv->name != NULL) {
g_free (priv->name);
priv->name = NULL;
}
if (priv->desc != NULL) {
g_free (priv->desc);
priv->desc = NULL;
}
if (priv->plugin != NULL) {
g_free (priv->plugin);
priv->plugin = NULL;
}
g_rec_mutex_clear (& (priv->mutex)); g_rec_mutex_clear (& (priv->mutex));
/* parent class */ /* parent class */
...@@ -586,14 +583,35 @@ gda_holder_set_property (GObject *object, ...@@ -586,14 +583,35 @@ gda_holder_set_property (GObject *object,
if (priv) { if (priv) {
switch (param_id) { switch (param_id) {
case PROP_ID: case PROP_ID:
g_free (priv->id); if (priv->id != NULL) {
g_free (priv->id);
priv->id = NULL;
}
priv->id = g_value_dup_string (value); priv->id = g_value_dup_string (value);
break; break;
case PROP_NAME: case PROP_NAME:
gda_holder_set_attribute_static (holder, GDA_ATTRIBUTE_NAME, value); if (priv->name != NULL) {
g_free (priv->name);
priv->name = NULL;
}
priv->name = g_value_dup_string (value);
g_signal_emit (holder, gda_holder_signals[CHANGED], 0);
break; break;
case PROP_DESCR: case PROP_DESCR:
gda_holder_set_attribute_static (holder, GDA_ATTRIBUTE_DESCRIPTION, value); if (priv->desc != NULL) {
g_free (priv->desc);
priv->desc = NULL;
}
priv->desc = g_value_dup_string (value);
g_signal_emit (holder, gda_holder_signals[CHANGED], 0);
break;
case PROP_PLUGIN:
if (priv->plugin != NULL) {
g_free (priv->plugin);
priv->plugin = NULL;
}
priv->plugin = g_value_dup_string (value);
g_signal_emit (holder, gda_holder_signals[CHANGED], 0);
break; break;
case PROP_GDA_TYPE: case PROP_GDA_TYPE:
if (priv->g_type == GDA_TYPE_NULL) { if (priv->g_type == GDA_TYPE_NULL) {
...@@ -664,16 +682,14 @@ gda_holder_get_property (GObject *object, ...@@ -664,16 +682,14 @@ gda_holder_get_property (GObject *object,
g_value_set_string (value, priv->id); g_value_set_string (value, priv->id);
break; break;
case PROP_NAME: case PROP_NAME:
cvalue = gda_holder_get_attribute (holder, GDA_ATTRIBUTE_NAME); if (priv->name != NULL)
if (cvalue) g_value_set_string (value, priv->name);
g_value_set_string (value, g_value_get_string (cvalue));
else else
g_value_set_string (value, priv->id); g_value_set_string (value, priv->id);
break; break;
case PROP_DESCR: case PROP_DESCR:
cvalue = gda_holder_get_attribute (holder, GDA_ATTRIBUTE_DESCRIPTION); if (priv->desc != NULL)
if (cvalue) g_value_set_string (value, priv->desc);
g_value_set_string (value, g_value_get_string (cvalue));
else else
g_value_set_string (value, NULL); g_value_set_string (value, NULL);
break; break;
...@@ -1067,10 +1083,6 @@ real_gda_holder_set_value (GdaHolder *holder, GValue *value, gboolean do_copy, G ...@@ -1067,10 +1083,6 @@ real_gda_holder_set_value (GdaHolder *holder, GValue *value, gboolean do_copy, G
new_value && (G_VALUE_TYPE (new_value) == priv->g_type)) new_value && (G_VALUE_TYPE (new_value) == priv->g_type))
priv->default_forced = !gda_value_compare (priv->default_value, new_value); priv->default_forced = !gda_value_compare (priv->default_value, new_value);
} }
GValue att_value = {0};
g_value_init (&att_value, G_TYPE_BOOLEAN);
g_value_set_boolean (&att_value, priv->default_forced);
gda_holder_set_attribute_static (holder, GDA_ATTRIBUTE_IS_DEFAULT, &att_value);
/* real setting of the value */ /* real setting of the value */
if (priv->full_bind) { if (priv->full_bind) {
...@@ -1213,10 +1225,6 @@ real_gda_holder_set_const_value (GdaHolder *holder, const GValue *value, ...@@ -1213,10 +1225,6 @@ real_gda_holder_set_const_value (GdaHolder *holder, const GValue *value,
value && (G_VALUE_TYPE (value) == priv->g_type)) value && (G_VALUE_TYPE (value) == priv->g_type))
priv->default_forced = !gda_value_compare (priv->default_value, value); priv->default_forced = !gda_value_compare (priv->default_value, value);
} }
GValue *att_value;
g_value_set_boolean ((att_value = gda_value_new (G_TYPE_BOOLEAN)), priv->default_forced);
gda_holder_set_attribute_static (holder, GDA_ATTRIBUTE_IS_DEFAULT, att_value);
gda_value_free (att_value);
/* real setting of the value */ /* real setting of the value */
if (priv->full_bind) { if (priv->full_bind) {
...@@ -1451,10 +1459,6 @@ gda_holder_set_value_to_default (GdaHolder *holder) ...@@ -1451,10 +1459,6 @@ gda_holder_set_value_to_default (GdaHolder *holder)
} }
} }
GValue *att_value;
g_value_set_boolean ((att_value = gda_value_new (G_TYPE_BOOLEAN)), TRUE);
gda_holder_set_attribute_static (holder, GDA_ATTRIBUTE_IS_DEFAULT, att_value);
gda_value_free (att_value);
g_signal_emit (holder, gda_holder_signals[CHANGED], 0); g_signal_emit (holder, gda_holder_signals[CHANGED], 0);
gda_holder_unlock ((GdaLockable*) holder); gda_holder_unlock ((GdaLockable*) holder);
...@@ -1534,20 +1538,17 @@ gda_holder_set_default_value (GdaHolder *holder, const GValue *value) ...@@ -1534,20 +1538,17 @@ gda_holder_set_default_value (GdaHolder *holder, const GValue *value)
/* check if default is equal to current value */ /* check if default is equal to current value */
if (GDA_VALUE_HOLDS_NULL (value) && if (GDA_VALUE_HOLDS_NULL (value) &&
(!current || GDA_VALUE_HOLDS_NULL (current))) (!current || GDA_VALUE_HOLDS_NULL (current))) {
priv->default_forced = TRUE; priv->default_forced = TRUE;
else if ((G_VALUE_TYPE (value) == priv->g_type) && } else if ((G_VALUE_TYPE (value) == priv->g_type) &&
current && !gda_value_compare (value, current)) current && !gda_value_compare (value, current)) {
priv->default_forced = TRUE; priv->default_forced = TRUE;
}
priv->default_value = gda_value_copy ((GValue *)value); priv->default_value = gda_value_copy ((GValue *)value);
//g_signal_emit (holder, gda_holder_signals[CHANGED], 0);
} }
GValue *att_value;
g_value_set_boolean ((att_value = gda_value_new (G_TYPE_BOOLEAN)), priv->default_forced);
gda_holder_set_attribute_static (holder, GDA_ATTRIBUTE_IS_DEFAULT, att_value);
gda_value_free (att_value);
/* don't emit the "changed" signal */ /* don't emit the "changed" signal */
gda_holder_unlock ((GdaLockable*) holder); gda_holder_unlock ((GdaLockable*) holder);
} }
...@@ -1715,8 +1716,7 @@ bind_to_notify_cb (GdaHolder *bind_to, G_GNUC_UNUSED GParamSpec *pspec, GdaHolde ...@@ -1715,8 +1716,7 @@ bind_to_notify_cb (GdaHolder *bind_to, G_GNUC_UNUSED GParamSpec *pspec, GdaHolde
} }
else if (priv->g_type != bpriv->g_type) { else if (priv->g_type != bpriv->g_type) {
/* break holder's binding because type differ */ /* break holder's binding because type differ */
g_warning (_("Cannot bind holders if their type is not the same, " g_message (_("Cannot bind holders if their type is not the same, breaking existing bind where '%s' was bound to '%s'"),
"breaking existing bind where '%s' was bound to '%s'"),
gda_holder_get_id (holder), gda_holder_get_id (bind_to)); gda_holder_get_id (holder), gda_holder_get_id (bind_to));
gda_holder_set_bind (holder, NULL, NULL); gda_holder_set_bind (holder, NULL, NULL);
} }
...@@ -1980,67 +1980,6 @@ gda_holder_get_alphanum_id (GdaHolder *holder) ...@@ -1980,67 +1980,6 @@ gda_holder_get_alphanum_id (GdaHolder *holder)
return gda_text_to_alphanum (priv->id); return gda_text_to_alphanum (priv->id);
} }
/**
* gda_holder_get_attribute:
* @holder: a #GdaHolder
* @attribute: attribute name as a string
*
* Get the value associated to a named attribute.
*
* Attributes can have any name, but Libgda proposes some default names, see <link linkend="libgda-40-Attributes-manager.synopsis">this section</link>.
*
* Returns: a read-only #GValue, or %NULL if not attribute named @attribute has been set for @holder
*/
const GValue *
gda_holder_get_attribute (GdaHolder *holder, const gchar *attribute)
{
g_return_val_if_fail (GDA_IS_HOLDER (holder), NULL);
/*g_print ("GdaHolder %p ATTR '%s' get => '%s'\n", holder, attribute,
gda_value_stringify (gda_attributes_manager_get (gda_holder_attributes_manager, holder, attribute))); */
return gda_attributes_manager_get (gda_holder_attributes_manager, holder, attribute);
}
/**
* gda_holder_set_attribute:
* @holder: a #GdaHolder
* @attribute: attribute name
* @value: a #GValue, or %NULL
* @destroy: a function to be called when @attribute is not needed anymore, or %NULL
*
* Set the value associated to a named attribute. The @attribute string is 'stolen' by this method, and
* the memory it uses will be freed using the @destroy function when no longer needed (if @destroy is %NULL,
* then the string will not be freed at all).
*
* Attributes can have any name, but Libgda proposes some default names,
* see <link linkend="libgda-6.0-Attributes-manager.synopsis">this section</link>.
*
* For example one would use it as:
*
* <code>gda_holder_set_attribute (holder, g_strdup (my_attribute), my_value, g_free);</code>
* <code>gda_holder_set_attribute (holder, GDA_ATTRIBUTE_NAME, my_value, NULL);</code>
*
* If there is already an attribute named @attribute set, then its value is replaced with the new value (@value is
* copied), except if @value is %NULL, in which case the attribute is removed.
*/
void
gda_holder_set_attribute (GdaHolder *holder, const gchar *attribute, const GValue *value, GDestroyNotify destroy)
{
const GValue *cvalue;
g_return_if_fail (GDA_IS_HOLDER (holder));
gda_holder_lock ((GdaLockable*) holder);
cvalue = gda_attributes_manager_get (gda_holder_attributes_manager, holder, attribute);
if ((value && cvalue && !gda_value_differ (cvalue, value)) ||
(!value && !cvalue)) {
gda_holder_unlock ((GdaLockable*) holder);
return;
}
gda_attributes_manager_set_full (gda_holder_attributes_manager, holder, attribute, value, destroy);
//g_print ("GdaHolder %p ATTR '%s' set to '%s'\n", holder, attribute, gda_value_stringify (value));
gda_holder_unlock ((GdaLockable*) holder);
}
static void static void
gda_holder_lock (GdaLockable *lockable) gda_holder_lock (GdaLockable *lockable)
{ {
......
...@@ -75,7 +75,7 @@ struct _GdaHolderClass ...@@ -75,7 +75,7 @@ struct _GdaHolderClass
* Each GdaHolder object is thread safe. * Each GdaHolder object is thread safe.
*/ */
GdaHolder *gda_holder_new (GType type); GdaHolder *gda_holder_new (GType type, const gchar *id);
GdaHolder *gda_holder_new_inline (GType type, const gchar *id, ...); GdaHolder *gda_holder_new_inline (GType type, const gchar *id, ...);
GdaHolder *gda_holder_copy (GdaHolder *orig); GdaHolder *gda_holder_copy (GdaHolder *orig);
...@@ -148,20 +148,6 @@ GdaDataModel *gda_holder_get_source_model (GdaHolder *holder, gint ...@@ -148,20 +148,6 @@ GdaDataModel *gda_holder_get_source_model (GdaHolder *holder, gint
gboolean gda_holder_set_bind (GdaHolder *holder, GdaHolder *bind_to, GError **error); gboolean gda_holder_set_bind (GdaHolder *holder, GdaHolder *bind_to, GError **error);
GdaHolder *gda_holder_get_bind (GdaHolder *holder); GdaHolder *gda_holder_get_bind (GdaHolder *holder);
const GValue *gda_holder_get_attribute (GdaHolder *holder, const gchar *attribute);
void gda_holder_set_attribute (GdaHolder *holder, const gchar *attribute, const GValue *value,
GDestroyNotify destroy);
/**
* gda_holder_set_attribute_static:
* @holder: a #GdaHolder
* @attribute: attribute's name
* @value: (nullable): a #GValue, or %NULL
*
* This function is similar to gda_holder_set_attribute() but for static strings
*/
#define gda_holder_set_attribute_static(holder,attribute,value) gda_holder_set_attribute((holder),(attribute),(value),NULL)
G_END_DECLS G_END_DECLS
#endif #endif
...@@ -651,7 +651,6 @@ static void set_remove_source (GdaSet *set, GdaSetSource *source); ...@@ -651,7 +651,6 @@ static void set_remove_source (GdaSet *set, GdaSetSource *source);
static void changed_holder_cb (GdaHolder *holder, GdaSet *dataset); static void changed_holder_cb (GdaHolder *holder, GdaSet *dataset);
static GError *validate_change_holder_cb (GdaHolder *holder, const GValue *value, GdaSet *dataset); static GError *validate_change_holder_cb (GdaHolder *holder, const GValue *value, GdaSet *dataset);
static void source_changed_holder_cb (GdaHolder *holder, GdaSet *dataset); static void source_changed_holder_cb (GdaHolder *holder, GdaSet *dataset);
static void att_holder_changed_cb (GdaHolder *holder, const gchar *att_name, const GValue *att_value, GdaSet *dataset);
static void holder_notify_cb (GdaHolder *holder, GParamSpec *pspec, GdaSet *dataset); static void holder_notify_cb (GdaHolder *holder, GParamSpec *pspec, GdaSet *dataset);
...@@ -1098,7 +1097,7 @@ gda_set_new_inline (gint nb, ...) ...@@ -1098,7 +1097,7 @@ gda_set_new_inline (gint nb, ...)
id = va_arg (ap, char *); id = va_arg (ap, char *);
type = va_arg (ap, GType); type = va_arg (ap, GType);
holder = (GdaHolder *) g_object_new (GDA_TYPE_HOLDER, "g-type", type, "id", id, NULL); holder = gda_holder_new (type, id);
value = gda_value_new (type); value = gda_value_new (type);
if (g_type_is_a (type, G_TYPE_BOOLEAN)) if (g_type_is_a (type, G_TYPE_BOOLEAN))
...@@ -1596,8 +1595,6 @@ gda_set_remove_holder (GdaSet *set, GdaHolder *holder) ...@@ -1596,8 +1595,6 @@ gda_set_remove_holder (GdaSet *set, GdaHolder *holder)
G_CALLBACK (changed_holder_cb), set); G_CALLBACK (changed_holder_cb), set);
g_signal_handlers_disconnect_by_func (G_OBJECT (holder), g_signal_handlers_disconnect_by_func (G_OBJECT (holder),
G_CALLBACK (source_changed_holder_cb), set); G_CALLBACK (source_changed_holder_cb), set);
g_signal_handlers_disconnect_by_func (G_OBJECT (holder),
G_CALLBACK (att_holder_changed_cb), set);
} }
g_signal_handlers_disconnect_by_func (holder, g_signal_handlers_disconnect_by_func (holder,
G_CALLBACK (holder_notify_cb), set); G_CALLBACK (holder_notify_cb), set);
...@@ -1634,17 +1631,6 @@ source_changed_holder_cb (G_GNUC_UNUSED GdaHolder *holder, GdaSet *set) ...@@ -1634,17 +1631,6 @@ source_changed_holder_cb (G_GNUC_UNUSED GdaHolder *holder, GdaSet *set)
compute_public_data (set); compute_public_data (set);
} }
static void
att_holder_changed_cb (GdaHolder *holder, const gchar *att_name, const GValue *att_value, GdaSet *set)
{
#ifdef GDA_DEBUG_signal
g_print (">> 'HOLDER_ATTR_CHANGED' from %s\n", __FUNCTION__);
#endif
g_signal_emit (G_OBJECT (set), gda_set_signals[HOLDER_ATTR_CHANGED], 0, holder, att_name, att_value);
#ifdef GDA_DEBUG_signal
g_print ("<< 'HOLDER_ATTR_CHANGED' from %s\n", __FUNCTION__);
#endif
}
static GError * static GError *
validate_change_holder_cb (GdaHolder *holder, const GValue *value, GdaSet *set) validate_change_holder_cb (GdaHolder *holder, const GValue *value, GdaSet *set)
...@@ -1710,8 +1696,6 @@ gda_set_dispose (GObject *object) ...@@ -1710,8 +1696,6 @@ gda_set_dispose (GObject *object)
G_CALLBACK (changed_holder_cb), set); G_CALLBACK (changed_holder_cb), set);
g_signal_handlers_disconnect_by_func (G_OBJECT (list->data), g_signal_handlers_disconnect_by_func (G_OBJECT (list->data),
G_CALLBACK (source_changed_holder_cb), set); G_CALLBACK (source_changed_holder_cb), set);
g_signal_handlers_disconnect_by_func (G_OBJECT (list->data),
G_CALLBACK (att_holder_changed_cb), set);
} }
g_object_unref (list->data); g_object_unref (list->data);
} }
...@@ -1889,24 +1873,22 @@ holder_notify_cb (GdaHolder *holder, GParamSpec *pspec, GdaSet *dataset) ...@@ -1889,24 +1873,22 @@ holder_notify_cb (GdaHolder *holder, GParamSpec *pspec, GdaSet *dataset)
g_signal_emit (dataset, gda_set_signals[HOLDER_TYPE_SET], 0, holder); g_signal_emit (dataset, gda_set_signals[HOLDER_TYPE_SET], 0, holder);
} }
else if (!strcmp (pspec->name, "name")) { else if (!strcmp (pspec->name, "name")) {
#ifdef GDA_DEBUG_signal gchar *name = NULL;
g_print (">> 'HOLDER_ATTR_CHANGED' from %s\n", __FUNCTION__); g_object_get (dataset, "name", &name, NULL);
#endif g_signal_emit (G_OBJECT (dataset), gda_set_signals[HOLDER_ATTR_CHANGED], 0, holder,
g_signal_emit (G_OBJECT (dataset), gda_set_signals[HOLDER_ATTR_CHANGED], 0, holder, "name", name != NULL ? name : "NULL");
GDA_ATTRIBUTE_NAME, gda_holder_get_attribute (holder, GDA_ATTRIBUTE_NAME)); if (name != NULL) {
#ifdef GDA_DEBUG_signal g_free (name);
g_print ("<< 'HOLDER_ATTR_CHANGED' from %s\n", __FUNCTION__); }
#endif
} }
else if (!strcmp (pspec->name, "description")) { else if (!strcmp (pspec->name, "description")) {
#ifdef GDA_DEBUG_signal gchar *desc = NULL;
g_print (">> 'HOLDER_ATTR_CHANGED' from %s\n", __FUNCTION__); g_object_get (dataset, "description", &desc, NULL);
#endif g_signal_emit (G_OBJECT (dataset), gda_set_signals[HOLDER_ATTR_CHANGED], 0, holder,
g_signal_emit (G_OBJECT (dataset), gda_set_signals[HOLDER_ATTR_CHANGED], 0, holder, "description", desc);
GDA_ATTRIBUTE_DESCRIPTION, gda_holder_get_attribute (holder, GDA_ATTRIBUTE_DESCRIPTION)); if (desc != NULL) {
#ifdef GDA_DEBUG_signal g_free (desc);
g_print ("<< 'HOLDER_ATTR_CHANGED' from %s\n", __FUNCTION__); }
#endif
} }
} }
...@@ -1924,7 +1906,7 @@ gda_set_real_add_holder (GdaSet *set, GdaHolder *holder) ...@@ -1924,7 +1906,7 @@ gda_set_real_add_holder (GdaSet *set, GdaHolder *holder)
* a holder B is similar to a holder A if it has the same ID * a holder B is similar to a holder A if it has the same ID
*/ */
hid = gda_holder_get_id (holder); hid = gda_holder_get_id (holder);
if (!hid) { if (hid == NULL) {
g_warning (_("GdaHolder needs to have an ID")); g_warning (_("GdaHolder needs to have an ID"));
return FALSE; return FALSE;
} }
...@@ -1947,8 +1929,6 @@ gda_set_real_add_holder (GdaSet *set, GdaHolder *holder) ...@@ -1947,8 +1929,6 @@ gda_set_real_add_holder (GdaSet *set, GdaHolder *holder)
G_CALLBACK (changed_holder_cb), set); G_CALLBACK (changed_holder_cb), set);
g_signal_connect (G_OBJECT (holder), "source-changed", g_signal_connect (G_OBJECT (holder), "source-changed",
G_CALLBACK (source_changed_holder_cb), set); G_CALLBACK (source_changed_holder_cb), set);
g_signal_connect (G_OBJECT (holder), "attribute-changed",
G_CALLBACK (att_holder_changed_cb), set);
} }
if (gda_holder_get_g_type (holder) == GDA_TYPE_NULL) if (gda_holder_get_g_type (holder) == GDA_TYPE_NULL)
g_signal_connect (G_OBJECT (holder), "notify::g-type", g_signal_connect (G_OBJECT (holder), "notify::g-type",
......
...@@ -453,8 +453,8 @@ get_params_foreach_func (GdaSqlAnyPart *node, GdaSet **params, GError **error) ...@@ -453,8 +453,8 @@ get_params_foreach_func (GdaSqlAnyPart *node, GdaSet **params, GError **error)
} }
if (!*params) if (!*params)
*params = gda_set_new (NULL); *params = gda_set_new (NULL);
h = gda_holder_new (pspec->g_type); h = gda_holder_new (pspec->g_type, pspec->name);
g_object_set (G_OBJECT (h), "id", pspec->name, "name", pspec->name, g_object_set (G_OBJECT (h), "name", pspec->name,
"description", pspec->descr, NULL); "description", pspec->descr, NULL);
gda_holder_set_not_null (h, ! pspec->nullok); gda_holder_set_not_null (h, ! pspec->nullok);
if (((GdaSqlExpr*) node)->value) { if (((GdaSqlExpr*) node)->value) {
......
...@@ -663,8 +663,8 @@ gda_utility_holder_load_attributes (GdaHolder *holder, xmlNodePtr node, GSList * ...@@ -663,8 +663,8 @@ gda_utility_holder_load_attributes (GdaHolder *holder, xmlNodePtr node, GSList *
if (str) { if (str) {
GValue *value; GValue *value;
#define GDAUI_ATTRIBUTE_PLUGIN "__gdaui_attr_plugin" #define GDAUI_ATTRIBUTE_PLUGIN "__gdaui_attr_plugin"
value = gda_value_new_from_string ((gchar*) str, G_TYPE_STRING); value = gda_value_new_from_string ((gchar*) str, G_TYPE_STRING);
gda_holder_set_attribute_static (holder, GDAUI_ATTRIBUTE_PLUGIN, value); g_object_set (holder, "plugin", value, NULL);
gda_value_free (value); gda_value_free (value);
xmlFree (str); xmlFree (str);
} }
...@@ -733,14 +733,7 @@ gda_utility_holder_load_attributes (GdaHolder *holder, xmlNodePtr node, GSList * ...@@ -733,14 +733,7 @@ gda_utility_holder_load_attributes (GdaHolder *holder, xmlNodePtr node, GSList *
xmlChar *att_name; xmlChar *att_name;
att_name = xmlGetProp (vnode, (xmlChar*) "name"); att_name = xmlGetProp (vnode, (xmlChar*) "name");
if (att_name) { if (att_name) {
GValue *value; g_object_set_data_full ((GObject*) holder, att_name, g_strdup ((gchar*) xmlNodeGetContent (vnode)), (GDestroyNotify) g_free);
g_value_set_string ((value = gda_value_new (G_TYPE_STRING)),
(gchar*) xmlNodeGetContent (vnode));
gda_attributes_manager_set_full (gda_holder_attributes_manager,
(gpointer) holder,
(gchar*) att_name, value,
(GDestroyNotify) xmlFree);
gda_value_free (value);
} }
vnode = vnode->next; vnode = vnode->next;
continue; continue;
......
...@@ -62,7 +62,11 @@ _gda_sqlite_render_CREATE_TABLE (GdaServerProvider *provider, GdaConnection *cnc ...@@ -62,7 +62,11 @@ _gda_sqlite_render_CREATE_TABLE (GdaServerProvider *provider, GdaConnection *cnc
tmp = gda_connection_operation_get_sql_identifier_at (cnc, op, "/TABLE_DEF_P/TABLE_NAME", error); tmp = gda_connection_operation_get_sql_identifier_at (cnc, op, "/TABLE_DEF_P/TABLE_NAME", error);
if (!tmp) { if (!tmp) {
g_string_free (string, TRUE); g_string_free (string, TRUE);
g_assert (*error != NULL); if (error != NULL) {
if (*error == NULL) {
g_warning (_("Internal error, creating table in SQLite provider"));
}
}
return NULL; return NULL;
} }
g_string_append (string, tmp); g_string_append (string, tmp);
......
...@@ -3136,9 +3136,9 @@ make_last_inserted_set (GdaConnection *cnc, GdaStatement *stmt, sqlite3_int64 la ...@@ -3136,9 +3136,9 @@ make_last_inserted_set (GdaConnection *cnc, GdaStatement *stmt, sqlite3_int64 la
gchar *id; gchar *id;
const GValue *cvalue; const GValue *cvalue;
col = gda_data_model_describe_column (model, i); col = gda_data_model_describe_column (model, i);
h = gda_holder_new (gda_column_get_g_type (col));
id = g_strdup_printf ("+%d", i); id = g_strdup_printf ("+%d", i);
g_object_set (G_OBJECT (h), "id", id, h = gda_holder_new (gda_column_get_g_type (col), id);
g_object_set (G_OBJECT (h),
"name", gda_column_get_name (col), NULL); "name", gda_column_get_name (col), NULL);
g_free (id); g_free (id);
cvalue = gda_data_model_get_value_at (model, i, 0, NULL); cvalue = gda_data_model_get_value_at (model, i, 0, NULL);
...@@ -3922,8 +3922,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio ...@@ -3922,8 +3922,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
GValue *value; GValue *value;
GSList *list; GSList *list;
holder = gda_holder_new (G_TYPE_INT); holder = gda_holder_new (G_TYPE_INT, "IMPACTED_ROWS");
g_object_set ((GObject*) holder, "id", "IMPACTED_ROWS", NULL);
g_value_set_int ((value = gda_value_new (G_TYPE_INT)), changes); g_value_set_int ((value = gda_value_new (G_TYPE_INT)), changes);
gda_holder_take_value (holder, value, NULL); gda_holder_take_value (holder, value, NULL);
list = g_slist_append (NULL, holder); list = g_slist_append (NULL, holder);
......
...@@ -623,9 +623,9 @@ vcontext_free (VContext *context) ...@@ -623,9 +623,9 @@ vcontext_free (VContext *context)
void void
_gda_vconnection_set_working_obj (GdaVconnectionDataModel *cnc, GObject *obj) _gda_vconnection_set_working_obj (GdaVconnectionDataModel *cnc, GObject *obj)
{ {
g_mutex_lock (& (cnc->priv->lock_context));
GSList *list; GSList *list;
if (obj) { if (obj) {
g_mutex_lock (& (cnc->priv->lock_context));
for (list = cnc->priv->table_data_list; list; list = list->next) { for (list = cnc->priv->table_data_list; list; list = list->next) {
GdaVConnectionTableData *td = (GdaVConnectionTableData*) list->data; GdaVConnectionTableData *td = (GdaVConnectionTableData*) list->data;
VContext *vc = NULL; VContext *vc = NULL;
...@@ -660,8 +660,8 @@ _gda_vconnection_set_working_obj (GdaVconnectionDataModel *cnc, GObject *obj) ...@@ -660,8 +660,8 @@ _gda_vconnection_set_working_obj (GdaVconnectionDataModel *cnc, GObject *obj)
* an exception already occurred */ * an exception already occurred */
td->context.current_vcontext = NULL; td->context.current_vcontext = NULL;
} }
g_mutex_unlock (& (cnc->priv->lock_context));
} }
g_mutex_unlock (& (cnc->priv->lock_context));
} }
void void
......
...@@ -2044,9 +2044,9 @@ make_last_inserted_set (GdaConnection *cnc, GdaStatement *stmt, my_ulonglong las ...@@ -2044,9 +2044,9 @@ make_last_inserted_set (GdaConnection *cnc, GdaStatement *stmt, my_ulonglong las
const GValue *cvalue; const GValue *cvalue;
col = gda_data_model_describe_column (model, i); col = gda_data_model_describe_column (model, i);
h = gda_holder_new (gda_column_get_g_type (col));
id = g_strdup_printf ("+%d", i); id = g_strdup_printf ("+%d", i);
g_object_set (G_OBJECT (h), "id", id, "not-null", FALSE, h = gda_holder_new (gda_column_get_g_type (col), id);
g_object_set (G_OBJECT (h), "not-null", FALSE,
"name", gda_column_get_name (col), NULL); "name", gda_column_get_name (col), NULL);
g_free (id); g_free (id);
cvalue = gda_data_model_get_value_at (model, i, 0, NULL); cvalue = gda_data_model_get_value_at (model, i, 0, NULL);
......
...@@ -1843,9 +1843,9 @@ make_last_inserted_set (GdaConnection *cnc, GdaStatement *stmt, Oid last_id) ...@@ -1843,9 +1843,9 @@ make_last_inserted_set (GdaConnection *cnc, GdaStatement *stmt, Oid last_id)
const GValue *cvalue; const GValue *cvalue;
col = gda_data_model_describe_column (model, i); col = gda_data_model_describe_column (model, i);
h = gda_holder_new (gda_column_get_g_type (col));
id = g_strdup_printf ("+%d", i); id = g_strdup_printf ("+%d", i);
g_object_set (G_OBJECT (h), "id", id, "not-null", FALSE, h = gda_holder_new (gda_column_get_g_type (col), id);
g_object_set (G_OBJECT (h), "not-null", FALSE,
"name", gda_column_get_name (col), NULL); "name", gda_column_get_name (col), NULL);
g_free (id); g_free (id);
cvalue = gda_data_model_get_value_at (model, i, 0, NULL); cvalue = gda_data_model_get_value_at (model, i, 0, NULL);
......
...@@ -984,15 +984,12 @@ build_form_test_for_gtype (G_GNUC_UNUSED GdaDataHandler *dh, GType type, const g ...@@ -984,15 +984,12 @@ build_form_test_for_gtype (G_GNUC_UNUSED GdaDataHandler *dh, GType type, const g
if (model) { if (model) {
GdaSet *plist; GdaSet *plist;
GdaHolder *param; GdaHolder *param;
GValue *value;
wid = gdaui_form_new (model); wid = gdaui_form_new (model);
plist = GDA_SET (gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (wid))); plist = GDA_SET (gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (wid)));
param = gda_set_get_holders (plist)->data; param = gda_set_get_holders (plist)->data;
value = gda_value_new_from_string (plugin_name, G_TYPE_STRING); g_object_set ((GObject*) param, "plugin", plugin_name, NULL);
gda_holder_set_attribute_static (param, GDAUI_ATTRIBUTE_PLUGIN, value);
gda_value_free (value);
} }
else { else {
gchar *str; gchar *str;
...@@ -1016,15 +1013,12 @@ build_grid_test_for_gtype (G_GNUC_UNUSED GdaDataHandler *dh, GType type, const g ...@@ -1016,15 +1013,12 @@ build_grid_test_for_gtype (G_GNUC_UNUSED GdaDataHandler *dh, GType type, const g
if (model) { if (model) {
GdaSet *plist; GdaSet *plist;
GdaHolder *param; GdaHolder *param;
GValue *value;
wid = gdaui_grid_new (model); wid = gdaui_grid_new (model);
plist = GDA_SET (gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (wid))); plist = GDA_SET (gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (wid)));
param = gda_set_get_holders (plist)->data; param = gda_set_get_holders (plist)->data;
value = gda_value_new_from_string (plugin_name, G_TYPE_STRING); g_object_set ((GObject*) param, "plugin", plugin_name, NULL);
gda_holder_set_attribute_static (param, GDAUI_ATTRIBUTE_PLUGIN, value);
gda_value_free (value);
} }
else { else {
gchar *str; gchar *str;
......
...@@ -166,10 +166,9 @@ common_load_csv_file (const gchar *data_file, ...) ...@@ -166,10 +166,9 @@ common_load_csv_file (const gchar *data_file, ...)
GdaHolder *holder; GdaHolder *holder;
GValue *v; GValue *v;
gchar *id; gchar *id;
holder = gda_holder_new (G_TYPE_GTYPE);
id = g_strdup_printf ("G_TYPE_%d", cnum); id = g_strdup_printf ("G_TYPE_%d", cnum);
g_object_set (G_OBJECT (holder), "id", id, NULL); holder = gda_holder_new (G_TYPE_GTYPE, id);
g_free (id); g_free (id);
v = gda_value_new (G_TYPE_GTYPE); v = gda_value_new (G_TYPE_GTYPE);
......
...@@ -109,7 +109,7 @@ test1 (GError **error) ...@@ -109,7 +109,7 @@ test1 (GError **error)
const GValue *cvalue; const GValue *cvalue;
GValue *value, *copy; GValue *value, *copy;
h = gda_holder_new (G_TYPE_STRING); h = gda_holder_new (G_TYPE_STRING, "id");
emitted_signals_monitor_holder (h); emitted_signals_monitor_holder (h);
cvalue = gda_holder_get_value (h); cvalue = gda_holder_get_value (h);
if (!gda_value_is_null (cvalue)) { if (!gda_value_is_null (cvalue)) {
...@@ -296,17 +296,20 @@ test4 (GError **error) ...@@ -296,17 +296,20 @@ test4 (GError **error)
} }
/***/ /***/
if (gda_holder_set_value_to_default (h)) { if (gda_holder_set_value_to_default (h)) {
g_set_error (error, TEST_ERROR, TEST_ERROR_GENERIC, "%s", g_set_error (error, TEST_ERROR, TEST_ERROR_GENERIC, "%s",
"Should not set GdaHolder's value to default"); "Should not set GdaHolder's value to default");
return FALSE; return FALSE;
} }
printf ("Checking signals \"changed\" after try to set to default\n");
if (!emitted_signals_check_empty (NULL, "changed", error)) if (!emitted_signals_check_empty (NULL, "changed", error))
return FALSE; return FALSE;
/** Set a default value to NULL */ /** Set a default value to NULL */
value = gda_value_new_null (); value = gda_value_new_null ();
gda_holder_set_default_value (h, value); gda_holder_set_default_value (h, value);
printf ("Checking signals \"changed\" after change default value\n");
if (!emitted_signals_check_empty (NULL, "changed", error)) if (!emitted_signals_check_empty (NULL, "changed", error))
return FALSE; return FALSE;
...@@ -331,8 +334,10 @@ test4 (GError **error) ...@@ -331,8 +334,10 @@ test4 (GError **error)
"Could not set GdaHolder's value to default"); "Could not set GdaHolder's value to default");
return FALSE; return FALSE;
} }
printf ("Find \"changed\" signals after reset to default\n");
if (!emitted_signals_find (h, "changed", error)) if (!emitted_signals_find (h, "changed", error))
return FALSE; return FALSE;
printf ("Checking empty signals \"changed\" after reset to default\n");
if (!emitted_signals_check_empty (NULL, "changed", error)) if (!emitted_signals_check_empty (NULL, "changed", error))
return FALSE; return FALSE;
...@@ -344,10 +349,12 @@ test4 (GError **error) ...@@ -344,10 +349,12 @@ test4 (GError **error)
return FALSE; return FALSE;
} }
printf ("Changing value to 'hey'\n");
/** set value to "hey" */ /** set value to "hey" */
value = gda_value_new_from_string ("hey", G_TYPE_STRING); value = gda_value_new_from_string ("hey", G_TYPE_STRING);
if (!gda_holder_set_value (h, value, error)) if (!gda_holder_set_value (h, value, error))
return FALSE; return FALSE;
printf ("Checking signals \"changed\"");
if (!emitted_signals_find (h, "changed", error)) if (!emitted_signals_find (h, "changed", error))
return FALSE; return FALSE;
if (!emitted_signals_check_empty (NULL, "changed", error)) if (!emitted_signals_check_empty (NULL, "changed", error))
...@@ -724,7 +731,7 @@ test8 (GError **error) ...@@ -724,7 +731,7 @@ test8 (GError **error)
GdaHolder *h; GdaHolder *h;
GValue *value; GValue *value;
h = gda_holder_new (G_TYPE_STRING); h = gda_holder_new (G_TYPE_STRING, "id");
emitted_signals_monitor_holder (h); emitted_signals_monitor_holder (h);
emitted_signals_reset (); emitted_signals_reset ();
...@@ -758,7 +765,7 @@ test9 (GError **error) ...@@ -758,7 +765,7 @@ test9 (GError **error)
gchar *model_data="1,John\n2,Jack"; gchar *model_data="1,John\n2,Jack";
gint col; gint col;
h = gda_holder_new (G_TYPE_STRING); h = gda_holder_new (G_TYPE_STRING, "id");
emitted_signals_monitor_holder (h); emitted_signals_monitor_holder (h);
emitted_signals_reset (); emitted_signals_reset ();
...@@ -840,7 +847,7 @@ test10 (GError **error) ...@@ -840,7 +847,7 @@ test10 (GError **error)
const GValue *cvalue; const GValue *cvalue;
GValue *value; GValue *value;
h = gda_holder_new (G_TYPE_STRING); h = gda_holder_new