[libgda] gdaui-data-proxy-info: removed private from public API



commit 2b3309bad4deca9514ba94ae7e7487ebed5ead94
Author: Daniel Espinosa <esodan gmail com>
Date:   Mon Sep 10 09:23:42 2018 -0500

    gdaui-data-proxy-info: removed private from public API

 libgda-ui/gdaui-data-proxy-info.c | 436 ++++++++++++++++++--------------------
 libgda-ui/gdaui-data-proxy-info.h |  22 +-
 2 files changed, 213 insertions(+), 245 deletions(-)
---
diff --git a/libgda-ui/gdaui-data-proxy-info.c b/libgda-ui/gdaui-data-proxy-info.c
index 4a3c18301..debbabf12 100644
--- a/libgda-ui/gdaui-data-proxy-info.c
+++ b/libgda-ui/gdaui-data-proxy-info.c
@@ -2,6 +2,7 @@
  * Copyright (C) 2009 - 2015 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2010 David King <davidk openismus com>
  * Copyright (C) 2011 Murray Cumming <murrayc murrayc com>
+ * Copyright (C) 2018 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
@@ -29,8 +30,6 @@
 #include "gdaui-data-filter.h"
 #include "gdaui-enum-types.h"
 
-static void gdaui_data_proxy_info_class_init (GdauiDataProxyInfoClass * class);
-static void gdaui_data_proxy_info_init (GdauiDataProxyInfo *wid);
 static void gdaui_data_proxy_info_dispose (GObject *object);
 
 static void gdaui_data_proxy_info_set_property (GObject *object,
@@ -103,7 +102,7 @@ UIAction uiactions[] = {
        {GDAUI_ACTION_MOVE_LAST_CHUNK, GDAUI_ACTION_MOVE_LAST_CHUNK, "go-last-symbolic", N_("Show last chunk 
of data")},
 };
 
-struct _GdauiDataProxyInfoPriv
+typedef struct
 {
        GdauiDataProxy *data_proxy;
        GdaDataProxy      *proxy;
@@ -117,10 +116,9 @@ struct _GdauiDataProxyInfoPriv
        GtkWidget         *filter_popover;
 
        guint              idle_id;
-};
+} GdauiDataProxyInfoPrivate;
 
-/* get a pointer to the parents to be able to call their destructor */
-static GObjectClass *parent_class = NULL;
+G_DEFINE_TYPE_WITH_PRIVATE (GdauiDataProxyInfo, gdaui_data_proxy_info, GTK_TYPE_TOOLBAR)
 
 /* properties */
 enum {
@@ -129,39 +127,11 @@ enum {
        PROP_FLAGS
 };
 
-GType
-gdaui_data_proxy_info_get_type (void)
-{
-       static GType type = 0;
-
-       if (G_UNLIKELY (type == 0)) {
-               static const GTypeInfo info = {
-                       sizeof (GdauiDataProxyInfoClass),
-                       (GBaseInitFunc) NULL,
-                       (GBaseFinalizeFunc) NULL,
-                       (GClassInitFunc) gdaui_data_proxy_info_class_init,
-                       NULL,
-                       NULL,
-                       sizeof (GdauiDataProxyInfo),
-                       0,
-                       (GInstanceInitFunc) gdaui_data_proxy_info_init,
-                       0
-               };
-
-               type = g_type_register_static (GTK_TYPE_TOOLBAR, "GdauiDataProxyInfo", &info, 0);
-       }
-
-       return type;
-}
-
 static void
 gdaui_data_proxy_info_class_init (GdauiDataProxyInfoClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-       parent_class = g_type_class_peek_parent (klass);
-
-
        object_class->dispose = gdaui_data_proxy_info_dispose;
 
        /* Properties */
@@ -177,12 +147,12 @@ gdaui_data_proxy_info_class_init (GdauiDataProxyInfoClass *klass)
 }
 
 static void
-gdaui_data_proxy_info_init (GdauiDataProxyInfo *wid)
+gdaui_data_proxy_info_init (GdauiDataProxyInfo *info)
 {
-       wid->priv = g_new0 (GdauiDataProxyInfoPriv, 1);
-       wid->priv->data_proxy = NULL;
-       wid->priv->proxy = NULL;
-       wid->priv->row_spin = NULL;
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
+       priv->data_proxy = NULL;
+       priv->proxy = NULL;
+       priv->row_spin = NULL;
 }
 
 /**
@@ -214,41 +184,47 @@ gdaui_data_proxy_info_new (GdauiDataProxy *data_proxy, GdauiDataProxyInfoFlag fl
 static void
 data_proxy_destroyed_cb (GdauiDataProxy *wid, GdauiDataProxyInfo *info)
 {
-       g_assert (wid == info->priv->data_proxy);
+       g_return_if_fail (GDAUI_IS_DATA_PROXY_INFO (info));
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
+       g_assert (wid == priv->data_proxy);
        g_signal_handlers_disconnect_by_func (G_OBJECT (wid),
                                              G_CALLBACK (data_proxy_destroyed_cb), info);
        g_signal_handlers_disconnect_by_func (G_OBJECT (wid),
                                              G_CALLBACK (data_proxy_proxy_changed_cb), info);
-       if (GDAUI_IS_RAW_GRID (info->priv->data_proxy))
-               g_signal_handlers_disconnect_by_func (info->priv->data_proxy,
+       if (GDAUI_IS_RAW_GRID (priv->data_proxy))
+               g_signal_handlers_disconnect_by_func (priv->data_proxy,
                                                      G_CALLBACK (raw_grid_selection_changed_cb), info);
 
-       info->priv->data_proxy = NULL;
+       priv->data_proxy = NULL;
 }
 
 static void
 release_proxy (GdauiDataProxyInfo *info)
 {
-       g_signal_handlers_disconnect_by_func (G_OBJECT (info->priv->proxy),
+       g_return_if_fail (GDAUI_IS_DATA_PROXY_INFO (info));
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
+       g_signal_handlers_disconnect_by_func (G_OBJECT (priv->proxy),
                                              G_CALLBACK (proxy_changed_cb), info);
-       g_signal_handlers_disconnect_by_func (G_OBJECT (info->priv->proxy),
+       g_signal_handlers_disconnect_by_func (G_OBJECT (priv->proxy),
                                              G_CALLBACK (proxy_sample_changed_cb), info);
-       g_signal_handlers_disconnect_by_func (G_OBJECT (info->priv->proxy),
+       g_signal_handlers_disconnect_by_func (G_OBJECT (priv->proxy),
                                              G_CALLBACK (proxy_row_changed_cb), info);
-       g_signal_handlers_disconnect_by_func (G_OBJECT (info->priv->proxy),
+       g_signal_handlers_disconnect_by_func (G_OBJECT (priv->proxy),
                                              G_CALLBACK (proxy_reset_cb), info);
-       g_object_unref (info->priv->proxy);
-       info->priv->proxy = NULL;
+       g_object_unref (priv->proxy);
+       priv->proxy = NULL;
 }
 
 static void iter_row_changed_cb (GdaDataModelIter *iter, gint row, GdauiDataProxyInfo *info);
 static void
 release_iter (GdauiDataProxyInfo *info)
 {
-       g_signal_handlers_disconnect_by_func (info->priv->iter,
+       g_return_if_fail (GDAUI_IS_DATA_PROXY_INFO (info));
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
+       g_signal_handlers_disconnect_by_func (priv->iter,
                                              G_CALLBACK (iter_row_changed_cb), info);
-       g_object_unref (info->priv->iter);
-       info->priv->iter = NULL;
+       g_object_unref (priv->iter);
+       priv->iter = NULL;
 }
 
 static void
@@ -262,27 +238,20 @@ gdaui_data_proxy_info_dispose (GObject *object)
 {
        GdauiDataProxyInfo *info;
 
-       g_return_if_fail (object != NULL);
-       g_return_if_fail (GDAUI_IS_DATA_PROXY_INFO (object));
        info = GDAUI_DATA_PROXY_INFO (object);
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
 
-       if (info->priv) {
-               if (info->priv->proxy)
-                       release_proxy (info);
-               if (info->priv->iter)
-                       release_iter (info);
-               if (info->priv->data_proxy)
-                       data_proxy_destroyed_cb (info->priv->data_proxy, info);
-               if (info->priv->idle_id)
-                       g_source_remove (info->priv->idle_id);
-
-               /* the private area itself */
-               g_free (info->priv);
-               info->priv = NULL;
-       }
+       if (priv->proxy)
+               release_proxy (info);
+       if (priv->iter)
+               release_iter (info);
+       if (priv->data_proxy)
+               data_proxy_destroyed_cb (priv->data_proxy, info);
+       if (priv->idle_id)
+               g_source_remove (priv->idle_id);
 
        /* for the parent class */
-       parent_class->dispose (object);
+       G_OBJECT_CLASS (gdaui_data_proxy_info_parent_class)->dispose (object);
 }
 
 static void
@@ -293,71 +262,70 @@ gdaui_data_proxy_info_set_property (GObject *object,
 {
        GdauiDataProxyInfo *info;
 
-        info = GDAUI_DATA_PROXY_INFO (object);
-        if (info->priv) {
-                switch (param_id) {
-                case PROP_DATA_PROXY:
-                       if (info->priv->data_proxy)
-                               data_proxy_destroyed_cb (info->priv->data_proxy, info);
-                       if (info->priv->iter)
-                               release_iter (info);
-                       if (info->priv->proxy)
-                               release_proxy (info);
-
-                       info->priv->data_proxy = GDAUI_DATA_PROXY (g_value_get_object (value));
-                       if (info->priv->data_proxy) {
-                               GdaDataProxy *proxy;
-                               GdaDataModelIter *iter;
-
-                               /* data widget */
-                               g_signal_connect (info->priv->data_proxy, "destroy",
-                                                 G_CALLBACK (data_proxy_destroyed_cb), info);
-                               g_signal_connect (info->priv->data_proxy, "proxy-changed",
-                                                 G_CALLBACK (data_proxy_proxy_changed_cb), info);
-                               if (GDAUI_IS_RAW_GRID (info->priv->data_proxy))
-                                       g_signal_connect (info->priv->data_proxy, "selection-changed",
-                                                         G_CALLBACK (raw_grid_selection_changed_cb), info);
-
-                               /* proxy */
-                               proxy = gdaui_data_proxy_get_proxy (info->priv->data_proxy);
-                               if (proxy) {
-                                       info->priv->proxy = proxy;
-                                       g_object_ref (info->priv->proxy);
-                                       g_signal_connect (G_OBJECT (proxy), "changed",
-                                                         G_CALLBACK (proxy_changed_cb), info);
-                                       g_signal_connect (G_OBJECT (proxy), "sample-changed",
-                                                         G_CALLBACK (proxy_sample_changed_cb), info);
-                                       g_signal_connect (G_OBJECT (proxy), "row-inserted",
-                                                         G_CALLBACK (proxy_row_changed_cb), info);
-                                       g_signal_connect (G_OBJECT (proxy), "row-removed",
-                                                         G_CALLBACK (proxy_row_changed_cb), info);
-                                       g_signal_connect (G_OBJECT (proxy), "reset",
-                                                         G_CALLBACK (proxy_reset_cb), info);
-
-
-                                       /* iter */
-                                       iter = gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR
-                                                                                         
(info->priv->data_proxy));
-                                       info->priv->iter = iter;
-                                       if (iter) {
-                                               g_object_ref (G_OBJECT (iter));
-                                               g_signal_connect (iter, "row-changed",
-                                                                 G_CALLBACK (iter_row_changed_cb), info);
-                                       }
+       info = GDAUI_DATA_PROXY_INFO (object);
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
+       switch (param_id) {
+       case PROP_DATA_PROXY:
+               if (priv->data_proxy)
+                       data_proxy_destroyed_cb (priv->data_proxy, info);
+               if (priv->iter)
+                       release_iter (info);
+               if (priv->proxy)
+                       release_proxy (info);
+
+               priv->data_proxy = GDAUI_DATA_PROXY (g_value_get_object (value));
+               if (priv->data_proxy) {
+                       GdaDataProxy *proxy;
+                       GdaDataModelIter *iter;
+
+                       /* data widget */
+                       g_signal_connect (priv->data_proxy, "destroy",
+                                         G_CALLBACK (data_proxy_destroyed_cb), info);
+                       g_signal_connect (priv->data_proxy, "proxy-changed",
+                                         G_CALLBACK (data_proxy_proxy_changed_cb), info);
+                       if (GDAUI_IS_RAW_GRID (priv->data_proxy))
+                               g_signal_connect (priv->data_proxy, "selection-changed",
+                                                 G_CALLBACK (raw_grid_selection_changed_cb), info);
+
+                       /* proxy */
+                       proxy = gdaui_data_proxy_get_proxy (priv->data_proxy);
+                       if (proxy) {
+                               priv->proxy = proxy;
+                               g_object_ref (priv->proxy);
+                               g_signal_connect (G_OBJECT (proxy), "changed",
+                                                 G_CALLBACK (proxy_changed_cb), info);
+                               g_signal_connect (G_OBJECT (proxy), "sample-changed",
+                                                 G_CALLBACK (proxy_sample_changed_cb), info);
+                               g_signal_connect (G_OBJECT (proxy), "row-inserted",
+                                                 G_CALLBACK (proxy_row_changed_cb), info);
+                               g_signal_connect (G_OBJECT (proxy), "row-removed",
+                                                 G_CALLBACK (proxy_row_changed_cb), info);
+                               g_signal_connect (G_OBJECT (proxy), "reset",
+                                                 G_CALLBACK (proxy_reset_cb), info);
+
+
+                               /* iter */
+                               iter = gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR
+                                                                                 (priv->data_proxy));
+                               priv->iter = iter;
+                               if (iter) {
+                                       g_object_ref (G_OBJECT (iter));
+                                       g_signal_connect (iter, "row-changed",
+                                                         G_CALLBACK (iter_row_changed_cb), info);
                                }
-                               modif_buttons_update (info);
                        }
-                        break;
-                case PROP_FLAGS:
-                       info->priv->flags = g_value_get_flags (value);
-                       modif_buttons_make (info);
                        modif_buttons_update (info);
-                        break;
-               default:
-                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
-                       break;
-                }
-        }
+               }
+                      break;
+              case PROP_FLAGS:
+               priv->flags = g_value_get_flags (value);
+               modif_buttons_make (info);
+               modif_buttons_update (info);
+                      break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+               break;
+       }
 }
 
 static void
@@ -368,20 +336,19 @@ gdaui_data_proxy_info_get_property (GObject *object,
 {
        GdauiDataProxyInfo *info;
 
-        info = GDAUI_DATA_PROXY_INFO (object);
-        if (info->priv) {
-                switch (param_id) {
+       info = GDAUI_DATA_PROXY_INFO (object);
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
+       switch (param_id) {
                case PROP_DATA_PROXY:
-                       g_value_set_object (value, info->priv->data_proxy);
+                       g_value_set_object (value, priv->data_proxy);
                        break;
                case PROP_FLAGS:
-                       g_value_set_flags (value, info->priv->flags);
+                       g_value_set_flags (value, priv->flags);
                        break;
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
                        break;
-                }
-        }
+       }
 }
 
 
@@ -426,23 +393,27 @@ raw_grid_selection_changed_cb (G_GNUC_UNUSED GdauiRawGrid *grid, GdauiDataProxyI
 static void
 filter_item_clicked_cb (GtkToolButton *titem, GdauiDataProxyInfo *info)
 {
-       if (!info->priv->filter_popover) {
+       g_return_if_fail (GDAUI_IS_DATA_PROXY_INFO (info));
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
+       if (!priv->filter_popover) {
                /* create filter window */
-               info->priv->filter_popover = gtk_popover_new (GTK_WIDGET (titem));
+               priv->filter_popover = gtk_popover_new (GTK_WIDGET (titem));
 
                /* add real filter widget */
                GtkWidget *filter;
-               filter = gdaui_data_filter_new (info->priv->data_proxy);
+               filter = gdaui_data_filter_new (priv->data_proxy);
                gtk_widget_show (filter);
-               gtk_container_add (GTK_CONTAINER (info->priv->filter_popover), filter);
+               gtk_container_add (GTK_CONTAINER (priv->filter_popover), filter);
        }
 
-       gtk_widget_show (info->priv->filter_popover);
+       gtk_widget_show (priv->filter_popover);
 }
 
 static void
 action_statefull_clicked_cb (GtkToggleToolButton *toggle_tool_button, GdauiDataProxyInfo *info)
 {
+       g_return_if_fail (GDAUI_IS_DATA_PROXY_INFO (info));
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
        UIAction *uiaction;;
        uiaction = g_object_get_data ((GObject*) toggle_tool_button, "uia");
        GdauiAction action;
@@ -450,26 +421,30 @@ action_statefull_clicked_cb (GtkToggleToolButton *toggle_tool_button, GdauiDataP
                action = uiaction->action;
        else
                action = uiaction->toggle_action;
-       gdaui_data_proxy_perform_action (info->priv->data_proxy, action);
+       gdaui_data_proxy_perform_action (priv->data_proxy, action);
 }
 
 static void
 action_stateless_clicked_cb (GtkToolButton *tool_button, GdauiDataProxyInfo *info)
 {
+       g_return_if_fail (GDAUI_IS_DATA_PROXY_INFO (info));
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
        UIAction *uiaction;;
        uiaction = g_object_get_data ((GObject*) tool_button, "uia");
-       gdaui_data_proxy_perform_action (info->priv->data_proxy, uiaction->action);
+       gdaui_data_proxy_perform_action (priv->data_proxy, uiaction->action);
 }
 
 static void row_spin_changed_cb (GtkSpinButton *spin, GdauiDataProxyInfo *info);
 static void
 modif_buttons_make (GdauiDataProxyInfo *info)
 {
+       g_return_if_fail (GDAUI_IS_DATA_PROXY_INFO (info));
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
        GtkWidget *wid;
-       GdauiDataProxyInfoFlag flags = info->priv->flags;
-       GtkWidget **action_items = info->priv->action_items;
+       GdauiDataProxyInfoFlag flags = priv->flags;
+       GtkWidget **action_items = priv->action_items;
 
-       if (! info->priv->data_proxy)
+       if (! priv->data_proxy)
                return;
 
        /* row modification actions */
@@ -478,7 +453,7 @@ modif_buttons_make (GdauiDataProxyInfo *info)
                for (atype = ACTION_NEW; atype <= ACTION_RESET; atype++) {
                        UIAction *uiaction = &(uiactions[atype]);
 
-                       if (! gdaui_data_proxy_supports_action (info->priv->data_proxy, uiaction->action))
+                       if (! gdaui_data_proxy_supports_action (priv->data_proxy, uiaction->action))
                                continue;
 
                        gboolean is_toggle;
@@ -518,7 +493,7 @@ modif_buttons_make (GdauiDataProxyInfo *info)
                for (atype = ACTION_FIRSTRECORD; atype <= ACTION_LASTRECORD; atype++) {
                        UIAction *uiaction = &(uiactions[atype]);
 
-                       if (! gdaui_data_proxy_supports_action (info->priv->data_proxy, uiaction->action))
+                       if (! gdaui_data_proxy_supports_action (priv->data_proxy, uiaction->action))
                                continue;
 
                        gboolean is_toggle;
@@ -558,7 +533,7 @@ modif_buttons_make (GdauiDataProxyInfo *info)
                for (atype = ACTION_FIRSTCHUNK; atype <= ACTION_LASTCHUNK; atype++) {
                        UIAction *uiaction = &(uiactions[atype]);
 
-                       if (! gdaui_data_proxy_supports_action (info->priv->data_proxy, uiaction->action))
+                       if (! gdaui_data_proxy_supports_action (priv->data_proxy, uiaction->action))
                                continue;
 
                        gboolean is_toggle;
@@ -624,8 +599,8 @@ modif_buttons_make (GdauiDataProxyInfo *info)
                if (action_items[ACTION_CURRENT_ROW]) {
                        /* remove the current contents */
                        gtk_widget_destroy (gtk_bin_get_child (GTK_BIN (action_items[ACTION_CURRENT_ROW])));
-                       info->priv->row_spin = NULL;
-                       info->priv->current_sample = NULL;
+                       priv->row_spin = NULL;
+                       priv->current_sample = NULL;
                        gtk_toolbar_insert (GTK_TOOLBAR (info),
                                            GTK_TOOL_ITEM (action_items[ACTION_CURRENT_ROW]), -1);
                }
@@ -652,7 +627,7 @@ modif_buttons_make (GdauiDataProxyInfo *info)
                        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (wid), TRUE);
                        gtk_box_pack_start (GTK_BOX (toolwid), wid, FALSE, TRUE, 2);
                        gtk_widget_set_sensitive (wid, FALSE);
-                       info->priv->row_spin = wid;
+                       priv->row_spin = wid;
                        g_signal_connect (G_OBJECT (wid), "value-changed",
                                          G_CALLBACK (row_spin_changed_cb), info);
 
@@ -660,7 +635,7 @@ modif_buttons_make (GdauiDataProxyInfo *info)
                        wid = gtk_label_new (" /?");
       context = gtk_widget_get_style_context (wid);
       gtk_style_context_add_class (context, "small-text");
-                       info->priv->current_sample = wid;
+                       priv->current_sample = wid;
                        gtk_box_pack_start (GTK_BOX (toolwid), wid, FALSE, FALSE, 2);
                }
                else {
@@ -668,7 +643,7 @@ modif_buttons_make (GdauiDataProxyInfo *info)
                        wid = gtk_label_new (" ? - ? /?");
       context = gtk_widget_get_style_context (wid);
       gtk_style_context_add_class (context, "small-text");
-                       info->priv->current_sample = wid;
+                       priv->current_sample = wid;
                        toolwid = wid;
                }
 
@@ -680,9 +655,11 @@ modif_buttons_make (GdauiDataProxyInfo *info)
 static void
 row_spin_changed_cb (GtkSpinButton *spin, GdauiDataProxyInfo *info)
 {
+       g_return_if_fail (GDAUI_IS_DATA_PROXY_INFO (info));
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
        gint row, nrows;
        gint value = gtk_spin_button_get_value (spin);
-       nrows = gda_data_model_get_n_rows (GDA_DATA_MODEL (info->priv->proxy));
+       nrows = gda_data_model_get_n_rows (GDA_DATA_MODEL (priv->proxy));
 
        if ((value >= 1) && (value <= nrows))
                row = value - 1;
@@ -690,7 +667,7 @@ row_spin_changed_cb (GtkSpinButton *spin, GdauiDataProxyInfo *info)
                row = nrows - 1;
        else
                row = 0;
-       gda_data_model_iter_move_to_row (gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR 
(info->priv->data_proxy)),
+       gda_data_model_iter_move_to_row (gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR 
(priv->data_proxy)),
                                         row);
 }
 
@@ -698,20 +675,24 @@ static gboolean idle_modif_buttons_update (GdauiDataProxyInfo *info);
 static void
 modif_buttons_update (GdauiDataProxyInfo *info)
 {
-       if (info->priv->idle_id == 0)
-               info->priv->idle_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE,
+       g_return_if_fail (GDAUI_IS_DATA_PROXY_INFO (info));
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
+       if (priv->idle_id == 0)
+               priv->idle_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE,
                                                       (GSourceFunc) idle_modif_buttons_update,
                                                       g_object_ref (info), g_object_unref);
 }
 
 
-#define BLOCK_SPIN (g_signal_handlers_block_by_func (G_OBJECT (info->priv->row_spin), \
+#define BLOCK_SPIN (g_signal_handlers_block_by_func (G_OBJECT (priv->row_spin), \
                                                     G_CALLBACK (row_spin_changed_cb), info))
-#define UNBLOCK_SPIN (g_signal_handlers_unblock_by_func (G_OBJECT (info->priv->row_spin), \
+#define UNBLOCK_SPIN (g_signal_handlers_unblock_by_func (G_OBJECT (priv->row_spin), \
                                                         G_CALLBACK (row_spin_changed_cb), info))
 static gboolean
 idle_modif_buttons_update (GdauiDataProxyInfo *info)
 {
+       g_return_val_if_fail (GDAUI_IS_DATA_PROXY_INFO (info), FALSE);
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
        GdaDataModelIter *model_iter;
        gboolean wrows, filtered_proxy = FALSE;
        gint row;
@@ -723,50 +704,50 @@ idle_modif_buttons_update (GdauiDataProxyInfo *info)
        gint sample_first_row = 0, sample_last_row = 0, sample_size = 0;
        GdauiDataProxyInfoFlag flags = 0;
 
-       GtkWidget **action_items = info->priv->action_items;
+       GtkWidget **action_items = priv->action_items;
 
-       model_iter = gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (info->priv->data_proxy));
-       if (info->priv->proxy) {
-               filtered_proxy = gda_data_proxy_get_filter_expr (info->priv->proxy) ? TRUE : FALSE;
-               proxy_rows = gda_data_model_get_n_rows (GDA_DATA_MODEL (info->priv->proxy));
+       model_iter = gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (priv->data_proxy));
+       if (priv->proxy) {
+               filtered_proxy = gda_data_proxy_get_filter_expr (priv->proxy) ? TRUE : FALSE;
+               proxy_rows = gda_data_model_get_n_rows (GDA_DATA_MODEL (priv->proxy));
                if (filtered_proxy) {
-                       proxied_rows = gda_data_proxy_get_filtered_n_rows (info->priv->proxy);
+                       proxied_rows = gda_data_proxy_get_filtered_n_rows (priv->proxy);
                        all_rows = proxied_rows;
                }
                else {
-                       proxied_rows = gda_data_proxy_get_proxied_model_n_rows (info->priv->proxy);
-                       all_rows = proxied_rows + gda_data_proxy_get_n_new_rows (info->priv->proxy);
+                       proxied_rows = gda_data_proxy_get_proxied_model_n_rows (priv->proxy);
+                       all_rows = proxied_rows + gda_data_proxy_get_n_new_rows (priv->proxy);
                }
 
                /* samples don't take into account the proxy's inserted rows */
-               sample_first_row = gda_data_proxy_get_sample_start (info->priv->proxy);
-               sample_last_row = gda_data_proxy_get_sample_end (info->priv->proxy);
-               sample_size = gda_data_proxy_get_sample_size (info->priv->proxy);
+               sample_first_row = gda_data_proxy_get_sample_start (priv->proxy);
+               sample_last_row = gda_data_proxy_get_sample_end (priv->proxy);
+               sample_size = gda_data_proxy_get_sample_size (priv->proxy);
 
-               flags = gda_data_model_get_access_flags (GDA_DATA_MODEL (info->priv->proxy));
+               flags = gda_data_model_get_access_flags (GDA_DATA_MODEL (priv->proxy));
        }
 
        /* sensitiveness of the text indications and of the spin button */
        wrows = (proxy_rows <= 0) ? FALSE : TRUE;
        row = model_iter ? gda_data_model_iter_get_row (model_iter) : 0;
-       if (info->priv->flags & GDAUI_DATA_PROXY_INFO_CURRENT_ROW) {
+       if (priv->flags & GDAUI_DATA_PROXY_INFO_CURRENT_ROW) {
                if (proxy_rows < 0) {
-                       if (info->priv->flags & GDAUI_DATA_PROXY_INFO_ROW_MOVE_BUTTONS) {
+                       if (priv->flags & GDAUI_DATA_PROXY_INFO_ROW_MOVE_BUTTONS) {
                                BLOCK_SPIN;
-                               gtk_spin_button_set_range (GTK_SPIN_BUTTON (info->priv->row_spin), 0, 1);
-                               gtk_spin_button_set_value (GTK_SPIN_BUTTON (info->priv->row_spin), 0);
+                               gtk_spin_button_set_range (GTK_SPIN_BUTTON (priv->row_spin), 0, 1);
+                               gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->row_spin), 0);
                                UNBLOCK_SPIN;
-                               gtk_label_set_text (GTK_LABEL (info->priv->current_sample), " /?");
+                               gtk_label_set_text (GTK_LABEL (priv->current_sample), " /?");
                        }
                        else
-                               gtk_label_set_text (GTK_LABEL (info->priv->current_sample), " ? - ? /?");
+                               gtk_label_set_text (GTK_LABEL (priv->current_sample), " ? - ? /?");
                }
                else {
                        gchar *str;
                        gint total;
 
                        total = sample_first_row + proxy_rows;
-                       if (info->priv->flags & GDAUI_DATA_PROXY_INFO_ROW_MOVE_BUTTONS) {
+                       if (priv->flags & GDAUI_DATA_PROXY_INFO_ROW_MOVE_BUTTONS) {
                                if (total <= 0)
                                        str = g_strdup (" / 0");
                                else {
@@ -776,12 +757,12 @@ idle_modif_buttons_update (GdauiDataProxyInfo *info)
                                                str = g_strdup_printf (" / %d", proxy_rows);
                                }
                                BLOCK_SPIN;
-                               gtk_spin_button_set_range (GTK_SPIN_BUTTON (info->priv->row_spin),
+                               gtk_spin_button_set_range (GTK_SPIN_BUTTON (priv->row_spin),
                                                           proxy_rows > 0 ? 1 : 0,
                                                           proxy_rows);
                                if (row >= 0)
-                                       if (gtk_spin_button_get_value (GTK_SPIN_BUTTON 
(info->priv->row_spin)) != row+1)
-                                               gtk_spin_button_set_value (GTK_SPIN_BUTTON 
(info->priv->row_spin), row+1);
+                                       if (gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->row_spin)) != 
row+1)
+                                               gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->row_spin), 
row+1);
                                UNBLOCK_SPIN;
                        }
                        else {
@@ -801,13 +782,13 @@ idle_modif_buttons_update (GdauiDataProxyInfo *info)
                                }
                        }
 
-                       gtk_label_set_text (GTK_LABEL (info->priv->current_sample), str);
+                       gtk_label_set_text (GTK_LABEL (priv->current_sample), str);
                        g_free (str);
                }
 
