libgda r3227 - in trunk: . doc/C doc/C/tmpl libgda
- From: vivien svn gnome org
- To: svn-commits-list gnome org
- Subject: libgda r3227 - in trunk: . doc/C doc/C/tmpl libgda
- Date: Mon, 6 Oct 2008 16:51:41 +0000 (UTC)
Author: vivien
Date: Mon Oct 6 16:51:41 2008
New Revision: 3227
URL: http://svn.gnome.org/viewvc/libgda?rev=3227&view=rev
Log:
2008-10-06 Vivien Malerba <malerba gnome-db org>
* libgda/gda-attributes-manager.[ch]: added gda_attributes_manager_set_full()
and the GDA_ATTRIBUTE_IS_DEFAULT define
* libgda/gda-holder.[ch]:
- added an "attribute-changed" signal
- use the GDA_ATTRIBUTE_IS_DEFAULT when there is a default value
* libgda/gda-set.[ch]:
- removed the "holder-plugin-changed" signal
- changed the signature of the "holder-attr-changed" signal
- use the GdaHolder's "attribute-changed" signal
- removed gda_set_get_spec()
* libgda/gda-data-model-iter.c: update for the "holder-attr-changed" signal'
signature change
* libgda/libgda-paramlist.dtd: allow some <attribute> children nodes to the
<parameter> node
* libgda/gda-util.c: adaptations to the DTD changes
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/doc/C/libgda-4.0-sections.txt
trunk/doc/C/tmpl/gda-attributes-manager.sgml
trunk/doc/C/tmpl/gda-holder.sgml
trunk/doc/C/tmpl/gda-set.sgml
trunk/libgda/gda-attributes-manager.c
trunk/libgda/gda-attributes-manager.h
trunk/libgda/gda-data-model-iter.c
trunk/libgda/gda-data-proxy.c
trunk/libgda/gda-holder.c
trunk/libgda/gda-holder.h
trunk/libgda/gda-marshal.list
trunk/libgda/gda-set.c
trunk/libgda/gda-set.h
trunk/libgda/gda-util.c
trunk/libgda/libgda-paramlist.dtd
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Mon Oct 6 16:51:41 2008
@@ -1,10 +1,20 @@
+libgda 3.99.5,
+This version includes:
+ - Meta data retreiving corrections
+ - A few API improvements (removed the GdaDataModelQuery object as its features are now implemented
+ in any result of a SELECT execution) (Massimo Cora, Vivien Malerba)
+ - More NR tests
+ - Limit the exported symbols
+ - Improved the WIN32 ZIP packages creation script
+ - Lots of improvements to the SQL console (gda-sql-4.0)
+ - Lots of small bug fixes (Johannes Schmid, Vivien Malerba)
+ - Lots of documentation improvements
- bug fixes: #508407, #552708, #90751
libgda 3.99.4, 2008-09-16
This version includes:
-
- Lots of code cleanups and API review
- now internally use SQLite 3.6.2
- Resultsets returned after the execution of a SELECT can now be writable
Modified: trunk/doc/C/libgda-4.0-sections.txt
==============================================================================
--- trunk/doc/C/libgda-4.0-sections.txt (original)
+++ trunk/doc/C/libgda-4.0-sections.txt Mon Oct 6 16:51:41 2008
@@ -44,9 +44,11 @@
gda_attributes_manager_new
gda_attributes_manager_free
gda_attributes_manager_set
+gda_attributes_manager_set_full
gda_attributes_manager_get
gda_attributes_manager_copy
gda_attributes_manager_clear
+gda_attributes_manager_foreach
</SECTION>
<SECTION>
@@ -1054,7 +1056,6 @@
gda_set_add_holder
gda_set_remove_holder
gda_set_merge_with_set
-gda_set_get_spec
<SUBSECTION>
GdaSetNode
GdaSetHint
Modified: trunk/doc/C/tmpl/gda-attributes-manager.sgml
==============================================================================
--- trunk/doc/C/tmpl/gda-attributes-manager.sgml (original)
+++ trunk/doc/C/tmpl/gda-attributes-manager.sgml Mon Oct 6 16:51:41 2008
@@ -99,6 +99,18 @@
@value:
+<!-- ##### FUNCTION gda_attributes_manager_set_full ##### -->
+<para>
+
+</para>
+
+ mgr:
+ ptr:
+ att_name:
+ value:
+ destroy:
+
+
<!-- ##### FUNCTION gda_attributes_manager_get ##### -->
<para>
@@ -130,3 +142,14 @@
@ptr:
+<!-- ##### FUNCTION gda_attributes_manager_foreach ##### -->
+<para>
+
+</para>
+
+ mgr:
+ ptr:
+ func:
+ data:
+
+
Modified: trunk/doc/C/tmpl/gda-holder.sgml
==============================================================================
--- trunk/doc/C/tmpl/gda-holder.sgml (original)
+++ trunk/doc/C/tmpl/gda-holder.sgml Mon Oct 6 16:51:41 2008
@@ -24,6 +24,15 @@
</para>
+<!-- ##### SIGNAL GdaHolder::attribute-changed ##### -->
+<para>
+
+</para>
+
+ gdaholder: the object which received the signal.
+ arg1:
+ arg2:
+
<!-- ##### SIGNAL GdaHolder::changed ##### -->
<para>
Modified: trunk/doc/C/tmpl/gda-set.sgml
==============================================================================
--- trunk/doc/C/tmpl/gda-set.sgml (original)
+++ trunk/doc/C/tmpl/gda-set.sgml Mon Oct 6 16:51:41 2008
@@ -36,6 +36,8 @@
@gdaset: the object which received the signal.
@arg1:
+ Param3:
+ Param4:
<!-- ##### SIGNAL GdaSet::holder-changed ##### -->
<para>
@@ -45,14 +47,6 @@
@gdaset: the object which received the signal.
@arg1:
-<!-- ##### SIGNAL GdaSet::holder-plugin-changed ##### -->
-<para>
-
-</para>
-
- gdaset: the object which received the signal.
- arg1:
-
<!-- ##### SIGNAL GdaSet::public-data-changed ##### -->
<para>
@@ -216,15 +210,6 @@
@set_to_merge:
-<!-- ##### FUNCTION gda_set_get_spec ##### -->
-<para>
-
-</para>
-
- set:
- Returns:
-
-
<!-- ##### STRUCT GdaSetNode ##### -->
<para>
Modified: trunk/libgda/gda-attributes-manager.c
==============================================================================
--- trunk/libgda/gda-attributes-manager.c (original)
+++ trunk/libgda/gda-attributes-manager.c Mon Oct 6 16:51:41 2008
@@ -28,7 +28,8 @@
typedef struct {
GdaAttributesManager *mgr;
gpointer ptr;
- const gchar *att_name;
+ gchar *att_name;
+ GDestroyNotify att_name_destroy;
} Key;
static guint hash_func (gconstpointer key);
@@ -63,7 +64,9 @@
{
if (key->ptr && key->mgr->for_objects)
g_object_weak_unref (G_OBJECT (key->ptr), (GWeakNotify) obj_destroyed_cb, key);
- /* DON'T g_free (key->att_name) as it is static data */
+ if (key->att_name_destroy)
+ key->att_name_destroy (key->att_name);
+
g_free (key);
}
@@ -108,22 +111,10 @@
g_hash_table_remove (key->mgr->hash, key);
}
-/**
- * gda_attributes_manager_set
- * @mgr: a #GdaAttributesManager
- * @ptr: a pointer to the ressources to which the attribute will apply
- * @att_name: an attribute's name, as a *static* string
- * @value: a #GValue, or %NULL
- *
- * Associates an attribute named @att_name to @ptr, with the value @value. Any previous association is replaced by
- * this one, and if @value is %NULL then the association is removed.
- *
- * Note: @att_name is *not* copied, so it should be a static string, or a string which exists as long as @mgr exists (or,
- * in case @ptr is an object, as long as that object exists). Libgda provides several predefined names for common attributes,
- * see <link linkend="libgda-40-Attributes-manager.synopsis">this section</link>.
- */
-void
-gda_attributes_manager_set (GdaAttributesManager *mgr, gpointer ptr, const gchar *att_name, const GValue *value)
+static void
+manager_real_set (GdaAttributesManager *mgr, gpointer ptr,
+ const gchar *att_name, GDestroyNotify destroy,
+ const GValue *value, gboolean steal_value)
{
g_return_if_fail (att_name);
if (mgr->for_objects)
@@ -136,9 +127,13 @@
key->mgr = mgr;
key->ptr = ptr;
key->att_name = att_name; /* NOT duplicated */
+ key->att_name_destroy = destroy;
if (mgr->for_objects)
g_object_weak_ref (G_OBJECT (key->ptr), (GWeakNotify) obj_destroyed_cb, key);
- g_hash_table_insert (mgr->hash, key, gda_value_copy (value));
+ if (steal_value)
+ g_hash_table_insert (mgr->hash, key, value);
+ else
+ g_hash_table_insert (mgr->hash, key, gda_value_copy (value));
}
else {
Key key;
@@ -149,6 +144,45 @@
}
/**
+ * gda_attributes_manager_set
+ * @mgr: a #GdaAttributesManager
+ * @ptr: a pointer to the ressources to which the attribute will apply
+ * @att_name: an attribute's name, as a *static* string
+ * @value: a #GValue, or %NULL
+ *
+ * Associates an attribute named @att_name to @ptr, with the value @value. Any previous association is replaced by
+ * this one, and if @value is %NULL then the association is removed.
+ *
+ * Note: @att_name is *not* copied, so it should be a static string, or a string which exists as long as @mgr exists (or,
+ * in case @ptr is an object, as long as that object exists). Libgda provides several predefined names for common attributes,
+ * see <link linkend="libgda-40-Attributes-manager.synopsis">this section</link>.
+ */
+void
+gda_attributes_manager_set (GdaAttributesManager *mgr, gpointer ptr, const gchar *att_name, const GValue *value)
+{
+ manager_real_set (mgr, ptr, att_name, NULL, value, FALSE);
+}
+
+/**
+ * gda_attributes_manager_set_full
+ * @mgr: a #GdaAttributesManager
+ * @ptr: a pointer to the ressources to which the attribute will apply
+ * @att_name: an attribute's name, as a *static* string
+ * @value: a #GValue, or %NULL
+ * @destroy: function called when @att_name is destroyed
+ *
+ * Does the same as gda_attributes_manager_set() except that @destroy is called when @att_name needs
+ * to be freed
+ */
+void
+gda_attributes_manager_set_full (GdaAttributesManager *mgr, gpointer ptr,
+ const gchar *att_name, const GValue *value, GDestroyNotify destroy)
+{
+ manager_real_set (mgr, ptr, att_name, destroy, value, FALSE);
+}
+
+
+/**
* gda_attributes_manager_get
* @mgr: a #GdaAttributesManager
* @ptr: a pointer to the ressources to which the attribute will apply
@@ -170,7 +204,7 @@
typedef struct {
gpointer *from;
gpointer *to;
- GSList *names;
+ GSList *keys;
GSList *values;
} CopyData;
static void foreach_copy_func (Key *key, const GValue *value, CopyData *cdata);
@@ -193,14 +227,15 @@
GSList *nlist, *vlist;
cdata.from = from;
cdata.to = to;
- cdata.names = NULL;
+ cdata.keys = NULL;
cdata.values = NULL;
g_hash_table_foreach (from_mgr->hash, (GHFunc) foreach_copy_func, &cdata);
- for (nlist = cdata.names, vlist = cdata.values;
+ for (nlist = cdata.keys, vlist = cdata.values;
nlist && vlist;
nlist = nlist->next, vlist = vlist->next)
- gda_attributes_manager_set (to_mgr, to, (gchar*) nlist->data, (GValue*) vlist->data);
- g_slist_free (cdata.names);
+ gda_attributes_manager_set_full (to_mgr, to, ((Key*) nlist->data)->att_name, (GValue*) vlist->data,
+ ((Key*) nlist->data)->att_name_destroy);
+ g_slist_free (cdata.keys);
g_slist_free (cdata.values);
}
@@ -208,7 +243,7 @@
foreach_copy_func (Key *key, const GValue *value, CopyData *cdata)
{
if (key->ptr == cdata->from) {
- cdata->names = g_slist_prepend (cdata->names, (gpointer) key->att_name);
+ cdata->keys = g_slist_prepend (cdata->keys, key);
cdata->values = g_slist_prepend (cdata->values, (gpointer) value);
}
}
@@ -229,19 +264,19 @@
GSList *nlist;
cdata.from = ptr;
cdata.to = NULL;
- cdata.names = NULL;
+ cdata.keys = NULL;
cdata.values = NULL;
g_hash_table_foreach (mgr->hash, (GHFunc) foreach_clear_func, &cdata);
- for (nlist = cdata.names; nlist; nlist = nlist->next)
+ for (nlist = cdata.keys; nlist; nlist = nlist->next)
gda_attributes_manager_set (mgr, ptr, (gchar*) nlist->data, NULL);
- g_slist_free (cdata.names);
+ g_slist_free (cdata.keys);
}
static void
foreach_clear_func (Key *key, const GValue *value, CopyData *cdata)
{
if (key->ptr == cdata->from)
- cdata->names = g_slist_prepend (cdata->names, (gpointer) key->att_name);
+ cdata->keys = g_slist_prepend (cdata->keys, (gpointer) key->att_name);
}
Modified: trunk/libgda/gda-attributes-manager.h
==============================================================================
--- trunk/libgda/gda-attributes-manager.h (original)
+++ trunk/libgda/gda-attributes-manager.h Mon Oct 6 16:51:41 2008
@@ -36,6 +36,8 @@
void gda_attributes_manager_set (GdaAttributesManager *mgr, gpointer ptr,
const gchar *att_name, const GValue *value);
+void gda_attributes_manager_set_full (GdaAttributesManager *mgr, gpointer ptr,
+ const gchar *att_name, const GValue *value, GDestroyNotify destroy);
const GValue *gda_attributes_manager_get (GdaAttributesManager *mgr, gpointer ptr, const gchar *att_name);
void gda_attributes_manager_copy (GdaAttributesManager *from_mgr, gpointer *from,
GdaAttributesManager *to_mgr, gpointer *to);
@@ -50,7 +52,7 @@
#define GDA_ATTRIBUTE_NUMERIC_PRECISION "__gda_attr_numeric_precision"
#define GDA_ATTRIBUTE_NUMERIC_SCALE "__gda_attr_numeric_scale"
#define GDA_ATTRIBUTE_AUTO_INCREMENT "__gda_attr_autoinc"
-
+#define GDA_ATTRIBUTE_IS_DEFAULT "__gda_attr_is_default"
G_END_DECLS
Modified: trunk/libgda/gda-data-model-iter.c
==============================================================================
--- trunk/libgda/gda-data-model-iter.c (original)
+++ trunk/libgda/gda-data-model-iter.c Mon Oct 6 16:51:41 2008
@@ -56,7 +56,7 @@
static void model_reset_cb (GdaDataModel *model, GdaDataModelIter *iter);
static GError *validate_holder_change_cb (GdaSet *paramlist, GdaHolder *param, const GValue *new_value);
-static void holder_attr_changed_cb (GdaSet *paramlist, GdaHolder *param);
+static void holder_attr_changed_cb (GdaSet *paramlist, GdaHolder *param, const gchar *att_name, const GValue *att_value);
/* get a pointer to the parents to be able to cvalue their destructor */
static GObjectClass *parent_class = NULL;
@@ -304,17 +304,18 @@
* paramlist is an iter for
*/
static void
-holder_attr_changed_cb (GdaSet *paramlist, GdaHolder *param)
+holder_attr_changed_cb (GdaSet *paramlist, GdaHolder *param, const gchar *att_name, const GValue *att_value)
{
GdaDataModelIter *iter;
gint col;
- gboolean toset;
+ gboolean toset = FALSE;
iter = GDA_DATA_MODEL_ITER (paramlist);
if (!GDA_IS_DATA_PROXY (iter->priv->data_model))
return;
- if (!iter->priv->keep_param_changes && (iter->priv->row >= 0)) {
+ if (!strcmp (att_name, GDA_ATTRIBUTE_IS_DEFAULT) &&
+ !iter->priv->keep_param_changes && (iter->priv->row >= 0)) {
g_signal_handler_block (iter->priv->data_model, iter->priv->model_changes_signals [0]);
g_signal_handler_block (iter->priv->data_model, iter->priv->model_changes_signals [1]);
@@ -322,7 +323,8 @@
col = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (param), "model_col")) - 1;
g_return_if_fail (col >= 0);
- g_object_get (G_OBJECT (param), "use-default-value", &toset, NULL);
+ if (att_value && g_value_get_boolean (att_value))
+ toset = TRUE;
if (toset && gda_holder_get_default_value (param))
gda_data_proxy_alter_value_attributes (GDA_DATA_PROXY (iter->priv->data_model),
iter->priv->row, col,
@@ -334,7 +336,7 @@
/* for the parent class */
if (((GdaSetClass *) parent_class)->holder_attr_changed)
- ((GdaSetClass *) parent_class)->holder_attr_changed (paramlist, param);
+ ((GdaSetClass *) parent_class)->holder_attr_changed (paramlist, param, att_name, att_value);
}
static void
Modified: trunk/libgda/gda-data-proxy.c
==============================================================================
--- trunk/libgda/gda-data-proxy.c (original)
+++ trunk/libgda/gda-data-proxy.c Mon Oct 6 16:51:41 2008
@@ -88,6 +88,7 @@
/* get a pointer to the parents to be able to call their destructor */
static GObjectClass *parent_class = NULL;
+extern GdaAttributesManager *gda_holder_attributes_manager;
static GStaticMutex parser_mutex = G_STATIC_MUTEX_INIT;
static GdaSqlParser *internal_parser;
@@ -3377,13 +3378,9 @@
plist1 = GDA_SET (iter)->holders;
plist2 = GDA_SET (iter2)->holders;
- for (; plist1 && plist2; plist1 = plist1->next, plist2 = plist2->next) {
- const gchar *plugin;
-
- plugin = g_object_get_data (G_OBJECT (plist2->data), "__gda_entry_plugin");
- if (plugin)
- g_object_set_data_full (G_OBJECT (plist1->data), "__gda_entry_plugin", g_strdup (plugin), g_free);
- }
+ for (; plist1 && plist2; plist1 = plist1->next, plist2 = plist2->next)
+ gda_attributes_manager_copy (gda_holder_attributes_manager, (gpointer) plist2->data,
+ gda_holder_attributes_manager, (gpointer) plist1->data);
if (plist1 || plist2)
g_warning ("Proxy iterator does not have the same length as proxied model's iterator: %d/%d",
g_slist_length (GDA_SET (iter)->holders),
Modified: trunk/libgda/gda-holder.c
==============================================================================
--- trunk/libgda/gda-holder.c (original)
+++ trunk/libgda/gda-holder.c Mon Oct 6 16:51:41 2008
@@ -60,10 +60,11 @@
CHANGED,
SOURCE_CHANGED,
VALIDATE_CHANGE,
+ ATT_CHANGED,
LAST_SIGNAL
};
-static gint gda_holder_signals[LAST_SIGNAL] = { 0, 0, 0 };
+static gint gda_holder_signals[LAST_SIGNAL] = { 0, 0, 0, 0 };
/* properties */
@@ -181,6 +182,15 @@
G_STRUCT_OFFSET (GdaHolderClass, changed),
NULL, NULL,
gda_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ 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_POINTER, G_TYPE_NONE, 2,
+ G_TYPE_STRING, G_TYPE_POINTER);
+
/**
* GdaHolder::before-change:
* @holder: the object which received the signal
@@ -203,6 +213,7 @@
class->changed = NULL;
class->source_changed = NULL;
class->validate_change = m_validate_change;
+ class->att_changed = NULL;
/* virtual functions */
object_class->dispose = gda_holder_dispose;
@@ -341,6 +352,12 @@
holder->priv->not_null = orig->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)), holder->priv->default_forced);
+ gda_holder_set_attribute (holder, GDA_ATTRIBUTE_IS_DEFAULT, att_value);
+ gda_value_free (att_value);
+
+
return holder;
}
else {
@@ -929,6 +946,10 @@
value && (G_VALUE_TYPE (value) == holder->priv->g_type))
holder->priv->default_forced = !gda_value_compare (holder->priv->default_value, value);
}
+ GValue *att_value;
+ g_value_set_boolean ((att_value = gda_value_new (G_TYPE_BOOLEAN)), holder->priv->default_forced);
+ gda_holder_set_attribute (holder, GDA_ATTRIBUTE_IS_DEFAULT, att_value);
+ gda_value_free (att_value);
/* real setting of the value */
if (holder->priv->full_bind) {
@@ -1056,6 +1077,10 @@
value && (G_VALUE_TYPE (value) == holder->priv->g_type))
holder->priv->default_forced = !gda_value_compare (holder->priv->default_value, value);
}
+ GValue *att_value;
+ g_value_set_boolean ((att_value = gda_value_new (G_TYPE_BOOLEAN)), holder->priv->default_forced);
+ gda_holder_set_attribute (holder, GDA_ATTRIBUTE_IS_DEFAULT, att_value);
+ gda_value_free (att_value);
/* real setting of the value */
if (holder->priv->full_bind) {
@@ -1216,7 +1241,12 @@
}
}
+ GValue *att_value;
+ g_value_set_boolean ((att_value = gda_value_new (G_TYPE_BOOLEAN)), TRUE);
+ gda_holder_set_attribute (holder, GDA_ATTRIBUTE_IS_DEFAULT, att_value);
+ gda_value_free (att_value);
g_signal_emit (holder, gda_holder_signals[CHANGED], 0);
+
return TRUE;
}
@@ -1301,6 +1331,11 @@
holder->priv->default_value = gda_value_copy ((GValue *)value);
}
+ GValue *att_value;
+ g_value_set_boolean ((att_value = gda_value_new (G_TYPE_BOOLEAN)), holder->priv->default_forced);
+ gda_holder_set_attribute (holder, GDA_ATTRIBUTE_IS_DEFAULT, att_value);
+ gda_value_free (att_value);
+
/* don't emit the "changed" signal */
}
@@ -1638,6 +1673,13 @@
void
gda_holder_set_attribute (GdaHolder *holder, const gchar *attribute, const GValue *value)
{
+ const GValue *cvalue;
g_return_if_fail (GDA_IS_HOLDER (holder));
+
+ cvalue = gda_attributes_manager_get (gda_holder_attributes_manager, holder, attribute);
+ if (cvalue && !gda_value_differ (cvalue, value))
+ return;
+
gda_attributes_manager_set (gda_holder_attributes_manager, holder, attribute, value);
+ g_signal_emit (holder, gda_holder_signals[ATT_CHANGED], 0, attribute, value);
}
Modified: trunk/libgda/gda-holder.h
==============================================================================
--- trunk/libgda/gda-holder.h (original)
+++ trunk/libgda/gda-holder.h Mon Oct 6 16:51:41 2008
@@ -57,6 +57,7 @@
void (*changed) (GdaHolder *holder);
void (*source_changed) (GdaHolder *holder);
GError *(*validate_change) (GdaHolder *holder, const GValue *new_value);
+ void (*att_changed) (GdaHolder *holder, const gchar *att_name, const GValue *att_value);
};
GType gda_holder_get_type (void) G_GNUC_CONST;
Modified: trunk/libgda/gda-marshal.list
==============================================================================
--- trunk/libgda/gda-marshal.list (original)
+++ trunk/libgda/gda-marshal.list Mon Oct 6 16:51:41 2008
@@ -43,3 +43,5 @@
POINTER:POINTER
BOOLEAN:POINTER
POINTER:OBJECT,POINTER
+VOID:STRING,POINTER
+VOID:OBJECT,STRING,POINTER
Modified: trunk/libgda/gda-set.c
==============================================================================
--- trunk/libgda/gda-set.c (original)
+++ trunk/libgda/gda-set.c Mon Oct 6 16:51:41 2008
@@ -53,13 +53,14 @@
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 notify_holder_cb (GdaHolder *holder, GParamSpec *pspec, GdaSet *dataset);
+static void att_holder_changed_cb (GdaHolder *holder, const gchar *att_name, const GValue *att_value, GdaSet *dataset);
static void compute_public_data (GdaSet *set);
static gboolean gda_set_real_add_holder (GdaSet *set, GdaHolder *holder);
/* get a pointer to the parents to be able to call their destructor */
static GObjectClass *parent_class = NULL;
+extern GdaAttributesManager *gda_holder_attributes_manager;
/* properties */
enum
@@ -76,14 +77,13 @@
{
HOLDER_CHANGED,
PUBLIC_DATA_CHANGED,
- HOLDER_PLUGIN_CHANGED,
HOLDER_ATTR_CHANGED,
VALIDATE_HOLDER_CHANGE,
VALIDATE_SET,
LAST_SIGNAL
};
-static gint gda_set_signals[LAST_SIGNAL] = { 0, 0, 0, 0, 0, 0};
+static gint gda_set_signals[LAST_SIGNAL] = { 0, 0, 0, 0, 0 };
/* private structure */
@@ -276,22 +276,14 @@
G_STRUCT_OFFSET (GdaSetClass, validate_set),
validate_accumulator, NULL,
gda_marshal_POINTER__VOID, G_TYPE_POINTER, 0);
- gda_set_signals[HOLDER_PLUGIN_CHANGED] =
- g_signal_new ("holder-plugin-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdaSetClass, holder_plugin_changed),
- NULL, NULL,
- gda_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
- GDA_TYPE_HOLDER);
gda_set_signals[HOLDER_ATTR_CHANGED] =
g_signal_new ("holder-attr-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaSetClass, holder_attr_changed),
NULL, NULL,
- gda_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
- GDA_TYPE_HOLDER);
+ gda_marshal_VOID__OBJECT_STRING_POINTER, G_TYPE_NONE, 3,
+ GDA_TYPE_HOLDER, G_TYPE_STRING, G_TYPE_POINTER);
gda_set_signals[PUBLIC_DATA_CHANGED] =
g_signal_new ("public-data-changed",
G_TYPE_FROM_CLASS (object_class),
@@ -303,7 +295,6 @@
class->holder_changed = NULL;
class->validate_holder_change = m_validate_holder_change;
class->validate_set = m_validate_set;
- class->holder_plugin_changed = NULL;
class->holder_attr_changed = NULL;
class->public_data_changed = NULL;
@@ -869,70 +860,6 @@
return set;
}
-
-/**
- * gda_set_get_spec
- * @set: a #GdaSet object
- *
- * Get the specification as an XML string. See the gda_set_new_from_spec_string()
- * form more information about the XML specification string format.
- *
- * Returns: a new string
- */
-gchar *
-gda_set_get_spec (GdaSet *set)
-{
- xmlDocPtr doc;
- xmlNodePtr root;
- xmlChar *xmlbuff;
- int buffersize;
- GSList *list;
-
- g_return_val_if_fail (GDA_IS_SET (set), NULL);
-
- doc = xmlNewDoc ((xmlChar*)"1.0");
- g_return_val_if_fail (doc, NULL);
- root = xmlNewDocNode (doc, NULL, (xmlChar*)"data-set-spec", NULL);
- xmlDocSetRootElement (doc, root);
-
- /* holders list */
- for (list = set->holders; list; list = list->next) {
- xmlNodePtr node;
- GdaHolder *holder = GDA_HOLDER (list->data);
- gchar *str;
-
- node = xmlNewTextChild (root, NULL, (xmlChar*)"parameter", NULL);
- g_object_get (G_OBJECT (holder), "id", &str, NULL);
- if (str)
- xmlSetProp(node, (xmlChar*)"id", (xmlChar*)str);
- g_free (str);
-
- g_object_get (G_OBJECT (holder), "name", &str, NULL);
- if (str)
- xmlSetProp(node, (xmlChar*)"name", (xmlChar*)str);
- g_free (str);
-
- g_object_get (G_OBJECT (holder), "description", &str, NULL);
- if (str)
- xmlSetProp(node, (xmlChar*)"descr", (xmlChar*)str);
- g_free (str);
-
- xmlSetProp(node, (xmlChar*)"gdatype", (xmlChar*)gda_g_type_to_string (gda_holder_get_g_type (holder)));
-
- xmlSetProp(node, (xmlChar*)"nullok", (xmlChar*)(gda_holder_get_not_null (holder) ? "FALSE" : "TRUE"));
- str = g_object_get_data (G_OBJECT (holder), "__gda_entry_plugin");
- if (str)
- xmlSetProp(node, (xmlChar*)"plugin", (xmlChar*)str);
- }
-
- /* holders' values, sources, constraints: TODO */
-
- xmlDocDumpFormatMemory (doc, &xmlbuff, &buffersize, 1);
-
- xmlFreeDoc(doc);
- return (gchar *) xmlbuff;
-}
-
/**
* gda_set_remove_holder
* @set:
@@ -954,7 +881,7 @@
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 (notify_holder_cb), set);
+ G_CALLBACK (att_holder_changed_cb), set);
/* now destroy the GdaSetNode and the GdaSetSource if necessary */
node = gda_set_get_node (set, holder);
@@ -982,26 +909,15 @@
}
static void
-notify_holder_cb (GdaHolder *holder, GParamSpec *pspec, GdaSet *set)
+att_holder_changed_cb (GdaHolder *holder, const gchar *att_name, const GValue *att_value, GdaSet *set)
{
- if (!strcmp (pspec->name, "plugin")) {
-#ifdef GDA_DEBUG_signal
- g_print (">> 'HOLDER_PLUGIN_CHANGED' from %s\n", __FUNCTION__);
-#endif
- g_signal_emit (G_OBJECT (set), gda_set_signals[HOLDER_PLUGIN_CHANGED], 0, holder);
#ifdef GDA_DEBUG_signal
- g_print ("<< 'HOLDER_PLUGIN_CHANGED' from %s\n", __FUNCTION__);
+ g_print (">> 'HOLDER_ATTR_CHANGED' from %s\n", __FUNCTION__);
#endif
- }
- if (!strcmp (pspec->name, "use-default-value")) {
+ 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__);
+ g_print ("<< 'HOLDER_ATTR_CHANGED' from %s\n", __FUNCTION__);
#endif
- g_signal_emit (G_OBJECT (set), gda_set_signals[HOLDER_ATTR_CHANGED], 0, holder);
-#ifdef GDA_DEBUG_signal
- g_print ("<< 'HOLDER_ATTR_CHANGED' from %s\n", __FUNCTION__);
-#endif
- }
}
static GError *
@@ -1053,13 +969,13 @@
if (set->holders) {
for (list = set->holders; list; list = list->next) {
g_signal_handlers_disconnect_by_func (G_OBJECT (list->data),
- G_CALLBACK (changed_holder_cb), set);
+ G_CALLBACK (changed_holder_cb), set);
g_signal_handlers_disconnect_by_func (G_OBJECT (list->data),
- G_CALLBACK (validate_change_holder_cb), set);
+ G_CALLBACK (validate_change_holder_cb), set);
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 (notify_holder_cb), set);
+ G_CALLBACK (att_holder_changed_cb), set);
g_object_unref (G_OBJECT (list->data));
}
g_slist_free (set->holders);
@@ -1361,8 +1277,8 @@
G_CALLBACK (validate_change_holder_cb), set);
g_signal_connect (G_OBJECT (holder), "source-changed",
G_CALLBACK (source_changed_holder_cb), set);
- g_signal_connect (G_OBJECT (holder), "notify",
- G_CALLBACK (notify_holder_cb), set);
+ g_signal_connect (G_OBJECT (holder), "attribute-changed",
+ G_CALLBACK (att_holder_changed_cb), set);
return TRUE;
}
else {
Modified: trunk/libgda/gda-set.h
==============================================================================
--- trunk/libgda/gda-set.h (original)
+++ trunk/libgda/gda-set.h Mon Oct 6 16:51:41 2008
@@ -121,8 +121,8 @@
GError *(*validate_holder_change)(GdaSet *set, GdaHolder *holder, const GValue *new_value);
GError *(*validate_set) (GdaSet *set);
void (*holder_changed) (GdaSet *set, GdaHolder *holder);
- void (*holder_plugin_changed) (GdaSet *set, GdaHolder *holder);
- void (*holder_attr_changed) (GdaSet *set, GdaHolder *holder);
+ void (*holder_attr_changed) (GdaSet *set, GdaHolder *holder,
+ const gchar *attr_name, const GValue *value);
void (*public_data_changed) (GdaSet *set);
};
@@ -133,7 +133,6 @@
GdaSet *gda_set_new_from_spec_string (const gchar *xml_spec, GError **error);
GdaSet *gda_set_new_from_spec_node (xmlNodePtr xml_spec, GError **error);
-gchar *gda_set_get_spec (GdaSet *set);
gboolean gda_set_set_holder_value (GdaSet *set, GError **error, const gchar *holder_id, ...);
const GValue *gda_set_get_holder_value (GdaSet *set, const gchar *holder_id);
Modified: trunk/libgda/gda-util.c
==============================================================================
--- trunk/libgda/gda-util.c (original)
+++ trunk/libgda/gda-util.c Mon Oct 6 16:51:41 2008
@@ -44,6 +44,7 @@
#include <libgda/binreloc/gda-binreloc.h>
extern gchar *gda_lang_locale;
+extern GdaAttributesManager *gda_holder_attributes_manager;
/**
* gda_g_type_to_string
@@ -430,9 +431,6 @@
}
else
gda_holder_set_not_null (holder, FALSE);
- str = xmlGetProp (node, BAD_CAST "plugin");
- if (str)
- g_object_set_data_full (G_OBJECT (holder), "__gda_entry_plugin", str, xmlFree);
str = xmlGetProp (node, BAD_CAST "source");
if (str)
@@ -495,6 +493,20 @@
continue;
}
+ if (!strcmp ((gchar*)vnode->name, "attribute")) {
+ 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,
+ att_name, value, (GDestroyNotify) xmlFree);
+ gda_value_free (value);
+ }
+ vnode = vnode->next;
+ continue;
+ }
if (strcmp ((gchar*)vnode->name, "gda_value")) {
vnode = vnode->next;
continue;
Modified: trunk/libgda/libgda-paramlist.dtd
==============================================================================
--- trunk/libgda/libgda-paramlist.dtd (original)
+++ trunk/libgda/libgda-paramlist.dtd Mon Oct 6 16:51:41 2008
@@ -17,7 +17,7 @@
descr CDATA #IMPLIED
status (OPT|REQ) #IMPLIED>
-<!ELEMENT parameter (gda_value*)>
+<!ELEMENT parameter (gda_value*, attribute*)>
<!ATTLIST parameter
id NMTOKEN #REQUIRED
dbmstype NMTOKEN #IMPLIED
@@ -31,6 +31,10 @@
hint CDATA #IMPLIED
status (OPT|REQ) #IMPLIED>
+<!ELEMENT attribute (#PCDATA)>
+<!ATTLIST attribute
+ name CDATA #REQUIRED>
+
<!ELEMENT sources (gda_array*)>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]