[mutter/wip/nielsdg/use-g-declare-interface: 51/53] clutter: Content: Use G_DECLARE_INTERFACE()



commit b77e6f0c98db247e3c4ee6266c1d717d737eae21
Author: Niels De Graef <niels degraef barco com>
Date:   Tue Jan 8 15:16:47 2019 +0100

    clutter: Content: Use G_DECLARE_INTERFACE()
    
    It cuts away a bit of the GObject boilerplate, gives us support for
    `g_autoptr`, and removes the typedef hack inside clutter-content.c.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/380

 clutter/clutter/clutter-autocleanups.h   |  1 -
 clutter/clutter/clutter-canvas.c         |  4 ++--
 clutter/clutter/clutter-content.c        | 12 +++++-------
 clutter/clutter/clutter-content.h        | 26 ++++++--------------------
 clutter/clutter/clutter-image.c          |  4 ++--
 clutter/tests/interactive/test-content.c |  4 ++--
 clutter/tests/interactive/test-image.c   |  4 ++--
 7 files changed, 19 insertions(+), 36 deletions(-)
---
diff --git a/clutter/clutter/clutter-autocleanups.h b/clutter/clutter/clutter-autocleanups.h
index 10c73fdd4..86aa399df 100644
--- a/clutter/clutter/clutter-autocleanups.h
+++ b/clutter/clutter/clutter-autocleanups.h
@@ -49,7 +49,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterClone, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterColorizeEffect, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterConstraint, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterContainer, g_object_unref)
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterContent, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDeformEffect, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDesaturateEffect, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDeviceManager, g_object_unref)
diff --git a/clutter/clutter/clutter-canvas.c b/clutter/clutter/clutter-canvas.c
index aa9f1ea41..9f29f18ad 100644
--- a/clutter/clutter/clutter-canvas.c
+++ b/clutter/clutter/clutter-canvas.c
@@ -97,7 +97,7 @@ enum
 
 static guint canvas_signals[LAST_SIGNAL] = { 0, };
 
