[libgda] data-model-dsn-list: removed private from object's struct
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] data-model-dsn-list: removed private from object's struct
- Date: Wed, 12 Sep 2018 11:55:20 +0000 (UTC)
commit a28e2303c9483f3f60d2ac7a6cbc7efe4f212f9c
Author: Daniel Espinosa <esodan gmail com>
Date: Sun Sep 2 18:25:10 2018 -0500
data-model-dsn-list: removed private from object's struct
libgda/gda-data-model-dsn-list.c | 119 ++++++++++++++++++++-------------------
libgda/gda-data-model-dsn-list.h | 18 +-----
2 files changed, 63 insertions(+), 74 deletions(-)
---
diff --git a/libgda/gda-data-model-dsn-list.c b/libgda/gda-data-model-dsn-list.c
index 3f5c72b06..2b1ec05d8 100644
--- a/libgda/gda-data-model-dsn-list.c
+++ b/libgda/gda-data-model-dsn-list.c
@@ -27,16 +27,16 @@
#include <libgda/gda-data-model-dsn-list.h>
#include <libgda/gda-config.h>
-struct _GdaDataModelDsnListPrivate {
+typedef struct {
gint nb_dsn;
GSList *columns;
gint row_to_remove;
GValue *tmp_value;
-};
+} GdaDataModelDsnListPrivate;
+#define gda_data_model_dsn_list_get_instance_private(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj,
GDA_TYPE_DATA_MODEL_DSN_LIST, GdaDataModelDsnListPrivate)
static void gda_data_model_dsn_list_class_init (GdaDataModelDsnListClass *klass);
-static void gda_data_model_dsn_list_init (GdaDataModelDsnList *model,
- GdaDataModelDsnListClass *klass);
+static void gda_data_model_dsn_list_init (GdaDataModelDsnList *model);
static void gda_data_model_dsn_list_dispose (GObject *object);
/* GdaDataModel interface */
@@ -84,35 +84,35 @@ gda_data_model_dsn_list_data_model_init (GdaDataModelIface *iface)
}
static void
-gda_data_model_dsn_list_init (GdaDataModelDsnList *model,
- G_GNUC_UNUSED GdaDataModelDsnListClass *klass)
+gda_data_model_dsn_list_init (GdaDataModelDsnList *model)
{
GdaConfig *config;
GdaColumn *col;
g_return_if_fail (GDA_IS_DATA_MODEL_DSN_LIST (model));
+ GdaDataModelDsnListPrivate *priv = gda_data_model_dsn_list_get_instance_private (model);
- model->priv = g_new0 (GdaDataModelDsnListPrivate, 1);
- model->priv->nb_dsn = gda_config_get_nb_dsn ();
- model->priv->row_to_remove = -1;
+ priv = g_new0 (GdaDataModelDsnListPrivate, 1);
+ priv->nb_dsn = gda_config_get_nb_dsn ();
+ priv->row_to_remove = -1;
col = gda_column_new ();
gda_column_set_name (col, _("DSN"));
gda_column_set_description (col, _("DSN"));
gda_column_set_g_type (col, G_TYPE_STRING);
- model->priv->columns = g_slist_append (NULL, col);
+ priv->columns = g_slist_append (NULL, col);
col = gda_column_new ();
gda_column_set_name (col, _("Provider"));
gda_column_set_description (col, _("Provider"));
gda_column_set_g_type (col, G_TYPE_STRING);
- model->priv->columns = g_slist_append (model->priv->columns, col);
+ priv->columns = g_slist_append (priv->columns, col);
col = gda_column_new ();
gda_column_set_name (col, _("Description"));
gda_column_set_description (col, _("Description"));
gda_column_set_g_type (col, G_TYPE_STRING);
- model->priv->columns = g_slist_append (model->priv->columns, col);
+ priv->columns = g_slist_append (priv->columns, col);
col = gda_column_new ();
/* To translators: a "Connection string" is a semi-colon delimited list of key=value pairs which
@@ -120,19 +120,19 @@ gda_data_model_dsn_list_init (GdaDataModelDsnList *model,
gda_column_set_name (col, _("Connection string"));
gda_column_set_description (col, _("Connection string"));
gda_column_set_g_type (col, G_TYPE_STRING);
- model->priv->columns = g_slist_append (model->priv->columns, col);
+ priv->columns = g_slist_append (priv->columns, col);
col = gda_column_new ();
gda_column_set_name (col, _("Username"));
gda_column_set_description (col, _("Username"));
gda_column_set_g_type (col, G_TYPE_STRING);
- model->priv->columns = g_slist_append (model->priv->columns, col);
+ priv->columns = g_slist_append (priv->columns, col);
col = gda_column_new ();
gda_column_set_name (col, _("Global"));
gda_column_set_description (col, _("Global"));
gda_column_set_g_type (col, G_TYPE_BOOLEAN);
- model->priv->columns = g_slist_append (model->priv->columns, col);
+ priv->columns = g_slist_append (priv->columns, col);
g_object_set_data (G_OBJECT (model), "name", _("List of defined data sources"));
@@ -147,7 +147,7 @@ gda_data_model_dsn_list_init (GdaDataModelDsnList *model,
G_CALLBACK (dsn_changed_cb), model);
g_object_unref (config);
- model->priv->tmp_value = NULL;
+ priv->tmp_value = NULL;
}
static void
@@ -166,49 +166,48 @@ gda_data_model_dsn_list_dispose (GObject *object)
GdaDataModelDsnList *model = (GdaDataModelDsnList *) object;
g_return_if_fail (GDA_IS_DATA_MODEL_DSN_LIST (model));
-
- if (model->priv) {
- GdaConfig *config = gda_config_get ();
- g_signal_handlers_disconnect_by_func (G_OBJECT (config),
- G_CALLBACK (dsn_added_cb), model);
- g_signal_handlers_disconnect_by_func (G_OBJECT (config),
- G_CALLBACK (dsn_removed_cb), model);
- g_signal_handlers_disconnect_by_func (G_OBJECT (config),
- G_CALLBACK (dsn_to_be_removed_cb), model);
- g_signal_handlers_disconnect_by_func (G_OBJECT (config),
- G_CALLBACK (dsn_changed_cb), model);
- g_object_unref (config);
- if (model->priv->tmp_value) {
- gda_value_free (model->priv->tmp_value);
- model->priv->tmp_value = NULL;
- }
-
- g_free (model->priv);
- model->priv = NULL;
+ GdaDataModelDsnListPrivate *priv = gda_data_model_dsn_list_get_instance_private (model);
+
+ GdaConfig *config = gda_config_get ();
+ g_signal_handlers_disconnect_by_func (G_OBJECT (config),
+ G_CALLBACK (dsn_added_cb), model);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (config),
+ G_CALLBACK (dsn_removed_cb), model);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (config),
+ G_CALLBACK (dsn_to_be_removed_cb), model);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (config),
+ G_CALLBACK (dsn_changed_cb), model);
+ g_object_unref (config);
+ if (priv->tmp_value) {
+ gda_value_free (priv->tmp_value);
+ priv->tmp_value = NULL;
}
-
+
parent_class->dispose (object);
}
static void
dsn_added_cb (G_GNUC_UNUSED GdaConfig *conf, GdaDsnInfo *info, GdaDataModelDsnList *model)
{
- model->priv->nb_dsn++;
+ GdaDataModelDsnListPrivate *priv = gda_data_model_dsn_list_get_instance_private (model);
+ priv->nb_dsn++;
gda_data_model_row_inserted ((GdaDataModel *) model, gda_config_get_dsn_info_index (info->name));
}
static void
dsn_to_be_removed_cb (G_GNUC_UNUSED GdaConfig *conf, GdaDsnInfo *info, GdaDataModelDsnList *model)
{
- model->priv->row_to_remove = gda_config_get_dsn_info_index (info->name);
+ GdaDataModelDsnListPrivate *priv = gda_data_model_dsn_list_get_instance_private (model);
+ priv->row_to_remove = gda_config_get_dsn_info_index (info->name);
}
static void
dsn_removed_cb (G_GNUC_UNUSED GdaConfig *conf, G_GNUC_UNUSED GdaDsnInfo *info, GdaDataModelDsnList *model)
{
- model->priv->nb_dsn--;
- gda_data_model_row_removed ((GdaDataModel *) model, model->priv->row_to_remove);
- model->priv->row_to_remove = -1;
+ GdaDataModelDsnListPrivate *priv = gda_data_model_dsn_list_get_instance_private (model);
+ priv->nb_dsn--;
+ gda_data_model_row_removed ((GdaDataModel *) model, priv->row_to_remove);
+ priv->row_to_remove = -1;
}
static void
@@ -223,7 +222,7 @@ dsn_changed_cb (G_GNUC_UNUSED GdaConfig *conf, GdaDsnInfo *info, GdaDataModelDsn
*/
GType
-_gda_data_model_dsn_list_get_type (void)
+gda_data_model_dsn_list_get_type (void)
{
static GType type = 0;
@@ -266,24 +265,27 @@ static gint
gda_data_model_dsn_list_get_n_rows (GdaDataModel *model)
{
GdaDataModelDsnList *dmodel = GDA_DATA_MODEL_DSN_LIST (model);
+ GdaDataModelDsnListPrivate *priv = gda_data_model_dsn_list_get_instance_private (dmodel);
- return dmodel->priv->nb_dsn;
+ return priv->nb_dsn;
}
static gint
gda_data_model_dsn_list_get_n_columns (GdaDataModel *model)
{
GdaDataModelDsnList *dmodel = GDA_DATA_MODEL_DSN_LIST (model);
+ GdaDataModelDsnListPrivate *priv = gda_data_model_dsn_list_get_instance_private (dmodel);
- return g_slist_length (dmodel->priv->columns);
+ return g_slist_length (priv->columns);
}
static GdaColumn *
gda_data_model_dsn_list_describe_column (GdaDataModel *model, gint col)
{
GdaDataModelDsnList *dmodel = GDA_DATA_MODEL_DSN_LIST (model);
+ GdaDataModelDsnListPrivate *priv = gda_data_model_dsn_list_get_instance_private (model);
- return g_slist_nth_data (dmodel->priv->columns, col);
+ return g_slist_nth_data (priv->columns, col);
}
static GdaDataModelAccessFlags
@@ -296,10 +298,11 @@ static const GValue *
gda_data_model_dsn_list_get_value_at (GdaDataModel *model, gint col, gint row, GError **error)
{
GdaDataModelDsnList *dmodel = GDA_DATA_MODEL_DSN_LIST (model);
+ GdaDataModelDsnListPrivate *priv = gda_data_model_dsn_list_get_instance_private (dmodel);
- if (dmodel->priv->tmp_value) {
- gda_value_free (dmodel->priv->tmp_value);
- dmodel->priv->tmp_value = NULL;
+ if (priv->tmp_value) {
+ gda_value_free (priv->tmp_value);
+ priv->tmp_value = NULL;
}
if ((col >= gda_data_model_dsn_list_get_n_columns (model)) ||
@@ -323,41 +326,41 @@ gda_data_model_dsn_list_get_value_at (GdaDataModel *model, gint col, gint row, G
GdaDsnInfo *info = gda_config_get_dsn_info_at_index (row);
g_assert (info);
if (col != 5)
- dmodel->priv->tmp_value = gda_value_new (G_TYPE_STRING);
+ priv->tmp_value = gda_value_new (G_TYPE_STRING);
else
- dmodel->priv->tmp_value = gda_value_new (G_TYPE_BOOLEAN);
+ priv->tmp_value = gda_value_new (G_TYPE_BOOLEAN);
switch (col) {
case 0:
- g_value_set_string (dmodel->priv->tmp_value, info->name);
+ g_value_set_string (priv->tmp_value, info->name);
break;
case 1:
- g_value_set_string (dmodel->priv->tmp_value, info->provider);
+ g_value_set_string (priv->tmp_value, info->provider);
break;
case 2:
- g_value_set_string (dmodel->priv->tmp_value, info->description);
+ g_value_set_string (priv->tmp_value, info->description);
break;
case 3:
- g_value_set_string (dmodel->priv->tmp_value, info->cnc_string);
+ g_value_set_string (priv->tmp_value, info->cnc_string);
break;
case 4:
if (info->auth_string) {
GdaQuarkList* ql;
ql = gda_quark_list_new_from_string (info->auth_string);
- g_value_set_string (dmodel->priv->tmp_value, gda_quark_list_find (ql, "USERNAME"));
+ g_value_set_string (priv->tmp_value, gda_quark_list_find (ql, "USERNAME"));
gda_quark_list_free (ql);
}
else
- g_value_set_string (dmodel->priv->tmp_value, "");
+ g_value_set_string (priv->tmp_value, "");
break;
case 5:
- g_value_set_boolean (dmodel->priv->tmp_value, info->is_system);
+ g_value_set_boolean (priv->tmp_value, info->is_system);
break;
default:
g_assert_not_reached ();
}
- return dmodel->priv->tmp_value;
+ return priv->tmp_value;
}
static GdaValueAttribute
diff --git a/libgda/gda-data-model-dsn-list.h b/libgda/gda-data-model-dsn-list.h
index 1dc9c05bc..ac4dbf07d 100644
--- a/libgda/gda-data-model-dsn-list.h
+++ b/libgda/gda-data-model-dsn-list.h
@@ -25,21 +25,9 @@
G_BEGIN_DECLS
-#define GDA_TYPE_DATA_MODEL_DSN_LIST (_gda_data_model_dsn_list_get_type())
-#define GDA_DATA_MODEL_DSN_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj,
GDA_TYPE_DATA_MODEL_DSN_LIST, GdaDataModelDsnList))
-#define GDA_DATA_MODEL_DSN_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass,
GDA_TYPE_DATA_MODEL_DSN_LIST, GdaDataModelDsnListClass))
-#define GDA_IS_DATA_MODEL_DSN_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj,
GDA_TYPE_DATA_MODEL_DSN_LIST))
-#define GDA_IS_DATA_MODEL_DSN_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),
GDA_TYPE_DATA_MODEL_DSN_LIST))
-
-typedef struct _GdaDataModelDsnList GdaDataModelDsnList;
-typedef struct _GdaDataModelDsnListClass GdaDataModelDsnListClass;
-typedef struct _GdaDataModelDsnListPrivate GdaDataModelDsnListPrivate;
-
-struct _GdaDataModelDsnList {
- GObject object;
- GdaDataModelDsnListPrivate *priv;
-};
+#define GDA_TYPE_DATA_MODEL_DSN_LIST (gda_data_model_dsn_list_get_type())
+G_DECLARE_DERIVABLE_TYPE(GdaDataModelDsnList, gda_data_model_dsn_list, GDA, DATA_MODEL_DSN_LIST, GObject)
struct _GdaDataModelDsnListClass {
GObjectClass object_class;
@@ -50,8 +38,6 @@ struct _GdaDataModelDsnListClass {
void (*_gda_reserved4) (void);
};
-GType _gda_data_model_dsn_list_get_type (void) G_GNUC_CONST;
-
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]