-               gtk_widget_set_sensitive (info->priv->current_sample, wrows);
-               if (info->priv->row_spin)
-                       gtk_widget_set_sensitive (info->priv->row_spin, wrows && (row >= 0));
+               gtk_widget_set_sensitive (priv->current_sample, wrows);
+               if (priv->row_spin)
+                       gtk_widget_set_sensitive (priv->row_spin, wrows && (row >= 0));
        }
 
        /* current row modifications */
@@ -819,23 +800,23 @@ idle_modif_buttons_update (GdauiDataProxyInfo *info)
        gboolean has_selection;
 
        has_selection = (row >= 0) ? TRUE : FALSE;
-       if (info->priv->proxy) {
-               changed = gda_data_proxy_has_changed (info->priv->proxy);
+       if (priv->proxy) {
+               changed = gda_data_proxy_has_changed (priv->proxy);
 
                if (has_selection) {
-                       to_be_deleted = gda_data_proxy_row_is_deleted (info->priv->proxy, row);
-                       is_inserted = gda_data_proxy_row_is_inserted (info->priv->proxy, row);
+                       to_be_deleted = gda_data_proxy_row_is_deleted (priv->proxy, row);
+                       is_inserted = gda_data_proxy_row_is_inserted (priv->proxy, row);
                }
-               else if (GDAUI_IS_RAW_GRID (info->priv->data_proxy)) {
+               else if (GDAUI_IS_RAW_GRID (priv->data_proxy)) {
                        /* bad for encapsulation, but very useful... */
                        GList *sel, *list;
 
-                       sel = _gdaui_raw_grid_get_selection ((GdauiRawGrid*) info->priv->data_proxy);
+                       sel = _gdaui_raw_grid_get_selection ((GdauiRawGrid*) priv->data_proxy);
                        if (sel) {
                                list = sel;
                                while (list && (!force_del_btn || !force_undel_btn)) {
                                        if ((GPOINTER_TO_INT (list->data) != -1) &&
-                                           gda_data_proxy_row_is_deleted (info->priv->proxy,
+                                           gda_data_proxy_row_is_deleted (priv->proxy,
                                                                           GPOINTER_TO_INT (list->data)))
                                                force_undel_btn = TRUE;
                                        else
@@ -855,32 +836,32 @@ idle_modif_buttons_update (GdauiDataProxyInfo *info)
                }
        }
 
-       if (info->priv->flags & GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS) {
+       if (priv->flags & GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS) {
                GdauiDataProxyWriteMode mode;
-               mode = gdaui_data_proxy_get_write_mode (info->priv->data_proxy);
+               mode = gdaui_data_proxy_get_write_mode (priv->data_proxy);
 
-               if (info->priv->action_items [ACTION_COMMIT]) {
-                       gtk_widget_set_sensitive (info->priv->action_items [ACTION_COMMIT], changed ? TRUE : 
FALSE);
+               if (priv->action_items [ACTION_COMMIT]) {
+                       gtk_widget_set_sensitive (priv->action_items [ACTION_COMMIT], changed ? TRUE : FALSE);
                        if (mode == GDAUI_DATA_PROXY_WRITE_ON_VALUE_CHANGE)
                                gtk_widget_hide (action_items [ACTION_COMMIT]);
                        else if (! gtk_widget_get_no_show_all (action_items [ACTION_COMMIT]))
                                gtk_widget_show (action_items [ACTION_COMMIT]);
                }
 
-               if (info->priv->action_items [ACTION_RESET]) {
-                       gtk_widget_set_sensitive (info->priv->action_items [ACTION_RESET], changed ? TRUE : 
FALSE);
+               if (priv->action_items [ACTION_RESET]) {
+                       gtk_widget_set_sensitive (priv->action_items [ACTION_RESET], changed ? TRUE : FALSE);
                        if (mode == GDAUI_DATA_PROXY_WRITE_ON_VALUE_CHANGE)
                                gtk_widget_hide (action_items [ACTION_RESET]);
                        else if (! gtk_widget_get_no_show_all (action_items [ACTION_RESET]))
                                gtk_widget_show (action_items [ACTION_RESET]);
                }
 
-               if (info->priv->action_items [ACTION_NEW]) {
-                       gtk_widget_set_sensitive (info->priv->action_items [ACTION_NEW],
+               if (priv->action_items [ACTION_NEW]) {
+                       gtk_widget_set_sensitive (priv->action_items [ACTION_NEW],
                                                  flags & GDA_DATA_MODEL_ACCESS_INSERT ? TRUE : FALSE);
                }
 
-               if (info->priv->action_items [ACTION_DELETE]) {
+               if (priv->action_items [ACTION_DELETE]) {
                        g_signal_handlers_block_by_func (action_items[ACTION_DELETE],
                                                         G_CALLBACK (action_statefull_clicked_cb), info);
                        gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON 
(action_items[ACTION_DELETE]),
@@ -891,55 +872,55 @@ idle_modif_buttons_update (GdauiDataProxyInfo *info)
                        if (to_be_deleted) {
                                wrows = (flags & GDA_DATA_MODEL_ACCESS_DELETE) &&
                                        (force_undel_btn || has_selection);
-                               gtk_widget_set_tooltip_text (info->priv->action_items [ACTION_DELETE],
+                               gtk_widget_set_tooltip_text (priv->action_items [ACTION_DELETE],
                                                             _("Undelete the selected entry"));
                        }
                        else {
                                wrows = is_inserted ||
                                        ((flags & GDA_DATA_MODEL_ACCESS_DELETE) &&
                                         (force_del_btn || has_selection));
-                               gtk_widget_set_tooltip_text (info->priv->action_items [ACTION_DELETE],
+                               gtk_widget_set_tooltip_text (priv->action_items [ACTION_DELETE],
                                                             _("Delete the selected entry"));
                        }
-                       gtk_widget_set_sensitive (info->priv->action_items [ACTION_DELETE], wrows);
+                       gtk_widget_set_sensitive (priv->action_items [ACTION_DELETE], wrows);
                }
        }
 
        /* current row moving */
-       if (info->priv->flags & GDAUI_DATA_PROXY_INFO_ROW_MOVE_BUTTONS) {
-               if (info->priv->action_items [ACTION_FIRSTRECORD])
-                       gtk_widget_set_sensitive (info->priv->action_items [ACTION_FIRSTRECORD], (row <= 0) ? 
FALSE : TRUE);
-               if (info->priv->action_items [ACTION_PREVRECORD])
-                       gtk_widget_set_sensitive (info->priv->action_items [ACTION_PREVRECORD], (row <= 0) ? 
FALSE : TRUE);
-               if (info->priv->action_items [ACTION_NEXTRECORD])
-                       gtk_widget_set_sensitive (info->priv->action_items [ACTION_NEXTRECORD],
+       if (priv->flags & GDAUI_DATA_PROXY_INFO_ROW_MOVE_BUTTONS) {
+               if (priv->action_items [ACTION_FIRSTRECORD])
+                       gtk_widget_set_sensitive (priv->action_items [ACTION_FIRSTRECORD], (row <= 0) ? FALSE 
: TRUE);
+               if (priv->action_items [ACTION_PREVRECORD])
+                       gtk_widget_set_sensitive (priv->action_items [ACTION_PREVRECORD], (row <= 0) ? FALSE 
: TRUE);
+               if (priv->action_items [ACTION_NEXTRECORD])
+                       gtk_widget_set_sensitive (priv->action_items [ACTION_NEXTRECORD],
                                                  (row == proxy_rows -1) || (row < 0) ? FALSE : TRUE);
-               if (info->priv->action_items [ACTION_LASTRECORD])
-                       gtk_widget_set_sensitive (info->priv->action_items [ACTION_LASTRECORD],
+               if (priv->action_items [ACTION_LASTRECORD])
+                       gtk_widget_set_sensitive (priv->action_items [ACTION_LASTRECORD],
                                                  (row == proxy_rows -1) || (row < 0) ? FALSE : TRUE);
        }
 
        /* chunk indications */
-       if (info->priv->flags & GDAUI_DATA_PROXY_INFO_CHUNK_CHANGE_BUTTONS) {
+       if (priv->flags & GDAUI_DATA_PROXY_INFO_CHUNK_CHANGE_BUTTONS) {
                gboolean abool;
                wrows = (sample_size > 0) ? TRUE : FALSE;
-               if (info->priv->action_items [ACTION_FIRSTCHUNK])
-                       gtk_widget_set_sensitive (info->priv->action_items [ACTION_FIRSTCHUNK],
+               if (priv->action_items [ACTION_FIRSTCHUNK])
+                       gtk_widget_set_sensitive (priv->action_items [ACTION_FIRSTCHUNK],
                                                  wrows && (sample_first_row > 0) ? TRUE : FALSE);
-               if (info->priv->action_items [ACTION_PREVCHUNK])
-                       gtk_widget_set_sensitive (info->priv->action_items [ACTION_PREVCHUNK],
+               if (priv->action_items [ACTION_PREVCHUNK])
+                       gtk_widget_set_sensitive (priv->action_items [ACTION_PREVCHUNK],
                                                  wrows && (sample_first_row > 0) ? TRUE : FALSE);
 
                abool = (proxied_rows != -1) ? (wrows && (sample_last_row < proxied_rows - 1)) : TRUE;
-               if (info->priv->action_items [ACTION_NEXTCHUNK])
-                       gtk_widget_set_sensitive (info->priv->action_items [ACTION_NEXTCHUNK], abool);
-               if (info->priv->action_items [ACTION_LASTCHUNK])
-                       gtk_widget_set_sensitive (info->priv->action_items [ACTION_LASTCHUNK],
+               if (priv->action_items [ACTION_NEXTCHUNK])
+                       gtk_widget_set_sensitive (priv->action_items [ACTION_NEXTCHUNK], abool);
+               if (priv->action_items [ACTION_LASTCHUNK])
+                       gtk_widget_set_sensitive (priv->action_items [ACTION_LASTCHUNK],
                                                  wrows && (sample_last_row < proxied_rows - 1));
        }
 
        /* remove IDLE */
-       info->priv->idle_id = 0;
+       priv->idle_id = 0;
        return FALSE;
 }
 
@@ -959,13 +940,14 @@ gdaui_data_proxy_info_get_item (GdauiDataProxyInfo *info, GdauiAction action)
 {
        g_return_val_if_fail (GDAUI_IS_DATA_PROXY_INFO (info), NULL);
        g_return_val_if_fail ((action >= GDAUI_ACTION_NEW_DATA) && (action <= GDAUI_ACTION_MOVE_LAST_CHUNK), 
NULL);
+       GdauiDataProxyInfoPrivate *priv = gdaui_data_proxy_info_get_instance_private (info);
 
        ActionType type;
        for (type = ACTION_NEW; type < ACTION_COUNT; type++) {
                UIAction *act;
                act = &(uiactions[type]);
                if (act->action == action)
-                       return GTK_TOOL_ITEM (info->priv->action_items [type]);
+                       return GTK_TOOL_ITEM (priv->action_items [type]);
        }
        return NULL;
 }
diff --git a/libgda-ui/gdaui-data-proxy-info.h b/libgda-ui/gdaui-data-proxy-info.h
index 1b6467abc..547ed9c56 100644
--- a/libgda-ui/gdaui-data-proxy-info.h
+++ b/libgda-ui/gdaui-data-proxy-info.h
@@ -28,16 +28,6 @@
 
 G_BEGIN_DECLS
 
-#define GDAUI_TYPE_DATA_PROXY_INFO          (gdaui_data_proxy_info_get_type())
-#define GDAUI_DATA_PROXY_INFO(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, 
gdaui_data_proxy_info_get_type(), GdauiDataProxyInfo)
-#define GDAUI_DATA_PROXY_INFO_CLASS(klass)  G_TYPE_CHECK_CLASS_CAST (klass, gdaui_data_proxy_info_get_type 
(), GdauiDataProxyInfoClass)
-#define GDAUI_IS_DATA_PROXY_INFO(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, gdaui_data_proxy_info_get_type 
())
-
-
-typedef struct _GdauiDataProxyInfo      GdauiDataProxyInfo;
-typedef struct _GdauiDataProxyInfoClass GdauiDataProxyInfoClass;
-typedef struct _GdauiDataProxyInfoPriv  GdauiDataProxyInfoPriv;
-
 /**
  * GdauiDataProxyInfoFlag:
  * @GDAUI_DATA_PROXY_INFO_NONE: 
@@ -57,18 +47,15 @@ typedef enum
        GDAUI_DATA_PROXY_INFO_NO_FILTER = 1 << 5
 } GdauiDataProxyInfoFlag;
 
-/* struct for the object's data */
-struct _GdauiDataProxyInfo
-{
-       GtkToolbar              object;
+#define GDAUI_TYPE_DATA_PROXY_INFO          (gdaui_data_proxy_info_get_type())
+G_DECLARE_DERIVABLE_TYPE (GdauiDataProxyInfo, gdaui_data_proxy_info, GDAUI, DATA_PROXY_INFO, GtkToolbar)
 
-       GdauiDataProxyInfoPriv *priv;
-};
 
 /* struct for the object's class */
 struct _GdauiDataProxyInfoClass
 {
-       GtkToolbarClass         parent_class;
+       GtkToolbarClass     parent_class;
+       gpointer            padding[12];
 };
 
 /**
@@ -86,7 +73,6 @@ struct _GdauiDataProxyInfoClass
  * </itemizedlist>
  */
 
-GType             gdaui_data_proxy_info_get_type (void) G_GNUC_CONST;
 GtkWidget        *gdaui_data_proxy_info_new      (GdauiDataProxy *data_proxy, GdauiDataProxyInfoFlag flags);
 GtkToolItem      *gdaui_data_proxy_info_get_item (GdauiDataProxyInfo *info, GdauiAction action);
 G_END_DECLS


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