-static void clutter_content_iface_init (ClutterContentIface *iface);
+static void clutter_content_iface_init (ClutterContentInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (ClutterCanvas, clutter_canvas, G_TYPE_OBJECT,
                          G_ADD_PRIVATE (ClutterCanvas)
@@ -457,7 +457,7 @@ clutter_canvas_get_preferred_size (ClutterContent *content,
 }
 
 static void
-clutter_content_iface_init (ClutterContentIface *iface)
+clutter_content_iface_init (ClutterContentInterface *iface)
 {
   iface->invalidate = clutter_canvas_invalidate;
   iface->paint_content = clutter_canvas_paint_content;
diff --git a/clutter/clutter/clutter-content.c b/clutter/clutter/clutter-content.c
index b7aea04c2..e487b8955 100644
--- a/clutter/clutter/clutter-content.c
+++ b/clutter/clutter/clutter-content.c
@@ -45,8 +45,6 @@
 #include "clutter-marshal.h"
 #include "clutter-private.h"
 
-typedef struct _ClutterContentIface     ClutterContentInterface;
-
 enum
 {
   ATTACHED,
@@ -130,7 +128,7 @@ clutter_content_default_init (ClutterContentInterface *iface)
     g_signal_new (I_("attached"),
                   G_TYPE_FROM_INTERFACE (iface),
                   G_SIGNAL_RUN_FIRST,
-                  G_STRUCT_OFFSET (ClutterContentIface, attached),
+                  G_STRUCT_OFFSET (ClutterContentInterface, attached),
                   NULL, NULL,
                   _clutter_marshal_VOID__OBJECT,
                   G_TYPE_NONE, 1,
@@ -150,7 +148,7 @@ clutter_content_default_init (ClutterContentInterface *iface)
     g_signal_new (I_("detached"),
                   G_TYPE_FROM_INTERFACE (iface),
                   G_SIGNAL_RUN_FIRST,
-                  G_STRUCT_OFFSET (ClutterContentIface, detached),
+                  G_STRUCT_OFFSET (ClutterContentInterface, detached),
                   NULL, NULL,
                   _clutter_marshal_VOID__OBJECT,
                   G_TYPE_NONE, 1,
@@ -245,7 +243,7 @@ clutter_content_invalidate_size (ClutterContent *content)
  * is associated to a #ClutterContent, to set up a backpointer from
  * the @content to the @actor.
  *
- * This function will invoke the #ClutterContentIface.attached() virtual
+ * This function will invoke the #ClutterContentInterface.attached() virtual
  * function.
  */
 void
@@ -279,7 +277,7 @@ _clutter_content_attached (ClutterContent *content,
  * This function should be used internally every time a #ClutterActor
  * removes the association with a #ClutterContent.
  *
- * This function will invoke the #ClutterContentIface.detached() virtual
+ * This function will invoke the #ClutterContentInterface.detached() virtual
  * function.
  */
 void
@@ -308,7 +306,7 @@ _clutter_content_detached (ClutterContent *content,
  *
  * Creates the render tree for the @content and @actor.
  *
- * This function will invoke the #ClutterContentIface.paint_content()
+ * This function will invoke the #ClutterContentInterface.paint_content()
  * virtual function.
  */
 void
diff --git a/clutter/clutter/clutter-content.h b/clutter/clutter/clutter-content.h
index 0b676f6e3..4e2e1f58f 100644
--- a/clutter/clutter/clutter-content.h
+++ b/clutter/clutter/clutter-content.h
@@ -33,24 +33,13 @@
 
 G_BEGIN_DECLS
 
-#define CLUTTER_TYPE_CONTENT            (clutter_content_get_type ())
-#define CLUTTER_CONTENT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_CONTENT, 
ClutterContent))
-#define CLUTTER_IS_CONTENT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_CONTENT))
-#define CLUTTER_CONTENT_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CLUTTER_TYPE_CONTENT, 
ClutterContentIface))
+#define CLUTTER_TYPE_CONTENT (clutter_content_get_type ())
 
-typedef struct _ClutterContentIface     ClutterContentIface;
-
-/**
- * ClutterContent:
- *
- * The #ClutterContent structure is an opaque type
- * whose members cannot be acccessed directly.
- *
- * Since: 1.10
- */
+CLUTTER_EXPORT
+G_DECLARE_INTERFACE (ClutterContent, clutter_content, CLUTTER, CONTENT, GObject)
 
 /**
- * ClutterContentIface:
+ * ClutterContentInterface:
  * @get_preferred_size: virtual function; should be overridden by subclasses
  *   of #ClutterContent that have a natural size
  * @paint_content: virtual function; called each time the content needs to
@@ -62,12 +51,12 @@ typedef struct _ClutterContentIface     ClutterContentIface;
  * @invalidate: virtual function; called each time a #ClutterContent state
  *   is changed.
  *
- * The #ClutterContentIface structure contains only
+ * The #ClutterContentInterface structure contains only
  * private data.
  *
  * Since: 1.10
  */
-struct _ClutterContentIface
+struct _ClutterContentInterface
 {
   /*< private >*/
   GTypeInterface g_iface;
@@ -90,9 +79,6 @@ struct _ClutterContentIface
   void          (* invalidate_size)     (ClutterContent   *content);
 };
 
-CLUTTER_EXPORT
-GType clutter_content_get_type (void) G_GNUC_CONST;
-
 CLUTTER_EXPORT
 gboolean        clutter_content_get_preferred_size      (ClutterContent *content,
                                                          gfloat         *width,
diff --git a/clutter/clutter/clutter-image.c b/clutter/clutter/clutter-image.c
index 924626be0..266c68799 100644
--- a/clutter/clutter/clutter-image.c
+++ b/clutter/clutter/clutter-image.c
@@ -57,7 +57,7 @@ struct _ClutterImagePrivate
   gint height;
 };
 
-static void clutter_content_iface_init (ClutterContentIface *iface);
+static void clutter_content_iface_init (ClutterContentInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (ClutterImage, clutter_image, G_TYPE_OBJECT,
                          G_ADD_PRIVATE (ClutterImage)
@@ -154,7 +154,7 @@ clutter_image_get_preferred_size (ClutterContent *content,
 }
 
 static void
-clutter_content_iface_init (ClutterContentIface *iface)
+clutter_content_iface_init (ClutterContentInterface *iface)
 {
   iface->get_preferred_size = clutter_image_get_preferred_size;
   iface->paint_content = clutter_image_paint_content;
diff --git a/clutter/tests/interactive/test-content.c b/clutter/tests/interactive/test-content.c
index 94d33bfed..5f84c9218 100644
--- a/clutter/tests/interactive/test-content.c
+++ b/clutter/tests/interactive/test-content.c
@@ -17,7 +17,7 @@ typedef struct _ColorContentClass {
   GObjectClass parent_class;
 } ColorContentClass;
 
-static void clutter_content_iface_init (ClutterContentIface *iface);
+static void clutter_content_iface_init (ClutterContentInterface *iface);
 
 GType color_content_get_type (void);
 
@@ -135,7 +135,7 @@ color_content_paint_content (ClutterContent   *content,
 }
 
 static void
-clutter_content_iface_init (ClutterContentIface *iface)
+clutter_content_iface_init (ClutterContentInterface *iface)
 {
   iface->paint_content = color_content_paint_content;
 }
diff --git a/clutter/tests/interactive/test-image.c b/clutter/tests/interactive/test-image.c
index 126f3e6de..c565dd1fb 100644
--- a/clutter/tests/interactive/test-image.c
+++ b/clutter/tests/interactive/test-image.c
@@ -18,7 +18,7 @@ typedef struct _SolidContentClass {
   GObjectClass parent_class;
 } SolidContentClass;
 
-static void clutter_content_iface_init (ClutterContentIface *iface);
+static void clutter_content_iface_init (ClutterContentInterface *iface);
 
 GType solid_content_get_type (void);
 
@@ -136,7 +136,7 @@ solid_content_paint_content (ClutterContent   *content,
 }
 
 static void
-clutter_content_iface_init (ClutterContentIface *iface)
+clutter_content_iface_init (ClutterContentInterface *iface)
 {
   iface->paint_content = solid_content_paint_content;
 }


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