]> saetta.ns0.it Git - libgdaexgrid/commitdiff
Removed g_type_class_add_private deprecation. develop
authorAndrea Zagli <azagli@libero.it>
Sun, 28 Mar 2021 06:55:47 +0000 (08:55 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 28 Mar 2021 06:55:47 +0000 (08:55 +0200)
src/grid.c
src/gridcolumn.c

index 33ecfc60ef139ffd5c0526d86b53b47b3f74fe81..a98027ccc44ed3921376897b6d723a6a9046fd78 100644 (file)
@@ -81,8 +81,6 @@ static void gdaex_grid_on_menu_item_toggled (GtkCheckMenuItem *checkmenuitem,
 static GtkTreeModel *gdaex_grid_get_model (GdaExGrid *grid);
 static GtkTreeView *gdaex_grid_get_view (GdaExGrid *grid);
 
-#define GDAEX_GRID_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GDAEX_TYPE_GRID, GdaExGridPrivate))
-
 typedef struct _GdaExGridPrivate GdaExGridPrivate;
 struct _GdaExGridPrivate
        {
@@ -98,7 +96,7 @@ struct _GdaExGridPrivate
                gchar *app_textdomain;
        };
 
-G_DEFINE_TYPE (GdaExGrid, gdaex_grid, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (GdaExGrid, gdaex_grid, G_TYPE_OBJECT)
 
 #ifdef G_OS_WIN32
 static HMODULE hmodule;
@@ -124,8 +122,6 @@ gdaex_grid_class_init (GdaExGridClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-       g_type_class_add_private (object_class, sizeof (GdaExGridPrivate));
-
        object_class->set_property = gdaex_grid_set_property;
        object_class->get_property = gdaex_grid_get_property;
 }
@@ -133,7 +129,7 @@ gdaex_grid_class_init (GdaExGridClass *klass)
 static void
 gdaex_grid_init (GdaExGrid *gdaex_grid)
 {
-       GdaExGridPrivate *priv = GDAEX_GRID_GET_PRIVATE (gdaex_grid);
+       GdaExGridPrivate *priv = gdaex_grid_get_instance_private (gdaex_grid);
 
        priv->columns = g_ptr_array_new ();
        priv->title = NULL;
@@ -157,7 +153,7 @@ GdaExGrid
 
        GdaExGrid *gdaex_grid = GDAEX_GRID (g_object_new (gdaex_grid_get_type (), NULL));
 
-       GdaExGridPrivate *priv = GDAEX_GRID_GET_PRIVATE (gdaex_grid);
+       GdaExGridPrivate *priv = gdaex_grid_get_instance_private (gdaex_grid);
 
 #ifdef G_OS_WIN32
 
@@ -352,7 +348,7 @@ gdaex_grid_set_app_textdomain (GdaExGrid *grid, const gchar *textdomain)
 
        g_return_if_fail (GDAEX_IS_GRID (grid));
 
-       priv = GDAEX_GRID_GET_PRIVATE (grid);
+       priv = gdaex_grid_get_instance_private (grid);
 
        if (priv->app_textdomain != NULL)
                {
@@ -375,7 +371,7 @@ gdaex_grid_set_title (GdaExGrid *grid, const gchar *title)
 
        g_return_if_fail (GDAEX_IS_GRID (grid));
 
-       priv = GDAEX_GRID_GET_PRIVATE (grid);
+       priv = gdaex_grid_get_instance_private (grid);
 
        if (priv->title != NULL)
                {
@@ -407,7 +403,7 @@ const gchar
 
        g_return_val_if_fail (GDAEX_IS_GRID (grid), NULL);
 
-       priv = GDAEX_GRID_GET_PRIVATE (grid);
+       priv = gdaex_grid_get_instance_private (grid);
 
        if (priv->title != NULL)
                {
@@ -434,7 +430,7 @@ gdaex_grid_add_column (GdaExGrid *grid, GdaExGridColumn *column)
        g_return_if_fail (GDAEX_IS_GRID (grid));
        g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
 
-       priv = GDAEX_GRID_GET_PRIVATE (grid);
+       priv = gdaex_grid_get_instance_private (grid);
 
        g_ptr_array_add (priv->columns, g_object_ref (column));
 }
@@ -476,7 +472,7 @@ gdaex_grid_clear (GdaExGrid *grid)
 
        g_return_if_fail (GDAEX_IS_GRID (grid));
 
-       priv = GDAEX_GRID_GET_PRIVATE (grid);
+       priv = gdaex_grid_get_instance_private (grid);
 
        for (col = 0; priv->columns->len; col++)
                {
@@ -618,7 +614,7 @@ gdaex_grid_fill_from_datamodel_with_missing_func_with_sel (GdaExGrid *grid,
        g_return_val_if_fail (GDAEX_IS_GRID (grid), FALSE);
        g_return_val_if_fail (GDA_IS_DATA_MODEL (dm), FALSE);
 
-       priv = GDAEX_GRID_GET_PRIVATE (grid);
+       priv = gdaex_grid_get_instance_private (grid);
 
        if (priv->model == NULL)
                {
@@ -1074,7 +1070,7 @@ static void
 gdaex_grid_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
        GdaExGrid *gdaex_grid = GDAEX_GRID (object);
-       GdaExGridPrivate *priv = GDAEX_GRID_GET_PRIVATE (gdaex_grid);
+       GdaExGridPrivate *priv = gdaex_grid_get_instance_private (gdaex_grid);
 
        switch (property_id)
                {
@@ -1088,7 +1084,7 @@ static void
 gdaex_grid_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
 {
        GdaExGrid *gdaex_grid = GDAEX_GRID (object);
-       GdaExGridPrivate *priv = GDAEX_GRID_GET_PRIVATE (gdaex_grid);
+       GdaExGridPrivate *priv = gdaex_grid_get_instance_private (gdaex_grid);
 
        switch (property_id)
                {
@@ -1114,7 +1110,7 @@ static GtkTreeModel
 
        g_return_val_if_fail (GDAEX_IS_GRID (grid), NULL);
 
-       priv = GDAEX_GRID_GET_PRIVATE (grid);
+       priv = gdaex_grid_get_instance_private (grid);
 
        cols = priv->columns->len;
        gtype = g_new0 (GType, cols);
@@ -1189,7 +1185,7 @@ static GtkTreeView
 
        g_return_val_if_fail (GDAEX_IS_GRID (grid), NULL);
 
-       priv = GDAEX_GRID_GET_PRIVATE (grid);
+       priv = gdaex_grid_get_instance_private (grid);
 
        model = gdaex_grid_get_model (grid);
        view = gtk_tree_view_new_with_model (model);
@@ -1386,7 +1382,7 @@ gdaex_grid_on_print_menu_activate (GtkMenuItem *menuitem,
 
        gchar *_title;
 
-       priv = GDAEX_GRID_GET_PRIVATE (user_data);
+       priv = gdaex_grid_get_instance_private (user_data);
 
        if (priv->title != NULL)
                {
@@ -1430,7 +1426,7 @@ gdaex_grid_on_export_menu_activate (GtkMenuItem *menuitem,
        GdaExGridColumn *gcolumn;
        GString *gstr;
 
-       priv = GDAEX_GRID_GET_PRIVATE (user_data);
+       priv = gdaex_grid_get_instance_private (user_data);
 
        if (priv->columns->len)
                {
@@ -1468,7 +1464,7 @@ gdaex_grid_on_button_press_event (GtkWidget *widget,
 
        if (event->type == GDK_BUTTON_PRESS && event->button == 3)
                {
-                       priv = GDAEX_GRID_GET_PRIVATE (user_data);
+                       priv = gdaex_grid_get_instance_private (user_data);
 
                        gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL, NULL, NULL,
                                        event->button, event->time);
@@ -1484,7 +1480,7 @@ gdaex_grid_on_popup_menu (GtkWidget *widget,
 {
        GdaExGridPrivate *priv;
 
-       priv = GDAEX_GRID_GET_PRIVATE (user_data);
+       priv = gdaex_grid_get_instance_private (user_data);
        gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL, NULL, NULL,
                        0, gtk_get_current_event_time ());
 
@@ -1500,7 +1496,7 @@ gdaex_grid_on_menu_item_showall_activate (GtkMenuItem *menuitem,
        guint col;
        GdaExGridColumn *gcolumn;
 
-       priv = GDAEX_GRID_GET_PRIVATE (user_data);
+       priv = gdaex_grid_get_instance_private (user_data);
 
        for (col = 0; col < priv->columns->len; col++)
                {
@@ -1518,7 +1514,7 @@ gdaex_grid_on_menu_item_hideall_activate (GtkMenuItem *menuitem,
        guint col;
        GdaExGridColumn *gcolumn;
 
-       priv = GDAEX_GRID_GET_PRIVATE (user_data);
+       priv = gdaex_grid_get_instance_private (user_data);
 
        for (col = 0; col < priv->columns->len; col++)
                {
@@ -1533,7 +1529,7 @@ gdaex_grid_on_menu_item_toggled (GtkCheckMenuItem *checkmenuitem,
 {
        GdaExGridPrivate *priv;
 
-       priv = GDAEX_GRID_GET_PRIVATE (user_data);
+       priv = gdaex_grid_get_instance_private (user_data);
 
        GdaExGridColumn *gcolumn = g_object_get_data (G_OBJECT (checkmenuitem), "GdaExGridColumn");
 
index bc923f55d5ceb9e343d33a1521a91e47e54e17bb..c66509c591015ed710586cdca5af7360853ebcd4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  gridcolumn.c
  *
- *  Copyright (C) 2010-2019 Andrea Zagli <azagli@libero.it>
+ *  Copyright (C) 2010-2021 Andrea Zagli <azagli@libero.it>
  *
  *  This file is part of libgdaexgrid.
  *
@@ -41,8 +41,6 @@ static void gdaex_grid_column_get_property (GObject *object,
                                GValue *value,
                                GParamSpec *pspec);
 
-#define GDAEX_GRID_COLUMN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GDAEX_TYPE_GRID_COLUMN, GdaExGridColumnPrivate))
-
 typedef struct _GdaExGridColumnPrivate GdaExGridColumnPrivate;
 struct _GdaExGridColumnPrivate
        {
@@ -59,15 +57,13 @@ struct _GdaExGridColumnPrivate
                GtkTreeViewColumn *vcolumn;
        };
 
-G_DEFINE_TYPE (GdaExGridColumn, gdaex_grid_column, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (GdaExGridColumn, gdaex_grid_column, G_TYPE_OBJECT)
 
 static void
 gdaex_grid_column_class_init (GdaExGridColumnClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-       g_type_class_add_private (object_class, sizeof (GdaExGridColumnPrivate));
-
        object_class->set_property = gdaex_grid_column_set_property;
        object_class->get_property = gdaex_grid_column_get_property;
 }
@@ -75,7 +71,7 @@ gdaex_grid_column_class_init (GdaExGridColumnClass *klass)
 static void
 gdaex_grid_column_init (GdaExGridColumn *gdaex_grid_column)
 {
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (gdaex_grid_column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (gdaex_grid_column);
 
        priv->title = NULL;
        priv->field_name = NULL;
@@ -114,7 +110,7 @@ GdaExGridColumn
 {
        GdaExGridColumn *gdaex_grid_column = GDAEX_GRID_COLUMN (g_object_new (gdaex_grid_column_get_type (), NULL));
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (gdaex_grid_column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (gdaex_grid_column);
 
        gdaex_grid_column_set_title (gdaex_grid_column, title);
        gdaex_grid_column_set_field_name (gdaex_grid_column, field_name);
@@ -162,7 +158,7 @@ gdaex_grid_column_set_title (GdaExGridColumn *column, const gchar *title)
 {
        g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        g_free (priv->title);
        priv->title = g_strdup (title);
@@ -184,7 +180,7 @@ const gchar
 {
        g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), NULL);
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        return (const gchar *)g_strdup (priv->title);
 }
@@ -200,7 +196,7 @@ gdaex_grid_column_set_field_name (GdaExGridColumn *column, const gchar *field_na
 {
        g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        g_free (priv->field_name);
        priv->field_name = g_strdup (field_name);
@@ -217,7 +213,7 @@ const gchar
 {
        g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), NULL);
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        return (const gchar *)g_strdup (priv->field_name);
 }
@@ -233,7 +229,7 @@ gdaex_grid_column_set_gtype (GdaExGridColumn *column, GType type)
 {
        g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        priv->type = type;
 }
@@ -249,7 +245,7 @@ gdaex_grid_column_get_gtype (GdaExGridColumn *column)
 {
        g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), G_TYPE_NONE);
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        return priv->type;
 }
@@ -265,7 +261,7 @@ gdaex_grid_column_set_visible (GdaExGridColumn *column, gboolean visible)
 {
        g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        if (!priv->viewable)
                {
@@ -299,7 +295,7 @@ gdaex_grid_column_get_visible (GdaExGridColumn *column)
 {
        g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), FALSE);
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        return priv->visible;
 }
@@ -315,7 +311,7 @@ gdaex_grid_column_set_viewable (GdaExGridColumn *column, gboolean viewable)
 {
        g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        if (!viewable)
                {
@@ -339,7 +335,7 @@ gdaex_grid_column_get_viewable (GdaExGridColumn *column)
 {
        g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), FALSE);
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        return priv->viewable;
 }
@@ -355,7 +351,7 @@ gdaex_grid_column_set_resizable (GdaExGridColumn *column, gboolean resizable)
 {
        g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        priv->resizable = resizable;
 
@@ -376,7 +372,7 @@ gdaex_grid_column_get_resizable (GdaExGridColumn *column)
 {
        g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), FALSE);
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        return priv->resizable;
 }
@@ -392,7 +388,7 @@ gdaex_grid_column_set_sortable (GdaExGridColumn *column, gboolean sortable)
 {
        g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        priv->sortable = sortable;
 
@@ -413,7 +409,7 @@ gdaex_grid_column_get_sortable (GdaExGridColumn *column)
 {
        g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), FALSE);
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        return priv->sortable;
 }
@@ -429,7 +425,7 @@ gdaex_grid_column_set_reorderable (GdaExGridColumn *column, gboolean reorderable
 {
        g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        priv->reorderable = reorderable;
 
@@ -450,7 +446,7 @@ gdaex_grid_column_get_reorderable (GdaExGridColumn *column)
 {
        g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), FALSE);
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        return priv->reorderable;
 }
@@ -466,7 +462,7 @@ gdaex_grid_column_set_decimals (GdaExGridColumn *column, gint decimals)
 {
        g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        priv->decimals = decimals;
 }
@@ -482,7 +478,7 @@ gdaex_grid_column_get_decimals (GdaExGridColumn *column)
 {
        g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), FALSE);
 
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (column);
 
        return priv->decimals;
 }
@@ -502,7 +498,7 @@ GtkTreeViewColumn
 
        g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), NULL);
 
-       priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+       priv = gdaex_grid_column_get_instance_private (column);
 
        renderer = NULL;
        if (priv->type == G_TYPE_STRING
@@ -560,7 +556,7 @@ static void
 gdaex_grid_column_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
        GdaExGridColumn *gdaex_grid_column = GDAEX_GRID_COLUMN (object);
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (gdaex_grid_column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (gdaex_grid_column);
 
        switch (property_id)
                {
@@ -574,7 +570,7 @@ static void
 gdaex_grid_column_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
 {
        GdaExGridColumn *gdaex_grid_column = GDAEX_GRID_COLUMN (object);
-       GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (gdaex_grid_column);
+       GdaExGridColumnPrivate *priv = gdaex_grid_column_get_instance_private (gdaex_grid_column);
 
        switch (property_id)
                {