Commit b3bb804c authored by Daniel Espinosa Ortiz's avatar Daniel Espinosa Ortiz

GdaSet: removed GdaAttributeManager

GdaSet used to use Attribute Manager to
add aditional data to it, but GObject
already provides that functionality, so
it not needed anymore.
parent 8950e30d
Pipeline #58386 failed with stage
in 20 minutes and 14 seconds
......@@ -760,7 +760,7 @@ run_context_push_with_stmt (GdaReportEngine *engine, RunContext *context, GdaCon
GdaHolder *param;
GValue *value;
gchar *name;
param = gda_holder_new (G_TYPE_INT);
param = gda_holder_new (G_TYPE_INT, "id");
value = gda_value_new (G_TYPE_INT);
g_value_set_int (value, gda_data_model_get_n_rows (model));
if (! gda_holder_set_value (param, value, error)) {
......
......@@ -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;
mask |= GDA_VALUE_ATTR_CAN_BE_NULL;
defv = gda_holder_get_attribute (param, GDA_ATTRIBUTE_IS_DEFAULT);
if (defv && (G_VALUE_TYPE (defv) == G_TYPE_BOOLEAN) && g_value_get_boolean (defv)) {
if (gda_holder_value_is_default (param)) {
attrs |= GDA_VALUE_ATTR_IS_DEFAULT;
mask |= GDA_VALUE_ATTR_IS_DEFAULT;
}
g_signal_handlers_block_by_func (G_OBJECT (entry),
G_CALLBACK (entry_contents_modified), sentry);
gdaui_data_entry_set_attributes (GDAUI_DATA_ENTRY (entry), attrs, mask);
......@@ -912,14 +910,7 @@ create_entry_widget (SingleEntry *sentry)
value = default_val;
/* create entry */
plugin_val = gda_holder_get_attribute (param, GDAUI_ATTRIBUTE_PLUGIN);
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);
}
g_object_get (param, "plugin", &plugin, NULL);
entry = GTK_WIDGET (gdaui_new_data_entry (type, plugin));
sentry->entry = GDAUI_DATA_ENTRY (entry);
......@@ -1300,8 +1291,7 @@ load_xml_layout_column (GdauiBasicForm *form, xmlNodePtr box_node)
if (plugin && sentry->single_param) {
GValue *value;
value = gda_value_new_from_string ((gchar*) plugin, G_TYPE_STRING);
gda_holder_set_attribute_static (sentry->single_param,
GDAUI_ATTRIBUTE_PLUGIN, value);
g_object_set (sentry->single_param, "plugin", value, NULL);
gda_value_free (value);
}
if (plugin)
......
......@@ -55,6 +55,7 @@ catch_css_parsing_errors (GtkCssProvider *provider,
g_warning (_("Error parsing CSS: %s"), error->message);
}
extern void _gdaui_register_resource (void);
/**
* gdaui_init:
*
......
......@@ -707,14 +707,7 @@ create_columns_data (GdauiRawGrid *grid)
if (!title)
title = g_strdup (_("No title"));
plugin_val = gda_holder_get_attribute (param, GDAUI_ATTRIBUTE_PLUGIN);
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);
}
g_object_get (param, "plugin", &plugin, NULL);
renderer = _gdaui_new_cell_renderer (g_type, plugin);
cdata->data_cell = GTK_CELL_RENDERER (g_object_ref_sink ((GObject*) renderer));
g_hash_table_insert (priv->columns_hash, renderer, cdata);
......@@ -856,8 +849,7 @@ reset_columns_in_xml_layout (GdauiRawGrid *grid, xmlNodePtr grid_node)
if (plugin && cdata->single_param) {
GValue *value;
value = gda_value_new_from_string ((gchar*) plugin, G_TYPE_STRING);
gda_holder_set_attribute_static (cdata->single_param,
GDAUI_ATTRIBUTE_PLUGIN, value);
g_object_set (cdata->single_param, "plugin", value, NULL);
gda_value_free (value);
}
if (plugin)
......
......@@ -1954,8 +1954,8 @@ create_internal_provider (const gchar *path,
GValue *value;
#define GDAUI_ATTRIBUTE_PLUGIN "__gdaui_attr_plugin"
value = gda_value_new_from_string ("string:HIDDEN=true", G_TYPE_STRING);
gda_holder_set_attribute_static (h, GDAUI_ATTRIBUTE_PLUGIN, value);
gda_value_free (value);
g_object_set (h, "plugin", value, NULL);
gda_value_free (value);
}
info->icon_id = icon_id ? g_strdup (icon_id) : g_strdup (prov_name);
......
......@@ -34,7 +34,6 @@
#include "gda-marshal.h"
#include "gda-util.h"
#include <libgda.h>
#include <libgda/gda-attributes-manager.h>
#include <libgda/gda-custom-marshal.h>
/*
......@@ -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 gda_holder_set_full_bind (GdaHolder *holder, GdaHolder *alias_of);
GdaAttributesManager *gda_holder_attributes_manager;
/* signals */
enum
{
CHANGED,
SOURCE_CHANGED,
SOURCE_CHANGED,
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 */
......@@ -93,7 +89,8 @@ enum
PROP_SOURCE_COLUMN,
PROP_GDA_TYPE,
PROP_NOT_NULL,
PROP_VALIDATE_CHANGES
PROP_VALIDATE_CHANGES,
PROP_PLUGIN
};
......@@ -121,6 +118,9 @@ typedef struct {
GRecMutex mutex;
gboolean validate_changes;
gchar *name;
gchar *desc;
gchar *plugin;
} GdaHolderPrivate;
G_DEFINE_TYPE_WITH_CODE (GdaHolder, gda_holder, G_TYPE_OBJECT,
G_ADD_PRIVATE (GdaHolder)
......@@ -154,13 +154,6 @@ m_validate_change (G_GNUC_UNUSED GdaHolder *holder, G_GNUC_UNUSED const GValue *
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
gda_holder_class_init (GdaHolderClass *class)
{
......@@ -192,22 +185,6 @@ gda_holder_class_init (GdaHolderClass *class)
G_STRUCT_OFFSET (GdaHolderClass, changed),
NULL, NULL,
_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:
......@@ -276,6 +253,9 @@ gda_holder_class_init (GdaHolderClass *class)
"with the source-model property",
0, G_MAXINT, 0,
(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:
......@@ -288,9 +268,6 @@ gda_holder_class_init (GdaHolderClass *class)
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_READABLE | G_PARAM_WRITABLE)));
/* extra */
gda_holder_attributes_manager = gda_attributes_manager_new (TRUE, holder_attribute_set_cb, NULL);
}
static void
......@@ -306,7 +283,7 @@ gda_holder_init (GdaHolder *holder)
{
GdaHolderPrivate *priv = gda_holder_get_instance_private (holder);
priv->id = NULL;
priv->id = g_strdup ("id");
priv->g_type = GDA_TYPE_NULL;
priv->full_bind = NULL;
......@@ -328,20 +305,25 @@ gda_holder_init (GdaHolder *holder)
g_rec_mutex_init (& (priv->mutex));
priv->validate_changes = TRUE;
priv->name = NULL;
priv->desc = NULL;
priv->plugin = NULL;
}
/**
* gda_holder_new:
* @type: the #GType requested
* @id: an identifiation
*
* Creates a new holder of type @type
*
* Returns: a new #GdaHolder object
*/
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)
if (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)
gda_holder_set_full_bind (holder, priv->full_bind);
......@@ -397,13 +385,6 @@ gda_holder_copy (GdaHolder *orig)
if (priv->default_value)
cpriv->default_value = gda_value_copy (priv->default_value);
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);
return holder;
......@@ -438,22 +419,23 @@ gda_holder_new_inline (GType type, const gchar *id, ...)
static GMutex serial_mutex;
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);
if (holder) {
GValue *value;
va_list ap;
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);
value = gda_value_new (type);
if (type == G_TYPE_BOOLEAN)
......@@ -565,7 +547,22 @@ gda_holder_finalize (GObject * object)
holder = GDA_HOLDER (object);
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));
/* parent class */
......@@ -586,14 +583,35 @@ gda_holder_set_property (GObject *object,
if (priv) {
switch (param_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);
break;
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;
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;
case PROP_GDA_TYPE:
if (priv->g_type == GDA_TYPE_NULL) {
......@@ -664,16 +682,14 @@ gda_holder_get_property (GObject *object,
g_value_set_string (value, priv->id);
break;
case PROP_NAME:
cvalue = gda_holder_get_attribute (holder, GDA_ATTRIBUTE_NAME);
if (cvalue)
g_value_set_string (value, g_value_get_string (cvalue));
if (priv->name != NULL)
g_value_set_string (value, priv->name);
else
g_value_set_string (value, priv->id);
break;
case PROP_DESCR:
cvalue = gda_holder_get_attribute (holder, GDA_ATTRIBUTE_DESCRIPTION);
if (cvalue)
g_value_set_string (value, g_value_get_string (cvalue));
if (priv->desc != NULL)
g_value_set_string (value, priv->desc);
else
g_value_set_string (value, NULL);
break;
......@@ -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))
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 */
if (priv->full_bind) {
......@@ -1213,10 +1225,6 @@ real_gda_holder_set_const_value (GdaHolder *holder, const GValue *value,
value && (G_VALUE_TYPE (value) == priv->g_type))
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 */
if (priv->full_bind) {
......@@ -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);
gda_holder_unlock ((GdaLockable*) holder);
......@@ -1534,20 +1538,17 @@ gda_holder_set_default_value (GdaHolder *holder, const GValue *value)
/* check if default is equal to current value */
if (GDA_VALUE_HOLDS_NULL (value) &&
(!current || GDA_VALUE_HOLDS_NULL (current)))
(!current || GDA_VALUE_HOLDS_NULL (current))) {
priv->default_forced = TRUE;
else if ((G_VALUE_TYPE (value) == priv->g_type) &&
current && !gda_value_compare (value, current))
} else if ((G_VALUE_TYPE (value) == priv->g_type) &&
current && !gda_value_compare (value, current)) {
priv->default_forced = TRUE;
}
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 */
gda_holder_unlock ((GdaLockable*) holder);
}
......@@ -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) {
/* break holder's binding because type differ */
g_warning (_("Cannot bind holders if their type is not the same, "
"breaking existing bind where '%s' was bound to '%s'"),
g_message (_("Cannot bind holders if their type is not the same, breaking existing bind where '%s' was bound to '%s'"),
gda_holder_get_id (holder), gda_holder_get_id (bind_to));
gda_holder_set_bind (holder, NULL, NULL);
}
......@@ -1980,67 +1980,6 @@ gda_holder_get_alphanum_id (GdaHolder *holder)
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
gda_holder_lock (GdaLockable *lockable)
{
......
......@@ -75,7 +75,7 @@ struct _GdaHolderClass
* 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_copy (GdaHolder *orig);
......@@ -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);
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
#endif
......@@ -651,7 +651,6 @@ static void set_remove_source (GdaSet *set, GdaSetSource *source);
static void changed_holder_cb (GdaHolder *holder, 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 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);
......@@ -1098,7 +1097,7 @@ gda_set_new_inline (gint nb, ...)
id = va_arg (ap, char *);
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);
if (g_type_is_a (type, G_TYPE_BOOLEAN))
......@@ -1596,8 +1595,6 @@ gda_set_remove_holder (GdaSet *set, GdaHolder *holder)
G_CALLBACK (changed_holder_cb), set);
g_signal_handlers_disconnect_by_func (G_OBJECT (holder),
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_CALLBACK (holder_notify_cb), set);
......@@ -1634,17 +1631,6 @@ source_changed_holder_cb (G_GNUC_UNUSED GdaHolder *holder, GdaSet *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 *
validate_change_holder_cb (GdaHolder *holder, const GValue *value, GdaSet *set)
......@@ -1710,8 +1696,6 @@ gda_set_dispose (GObject *object)
G_CALLBACK (changed_holder_cb), set);
g_signal_handlers_disconnect_by_func (G_OBJECT (list->data),
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);
}
......@@ -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);
}
else if (!strcmp (pspec->name, "name")) {
#ifdef GDA_DEBUG_signal
g_print (">> 'HOLDER_ATTR_CHANGED' from %s\n", __FUNCTION__);
#endif
g_signal_emit (G_OBJECT (dataset), gda_set_signals[HOLDER_ATTR_CHANGED], 0, holder,
GDA_ATTRIBUTE_NAME, gda_holder_get_attribute (holder, GDA_ATTRIBUTE_NAME));
#ifdef GDA_DEBUG_signal
g_print ("<< 'HOLDER_ATTR_CHANGED' from %s\n", __FUNCTION__);
#endif
gchar *name = NULL;
g_object_get (dataset, "name", &name, NULL);
g_signal_emit (G_OBJECT (dataset), gda_set_signals[HOLDER_ATTR_CHANGED], 0, holder,
"name", name != NULL ? name : "NULL");
if (name != NULL) {
g_free (name);
}
}
else if (!strcmp (pspec->name, "description")) {
#ifdef GDA_DEBUG_signal
g_print (">> 'HOLDER_ATTR_CHANGED' from %s\n", __FUNCTION__);
#endif
g_signal_emit (G_OBJECT (dataset), gda_set_signals[HOLDER_ATTR_CHANGED], 0, holder,
GDA_ATTRIBUTE_DESCRIPTION, gda_holder_get_attribute (holder, GDA_ATTRIBUTE_DESCRIPTION));
#ifdef GDA_DEBUG_signal
g_print ("<< 'HOLDER_ATTR_CHANGED' from %s\n", __FUNCTION__);
#endif
gchar *desc = NULL;
g_object_get (dataset, "description", &desc, NULL);
g_signal_emit (G_OBJECT (dataset), gda_set_signals[HOLDER_ATTR_CHANGED], 0, holder,
"description", desc);
if (desc != NULL) {
g_free (desc);
}
}
}
......@@ -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
*/
hid = gda_holder_get_id (holder);
if (!hid) {
if (hid == NULL) {
g_warning (_("GdaHolder needs to have an ID"));
return FALSE;
}
......@@ -1947,8 +1929,6 @@ gda_set_real_add_holder (GdaSet *set, GdaHolder *holder)
G_CALLBACK (changed_holder_cb), set);
g_signal_connect (G_OBJECT (holder), "source-changed",
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)
g_signal_connect (G_OBJECT (holder), "notify::g-type",
......
......@@ -453,8 +453,8 @@ get_params_foreach_func (GdaSqlAnyPart *node, GdaSet **params, GError **error)
}
if (!*params)
*params = gda_set_new (NULL);
h = gda_holder_new (pspec->g_type);
g_object_set (G_OBJECT (h), "id", pspec->name, "name", pspec->name,
h = gda_holder_new (pspec->g_type, pspec->name);
g_object_set (G_OBJECT (h), "name", pspec->name,
"description", pspec->descr, NULL);
gda_holder_set_not_null (h, ! pspec->nullok);
if (((GdaSqlExpr*) node)->value) {
......
......@@ -663,8 +663,8 @@ gda_utility_holder_load_attributes (GdaHolder *holder, xmlNodePtr node, GSList *
if (str) {
GValue *value;
#define GDAUI_ATTRIBUTE_PLUGIN "__gdaui_attr_plugin"
value = gda_value_new_from_string ((gchar*) str, G_TYPE_STRING);
gda_holder_set_attribute_static (holder, GDAUI_ATTRIBUTE_PLUGIN, value);
value = gda_value_new_from_string ((gchar*) str, G_TYPE_STRING);
g_object_set (holder, "plugin", value, NULL);
gda_value_free (value);
xmlFree (str);
}
......@@ -733,14 +733,7 @@ gda_utility_holder_load_attributes (GdaHolder *holder, xmlNodePtr node, GSList *
xmlChar *att_name;
att_name = xmlGetProp (vnode, (xmlChar*) "name");
if (att_name) {
GValue *value;
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);
g_object_set_data_full ((GObject*) holder, att_name, g_strdup ((gchar*) xmlNodeGetContent (vnode)), (GDestroyNotify) g_free);
}
vnode = vnode->next;
continue;
......
......@@ -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);
if (!tmp) {
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;
}
g_string_append (string, tmp);
......
......@@ -3136,9 +3136,9 @@ make_last_inserted_set (GdaConnection *cnc, GdaStatement *stmt, sqlite3_int64 la
gchar *id;
const GValue *cvalue;
col = gda_data_model_describe_column (model, i);
h = gda_holder_new (gda_column_get_g_type (col));
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);
g_free (id);
cvalue = gda_data_model_get_value_at (model, i, 0, NULL);
......@@ -3922,8 +3922,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
GValue *value;
GSList *list;
holder = gda_holder_new (G_TYPE_INT);
g_object_set ((GObject*) holder, "id", "IMPACTED_ROWS", NULL);
holder = gda_holder_new (G_TYPE_INT, "IMPACTED_ROWS");
g_value_set_int ((value = gda_value_new (G_TYPE_INT)), changes);
gda_holder_take_value (holder, value, NULL);
list = g_slist_append (NULL, holder);
......
......@@ -2044,9 +2044,9 @@ make_last_inserted_set (GdaConnection *cnc, GdaStatement *stmt, my_ulonglong las
const GValue