[libgda] gdaui-data-poxy: using G_DECLARE/G_DEFINE and g_autoptr()



commit 4d6a44452734257dd12ca1367897ec40173f3c0f
Author: Daniel Espinosa <esodan gmail com>
Date:   Sun Sep 9 21:17:37 2018 -0500

    gdaui-data-poxy: using G_DECLARE/G_DEFINE and g_autoptr()

 libgda-ui/gdaui-data-filter.h     |  4 ++--
 libgda-ui/gdaui-data-proxy-info.h |  2 +-
 libgda-ui/gdaui-data-proxy.c      | 32 +++-----------------------------
 libgda-ui/gdaui-data-proxy.h      | 15 +++++----------
 libgda-ui/gdaui-decl.h            |  8 +-------
 libgda-ui/gdaui-form.c            |  4 ++--
 libgda-ui/gdaui-grid.c            |  4 ++--
 libgda-ui/gdaui-raw-form.c        |  4 ++--
 libgda-ui/gdaui-raw-grid.c        |  4 ++--
 tools/browser/ui-formgrid.h       |  1 +
 10 files changed, 21 insertions(+), 57 deletions(-)
---
diff --git a/libgda-ui/gdaui-data-filter.h b/libgda-ui/gdaui-data-filter.h
index d3fd18752..424dcf006 100644
--- a/libgda-ui/gdaui-data-filter.h
+++ b/libgda-ui/gdaui-data-filter.h
@@ -22,8 +22,8 @@
 #define __GDAUI_DATA_FILTER__
 
 #include <gtk/gtk.h>
-#include <libgda/gda-decl.h>
-#include <libgda-ui/gdaui-decl.h>
+#include <libgda-ui/gdaui-data-proxy.h>
+#include <libgda-ui/gdaui-data-filter.h>
 
 G_BEGIN_DECLS
 
diff --git a/libgda-ui/gdaui-data-proxy-info.h b/libgda-ui/gdaui-data-proxy-info.h
index 4367b9746..1b6467abc 100644
--- a/libgda-ui/gdaui-data-proxy-info.h
+++ b/libgda-ui/gdaui-data-proxy-info.h
@@ -23,7 +23,7 @@
 
 #include <gtk/gtk.h>
 #include <libgda/gda-decl.h>
-#include <libgda-ui/gdaui-decl.h>
+#include <libgda-ui/gdaui-data-proxy.h>
 #include <libgda-ui/gdaui-enums.h>
 
 G_BEGIN_DECLS
diff --git a/libgda-ui/gdaui-data-proxy.c b/libgda-ui/gdaui-data-proxy.c
index 502d89a98..2c0c0b8b6 100644
--- a/libgda-ui/gdaui-data-proxy.c
+++ b/libgda-ui/gdaui-data-proxy.c
@@ -35,36 +35,10 @@ enum {
 
 static gint gdaui_data_proxy_signals[LAST_SIGNAL] = { 0 };
 
-static void gdaui_data_proxy_iface_init (gpointer g_class);
-
-GType
-gdaui_data_proxy_get_type (void)
-{
-       static GType type = 0;
-
-       if (G_UNLIKELY (type == 0)) {
-               static const GTypeInfo info = {
-                       sizeof (GdauiDataProxyIface),
-                       (GBaseInitFunc) gdaui_data_proxy_iface_init,
-                       (GBaseFinalizeFunc) NULL,
-                       (GClassInitFunc) NULL,
-                       NULL,
-                       NULL,
-                       0,
-                       0,
-                       (GInstanceInitFunc) NULL,
-                       0
-               };
-               
-               type = g_type_register_static (G_TYPE_INTERFACE, "GdauiDataProxy", &info, 0);
-               g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
-       }
-       return type;
-}
-
+G_DEFINE_INTERFACE(GdauiDataProxy, gdaui_data_proxy, GTK_TYPE_WIDGET)
 
 static void
-gdaui_data_proxy_iface_init (G_GNUC_UNUSED gpointer g_class)
+gdaui_data_proxy_default_init (GdauiDataProxyInterface *iface)
 {
        static gboolean initialized = FALSE;
 
@@ -83,7 +57,7 @@ gdaui_data_proxy_iface_init (G_GNUC_UNUSED gpointer g_class)
                        g_signal_new ("proxy-changed",
                                       GDAUI_TYPE_DATA_PROXY,
                                       G_SIGNAL_RUN_FIRST,
-                                      G_STRUCT_OFFSET (GdauiDataProxyIface, proxy_changed),
+                                      G_STRUCT_OFFSET (GdauiDataProxyInterface, proxy_changed),
                                       NULL, NULL,
                                       g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE,
                                       1, GDA_TYPE_DATA_PROXY);
diff --git a/libgda-ui/gdaui-data-proxy.h b/libgda-ui/gdaui-data-proxy.h
index 1b5e55ebd..678309655 100644
--- a/libgda-ui/gdaui-data-proxy.h
+++ b/libgda-ui/gdaui-data-proxy.h
@@ -23,17 +23,12 @@
 
 #include <glib-object.h>
 #include <gtk/gtk.h>
-#include <libgda/gda-decl.h>
+#include <libgda/gda-data-proxy.h>
 #include "gdaui-decl.h"
 #include "gdaui-enums.h"
 
 G_BEGIN_DECLS
 
-#define GDAUI_TYPE_DATA_PROXY          (gdaui_data_proxy_get_type())
-#define GDAUI_DATA_PROXY(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, GDAUI_TYPE_DATA_PROXY, 
GdauiDataProxy)
-#define GDAUI_IS_DATA_PROXY(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, GDAUI_TYPE_DATA_PROXY)
-#define GDAUI_DATA_PROXY_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GDAUI_TYPE_DATA_PROXY, 
GdauiDataProxyIface))
-
 /**
  * GdauiDataProxyWriteMode:
  * @GDAUI_DATA_PROXY_WRITE_ON_DEMAND: write only when explicitly requested 
@@ -51,8 +46,11 @@ typedef enum {
        GDAUI_DATA_PROXY_WRITE_ON_VALUE_CHANGE     = 3 
 } GdauiDataProxyWriteMode;
 
+#define GDAUI_TYPE_DATA_PROXY          (gdaui_data_proxy_get_type())
+G_DECLARE_INTERFACE(GdauiDataProxy, gdaui_data_proxy, GDAUI, DATA_PROXY, GtkWidget)
+
 /* struct for the interface */
