[libgda] Improved Gda and Gdaui Vala Bindings * Fixed missing paramenters in gdaui-plugin.h * Set as opaque,



commit 1423a5d648a3ae8c04ffef86f5312eea68905c3a
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Mar 20 17:00:17 2013 -0600

    Improved Gda and Gdaui Vala Bindings
    * Fixed missing paramenters in gdaui-plugin.h
    * Set as opaque, added new methods and registering as GType
    GdaSetSource, GdaGroup, GdauiSetSource and GdauiSetGroup
    * Updated libgda-5.0.vapi

 libgda-ui/gdaui-plugin.h |   16 +-
 libgda-ui/gdaui-set.c    |  408 ++++++++++++++++++++++++++++++++++++++++++----
 libgda-ui/gdaui-set.h    |   78 ++++++++-
 libgda/gda-set.c         |  232 +++++++++++++++++++++++++--
 libgda/gda-set.h         |   32 ++++-
 libgda/libgda-5.0.vapi   |   51 ++++--
 6 files changed, 739 insertions(+), 78 deletions(-)
---
diff --git a/libgda-ui/gdaui-plugin.h b/libgda-ui/gdaui-plugin.h
index ddfac71..3c7c006 100644
--- a/libgda-ui/gdaui-plugin.h
+++ b/libgda-ui/gdaui-plugin.h
@@ -27,25 +27,25 @@
 
 /**
  * GdauiEntryCreateFunc:
- * @None: a #GdaDataHandler
- * @None: a #GType
- * @None: (allow-none): options, or %NULL
+ * @handler: a #GdaDataHandler
+ * @type: a #GType
+ * @options: (allow-none): options, or %NULL
  * @Returns: a new #GdauiDataEntry
  *
  * Defines a function which creates a #GdauiDataEntry widget
  */
-typedef GdauiDataEntry   *(*GdauiEntryCreateFunc)(GdaDataHandler *, GType, const gchar *);
+typedef GdauiDataEntry   *(*GdauiEntryCreateFunc)(GdaDataHandler *handler, GType type, const gchar *options);
 
 /**
  * GdauiCellCreateFunc:
- * @None: a #GdaDataHandler
- * @None: a #GType
- * @None: (allow-none): options, or %NULL
+ * @handler: a #GdaDataHandler
+ * @type: a #GType
+ * @options: (allow-none): options, or %NULL
  * @Returns:a new #GtkCellRenderer
  *
  * Defines a function which creates a #GtkCellRenderer object
  */
