[libgda] GdaSet: removed GdaAttributeManager
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaSet: removed GdaAttributeManager
- Date: Mon, 11 Feb 2019 23:25:35 +0000 (UTC)
commit b3bb804c57e125c196d5d7e4f0d88731ae241fda
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date: Mon Feb 11 17:23:52 2019 -0600
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.
libgda-report/engine/gda-report-engine.c | 2 +-
libgda-ui/gdaui-basic-form.c | 16 +-
libgda-ui/gdaui-init.c | 1 +
libgda-ui/gdaui-raw-grid.c | 12 +-
libgda/gda-config.c | 4 +-
libgda/gda-holder.c | 231 +++++++++---------------
libgda/gda-holder.h | 16 +-
libgda/gda-set.c | 52 ++----
libgda/gda-statement.c | 4 +-
libgda/gda-util.c | 13 +-
libgda/sqlite/gda-sqlite-ddl.c | 6 +-
libgda/sqlite/gda-sqlite-provider.c | 7 +-
providers/mysql/gda-mysql-provider.c | 4 +-
providers/postgres/gda-postgres-provider.c | 4 +-
testing/gdaui-test-data-entries.c | 12 +-
tests/meta-store/common.c | 5 +-
tests/value-holders/check_holder.c | 70 +++----
tests/value-holders/check_set.c | 9 +-
tools/base/base-tool-output.c | 9 +-
tools/browser/connection-binding-properties.c | 13 +-
tools/browser/data-manager/data-source-editor.c | 9 +-
tools/browser/gdaui-data-import.c | 3 +-
tools/browser/schema-browser/table-info.c | 5 +-
tools/browser/ui-formgrid.c | 5 +-
tools/common/t-app.c | 36 ++--
tools/common/t-connection.c | 18 +-
tools/common/t-term-context.c | 6 +-
27 files changed, 201 insertions(+), 371 deletions(-)
---
diff --git a/libgda-report/engine/gda-report-engine.c b/libgda-report/engine/gda-report-engine.c
index 167e29240..c4a1f0c07 100644
--- a/libgda-report/engine/gda-report-engine.c
+++ b/libgda-report/engine/gda-report-engine.c
@@ -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)) {
diff --git a/libgda-ui/gdaui-basic-form.c b/libgda-ui/gdaui-basic-form.c
index b58274d95..0f3bc3655 100644
--- a/libgda-ui/gdaui-basic-form.c
+++ b/libgda-ui/gdaui-basic-form.c
@@ -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)
diff --git a/libgda-ui/gdaui-init.c b/libgda-ui/gdaui-init.c
index 749d40cd5..00370453f 100644
--- a/libgda-ui/gdaui-init.c
+++ b/libgda-ui/gdaui-init.c
@@ -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:
*
diff --git a/libgda-ui/gdaui-raw-grid.c b/libgda-ui/gdaui-raw-grid.c
index 5d4659011..42db8a636 100644
--- a/libgda-ui/gdaui-raw-grid.c
+++ b/libgda-ui/gdaui-raw-grid.c
@@ -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)
diff --git a/libgda/gda-config.c b/libgda/gda-config.c
index ce98abe47..3d4cb8cea 100644
--- a/libgda/gda-config.c
+++ b/libgda/gda-config.c
@@ -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);
diff --git a/libgda/gda-holder.c b/libgda/gda-holder.c
index 4c69a832e..0f7e6531c 100644
--- a/libgda/gda-holder.c
+++ b/libgda/gda-holder.c
@@ -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)
{
diff --git a/libgda/gda-holder.h b/libgda/gda-holder.h
index 7fe3d4f45..72b531515 100644
--- a/libgda/gda-holder.h
+++ b/libgda/gda-holder.h
@@ -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
diff --git a/libgda/gda-set.c b/libgda/gda-set.c
index f24700157..f0ed267f0 100644
--- a/libgda/gda-set.c
+++ b/libgda/gda-set.c
@@ -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",
diff --git a/libgda/gda-statement.c b/libgda/gda-statement.c
index 26cd35f12..0a82b025f 100644
--- a/libgda/gda-statement.c
+++ b/libgda/gda-statement.c
@@ -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) {
diff --git a/libgda/gda-util.c b/libgda/gda-util.c
index fe4256f10..794c0a518 100644
--- a/libgda/gda-util.c
+++ b/libgda/gda-util.c
@@ -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;
diff --git a/libgda/sqlite/gda-sqlite-ddl.c b/libgda/sqlite/gda-sqlite-ddl.c
index 70639e747..6712bdef1 100644
--- a/libgda/sqlite/gda-sqlite-ddl.c
+++ b/libgda/sqlite/gda-sqlite-ddl.c
@@ -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);
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index 91e8e8faf..6aa0f0f4e 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -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);
diff --git a/providers/mysql/gda-mysql-provider.c b/providers/mysql/gda-mysql-provider.c
index 01f6ee6b6..9e9c477e0 100644
--- a/providers/mysql/gda-mysql-provider.c
+++ b/providers/mysql/gda-mysql-provider.c
@@ -2044,9 +2044,9 @@ make_last_inserted_set (GdaConnection *cnc, GdaStatement *stmt, my_ulonglong las
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, "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);
g_free (id);
cvalue = gda_data_model_get_value_at (model, i, 0, NULL);
diff --git a/providers/postgres/gda-postgres-provider.c b/providers/postgres/gda-postgres-provider.c
index dd7d3e100..5cb73d3e0 100644
--- a/providers/postgres/gda-postgres-provider.c
+++ b/providers/postgres/gda-postgres-provider.c
@@ -1843,9 +1843,9 @@ make_last_inserted_set (GdaConnection *cnc, GdaStatement *stmt, Oid last_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, "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);
g_free (id);
cvalue = gda_data_model_get_value_at (model, i, 0, NULL);
diff --git a/testing/gdaui-test-data-entries.c b/testing/gdaui-test-data-entries.c
index a3b9071f6..c88ef1303 100644
--- a/testing/gdaui-test-data-entries.c
+++ b/testing/gdaui-test-data-entries.c
@@ -984,15 +984,12 @@ build_form_test_for_gtype (G_GNUC_UNUSED GdaDataHandler *dh, GType type, const g
if (model) {
GdaSet *plist;
GdaHolder *param;
- GValue *value;
wid = gdaui_form_new (model);
plist = GDA_SET (gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (wid)));
param = gda_set_get_holders (plist)->data;
- value = gda_value_new_from_string (plugin_name, G_TYPE_STRING);
- gda_holder_set_attribute_static (param, GDAUI_ATTRIBUTE_PLUGIN, value);
- gda_value_free (value);
+ g_object_set ((GObject*) param, "plugin", plugin_name, NULL);
}
else {
gchar *str;
@@ -1016,15 +1013,12 @@ build_grid_test_for_gtype (G_GNUC_UNUSED GdaDataHandler *dh, GType type, const g
if (model) {
GdaSet *plist;
GdaHolder *param;
- GValue *value;
-
+
wid = gdaui_grid_new (model);
plist = GDA_SET (gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (wid)));
param = gda_set_get_holders (plist)->data;
- value = gda_value_new_from_string (plugin_name, G_TYPE_STRING);
- gda_holder_set_attribute_static (param, GDAUI_ATTRIBUTE_PLUGIN, value);
- gda_value_free (value);
+ g_object_set ((GObject*) param, "plugin", plugin_name, NULL);
}
else {
gchar *str;
diff --git a/tests/meta-store/common.c b/tests/meta-store/common.c
index fb31b97ef..fb36f332a 100644
--- a/tests/meta-store/common.c
+++ b/tests/meta-store/common.c
@@ -166,10 +166,9 @@ common_load_csv_file (const gchar *data_file, ...)
GdaHolder *holder;
GValue *v;
gchar *id;
-
- holder = gda_holder_new (G_TYPE_GTYPE);
+
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);
v = gda_value_new (G_TYPE_GTYPE);
diff --git a/tests/value-holders/check_holder.c b/tests/value-holders/check_holder.c
index 62bfa2077..00285bace 100644
--- a/tests/value-holders/check_holder.c
+++ b/tests/value-holders/check_holder.c
@@ -109,7 +109,7 @@ test1 (GError **error)
const GValue *cvalue;
GValue *value, *copy;
- h = gda_holder_new (G_TYPE_STRING);
+ h = gda_holder_new (G_TYPE_STRING, "id");
emitted_signals_monitor_holder (h);
cvalue = gda_holder_get_value (h);
if (!gda_value_is_null (cvalue)) {
@@ -296,17 +296,20 @@ test4 (GError **error)
}
/***/
+
if (gda_holder_set_value_to_default (h)) {
g_set_error (error, TEST_ERROR, TEST_ERROR_GENERIC, "%s",
"Should not set GdaHolder's value to default");
return FALSE;
}
+ printf ("Checking signals \"changed\" after try to set to default\n");
if (!emitted_signals_check_empty (NULL, "changed", error))
return FALSE;
/** Set a default value to NULL */
value = gda_value_new_null ();
gda_holder_set_default_value (h, value);
+ printf ("Checking signals \"changed\" after change default value\n");
if (!emitted_signals_check_empty (NULL, "changed", error))
return FALSE;
@@ -331,8 +334,10 @@ test4 (GError **error)
"Could not set GdaHolder's value to default");
return FALSE;
}
+ printf ("Find \"changed\" signals after reset to default\n");
if (!emitted_signals_find (h, "changed", error))
return FALSE;
+ printf ("Checking empty signals \"changed\" after reset to default\n");
if (!emitted_signals_check_empty (NULL, "changed", error))
return FALSE;
@@ -344,10 +349,12 @@ test4 (GError **error)
return FALSE;
}
+ printf ("Changing value to 'hey'\n");
/** set value to "hey" */
value = gda_value_new_from_string ("hey", G_TYPE_STRING);
if (!gda_holder_set_value (h, value, error))
return FALSE;
+ printf ("Checking signals \"changed\"");
if (!emitted_signals_find (h, "changed", error))
return FALSE;
if (!emitted_signals_check_empty (NULL, "changed", error))
@@ -724,7 +731,7 @@ test8 (GError **error)
GdaHolder *h;
GValue *value;
- h = gda_holder_new (G_TYPE_STRING);
+ h = gda_holder_new (G_TYPE_STRING, "id");
emitted_signals_monitor_holder (h);
emitted_signals_reset ();
@@ -758,7 +765,7 @@ test9 (GError **error)
gchar *model_data="1,John\n2,Jack";
gint col;
- h = gda_holder_new (G_TYPE_STRING);
+ h = gda_holder_new (G_TYPE_STRING, "id");
emitted_signals_monitor_holder (h);
emitted_signals_reset ();
@@ -840,7 +847,7 @@ test10 (GError **error)
const GValue *cvalue;
GValue *value;
- h = gda_holder_new (G_TYPE_STRING);
+ h = gda_holder_new (G_TYPE_STRING, "id");
emitted_signals_monitor_holder (h);
/***/
@@ -912,7 +919,7 @@ test11 (GError **error)
const GValue *cvalue;
GValue *value;
- h = gda_holder_new (GDA_TYPE_NULL);
+ h = gda_holder_new (GDA_TYPE_NULL, "id");
emitted_signals_monitor_holder (h);
/***/
@@ -965,48 +972,13 @@ test12 (GError **error)
const GValue *cvalue;
GValue *value;
- h = gda_holder_new (GDA_TYPE_NULL);
+ h = gda_holder_new (GDA_TYPE_NULL, "id");
- /***/
- value = gda_value_new_from_string ("my string", G_TYPE_STRING);
- if (gda_holder_get_attribute (h, "attname1")) {
- g_set_error (error, TEST_ERROR, TEST_ERROR_GENERIC, "%s",
- "gda_holder_get_attribute() should have retunred NULL");
- return FALSE;
- }
- gda_holder_set_attribute_static (h, "attname1", value);
- gda_value_free (value);
- cvalue = gda_holder_get_attribute (h, "attname1");
- if (!cvalue) {
- g_set_error (error, TEST_ERROR, TEST_ERROR_GENERIC, "%s",
- "gda_holder_get_attribute() should have retunred a value");
- return FALSE;
- }
- value = gda_value_new_from_string ("my string", G_TYPE_STRING);
- if (gda_value_differ (cvalue, value)) {
- g_set_error (error, TEST_ERROR, TEST_ERROR_GENERIC, "%s",
- "gda_holder_get_attribute() retunred a wrong value");
- return FALSE;
- }
-
- /***/
GdaHolder *copy;
gchar *name;
g_object_set (G_OBJECT (h), "name", "thename", NULL);
copy = gda_holder_copy (h);
- cvalue = gda_holder_get_attribute (copy, "attname1");
- if (!cvalue) {
- g_set_error (error, TEST_ERROR, TEST_ERROR_GENERIC, "%s",
- "gda_holder_get_attribute() should have retunred a value");
- return FALSE;
- }
- if (gda_value_differ (cvalue, value)) {
- g_set_error (error, TEST_ERROR, TEST_ERROR_GENERIC, "%s",
- "gda_holder_get_attribute() retunred a wrong value");
- return FALSE;
- }
- gda_value_free (value);
g_object_get (G_OBJECT (copy), "name", &name, NULL);
if (strcmp (name, "thename")) {
@@ -1027,8 +999,8 @@ static gboolean
test13 (GError **error)
{
GdaHolder *h1, *h2;
- h1 = gda_holder_new (GDA_TYPE_NULL);
- h2 = gda_holder_new (GDA_TYPE_NULL);
+ h1 = gda_holder_new (GDA_TYPE_NULL, "id1");
+ h2 = gda_holder_new (GDA_TYPE_NULL, "id2");
if (! gda_holder_set_bind (h1, h2, error)) {
g_object_unref (h1);
g_object_unref (h2);
@@ -1046,8 +1018,8 @@ test13 (GError **error)
g_object_unref (h2);
/* another test */
- h1 = gda_holder_new (GDA_TYPE_NULL);
- h2 = gda_holder_new (G_TYPE_INT);
+ h1 = gda_holder_new (GDA_TYPE_NULL, "1");
+ h2 = gda_holder_new (G_TYPE_INT, "2");
if (! gda_holder_set_bind (h1, h2, error)) {
g_object_unref (h1);
g_object_unref (h2);
@@ -1064,8 +1036,8 @@ test13 (GError **error)
g_object_unref (h2);
/* another test */
- h1 = gda_holder_new (G_TYPE_STRING);
- h2 = gda_holder_new (GDA_TYPE_NULL);
+ h1 = gda_holder_new (G_TYPE_STRING, "1");
+ h2 = gda_holder_new (GDA_TYPE_NULL, "2");
if (! gda_holder_set_bind (h1, h2, error)) {
g_object_unref (h1);
g_object_unref (h2);
@@ -1090,8 +1062,8 @@ test13 (GError **error)
g_object_unref (h2);
/* another test */
- h1 = gda_holder_new (G_TYPE_STRING);
- h2 = gda_holder_new (GDA_TYPE_NULL);
+ h1 = gda_holder_new (G_TYPE_STRING, "1");
+ h2 = gda_holder_new (GDA_TYPE_NULL, "2");
if (! gda_holder_set_bind (h1, h2, error)) {
g_object_unref (h1);
g_object_unref (h2);
diff --git a/tests/value-holders/check_set.c b/tests/value-holders/check_set.c
index fe615c799..05f45d770 100644
--- a/tests/value-holders/check_set.c
+++ b/tests/value-holders/check_set.c
@@ -280,9 +280,8 @@ test4 (GError **error)
{
GdaSet *set;
GdaHolder *h;
- GValue *value;
-
- set = gda_set_new_inline (3,
+
+ set = gda_set_new_inline (3,
"H1", G_TYPE_STRING, "A string",
"H2", G_TYPE_STRING, "1234",
"H3", G_TYPE_CHAR, 'r');
@@ -295,9 +294,7 @@ test4 (GError **error)
"Could not find GdaHolder H1");
return FALSE;
}
- g_value_set_string ((value = gda_value_new (G_TYPE_STRING)), "Hello!");
- gda_holder_set_attribute_static (h, "MyAttr", value);
- gda_value_free (value);
+ g_object_set ((GObject*) h, "description", "Hello!", NULL);
if (!emitted_signals_find (set, "holder-attr-changed", error))
return FALSE;
diff --git a/tools/base/base-tool-output.c b/tools/base/base-tool-output.c
index a11447541..e2ab64ad8 100644
--- a/tools/base/base-tool-output.c
+++ b/tools/base/base-tool-output.c
@@ -40,16 +40,15 @@ make_options_set_from_string (const gchar *context, GdaSet *options)
if (options) {
for (list = gda_set_get_holders (options); list; list = list->next) {
GdaHolder *param = GDA_HOLDER (list->data);
- const GValue *cvalue;
- cvalue = gda_holder_get_attribute (param, context);
- if (!cvalue)
+ gchar *val;
+ val = g_object_get_data ((GObject*) param, context);
+ if (!val)
continue;
GdaHolder *nparam;
const GValue *cvalue2;
cvalue2 = gda_holder_get_value (param);
- nparam = gda_holder_new (G_VALUE_TYPE (cvalue2));
- g_object_set ((GObject*) nparam, "id", g_value_get_string (cvalue), NULL);
+ nparam = gda_holder_new (G_VALUE_TYPE (cvalue2), val);
g_assert (gda_holder_set_value (nparam, cvalue2, NULL));
nlist = g_slist_append (nlist, nparam);
}
diff --git a/tools/browser/connection-binding-properties.c b/tools/browser/connection-binding-properties.c
index 0b372f326..4978f312e 100644
--- a/tools/browser/connection-binding-properties.c
+++ b/tools/browser/connection-binding-properties.c
@@ -441,15 +441,12 @@ create_part_for_model (ConnectionBindingProperties *cprop, TVirtualConnectionPar
GdaSet *set;
GdaHolder *holder;
GtkWidget *form;
- GValue *value;
set = gda_set_new_inline (1,
"NAME", G_TYPE_STRING, pm->table_name);
- holder = gda_holder_new (GDA_TYPE_DATA_MODEL);
- g_object_set (holder, "id", "DATASET", "name", "Data set", NULL);
- value = gda_value_new_from_string ("data-model-import", G_TYPE_STRING);
- gda_holder_set_attribute_static (holder, GDAUI_ATTRIBUTE_PLUGIN, value);
- gda_value_free (value);
+ holder = gda_holder_new (GDA_TYPE_DATA_MODEL, "DATASET");
+ g_object_set (holder, "name", "Data set", NULL);
+ g_object_set ((GObject*) holder, "plugin", "data-model-import", NULL);
g_assert (gda_set_add_holder (set, holder));
g_object_unref (holder);
@@ -555,8 +552,8 @@ create_part_for_cnc (ConnectionBindingProperties *cprop, TVirtualConnectionPart
set = gda_set_new_inline (1,
"SCHEMA", G_TYPE_STRING, cnc->table_schema);
- holder = gda_holder_new (T_TYPE_CONNECTION);
- g_object_set (holder, "id", "CNC", "name", "Connection", "not-null", TRUE, NULL);
+ holder = gda_holder_new (T_TYPE_CONNECTION, "CNC");
+ g_object_set (holder, "name", "Connection", "not-null", TRUE, NULL);
g_assert (gda_set_add_holder (set, holder));
g_value_set_object ((value = gda_value_new (T_TYPE_CONNECTION)), cnc->source_cnc);
diff --git a/tools/browser/data-manager/data-source-editor.c b/tools/browser/data-manager/data-source-editor.c
index 200648aa6..9a677830b 100644
--- a/tools/browser/data-manager/data-source-editor.c
+++ b/tools/browser/data-manager/data-source-editor.c
@@ -154,7 +154,6 @@ data_source_editor_init (DataSourceEditor *editor)
gtk_widget_show_all (ovl);
GdaHolder *holder;
- GValue *value;
holder = gda_set_get_holder (editor->priv->attributes, "id");
g_object_set ((GObject*) holder, "name", _("Id"),
"description",
@@ -175,17 +174,13 @@ data_source_editor_init (DataSourceEditor *editor)
g_object_set ((GObject*) holder, "name", _("SELECT\nSQL"),
"description", _("Actual SQL executed\nto select data\n"
"Can't be changed if a table name is set"), NULL);
- value = gda_value_new_from_string ("text:PROG_LANG=gda-sql", G_TYPE_STRING);
- gda_holder_set_attribute_static (holder, GDAUI_ATTRIBUTE_PLUGIN, value);
- gda_value_free (value);
+ g_object_set ((GObject*) holder, "plugin", "text:PROG_LANG=gda-sql", NULL);
holder = gda_set_get_holder (editor->priv->attributes, "depend");
g_object_set ((GObject*) holder, "name", _("Dependencies"),
"description", _("Required and provided named parameters"), NULL);
gdaui_basic_form_entry_set_editable (GDAUI_BASIC_FORM (form), holder, FALSE);
- value = gda_value_new_from_string ("rtext", G_TYPE_STRING);
- gda_holder_set_attribute_static (holder, GDAUI_ATTRIBUTE_PLUGIN, value);
- gda_value_free (value);
+ g_object_set ((GObject*) holder, "plugin", "rtext", NULL);
}
static void
diff --git a/tools/browser/gdaui-data-import.c b/tools/browser/gdaui-data-import.c
index 883db85b0..cfb8ab848 100644
--- a/tools/browser/gdaui-data-import.c
+++ b/tools/browser/gdaui-data-import.c
@@ -365,8 +365,7 @@ spec_changed_cb (GtkWidget *wid, GdauiDataImport *import)
for (sepno = SEP_COMMA; sepno < SEP_LAST; sepno++) {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (import->priv->sep_array [sepno]))) {
sep = g_object_get_data (G_OBJECT (import->priv->sep_array [sepno]), "_sep");
- psep = gda_holder_new (G_TYPE_STRING);
- g_object_set (G_OBJECT (psep), "id", "SEPARATOR", NULL);
+ psep = gda_holder_new (G_TYPE_STRING, "SEPARATOR");
if (sepno != SEP_OTHER)
gda_holder_set_value_str (psep, NULL, sep, NULL);
else
diff --git a/tools/browser/schema-browser/table-info.c b/tools/browser/schema-browser/table-info.c
index 84fe63499..d007530be 100644
--- a/tools/browser/schema-browser/table-info.c
+++ b/tools/browser/schema-browser/table-info.c
@@ -789,10 +789,7 @@ action_insert_cb (G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *s
if (!plugin && !col->default_value && !autoinc)
continue;
if (plugin) {
- GValue *value;
- value = gda_value_new_from_string (plugin, G_TYPE_STRING);
- gda_holder_set_attribute_static (holder, GDAUI_ATTRIBUTE_PLUGIN, value);
- gda_value_free (value);
+ g_object_set ((GObject*) holder, "plugin", plugin, NULL);
}
if (col->default_value) {
diff --git a/tools/browser/ui-formgrid.c b/tools/browser/ui-formgrid.c
index 62861dbd1..b8c230ab8 100644
--- a/tools/browser/ui-formgrid.c
+++ b/tools/browser/ui-formgrid.c
@@ -832,10 +832,7 @@ handle_user_prefs_for_sql_statement (UiFormGrid *formgrid, TConnection *tcnc,
GdaHolder *holder;
holder = gda_set_get_nth_holder (set, pos);
if (holder) {
- GValue *value;
- value = gda_value_new_from_string (plugin, G_TYPE_STRING);
- gda_holder_set_attribute_static (holder, GDAUI_ATTRIBUTE_PLUGIN, value);
- gda_value_free (value);
+ g_object_set ((GObject*) holder, "plugin", plugin, NULL);
}
g_free (plugin);
}
diff --git a/tools/common/t-app.c b/tools/common/t-app.c
index 7f702ac25..ffc7fc723 100644
--- a/tools/common/t-app.c
+++ b/tools/common/t-app.c
@@ -258,21 +258,18 @@ t_app_setup (TAppFeatures features)
value = gda_value_new (G_TYPE_STRING);
g_value_set_string (value, _("Set to TRUE when the 1st line of a CSV file holds column
names"));
opt = gda_set_get_holder (global_t_app->priv->options, "csv_names_on_first_line");
- gda_holder_set_attribute (opt, GDA_ATTRIBUTE_DESCRIPTION, value, NULL);
- g_value_set_string (value, "NAMES_ON_FIRST_LINE");
- gda_holder_set_attribute (opt, "csv", value, NULL);
+ g_object_set (opt, "description", value, NULL);
+ g_object_set_data ((GObject*) opt, "csv", "NAMES_ON_FIRST_LINE");
g_value_set_string (value, _("Quote character for CSV format"));
opt = gda_set_get_holder (global_t_app->priv->options, "csv_quote");
- gda_holder_set_attribute (opt, GDA_ATTRIBUTE_DESCRIPTION, value, NULL);
- g_value_set_string (value, "QUOTE");
- gda_holder_set_attribute (opt, "csv", value, NULL);
+ g_object_set (opt, "description", value, NULL);
+ g_object_set_data ((GObject*) opt, "csv", "QUOTE");
g_value_set_string (value, _("Separator character for CSV format"));
opt = gda_set_get_holder (global_t_app->priv->options, "csv_separator");
- gda_holder_set_attribute (opt, GDA_ATTRIBUTE_DESCRIPTION, value, NULL);
- g_value_set_string (value, "SEPARATOR");
- gda_holder_set_attribute (opt, "csv", value, NULL);
+ g_object_set (opt, "description", value, NULL);
+ g_object_set_data ((GObject*) opt, "csv", "SEPARATOR");
gda_value_free (value);
#ifdef HAVE_LDAP
@@ -2301,8 +2298,10 @@ extra_command_option (ToolCommand *command, guint argc, const gchar **argv,
gda_data_model_set_value_at (model, 1, row, value, NULL);
gda_value_free (value);
- value = (GValue*) gda_holder_get_attribute (opt, GDA_ATTRIBUTE_DESCRIPTION);
+ value = gda_value_new (G_TYPE_STRING);
+ g_object_get_property ((GObject*) opt, "description", value);
gda_data_model_set_value_at (model, 2, row, value, NULL);
+ gda_value_free (value);
}
res = g_new0 (ToolCommandResult, 1);
@@ -2372,8 +2371,10 @@ extra_command_info (ToolCommand *command, guint argc, const gchar **argv,
gda_data_model_set_value_at (model, 1, row, value, NULL);
gda_value_free (value);
- value = (GValue*) gda_holder_get_attribute (info, GDA_ATTRIBUTE_DESCRIPTION);
+ value = gda_value_new (G_TYPE_STRING);
+ g_object_get_property ((GObject*) info, "description", value);
gda_data_model_set_value_at (model, 2, row, value, NULL);
+ gda_value_free (value);
}
res = g_new0 (ToolCommandResult, 1);
@@ -4147,16 +4148,15 @@ make_options_set_from_gdasql_options (const gchar *context)
GSList *list, *nlist = NULL;
for (list = gda_set_get_holders (global_t_app->priv->options); list; list = list->next) {
GdaHolder *param = GDA_HOLDER (list->data);
- const GValue *cvalue;
- cvalue = gda_holder_get_attribute (param, context);
- if (!cvalue)
+ gchar *val;
+ val = g_object_get_data ((GObject*) param, context);
+ if (val == NULL)
continue;
GdaHolder *nparam;
const GValue *cvalue2;
cvalue2 = gda_holder_get_value (param);
- nparam = gda_holder_new (G_VALUE_TYPE (cvalue2));
- g_object_set ((GObject*) nparam, "id", g_value_get_string (cvalue), NULL);
+ nparam = gda_holder_new (G_VALUE_TYPE (cvalue2), val);
g_assert (gda_holder_set_value (nparam, cvalue2, NULL));
nlist = g_slist_append (nlist, nparam);
}
@@ -4641,7 +4641,7 @@ extra_command_set2 (ToolCommand *command, guint argc, const gchar **argv,
if (param)
g_hash_table_remove (global_t_app->priv->parameters, pname);
- param = gda_holder_new (G_VALUE_TYPE (value));
+ param = gda_holder_new (G_VALUE_TYPE (value), "blob");
g_assert (gda_holder_set_value (param, value, NULL));
g_hash_table_insert (global_t_app->priv->parameters, g_strdup (pname), param);
T_APP_UNLOCK (main_data);
@@ -4660,7 +4660,7 @@ extra_command_set2 (ToolCommand *command, guint argc, const gchar **argv,
if (param)
g_hash_table_remove (global_t_app->priv->parameters, pname);
- param = gda_holder_new (GDA_TYPE_BLOB);
+ param = gda_holder_new (GDA_TYPE_BLOB, "file");
bvalue = gda_value_new_blob_from_file (filename);
g_assert (gda_holder_take_value (param, bvalue, NULL));
g_hash_table_insert (global_t_app->priv->parameters, g_strdup (pname), param);
diff --git a/tools/common/t-connection.c b/tools/common/t-connection.c
index 65c8abc6c..d7f705dc6 100644
--- a/tools/common/t-connection.c
+++ b/tools/common/t-connection.c
@@ -339,8 +339,8 @@ have_meta_store_ready (TConnection *tcnc, GError **error)
GdaHolder *h;
h = gda_set_get_holder (tcnc->priv->infos, "meta_filename");
if (!h) {
- h = gda_holder_new (G_TYPE_STRING);
- g_object_set (h, "id", "meta_filename",
+ h = gda_holder_new (G_TYPE_STRING, "meta_filename");
+ g_object_set (h,
"description", _("File containing the meta data associated to the
connection"), NULL);
gda_set_add_holder (tcnc->priv->infos, h);
}
@@ -937,8 +937,8 @@ t_connection_open (const gchar *cnc_name, const gchar *cnc_string, const gchar *
GdaHolder *h;
h = gda_set_get_holder (tcnc->priv->infos, "date_format");
if (!h) {
- h = gda_holder_new (G_TYPE_STRING);
- g_object_set (h, "id", "date_format",
+ h = gda_holder_new (G_TYPE_STRING, "date_format");
+ g_object_set (h,
"description", _("Format of the date used for the connection,
where "
"YYYY is the year, MM the month and DD the
day"), NULL);
gda_set_add_holder (tcnc->priv->infos, h);
@@ -2063,7 +2063,7 @@ foreach_ui_plugins_for_params (GdaSqlAnyPart *part, ParamsData *data, G_GNUC_UNU
/*g_print ("Using plugin [%s]\n", plugin);*/
GValue *value;
g_value_take_string ((value = gda_value_new (G_TYPE_STRING)), plugin);
- gda_holder_set_attribute_static (holder, GDAUI_ATTRIBUTE_PLUGIN, value);
+ g_object_set (holder, "plugin", value, NULL);
gda_value_free (value);
}
@@ -2474,8 +2474,8 @@ t_connection_get_all_infos (TConnection *tcnc)
GdaHolder *h;
h = gda_set_get_holder (tcnc->priv->infos, "db_provider");
if (!h) {
- h = gda_holder_new (G_TYPE_STRING);
- g_object_set (h, "id", "db_provider",
+ h = gda_holder_new (G_TYPE_STRING, "db_provider");
+ g_object_set (h,
"description", _("Database provider"), NULL);
gda_set_add_holder (tcnc->priv->infos, h);
}
@@ -2484,8 +2484,8 @@ t_connection_get_all_infos (TConnection *tcnc)
/* database name */
h = gda_set_get_holder (tcnc->priv->infos, "db_name");
if (!h) {
- h = gda_holder_new (G_TYPE_STRING);
- g_object_set (h, "id", "db_name",
+ h = gda_holder_new (G_TYPE_STRING, "db_name");
+ g_object_set (h,
"description", _("Database name"), NULL);
gda_set_add_holder (tcnc->priv->infos, h);
}
diff --git a/tools/common/t-term-context.c b/tools/common/t-term-context.c
index 21bc4144b..73caa6c99 100644
--- a/tools/common/t-term-context.c
+++ b/tools/common/t-term-context.c
@@ -237,10 +237,10 @@ display_result (TApp *main_data, ToolCommandResult *res)
}
case BASE_TOOL_COMMAND_RESULT_EXIT:
break;
- case BASE_TOOL_COMMAND_RESULT_DATA_MODEL:
- t_app_store_data_model (res->u.model, T_LAST_DATA_MODEL_NAME);
- /* warning: no break! */
default: {
+ if (res->type == BASE_TOOL_COMMAND_RESULT_DATA_MODEL) {
+ t_app_store_data_model (res->u.model, T_LAST_DATA_MODEL_NAME);
+ }
gchar *str;
FILE *ostream;
ToolOutputFormat oformat;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]