-struct _GdauiDataProxyIface
+struct _GdauiDataProxyInterface
 {
        GTypeInterface           g_iface;
 
@@ -67,7 +65,6 @@ struct _GdauiDataProxyIface
        /* signals */
        void                 (* proxy_changed)       (GdauiDataProxy *iface, GdaDataProxy *proxy);
 };
-
 /**
  * SECTION:gdaui-data-proxy
  * @short_description: Displaying and modifying data in a #GdaDataProxy
@@ -81,8 +78,6 @@ struct _GdauiDataProxyIface
  * are written to the data model).
  */
 
-GType             gdaui_data_proxy_get_type                  (void) G_GNUC_CONST;
-
 GdaDataProxy     *gdaui_data_proxy_get_proxy                 (GdauiDataProxy *iface);
 
 gboolean          gdaui_data_proxy_supports_action           (GdauiDataProxy *iface, GdauiAction action);
diff --git a/libgda-ui/gdaui-decl.h b/libgda-ui/gdaui-decl.h
index dc2cfb84d..2c7efe6cf 100644
--- a/libgda-ui/gdaui-decl.h
+++ b/libgda-ui/gdaui-decl.h
@@ -20,14 +20,8 @@
 #ifndef __GDAUI_DECL_H_
 #define __GDAUI_DECL_H_
 
-/* 
- * Interfaces 
- */
-
-typedef struct _GdauiDataProxy       GdauiDataProxy;
-typedef struct _GdauiDataProxyIface  GdauiDataProxyIface;
 
-/* 
+/*
  * Colors
  */
 #define GDAUI_COLOR_NORMAL_NULL "#00cd66"
diff --git a/libgda-ui/gdaui-form.c b/libgda-ui/gdaui-form.c
index 0019e0778..580ad5cca 100644
--- a/libgda-ui/gdaui-form.c
+++ b/libgda-ui/gdaui-form.c
@@ -43,7 +43,7 @@ static void gdaui_form_get_property (GObject *object,
                                     GParamSpec *pspec);
 
 /* GdauiDataProxy interface */
-static void            gdaui_form_widget_init         (GdauiDataProxyIface *iface);
+static void            gdaui_form_widget_init         (GdauiDataProxyInterface *iface);
 static GdaDataProxy   *gdaui_form_get_proxy           (GdauiDataProxy *iface);
 static void            gdaui_form_set_column_editable (GdauiDataProxy *iface, gint column, gboolean 
editable);
 static gboolean        gdaui_form_supports_action       (GdauiDataProxy *iface, GdauiAction action);
@@ -119,7 +119,7 @@ gdaui_form_get_type (void)
 }
 
 static void