-typedef GtkCellRenderer  *(*GdauiCellCreateFunc) (GdaDataHandler *, GType, const gchar *);
+typedef GtkCellRenderer  *(*GdauiCellCreateFunc) (GdaDataHandler *handler, GType type, const gchar *options);
 
 
 /**
diff --git a/libgda-ui/gdaui-set.c b/libgda-ui/gdaui-set.c
index ad32c42..b4a5abb 100644
--- a/libgda-ui/gdaui-set.c
+++ b/libgda-ui/gdaui-set.c
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2009 - 2012 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2010 David King <davidk openismus com>
+ * Copyright (C) 2013 Daniel Espinosa <esodan gmail com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,6 +25,317 @@
 #include "gdaui-set.h"
 #include "marshallers/gdaui-marshal.h"
 
+/*
+   Register GdauiSetGroup type
+*/
+GType
+gdaui_set_group_get_type (void)
+{
+       static GType type = 0;
+
+       if (G_UNLIKELY (type == 0)) {
+        if (type == 0)
+                       type = g_boxed_type_register_static ("GdauiSetGroup",
+                                                            (GBoxedCopyFunc) gdaui_set_group_copy,
+                                                            (GBoxedFreeFunc) gdaui_set_group_free);
+       }
+
+       return type;
+}
+
+/**
+ * gdaui_set_group_new:
+ * 
+ * Creates a new #GdauiSetGroup struct.
+ *
+ * Return: (transfer full): a new #GdauiSetGroup struct.
+ *
+ * Since: 5.2
+ */
+GdauiSetGroup*
+gdaui_set_group_new (void)
+{
+       GdauiSetGroup *sg = g_new0 (GdauiSetGroup, 1);
+       sg->source = NULL;
+       sg->group = NULL;
+       return sg;
+}
+
+/**
+ * gdaui_set_group_copy:
+ * @sg: a #GdauiSetGroup
+ *
+ * Copy constructor.
+ *
+ * Returns: a new #GdauiSetGroup
+ *
+ * Since: 5.2
+ */
+GdauiSetGroup *
+gdaui_set_group_copy (GdauiSetGroup *sg)
+{
+       g_return_val_if_fail (sg, NULL);
+
+       GdauiSetGroup *n;
+       n = gdaui_set_group_new ();
+       n->source = sg->source;
+       n->group = sg->group;
+       return n;
+}
+
+/**
+ * gdaui_set_group_free:
+ * @sg: (allow-none): a #GdauiSetGroup struct to free
+ * 
+ * Frees any resources taken by @sg struct. If @sg is %NULL, then nothing happens.
+ *
+ * Since: 5.2
+ */
+void
+gdaui_set_group_free (GdauiSetGroup *sg)
+{
+       g_return_if_fail(sg);
+       g_free (sg);
+}
+
+/**
+ * gdaui_set_group_set_source:
+ * @sg: a #GdauiSetGroup struct to free
+ * @source: a #GdauiSetSource struct
+ * 
+ * Set source to @source.
+ *
+ * Since: 5.2
+ */
+void
+gdaui_set_group_set_source (GdauiSetGroup *sg, GdauiSetSource *source)
+{
+       g_return_if_fail (sg);
+       sg->source = sg->source;
+}
+
+/**
+ * gdaui_set_group_get_source:
+ * @sg: a #GdauiSetGroup struct
+ * 
+ * Get source used by @sg.
+ * 
+ * Returns: used #GdaSetGroup
+ *
+ * Since: 5.2
+ */
+GdauiSetSource*
+gdaui_set_group_get_source (GdauiSetGroup *sg)
+{
+       g_return_val_if_fail (sg, NULL);
+       return sg->source;
+}
+
+/**
+ * gdaui_set_group_set_group:
+ * @sg: a #GdauiSetGroup struct to free
+ * @group: a #GdaSetGroup struct
+ * 
+ * Set source to @source.
+ *
+ * Since: 5.2
+ */
+void
+gdaui_set_group_set_group (GdauiSetGroup *sg, GdaSetGroup *group)
+{
+       g_return_if_fail (sg);
+       g_return_if_fail (group);
+       sg->group = sg->group;
+}
+
+/**
+ * gdaui_set_group_get_group:
+ * @sg: a #GdauiSetGroup struct to free
+ * 
+ * Get group used by @sg.
+ * 
+ * Returns: used #GdaSetGroup
+ *
+ * Since: 5.2
+ */
+GdaSetGroup*
+gdaui_set_group_get_group (GdauiSetGroup *sg)
+{
+       g_return_val_if_fail (sg, NULL);
+       return sg->group;
+}
+
+/*
+   Register GdauiSetSource type
+*/
+GType
+gdaui_set_source_get_type (void)
+{
+       static GType type = 0;
+
+       if (G_UNLIKELY (type == 0)) {
+        if (type == 0)
+                       type = g_boxed_type_register_static ("GdauiSetSource",
+                                                            (GBoxedCopyFunc) gdaui_set_source_copy,
+                                                            (GBoxedFreeFunc) gdaui_set_source_free);
+       }
+
+       return type;
+}
+
+/**
+ * gdaui_set_source_new:
+ * 
+ * Creates a new #GdauiSetSource struct.
+ *
+ * Return: (transfer full): a new #GdauiSetSource struct.
+ *
+ * Since: 5.2
+ */
+GdauiSetSource*
+gdaui_set_source_new (void)
+{
+       GdauiSetSource *s = g_new0 (GdauiSetSource, 1);
+       s->source = NULL;
+       s->shown_n_cols = 0;
+       s->shown_cols_index = NULL;
+       s->ref_n_cols = 0;
+       s->ref_cols_index = NULL;
+       
+       return s;
+}
+
+/**
+ * gdaui_set_source_copy:
+ * @s: a #GdauiSetGroup
+ *
+ * Copy constructor.
+ *
+ * Returns: a new #GdauiSetSource
+ *
+ * Since: 5.2
+ */
+GdauiSetSource *
+gdaui_set_source_copy (GdauiSetSource *s)
+{
+       GdauiSetSource *n;
+       gint i,j;
+       g_return_val_if_fail (s, NULL); 
+       n = gdaui_set_source_new ();
+       n->source = s->source;
+       n->ref_n_cols = s->ref_n_cols;
+       n->ref_cols_index = g_new0 (gint,n->ref_n_cols);
+       for (i = 0; i < n->ref_n_cols; i++) {
+               n->ref_cols_index[i] = s->ref_cols_index[i];
+       }
+       n->shown_n_cols = s->shown_n_cols;
+       n->shown_cols_index = g_new0 (gint, n->shown_n_cols);
+       for (j = 0; j < n->shown_n_cols; j++) {
+               n->shown_cols_index[j] = s->shown_cols_index[j];
+       }
+       return n;
+}
+
+/**
+ * gdaui_set_source_free:
+ * @s: (allow-none): a #GdauiSetSource struct to free
+ * 
+ * Frees any resources taken by @s struct. If @s is %NULL, then nothing happens.
+ *
+ * Since: 5.2
+ */
+void
+gdaui_set_source_free (GdauiSetSource *s)
+{
+       g_return_if_fail(s);
+       if(s->shown_cols_index)
+               g_free(s->shown_cols_index);
+       if (s->ref_cols_index)
+               g_free(s->ref_cols_index);
+       g_free (s);
+}
+
+/**
+ * gdaui_set_source_set_source:
+ * @s: a #GdauiSetSource struct to free
+ * @source: a #GdaSetSource struct
+ * 
+ * Set source to @source.
+ *
+ * Since: 5.2
+ */
+void
+gdaui_set_source_set_source (GdauiSetSource *s, GdaSetSource *source)
+{
+       g_return_if_fail (s);
+       s->source = s->source;
+}
+
+/**
+ * gdaui_set_source_get_source:
+ * @s: a #GdauiSetGroup struct
+ * 
+ * Get source used by @sg.
+ * 
+ * Returns: used #GdaSetSource
+ *
+ * Since: 5.2
+ */
+GdaSetSource*
+gdaui_set_source_get_source (GdauiSetSource *s)
+{
+       g_return_val_if_fail (s, NULL);
+       return s->source;
+}
+
+/**
+ * gdaui_set_source_set_shown_columns:
+ * @s: a #GdauiSetSource struct to free
+ * @columns: (array length=n_columns): an array of with columns numbers to be shown from a #GdaSetSource
+ * @n_columns: number of columns of the array
+ * 
+ * Set the columns to be shown.
+ *
+ * Since: 5.2
+ */
+void
+gdaui_set_source_set_shown_columns (GdauiSetSource *s, gint *columns, gint n_columns)
+{
+       gint i;
+       g_return_if_fail (s);
+       g_return_if_fail (columns);
+       if (s->shown_cols_index)
+               g_free (s->shown_cols_index);
+       s->shown_n_cols = n_columns;
+       for (i = 0; i < n_columns; i++) {
+               s->shown_cols_index[i] = columns[i];
+       }
+}
+
+/**
+ * gdaui_set_source_set_ref_columns:
+ * @s: a #GdauiSetSource struct to free
+ * @columns: (array length=n_columns): an array of with columns numbers of referen (Primary Key) at 
#GdaSetSource
+ * @n_columns: number of columns of the array
+ * 
+ * Set the columns to be shown.
+ *
+ * Since: 5.2
+ */
+void
+gdaui_set_source_set_ref_columns (GdauiSetSource *s, gint *columns, gint n_columns)
+{
+       gint i;
+       g_return_if_fail (s);
+       g_return_if_fail (columns);
+       if (s->ref_cols_index)
+               g_free (s->ref_cols_index);
+       s->ref_n_cols = n_columns;
+       for (i = 0; i < n_columns; i++) {
+               s->ref_cols_index[i] = columns[i];
+       }
+}
+
 static void gdaui_set_class_init (GdauiSetClass * class);
 static void gdaui_set_init (GdauiSet *wid);
 static void gdaui_set_dispose (GObject *object);
