gegl r1821 - in trunk: . operations/core



Author: mitch
Date: Mon Jan  7 23:25:50 2008
New Revision: 1821
URL: http://svn.gnome.org/viewvc/gegl?rev=1821&view=rev

Log:
2008-01-08  Michael Natterer  <mitch gimp org>

	* operations/core/shift.c: cleanup, use G_DEFINE_DYNAMIC_TYPE().



Modified:
   trunk/ChangeLog
   trunk/operations/core/shift.c

Modified: trunk/operations/core/shift.c
==============================================================================
--- trunk/operations/core/shift.c	(original)
+++ trunk/operations/core/shift.c	Mon Jan  7 23:25:50 2008
@@ -16,33 +16,32 @@
  * Copyright 2006 Ãyvind KolÃs
  */
 
-
 #ifndef __GEGL_OPERATION_SHIFT_H__
 #define __GEGL_OPERATION_SHIFT_H__
 
-#include <glib-object.h>
-#include "gegl-types.h"
 #include "operation/gegl-operation.h"
 #include "gegl-module.h"
 
 G_BEGIN_DECLS
 
 #define GEGL_TYPE_OPERATION_SHIFT            (gegl_operation_shift_get_type ())
-#define GEGL_OPERATION_SHIFT(obj)            ((GeglOperationShift*)(obj))
+#define GEGL_OPERATION_SHIFT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION_SHIFT, GeglOperationShift))
 #define GEGL_OPERATION_SHIFT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GEGL_TYPE_OPERATION_SHIFT, GeglOperationShiftClass))
 #define GEGL_IS_OPERATION_SHIFT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_OPERATION_SHIFT))
 #define GEGL_IS_OPERATION_SHIFT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GEGL_TYPE_OPERATION_SHIFT))
 #define GEGL_OPERATION_SHIFT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GEGL_TYPE_OPERATION_SHIFT, GeglOperationShiftClass))
 
-typedef struct _GeglOperationShift  GeglOperationShift;
+typedef struct _GeglOperationShift      GeglOperationShift;
+typedef struct _GeglOperationShiftClass GeglOperationShiftClass;
+
 struct _GeglOperationShift
 {
   GeglOperation parent_instance;
+
   gfloat        x;
   gfloat        y;
 };
 
-typedef struct _GeglOperationShiftClass GeglOperationShiftClass;
 struct _GeglOperationShiftClass
 {
   GeglOperationClass parent_class;
@@ -78,53 +77,42 @@
   PROP_Y
 };
 
-static void
-gegl_operation_shift_class_init (GeglOperationShiftClass * klass);
-static void     get_property            (GObject       *gobject,
-                                         guint          prop_id,
-                                         GValue        *value,
-                                         GParamSpec    *pspec);
-
-static void     set_property            (GObject       *gobject,
-                                         guint          prop_id,
-                                         const GValue  *value,
-                                         GParamSpec    *pspec);
-
-static gboolean process                 (GeglOperation       *operation,
-                                         GeglNodeContext     *context,
-                                         const gchar         *output_prop,
-                                         const GeglRectangle *result);
-
-static void     attach                  (GeglOperation *operation);
-static GeglNode *detect                 (GeglOperation *operation,
-                                         gint           x,
-                                         gint           y);
-
-static GeglRectangle get_defined_region    (GeglOperation       *self);
-static GeglRectangle compute_input_request (GeglOperation       *operation,
-                                            const gchar         *input_pad,
-                                            const GeglRectangle *roi);
-static GeglRectangle
-compute_affected_region (GeglOperation       *operation,
-                         const gchar         *input_pad,
-                         const GeglRectangle *input_region);
-
-
-#if 0
-G_DEFINE_TYPE (GeglOperationShift, gegl_operation_shift, GEGL_TYPE_OPERATION)
-#endif
-
-
+static void            get_property            (GObject             *object,
+                                                guint                prop_id,
+                                                GValue              *value,
+                                                GParamSpec          *pspec);
+static void            set_property            (GObject             *object,
+                                                guint                prop_id,
+                                                const GValue        *value,
+                                                GParamSpec          *pspec);
+
+static gboolean        process                 (GeglOperation       *operation,
+                                                GeglNodeContext     *context,
+                                                const gchar         *output_prop,
+                                                const GeglRectangle *result);
+static void            attach                  (GeglOperation       *operation);
+static GeglNode      * detect                  (GeglOperation       *operation,
+                                                gint                 x,
+                                                gint                 y);
+static GeglRectangle   get_defined_region      (GeglOperation       *self);
+static GeglRectangle   compute_input_request   (GeglOperation       *operation,
+                                                const gchar         *input_pad,
+                                                const GeglRectangle *roi);
+static GeglRectangle   compute_affected_region (GeglOperation       *operation,
+                                                const gchar         *input_pad,
+                                                const GeglRectangle *input_region);
 