-gdaui_form_widget_init (GdauiDataProxyIface *iface)
+gdaui_form_widget_init (GdauiDataProxyInterface *iface)
 {
        iface->get_proxy = gdaui_form_get_proxy;
        iface->set_column_editable = gdaui_form_set_column_editable;
diff --git a/libgda-ui/gdaui-grid.c b/libgda-ui/gdaui-grid.c
index 13fdec3bf..9b58158f5 100644
--- a/libgda-ui/gdaui-grid.c
+++ b/libgda-ui/gdaui-grid.c
@@ -43,7 +43,7 @@ static void gdaui_grid_get_property (GObject *object,
                                     GParamSpec *pspec);
 
 /* GdauiDataProxy interface */
-static void            gdaui_grid_widget_init         (GdauiDataProxyIface *iface);
+static void            gdaui_grid_widget_init         (GdauiDataProxyInterface *iface);
 static GdaDataProxy   *gdaui_grid_get_proxy           (GdauiDataProxy *iface);
 static void            gdaui_grid_set_column_editable (GdauiDataProxy *iface, gint column, gboolean 
editable);
 static gboolean        gdaui_grid_supports_action       (GdauiDataProxy *iface, GdauiAction action);
@@ -120,7 +120,7 @@ gdaui_grid_get_type (void)
 }
 
 static void
-gdaui_grid_widget_init (GdauiDataProxyIface *iface)
+gdaui_grid_widget_init (GdauiDataProxyInterface *iface)
 {
        iface->get_proxy = gdaui_grid_get_proxy;
        iface->set_column_editable = gdaui_grid_set_column_editable;
diff --git a/libgda-ui/gdaui-raw-form.c b/libgda-ui/gdaui-raw-form.c
index 43e53ec93..8781328f1 100644
--- a/libgda-ui/gdaui-raw-form.c
+++ b/libgda-ui/gdaui-raw-form.c
@@ -54,7 +54,7 @@ static void proxy_access_changed_cb (GdaDataProxy *proxy, GdauiRawForm *form);
 static void proxy_row_inserted_or_removed_cb (GdaDataProxy *proxy, gint row, GdauiRawForm *form);
 
 /* GdauiDataProxy interface */
-static void            gdaui_raw_form_widget_init         (GdauiDataProxyIface *iface);
+static void            gdaui_raw_form_widget_init         (GdauiDataProxyInterface *iface);
 static GdaDataProxy   *gdaui_raw_form_get_proxy           (GdauiDataProxy *iface);
 static void            gdaui_raw_form_set_column_editable (GdauiDataProxy *iface, gint column, gboolean 
editable);
 static gboolean        gdaui_raw_form_supports_action       (GdauiDataProxy *iface, GdauiAction action);
@@ -133,7 +133,7 @@ gdaui_raw_form_get_type (void)
 }
 
 static void
-gdaui_raw_form_widget_init (GdauiDataProxyIface *iface)
+gdaui_raw_form_widget_init (GdauiDataProxyInterface *iface)
 {
        iface->get_proxy = gdaui_raw_form_get_proxy;
        iface->set_column_editable = gdaui_raw_form_set_column_editable;
diff --git a/libgda-ui/gdaui-raw-grid.c b/libgda-ui/gdaui-raw-grid.c
index db71c833a..2058d0b25 100644
--- a/libgda-ui/gdaui-raw-grid.c
+++ b/libgda-ui/gdaui-raw-grid.c
@@ -66,7 +66,7 @@ static void reset_columns_in_xml_layout (GdauiRawGrid *grid, xmlNodePtr grid_nod
 
 
 /* GdauiDataProxy interface */
-static void            gdaui_raw_grid_widget_init           (GdauiDataProxyIface *iface);
+static void            gdaui_raw_grid_widget_init           (GdauiDataProxyInterface *iface);
 static GdaDataProxy   *gdaui_raw_grid_get_proxy             (GdauiDataProxy *iface);
 static void            gdaui_raw_grid_set_column_editable   (GdauiDataProxy *iface, gint column, gboolean 
editable);
 static gboolean        gdaui_raw_grid_supports_action       (GdauiDataProxy *iface, GdauiAction action);
@@ -216,7 +216,7 @@ gdaui_raw_grid_get_type (void)
 }
 
 static void
-gdaui_raw_grid_widget_init (GdauiDataProxyIface *iface)
+gdaui_raw_grid_widget_init (GdauiDataProxyInterface *iface)
 {
        iface->get_proxy = gdaui_raw_grid_get_proxy;
        iface->set_column_editable = gdaui_raw_grid_set_column_editable;
diff --git a/tools/browser/ui-formgrid.h b/tools/browser/ui-formgrid.h
index 23e1ef4e7..31a30a250 100644
--- a/tools/browser/ui-formgrid.h
+++ b/tools/browser/ui-formgrid.h
@@ -24,6 +24,7 @@
 #include <libgda/gda-data-model.h>
 #include <libgda-ui/gdaui-data-proxy-info.h>
 #include <libgda-ui/gdaui-raw-grid.h>
+#include <libgda-ui/gdaui-data-proxy.h>
 #include "../common/t-connection.h"
 
 G_BEGIN_DECLS


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