@@ -69,7 +381,12 @@ enum {
 static gint gdaui_set_signals[LAST_SIGNAL] = { 0, 0 };
 
 GType
-_gdaui_set_get_type (void)
+_gdaui_set_get_type (void) {
+       return gdaui_set_get_type ();
+}
+
+GType
+gdaui_set_get_type (void)
 {
        static GType type = 0;
 
@@ -158,11 +475,28 @@ gdaui_set_init (GdauiSet *set)
  *
  * Creates a new #GdauiSet which wraps @set's properties
  *
- *  Returns: the new widget
+ * Returns: the new widget
+ * 
+ * Deprecated: Since 5.2
  */
 GdauiSet *
 _gdaui_set_new (GdaSet *set)
 {
+       return gdaui_set_new (set);
+}
+
+/**
+ * gdaui_set_new:
+ * @set: a #GdaSet
+ *
+ * Creates a new #GdauiSet which wraps @set's properties
+ *
+ * Returns: the new widget
+ * Since: 5.2
+ **/
+GdauiSet *
+gdaui_set_new (GdaSet *set)
+{
        g_return_val_if_fail (GDA_IS_SET (set), NULL);
 
        return (GdauiSet *) g_object_new (GDAUI_TYPE_SET, "set", set, NULL);
@@ -255,16 +589,14 @@ clean_public_data (GdauiSet *set)
        
        for (list = set->sources_list; list; list = list->next) {
                GdauiSetSource *dsource = (GdauiSetSource*) list->data;
-               g_free (dsource->shown_cols_index);
-               g_free (dsource->ref_cols_index);
-               g_free (dsource);
+               gdaui_set_source_free (dsource);
        }
        g_slist_free (set->sources_list);
        set->sources_list = NULL;
 
        for (list = set->groups_list; list; list = list->next) {
                GdauiSetGroup *dgroup = (GdauiSetGroup*) list->data;
-               g_free (dgroup);
+               gdaui_set_group_free (dgroup);
        }
        g_slist_free (set->groups_list);
        set->groups_list = NULL;
@@ -281,11 +613,11 @@ compute_public_data (GdauiSet *set)
        hash = g_hash_table_new (NULL, NULL);
        for (list = aset->sources_list; list; list = list->next) {
                GdauiSetSource *dsource;
-               dsource = g_new0 (GdauiSetSource, 1);
+               dsource = gdaui_set_source_new ();
                set->sources_list = g_slist_prepend (set->sources_list, dsource);
                g_hash_table_insert (hash, list->data, dsource);
 
-               dsource->source = GDA_SET_SOURCE (list->data);
+               gdaui_set_source_set_source (dsource, GDA_SET_SOURCE (list->data));
                compute_shown_columns_index (dsource);
                compute_ref_columns_index (dsource);
        }
@@ -294,10 +626,12 @@ compute_public_data (GdauiSet *set)
        /* scan GdaSetGroup list */
        for (list = aset->groups_list; list; list = list->next) {
                GdauiSetGroup *dgroup;
-               dgroup = g_new0 (GdauiSetGroup, 1);
+               dgroup = gdaui_set_group_new ();
                set->groups_list = g_slist_prepend (set->groups_list, dgroup);
-               dgroup->group = GDA_SET_GROUP (list->data);
-               dgroup->source = g_hash_table_lookup (hash, GDA_SET_GROUP (list->data)->nodes_source);
+               gdaui_set_group_set_group (dgroup, GDA_SET_GROUP (list->data));
+               gdaui_set_group_set_source (dgroup, 
+                                           g_hash_table_lookup (hash, 
+                                                                GDA_SET_GROUP (list->data)->nodes_source));
        }
        set->groups_list = g_slist_reverse (set->groups_list);
 
@@ -329,12 +663,11 @@ update_public_data (GdauiSet *set)
                        set->sources_list = g_slist_prepend (set->sources_list, dsource);
                        continue;
                }
-
-               dsource = g_new0 (GdauiSetSource, 1);
+               dsource = gdaui_set_source_new ();
                set->sources_list = g_slist_prepend (set->sources_list, dsource);
                g_hash_table_insert (shash, list->data, dsource);
 
-               dsource->source = GDA_SET_SOURCE (list->data);
+               gdaui_set_source_set_source (dsource, GDA_SET_SOURCE (list->data));
                compute_shown_columns_index (dsource);
                compute_ref_columns_index (dsource);
        }
@@ -344,9 +677,7 @@ update_public_data (GdauiSet *set)
                for (list = elist; list; list = list->next) {
                        if (!g_slist_find (set->sources_list, list->data)) {
                                GdauiSetSource *dsource = (GdauiSetSource*) list->data;
-                               g_free (dsource->shown_cols_index);
-                               g_free (dsource->ref_cols_index);
-                               g_free (dsource);
+                               gdaui_set_source_free (dsource);
                        }
                }
                g_slist_free (elist);
@@ -369,10 +700,10 @@ update_public_data (GdauiSet *set)
                        set->groups_list = g_slist_prepend (set->groups_list, dgroup);
                        continue;
                }