+G_DEFINE_DYNAMIC_TYPE (GeglOperationShift, gegl_operation_shift,
+                       GEGL_TYPE_OPERATION)
 
 static void
-gegl_operation_shift_class_init (GeglOperationShiftClass * klass)
+gegl_operation_shift_class_init (GeglOperationShiftClass *klass)
 {
   GObjectClass       *object_class    = G_OBJECT_CLASS (klass);
   GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
 
-  object_class->set_property = set_property;
-  object_class->get_property = get_property;
+  object_class->set_property             = set_property;
+  object_class->get_property             = get_property;
 
   operation_class->no_cache              = TRUE;
   operation_class->process               = process;
@@ -152,8 +140,7 @@
                                                         G_PARAM_READWRITE |
                                                         GEGL_PAD_INPUT));
 
-  g_object_class_install_property (object_class,
-                                   PROP_X,
+  g_object_class_install_property (object_class, PROP_X,
                                    g_param_spec_float ("x",
                                                        "X",
                                                        "X",
@@ -162,8 +149,7 @@
                                                        G_PARAM_READWRITE |
                                                        G_PARAM_CONSTRUCT));
 
-  g_object_class_install_property (object_class,
-                                   PROP_Y,
+  g_object_class_install_property (object_class, PROP_Y,
                                    g_param_spec_float ("y",
                                                        "Y",
                                                        "Y",
@@ -176,6 +162,11 @@
 }
 
 static void
+gegl_operation_shift_class_finalize (GeglOperationShiftClass *klass)
+{
+}
+
+static void
 gegl_operation_shift_init (GeglOperationShift *self)
 {
 }
@@ -222,17 +213,17 @@
 
   switch (property_id)
     {
-      case PROP_X:
-        g_value_set_float (value, self->x);
-        break;
-
-      case PROP_Y:
-        g_value_set_float (value, self->y);
-        break;
-
-      default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-        break;
+    case PROP_X:
+      g_value_set_float (value, self->x);
+      break;
+
+    case PROP_Y:
+      g_value_set_float (value, self->y);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
     }
 }
 
@@ -246,17 +237,17 @@
 
   switch (property_id)
     {
-      case PROP_X:
-        self->x = g_value_get_float (value);
-        break;
-
-      case PROP_Y:
-        self->y = g_value_get_float (value);
-        break;
-
-      default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-        break;
+    case PROP_X:
+      self->x = g_value_get_float (value);
+      break;
+
+    case PROP_Y:
+      self->y = g_value_get_float (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
     }
 }
 
@@ -267,11 +258,9 @@
          const gchar     *output_prop,
          const GeglRectangle *result)
 {
-  GeglOperationShift      *shift;
-  GeglBuffer              *input;
-  gboolean                 success = FALSE;
-
-  shift = GEGL_OPERATION_SHIFT (operation);
+  GeglOperationShift *shift   = GEGL_OPERATION_SHIFT (operation);
+  GeglBuffer         *input;
+  gboolean            success = FALSE;
 
   shift->x = floor (shift->x);
   shift->y = floor (shift->y);
@@ -287,12 +276,14 @@
   if (input != NULL)
     {
       GeglBuffer *output;
+
       output = g_object_new (GEGL_TYPE_BUFFER,
-                         "provider",    input,
-                         "shift-x",     (int)-shift->x,
-                         "shift-y",     (int)-shift->y,
-                         "abyss-width", -1,  /* turn of abyss (relying on abyss
-                                                of source) */
+                             "provider",    input,
+                             "shift-x",     (int)-shift->x,
+                             "shift-y",     (int)-shift->y,
+                             "abyss-width", -1,  /* turn of abyss
+                                                    (relying on abyss
+                                                    of source) */
                          NULL);
 
       gegl_node_context_set_object (context, "output", G_OBJECT (output));
@@ -307,15 +298,17 @@
                    gegl_node_get_debug_name (operation->node),
                    input==NULL?"input==NULL":"");
     }
+
   return success;
 }
 
 static GeglRectangle
 get_defined_region (GeglOperation *operation)
 {
-  GeglRectangle       result = {0,0,0,0};
-  GeglOperationShift *self = GEGL_OPERATION_SHIFT (operation);
+  GeglOperationShift *self    = GEGL_OPERATION_SHIFT (operation);
+  GeglRectangle       result  = { 0, 0, 0, 0 };
   GeglRectangle      *in_rect = gegl_operation_source_get_defined_region (operation, "input");
+
   if (!in_rect)
     return result;
 
@@ -332,8 +325,8 @@
                          const gchar         *input_pad,
                          const GeglRectangle *input_region)
 {
-  GeglOperationShift *self = GEGL_OPERATION_SHIFT (operation);
-  GeglRectangle       result   = *input_region;
+  GeglOperationShift *self   = GEGL_OPERATION_SHIFT (operation);
+  GeglRectangle       result = *input_region;
 
   result.x += floor (self->x);
   result.y += floor (self->y);
@@ -346,8 +339,8 @@
                        const gchar         *input_pad,
                        const GeglRectangle *roi)
 {
-  GeglOperationShift *self = GEGL_OPERATION_SHIFT (operation);
-  GeglRectangle result = *roi;
+  GeglOperationShift *self   = GEGL_OPERATION_SHIFT (operation);
+  GeglRectangle       result = *roi;
 
   result.x -= floor (self->x);
   result.y -= floor (self->y);
@@ -355,36 +348,8 @@
   return result;
 }
 