-               dgroup = g_new0 (GdauiSetGroup, 1);
+               dgroup = gdaui_set_group_new ();
                set->groups_list = g_slist_prepend (set->groups_list, dgroup);
-               dgroup->group = GDA_SET_GROUP (list->data);
-               dgroup->source = g_hash_table_lookup (shash, dgroup->group->nodes_source);
+               gdaui_set_group_set_group (dgroup, GDA_SET_GROUP (list->data));
+               gdaui_set_group_set_source (dgroup, g_hash_table_lookup (shash, dgroup->group->nodes_source));
        }
        set->groups_list = g_slist_reverse (set->groups_list);
 
@@ -380,7 +711,7 @@ update_public_data (GdauiSet *set)
                for (list = elist; list; list = list->next) {
                        if (!g_slist_find (set->groups_list, list->data)) {
                                GdauiSetGroup *dgroup = (GdauiSetGroup*) list->data;
-                               g_free (dgroup);
+                               gdaui_set_group_free (dgroup);
                        }
                }
                g_slist_free (elist);
@@ -433,9 +764,7 @@ compute_shown_columns_index (GdauiSetSource *dsource)
                        mask[i] = i;
                }
        }
-
-       dsource->shown_n_cols = masksize;
-       dsource->shown_cols_index = mask;
+       gdaui_set_source_set_shown_columns (dsource, mask, masksize);
 }
 
 void
@@ -481,9 +810,7 @@ compute_ref_columns_index (GdauiSetSource *dsource)
                        mask[i] = i;
                }
        }
-
-       dsource->ref_n_cols = masksize;
-       dsource->ref_cols_index = mask;
+       gdaui_set_source_set_ref_columns (dsource, mask, masksize);
 }
 
 
@@ -507,11 +834,30 @@ gdaui_set_get_property (GObject *object,
        }       
 }
 
-/*
- * _gdaui_set_get_group
- */
+/**
+ * _gdaui_set_get_group:
+ * @dbset:
+ * @holder:
+ * 
+ * Returns: A new #GdauiSetGroup struct
+ * Deprecated: Since 5.2
+ **/
+GdauiSetGroup  *
+_gdaui_set_get_group (GdauiSet *dbset, GdaHolder *holder) 
+{
+       return gdaui_set_get_group (dbset, holder);
+}
+
+/**
+ * gdaui_set_get_group:
+ * @dbset:
+ * @holder:
+ * 
+ * Returns: A new #GdauiSetGroup struct
+ * Since: 5.2
+ **/
 GdauiSetGroup  *
-_gdaui_set_get_group (GdauiSet *dbset, GdaHolder *holder)
+gdaui_set_get_group (GdauiSet *dbset, GdaHolder *holder)
 {
        GdaSetGroup *agroup;
        GSList *list;
diff --git a/libgda-ui/gdaui-set.h b/libgda-ui/gdaui-set.h
index f576044..3d81647 100644
--- a/libgda-ui/gdaui-set.h
+++ b/libgda-ui/gdaui-set.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2009 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2013 Daniel Espinosa <esodan gmail com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,10 +26,10 @@
 
 G_BEGIN_DECLS
 
-#define GDAUI_TYPE_SET          (_gdaui_set_get_type())
-#define GDAUI_SET(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, _gdaui_set_get_type(), GdauiSet)
-#define GDAUI_SET_CLASS(klass)  G_TYPE_CHECK_CLASS_CAST (klass, _gdaui_set_get_type (), GdauiSetClass)
-#define GDAUI_IS_SET(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, _gdaui_set_get_type ())
+#define GDAUI_TYPE_SET          (gdaui_set_get_type())
+#define GDAUI_SET(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, gdaui_set_get_type(), GdauiSet)
+#define GDAUI_SET_CLASS(klass)  G_TYPE_CHECK_CLASS_CAST (klass, gdaui_set_get_type (), GdauiSetClass)
+#define GDAUI_IS_SET(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, gdaui_set_get_type ())
 
 
 typedef struct _GdauiSet      GdauiSet;
@@ -38,6 +39,20 @@ typedef struct _GdauiSetPriv  GdauiSetPriv;
 typedef struct _GdauiSetGroup GdauiSetGroup;
 typedef struct _GdauiSetSource GdauiSetSource;
 
+/**
+ * GdauiSetGroup:
+ * @group: 
+ * @source: 
+ *
+ * The <structname>GdauiSetGroup</structname>.
+ *
+ * To create a new #GdauiSetGroup use #gdaiu_set_group_new. 
+ * 
+ * To free a #GdauiSetGroup, created by #gdaui_set_group_new, use #gda_set_group_free.
+ *
+ * Since 5.2, you must consider this struct as opaque. Any access to its internal must use public API.
+ * Don't try to use #gdaui_set_group_free on a struct that was created manually.
+ */
 struct _GdauiSetGroup {
         GdaSetGroup      *group;
         GdauiSetSource   *source; /* if NULL, then @group->nodes contains exactly one entry */
@@ -48,8 +63,23 @@ struct _GdauiSetGroup {
         gpointer      _gda_reserved2;
 };
 
-#define GDAUI_SET_GROUP(x) ((GdauiSetGroup*)(x))
-
+/**
+ * GdauiSetSource:
+ * @source: a #GdaSetSource
+ * @shown_cols_index: (array length=shown_n_cols): Array with the column number to be shown from 
#GdaSetSource
+ * @shown_n_cols: number of elements of @shown_cols_index
+ * @ref_cols_index: (array length=ref_n_cols): Array with the number of columns as PRIMARY KEY in 
#GdaSetSource
+ * @ref_n_cols: number of elements of @ref_cols_index
+ *
+ * The <structname>GdauiSetSource</structname> is a ...
+ *
+ * To create a new #GdauiSetSource use #gdaui_set_source_new.
+ * 
+ * To free a #GdauiSetSource, created by #gdaui_set_source_new, use #gdaui_set_source_free.
+ *
+ * Since 5.2, you must consider this struct as opaque. Any access to its internal must use public API.
+ * Don't try to use #gdaui_set_source_free on a struct that was created manually.
+ */
 struct _GdauiSetSource {
         GdaSetSource   *source;
 
@@ -69,9 +99,14 @@ struct _GdauiSetSource {
         gpointer        _gda_reserved4;
 };
 
-#define GDAUI_SET_SOURCE(x) ((GdauiSetSource*)(x))
+
 
 /* struct for the object's data */
+/**
+ * GdauiSet:
+ * @sources_list: (element-type Gdaui.SetSource): list of #GdauiSetSource
+ * @groups_list: (element-type Gdaui.SetGroup): list of #GdauiSetGroup
+ */
 struct _GdauiSet
 {
        GObject         object;
@@ -93,11 +128,36 @@ struct _GdauiSetClass
 /* 
  * Generic widget's methods 
  */
-GType             _gdaui_set_get_type            (void) G_GNUC_CONST;
+GType             gdaui_set_get_type            (void) G_GNUC_CONST;
+GdauiSet         *gdaui_set_new                 (GdaSet *set);
+GdauiSetGroup    *gdaui_set_get_group           (GdauiSet *dbset, GdaHolder *holder);
 
+#define GDAUI_TYPE_SET_GROUP (gdaui_set_group_get_type ())
+#define GDAUI_SET_GROUP(x) ((GdauiSetGroup*)(x))
+GType             gdaui_set_group_get_type           (void) G_GNUC_CONST;
+GdauiSetGroup    *gdaui_set_group_new                (void);
+void              gdaui_set_group_free               (GdauiSetGroup *sg);
+GdauiSetGroup    *gdaui_set_group_copy               (GdauiSetGroup *sg);
+void              gdaui_set_group_set_source         (GdauiSetGroup *sg, GdauiSetSource *source);
+GdauiSetSource   *gdaui_set_group_get_source         (GdauiSetGroup *sg);
+void              gdaui_set_group_set_group          (GdauiSetGroup *sg, GdaSetGroup *group);
+GdaSetGroup      *gdaui_set_group_get_group          (GdauiSetGroup *sg);
+
+#define GDAUI_TYPE_SET_SOURCE (gdaui_set_source_get_type ())
+#define GDAUI_SET_SOURCE(x) ((GdauiSetSource*)(x))
+GType             gdaui_set_source_get_type           (void) G_GNUC_CONST;
+GdauiSetSource   *gdaui_set_source_new                (void);
+void              gdaui_set_source_free               (GdauiSetSource *s);
+GdauiSetSource   *gdaui_set_source_copy               (GdauiSetSource *s);
+void              gdaui_set_source_set_source         (GdauiSetSource *s, GdaSetSource *source);
+GdaSetSource     *gdaui_set_source_get_source         (GdauiSetSource*s);
+void              gdaui_set_source_set_shown_columns  (GdauiSetSource *s, gint *columns, gint n_columns);
+void              gdaui_set_source_set_ref_columns    (GdauiSetSource *s, gint *columns, gint n_columns);
+
+/* Deprecated functions */
+GType             _gdaui_set_get_type            (void);
 GdauiSet         *_gdaui_set_new                 (GdaSet *set);
 GdauiSetGroup    *_gdaui_set_get_group           (GdauiSet *dbset, GdaHolder *holder);
-
 G_END_DECLS
 
 #endif
diff --git a/libgda/gda-set.c b/libgda/gda-set.c
index dfdea88..f16a08d 100644
--- a/libgda/gda-set.c
+++ b/libgda/gda-set.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2008 - 2012 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2009 Bas Driessen <bas driessen xobas com>
  * Copyright (C) 2010 David King <davidk openismus com>
+ * Copyright (C) 2013 Daniel Espinosa <esodan gmail com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -43,6 +44,216 @@
 extern xmlDtdPtr gda_paramlist_dtd;
 extern gchar *gda_lang_locale;
 
+/*
+   Register GdaSetGroup type
+*/
+GType
+gda_set_group_get_type (void)
+{
+       static GType type = 0;
+
+       if (G_UNLIKELY (type == 0)) {
+        if (type == 0)
+                       type = g_boxed_type_register_static ("GdaSetGroup",
+                                                            (GBoxedCopyFunc) gda_set_group_copy,
+                                                            (GBoxedFreeFunc) gda_set_group_free);
+       }
+
+       return type;
+}
+
+/**
+ * gda_set_group_new:
+ * 
+ * Creates a new #GdaSetGroup struct.
+ *
+ * Return: (transfer full): a new #GdaSetGroup struct.
+ *
+ * Since: 5.2
+ */
+GdaSetGroup*
+gda_set_group_new (void)
+{
+       GdaSetGroup *sg = g_new0 (GdaSetGroup, 1);
+       sg->nodes_source = NULL;
+       sg->nodes = NULL;
+       return sg;
+}
+
+/**
+ * gda_set_group_copy:
+ * @sg: a #GdaSetGroup
+ *
+ * Copy constructor.
+ *
+ * Returns: a new #GdaSetGroup
+ *
+ * Since: 5.2
+ */
+GdaSetGroup *
+gda_set_group_copy (GdaSetGroup *sg)
+{
+       g_return_val_if_fail (sg, NULL);
+
+       GdaSetGroup *n;
+       n = gda_set_group_new ();
+       n->nodes_source = g_object_ref (sg->nodes_source);
+       n->nodes = g_slist_copy (sg->nodes);
+       return n;
+}
+
+/**
+ * gda_set_group_free:
+ * @sg: (allow-none): a #GdaSetGroup struct to free
+ * 
+ * Frees any resources taken by @sg struct. If @sg is %NULL, then nothing happens.
+ *
+ * Since: 5.2
+ */
+void
+gda_set_group_free (GdaSetGroup *sg)
+{
+       g_return_if_fail(sg);
+       g_slist_free (sg->nodes);
+       g_free (sg);
+}
+
+/**
+ * gda_set_group_set_source:
+ * @sg: a #GdaSetGroup
+ * @source: a #GdaSetSource to set
+ * 
+ * Since: 5.2
+ */
+void gda_set_group_set_source (GdaSetGroup *sg, GdaSetSource *source)
+{
+       g_return_if_fail (sg);
+       sg->nodes_source = source;
+}
+
+/**
+ * gda_set_group_add_node:
+ * @sg: a #GdaSetGroup
+ * @source: a #GdaSetNode to set
+ * 
+ * Since: 5.2
+ */
+void gda_set_group_add_node (GdaSetGroup *sg, GdaSetNode *node)
+{
+       g_return_if_fail (sg);
+       g_return_if_fail (node);
+       sg->nodes = g_slist_append (sg->nodes, node);
+}
+
+/*
+   Register GdaSetSource type
+*/
+GType
+gda_set_source_get_type (void)
+{
+       static GType type = 0;
+
+       if (G_UNLIKELY (type == 0)) {
+        if (type == 0)
+                       type = g_boxed_type_register_static ("GdaSetSource",
+                                                            (GBoxedCopyFunc) gda_set_source_copy,
+                                                            (GBoxedFreeFunc) gda_set_source_free);
+       }
+
+       return type;
+}
+
+/**
+ * gda_set_source_new:
+ * 
+ * Creates a new #GdaSetSource struct.
+ *
+ * Return: (transfer full): a new #GdaSetSource struct.
+ *
+ * Since: 5.2
+ */
+GdaSetSource*
+gda_set_source_new (void)
+{
+       GdaSetSource *s = g_new0 (GdaSetSource, 1);
+       s->nodes = NULL;
+       s->data_model = NULL;
+       
+       return s;
+}
+
+/**
+ * gda_set_source_copy:
+ * @s: a #GdaSetGroup
+ *
+ * Copy constructor.
+ *
+ * Returns: a new #GdaSetSource
+ *
+ * Since: 5.2
+ */
+GdaSetSource *
+gda_set_source_copy (GdaSetSource *s)
+{
+       GdaSetSource *n;
+       g_return_val_if_fail (s, NULL); 
+       n = gda_set_source_new ();
+       n->nodes = g_slist_copy (s->nodes);
+       n->data_model = g_object_ref (s->data_model);
+       return n;
+}
+       
+/**
+ * gda_set_source_free:
+ * @s: (allow-none): a #GdaSetSource struct to free
+ * 
+ * Frees any resources taken by @s struct. If @s is %NULL, then nothing happens.
+ *
+ * Since: 5.2
+ */
+void
+gda_set_source_free (GdaSetSource *s)
+{
+       g_return_if_fail(s);
+       g_object_unref (s->data_model);
+       g_slist_free (s->nodes);
+       g_free (s);
+}
+
+/**
+ * gda_set_source_set_data_model:
+ * @s: (allow-none): a #GdaSetSource struct to free
+ * @model: a #GdaDataModel
+ * 
+ * Set a #GdaDataModel
+ *
+ * Since: 5.2
+ */
+void
+gda_set_source_set_data_model (GdaSetSource *s, GdaDataModel *model)
+{
+       g_return_if_fail (s);
+       g_return_if_fail (G_IS_OBJECT (model));
+       s->data_model = g_object_ref (model);
+}
+
+/**
+ * gda_set_source_add_node:
+ * @s: (allow-none): a #GdaSetSource struct to free
+ * @model: a #GdaDataModel
+ * 
+ * Set a #GdaDataModel
+ *
+ * Since: 5.2
+ */
+void
+gda_set_source_add_node (GdaSetSource *s, GdaSetNode *node)
+{
+       g_return_if_fail (s);
+       g_return_if_fail (node);
+       s->nodes = g_slist_append (s->nodes, node);
+}
+
 /* 
  * Main static functions 
  */
@@ -1118,8 +1329,7 @@ changed_holder_cb (GdaHolder *holder, GdaSet *set)
 static void
 group_free (GdaSetGroup *group, G_GNUC_UNUSED gpointer data)
 {
-       g_slist_free (group->nodes);
-       g_free (group);
+       gda_set_group_free (group);
 }
 
 static void
@@ -1243,12 +1453,12 @@ compute_public_data (GdaSet *set)
                source = NULL;
                if (node->source_model) {
                        source = gda_set_get_source_for_model (set, node->source_model);
-                       if (source) 
-                               source->nodes = g_slist_append (source->nodes, node);
+                       if (source)
+                               gda_set_source_add_node (source, node);
                        else {
-                               source = g_new0 (GdaSetSource, 1);
-                               source->data_model = node->source_model;
-                               source->nodes = g_slist_append (NULL, node);
+                               source = gda_set_source_new ();
+                               gda_set_source_set_data_model (source, node->source_model);
+                               gda_set_source_add_node (source, node);
                                set->sources_list = g_slist_prepend (set->sources_list, source);
                        }
                }
@@ -1258,11 +1468,11 @@ compute_public_data (GdaSet *set)
                if (node->source_model && groups)
                        group = g_hash_table_lookup (groups, node->source_model);
                if (group) 
-                       group->nodes = g_slist_append (group->nodes, node);
+                       gda_set_group_add_node (group, node);
                else {
-                       group = g_new0 (GdaSetGroup, 1);
-                       group->nodes = g_slist_append (NULL, node);
-                       group->nodes_source = source;
+                       group = gda_set_group_new ();
+                       gda_set_group_add_node (group, node);
+                       gda_set_group_set_source (group, source);
                        set->groups_list = g_slist_prepend (set->groups_list, group);
                        if (node->source_model) {
                                if (!groups)
diff --git a/libgda/gda-set.h b/libgda/gda-set.h
index fda5317..fe8ed8b 100644
--- a/libgda/gda-set.h
+++ b/libgda/gda-set.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2008 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2013 Daniel Espinosa <esodan gmail com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -56,10 +57,16 @@ struct _GdaSetNode {
        gpointer      _gda_reserved2;
 };
 
+#define GDA_SET_NODE(x) ((GdaSetNode *)(x))
+
+
 /**
  * GdaSetGroup:
  * @nodes: (element-type Gda.SetNode): list of GdaSetNode, at least one entry
  * @nodes_source: (allow-none):  if NULL, then @nodes contains exactly one entry 
+ *
+ * Since 5.2, you must consider this struct as opaque. Any access to its internal must use public API.
+ * Don't try to use #gda_meta_context_free on a struct that was created manually.
  */
 struct _GdaSetGroup {
        GSList       *nodes;       /* list of GdaSetNode, at least one entry */
@@ -71,11 +78,23 @@ struct _GdaSetGroup {
        gpointer      _gda_reserved2;
 };
 
+#define GDA_TYPE_SET_GROUP (gda_set_group_get_type ())
+#define GDA_SET_GROUP(x) ((GdaSetGroup *)(x))
+GType         gda_set_group_get_type        (void) G_GNUC_CONST;
+GdaSetGroup  *gda_set_group_new             (void);
+void          gda_set_group_free            (GdaSetGroup *sg);
+GdaSetGroup  *gda_set_group_copy            (GdaSetGroup *sg);
+void          gda_set_group_add_node        (GdaSetGroup *sg, GdaSetNode *node);
+void          gda_set_group_set_source      (GdaSetGroup *sg, GdaSetSource *source);
+
+
 /**
  * GdaSetSource:
  * @data_model: Can't be NULL
  * @nodes: (element-type Gda.SetNode): list of #GdaSetNode for which source_model == @data_model
- *
+ * 
+ * Since 5.2, you must consider this struct as opaque. Any access to its internal must use public API.
+ * Don't try to use #gda_meta_context_free on a struct that was created manually.
  **/
 struct _GdaSetSource {
        GdaDataModel   *data_model;   /* Can't be NULL */
@@ -89,9 +108,14 @@ struct _GdaSetSource {
        gpointer        _gda_reserved4;
 };
 
-#define GDA_SET_NODE(x) ((GdaSetNode *)(x))
+#define GDA_TYPE_SET_SOURCE (gda_set_source_get_type ())
 #define GDA_SET_SOURCE(x) ((GdaSetSource *)(x))
-#define GDA_SET_GROUP(x) ((GdaSetGroup *)(x))
+GType         gda_set_source_get_type       (void) G_GNUC_CONST;
+GdaSetSource *gda_set_source_new            (void);
+void          gda_set_source_free           (GdaSetSource *s);
+GdaSetSource *gda_set_source_copy           (GdaSetSource *s);
+void          gda_set_source_add_node       (GdaSetSource *s, GdaSetNode *node);
+void          gda_set_source_set_data_model (GdaSetSource *s, GdaDataModel *model);
 
 /* struct for the object's data */
 
@@ -184,6 +208,8 @@ gboolean      _gda_set_validate                (GdaSet *set, GError **error);
 GdaSet *      gda_set_new_read_only            (GSList *holders);
 
 
+
+
 G_END_DECLS
 
 #endif
diff --git a/libgda/libgda-5.0.vapi b/libgda/libgda-5.0.vapi
index 1939522..ed55d9a 100644
--- a/libgda/libgda-5.0.vapi
+++ b/libgda/libgda-5.0.vapi
@@ -572,6 +572,7 @@ namespace Gda {
                public weak string table_name;
                [CCode (has_construct_function = false)]
                public MetaContext ();
+               public Gda.MetaContext copy ();
                public void free ();
                public unowned string get_table ();
                public void set_column (string column, GLib.Value value, Gda.Connection? cnc);
@@ -776,6 +777,7 @@ namespace Gda {
                public virtual string escape_string (Gda.Connection? cnc, string str);
                public string find_file (string inst_dir, string filename);
                public unowned Gda.DataHandler get_data_handler_dbms (Gda.Connection? cnc, string for_type);
+               [Deprecated (since = "5.2")]
                public unowned Gda.DataHandler get_data_handler_default (Gda.Connection? cnc, GLib.Type type, 
string dbms_type);
                public unowned Gda.DataHandler get_data_handler_g_type (Gda.Connection? cnc, GLib.Type 
for_type);
                [NoWrapper]
@@ -789,7 +791,7 @@ namespace Gda {
                [NoWrapper]
                public virtual bool handle_async (Gda.Connection cnc) throws GLib.Error;
                public void handler_declare (Gda.DataHandler dh, Gda.Connection cnc, GLib.Type g_type, string 
dbms_type);
-               public unowned Gda.DataHandler handler_find (Gda.Connection cnc, GLib.Type g_type, string 
dbms_type);
+               public unowned Gda.DataHandler handler_find (Gda.Connection? cnc, GLib.Type g_type, string? 
dbms_type);
                [NoWrapper]
                public virtual string identifier_quote (Gda.Connection cnc, string id, bool for_meta_store, 
bool force_quotes);
                public unowned Gda.SqlParser internal_get_parser ();
@@ -829,13 +831,13 @@ namespace Gda {
                public Set.from_spec_node ([CCode (type = "xmlNodePtr")] Xml.Node* xml_spec) throws 
GLib.Error;
                [CCode (has_construct_function = false)]
                public Set.from_spec_string (string xml_spec) throws GLib.Error;
-               public Gda.SetGroup get_group (Gda.Holder holder);
+               public unowned Gda.SetGroup get_group (Gda.Holder holder);
                public unowned Gda.Holder get_holder (string holder_id);
                public unowned GLib.Value? get_holder_value (string holder_id);
                public Gda.SetNode get_node (Gda.Holder holder);
                public unowned Gda.Holder get_nth_holder (int pos);
-               public Gda.SetSource get_source (Gda.Holder holder);
-               public Gda.SetSource get_source_for_model (Gda.DataModel model);
+               public unowned Gda.SetSource get_source (Gda.Holder holder);
+               public unowned Gda.SetSource get_source_for_model (Gda.DataModel model);
                public bool is_valid () throws GLib.Error;
                public void merge_with_set (Gda.Set set_to_merge);
                [CCode (has_construct_function = false)]
@@ -859,6 +861,30 @@ namespace Gda {
                public virtual signal GLib.Error validate_holder_change (Gda.Holder holder, GLib.Value 
new_value);
                public virtual signal GLib.Error validate_set ();
        }
+       [CCode (cheader_filename = "libgda/libgda.h", copy_function = "g_boxed_copy", free_function = 
"g_boxed_free", type_id = "gda_set_group_get_type ()")]
+       [Compact]
+       public class SetGroup {
+               public GLib.List<Gda.SetNode> nodes;
+               public weak Gda.SetSource nodes_source;
+               [CCode (has_construct_function = false)]
+               public SetGroup ();
+               public void add_node (Gda.SetNode node);
+               public Gda.SetGroup copy ();
+               public void free ();
+               public void set_source (Gda.SetSource source);
+       }
+       [CCode (cheader_filename = "libgda/libgda.h", copy_function = "g_boxed_copy", free_function = 
"g_boxed_free", type_id = "gda_set_source_get_type ()")]
+       [Compact]
+       public class SetSource {
+               public weak Gda.DataModel data_model;
+               public GLib.List<Gda.SetNode> nodes;
+               [CCode (has_construct_function = false)]
+               public SetSource ();
+               public void add_node (Gda.SetNode node);
+               public Gda.SetSource copy ();
+               public void free ();
+               public void set_data_model (Gda.DataModel model);
+       }
        [CCode (cheader_filename = "libgda/libgda.h", type_id = "gda_short_get_type ()")]
        public class Short {
                [CCode (has_construct_function = false)]
@@ -1374,21 +1400,11 @@ namespace Gda {
                public weak string dbms_type;
        }
        [CCode (cheader_filename = "libgda/libgda.h", has_type_id = false)]
-       public struct SetGroup {
-               public GLib.List<Gda.SetNode> nodes;
-               public Gda.SetSource nodes_source;
-       }
-       [CCode (cheader_filename = "libgda/libgda.h", has_type_id = false)]
        public struct SetNode {
                public weak Gda.Holder holder;
                public weak Gda.DataModel source_model;
                public int source_column;
        }
-       [CCode (cheader_filename = "libgda/libgda.h", has_type_id = false)]
-       public struct SetSource {
-               public weak Gda.DataModel data_model;
-               public GLib.List<Gda.SetNode> nodes;
-       }
        [CCode (cheader_filename = "libgda/libgda.h")]
        [SimpleType]
        public struct SqlBuilderId : uint {
@@ -1467,7 +1483,8 @@ namespace Gda {
                TASK_NOT_FOUND_ERROR,
                UNSUPPORTED_THREADS_ERROR,
                CLOSED_ERROR,
-               META_DATA_CONTEXT_ERROR
+               META_DATA_CONTEXT_ERROR,
+               UNSUPPORTED_ASYNC_EXEC_ERROR
        }
        [CCode (cheader_filename = "libgda/libgda.h", cprefix = "GDA_CONNECTION_EVENT_CODE_", has_type_id = 
false)]
        public enum ConnectionEventCode {
@@ -1517,6 +1534,7 @@ namespace Gda {
                VIEWS,
                XA_TRANSACTIONS,
                MULTI_THREADING,
+               ASYNC_EXEC,
                LAST
        }
        [CCode (cheader_filename = "libgda/libgda.h", cprefix = "GDA_CONNECTION_META_", has_type_id = false)]
@@ -1571,7 +1589,8 @@ namespace Gda {
        [CCode (cheader_filename = "libgda/libgda.h", cprefix = "GDA_DATA_MODEL_IO_", has_type_id = false)]
        public enum DataModelIOFormat {
                DATA_ARRAY_XML,
-               TEXT_SEPARATED
+               TEXT_SEPARATED,
+               TEXT_TABLE
        }
        [CCode (cheader_filename = "libgda/libgda.h", cprefix = "GDA_DATA_MODEL_ITER_COLUMN_OUT_OF_RANGE_", 
has_type_id = false)]
        public enum DataModelIterError {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]