-
-
-GType shift_get_type (GTypeModule *module);
-G_MODULE_EXPORT const GeglModuleInfo * gegl_module_query (GTypeModule *module);
-G_MODULE_EXPORT gboolean gegl_module_register (GTypeModule *module);
-
-GType
-shift_get_type (GTypeModule *module)
+static const GeglModuleInfo modinfo =
 {
-  static GType g_define_type_id = 0;
-
-  if (G_UNLIKELY (g_define_type_id == 0))
-    {
-      static const GTypeInfo g_define_type_info = {
-        sizeof (GeglOperationShiftClass), (GBaseInitFunc) ((void *) 0),
-        (GBaseFinalizeFunc) ((void *) 0),
-        (GClassInitFunc) gegl_operation_shift_class_init,
-        (GClassFinalizeFunc) ((void *) 0), ((void *) 0),
-        sizeof (GeglOperationShift), 0,
-        (GInstanceInitFunc) gegl_operation_shift_init, ((void *) 0)
-      };
-      g_define_type_id = gegl_module_register_type (module, GEGL_TYPE_OPERATION,
-                                                    "GeglOpPlugIn-shift",
-                                                    &g_define_type_info,
-                                                    (GTypeFlags) 0);
-    }
-  return g_define_type_id;
-}
-
-static const GeglModuleInfo modinfo = {
   GEGL_MODULE_ABI_VERSION, "shift", "", ""
 };
 
@@ -397,6 +362,7 @@
 G_MODULE_EXPORT gboolean
 gegl_module_register (GTypeModule *module)
 {
-  shift_get_type (module);
+  gegl_operation_shift_register_type (module);
+
   return TRUE;
 }



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