[gegl/soc-2011-warp] gegl-chant: replace gegl_chant_sampler with a generic gegl_chant_enum and update ops



commit 7839d07596637ea105cc0efac3ecf919a8c68a8f
Author: Michael Murà <batolettre gmail com>
Date:   Sat Jul 9 11:54:54 2011 +0200

    gegl-chant: replace gegl_chant_sampler with a generic gegl_chant_enum and update ops

 gegl/gegl-chant.h                |   56 +++++++++++++++++++-------------------
 operations/common/map-absolute.c |    4 +-
 operations/common/map-relative.c |    4 +-
 3 files changed, 32 insertions(+), 32 deletions(-)
---
diff --git a/gegl/gegl-chant.h b/gegl/gegl-chant.h
index ff4706c..699f7c1 100644
--- a/gegl/gegl-chant.h
+++ b/gegl/gegl-chant.h
@@ -345,6 +345,7 @@ struct _GeglChantO
 #define gegl_chant_double(name, nick, min, max, def, blurb)  gdouble            name;
 #define gegl_chant_boolean(name, nick, def, blurb)           gboolean           name;
 #define gegl_chant_string(name, nick, def, blurb)            gchar             *name;
+#define gegl_chant_enum(name, nick, enum, type, def, blurb)  enum               name;
 #define gegl_chant_file_path(name, nick, def, blurb)         gchar             *name;
 #define gegl_chant_multiline(name, nick, def, blurb)         gchar             *name;
 #define gegl_chant_object(name,nick,  blurb)                 GObject           *name;
@@ -353,7 +354,6 @@ struct _GeglChantO
 #define gegl_chant_curve(name, nick, blurb)                  GeglCurve         *name;
 #define gegl_chant_path(name, nick, blurb)                   GeglPath          *name;\
                                                           guint path_changed_handler;
-#define gegl_chant_sampler(name, nick, def, blurb)           GeglSamplerType    name;
 
 #include GEGL_CHANT_C_FILE
 
@@ -361,6 +361,7 @@ struct _GeglChantO
 #undef gegl_chant_double
 #undef gegl_chant_boolean
 #undef gegl_chant_string
+#undef gegl_chant_enum
 #undef gegl_chant_file_path
 #undef gegl_chant_multiline
 #undef gegl_chant_object
@@ -368,7 +369,6 @@ struct _GeglChantO
 #undef gegl_chant_color
 #undef gegl_chant_curve
 #undef gegl_chant_path
-#undef gegl_chant_sampler
 };
 
 #define GEGL_CHANT_OPERATION(obj) ((Operation*)(obj))
@@ -380,6 +380,7 @@ enum
 #define gegl_chant_double(name, nick, min, max, def, blurb)  PROP_##name,
 #define gegl_chant_boolean(name, nick, def, blurb)           PROP_##name,
 #define gegl_chant_string(name, nick, def, blurb)            PROP_##name,
+#define gegl_chant_enum(name, nick, enum, type, def, blurb)  PROP_##name,
 #define gegl_chant_file_path(name, nick, def, blurb)         PROP_##name,
 #define gegl_chant_multiline(name, nick, def, blurb)         PROP_##name,
 #define gegl_chant_object(name, nick, blurb)                 PROP_##name,
@@ -387,7 +388,6 @@ enum
 #define gegl_chant_color(name, nick, def, blurb)             PROP_##name,
 #define gegl_chant_curve(name, nick, blurb)                  PROP_##name,
 #define gegl_chant_path(name, nick, blurb)                   PROP_##name,
-#define gegl_chant_sampler(name, nick, def, blurb)           PROP_##name,
 
 #include GEGL_CHANT_C_FILE
 
@@ -395,6 +395,7 @@ enum
 #undef gegl_chant_double
 #undef gegl_chant_boolean
 #undef gegl_chant_string
+#undef gegl_chant_enum
 #undef gegl_chant_file_path
 #undef gegl_chant_multiline
 #undef gegl_chant_object
@@ -402,7 +403,6 @@ enum
 #undef gegl_chant_color
 #undef gegl_chant_curve
 #undef gegl_chant_path
-#undef gegl_chant_sampler
   PROP_LAST
 };
 
@@ -434,6 +434,10 @@ get_property (GObject      *gobject,
     case PROP_##name:                                         \
       g_value_set_string (value, properties->name);           \
       break;
+#define gegl_chant_enum(name, nick, enum, type, def, blurb)   \
+    case PROP_##name:                                         \
+      g_value_set_enum (value, properties->name);             \
+      break;
 #define gegl_chant_file_path(name, nick, def, blurb)          \
     case PROP_##name:                                         \
       g_value_set_string (value, properties->name);           \
@@ -463,10 +467,6 @@ get_property (GObject      *gobject,
       if (!properties->name)properties->name = gegl_path_new (); /* this feels ugly */\
       g_value_set_object (value, properties->name);           \
       break;/*XXX*/
-#define gegl_chant_sampler(name, nick, def, blurb)            \
-    case PROP_##name:                                         \
-      g_value_set_enum (value, properties->name);             \
-      break;
 
 #include GEGL_CHANT_C_FILE
 
@@ -474,6 +474,7 @@ get_property (GObject      *gobject,
 #undef gegl_chant_double
 #undef gegl_chant_boolean
 #undef gegl_chant_string
+#undef gegl_chant_enum
 #undef gegl_chant_file_path
 #undef gegl_chant_multiline
 #undef gegl_chant_object
@@ -481,7 +482,6 @@ get_property (GObject      *gobject,
 #undef gegl_chant_color
 #undef gegl_chant_curve
 #undef gegl_chant_path
-#undef gegl_chant_sampler
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
       break;
@@ -519,6 +519,10 @@ set_property (GObject      *gobject,
         g_free (properties->name);                                    \
       properties->name = g_strdup (g_value_get_string (value));       \
       break;
+#define gegl_chant_enum(name, nick, enum, type, def, blurb)           \
+    case PROP_##name:                                                 \
+      properties->name = g_value_get_enum (value);                    \
+      break;
 #define gegl_chant_file_path(name, nick, def, blurb)                  \
     case PROP_##name:                                                 \
       if (properties->name)                                           \
@@ -569,10 +573,6 @@ set_property (GObject      *gobject,
           G_CALLBACK(path_changed), gobject);     \
          }\
       break; /*XXX*/
-#define gegl_chant_sampler(name, nick, def, blurb)                    \
-    case PROP_##name:                                                 \
-      properties->name = g_value_get_enum (value);                    \
-      break;
 
 #include GEGL_CHANT_C_FILE
 
@@ -580,6 +580,7 @@ set_property (GObject      *gobject,
 #undef gegl_chant_double
 #undef gegl_chant_boolean
 #undef gegl_chant_string
+#undef gegl_chant_enum
 #undef gegl_chant_file_path
 #undef gegl_chant_multiline
 #undef gegl_chant_object
@@ -587,7 +588,6 @@ set_property (GObject      *gobject,
 #undef gegl_chant_color
 #undef gegl_chant_curve
 #undef gegl_chant_path
-#undef gegl_chant_sampler
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
@@ -610,6 +610,7 @@ static void gegl_chant_destroy_notify (gpointer data)
       g_free (properties->name);                    \
       properties->name = NULL;                      \
     }
+#define gegl_chant_enum(name, nick, enum, type, def, blurb)
 #define gegl_chant_file_path(name, nick, def, blurb) \
   if (properties->name)                             \
     {                                               \
@@ -647,7 +648,6 @@ static void gegl_chant_destroy_notify (gpointer data)
       g_object_unref (properties->name);            \
       properties->name = NULL;                      \
     }
-#define gegl_chant_sampler(name, nick, def, blurb)
 
 #include GEGL_CHANT_C_FILE
 
@@ -655,6 +655,7 @@ static void gegl_chant_destroy_notify (gpointer data)
 #undef gegl_chant_double
 #undef gegl_chant_boolean
 #undef gegl_chant_string
+#undef gegl_chant_enum
 #undef gegl_chant_file_path
 #undef gegl_chant_multiline
 #undef gegl_chant_object
@@ -662,7 +663,6 @@ static void gegl_chant_destroy_notify (gpointer data)
 #undef gegl_chant_color
 #undef gegl_chant_curve
 #undef gegl_chant_path
-#undef gegl_chant_sampler
 
   g_slice_free (GeglChantO, properties);
 }
@@ -685,6 +685,7 @@ gegl_chant_constructor (GType                  type,
 #define gegl_chant_double(name, nick, min, max, def, blurb)
 #define gegl_chant_boolean(name, nick, def, blurb)
 #define gegl_chant_string(name, nick, def, blurb)
+#define gegl_chant_enum(name, nick, enum, type, def, blurb)
 #define gegl_chant_file_path(name, nick, def, blurb)
 #define gegl_chant_multiline(name, nick, def, blurb)
 #define gegl_chant_object(name, nick, blurb)
@@ -694,7 +695,6 @@ gegl_chant_constructor (GType                  type,
     {properties->name = gegl_color_new(def?def:"black");}
 #define gegl_chant_path(name, nick, blurb)
 #define gegl_chant_curve(name, nick, blurb)
-#define gegl_chant_sampler(name, nick, def, blurb)
 
 #include GEGL_CHANT_C_FILE
 
@@ -702,6 +702,7 @@ gegl_chant_constructor (GType                  type,
 #undef gegl_chant_double
 #undef gegl_chant_boolean
 #undef gegl_chant_string
+#undef gegl_chant_enum
 #undef gegl_chant_file_path
 #undef gegl_chant_multiline
 #undef gegl_chant_object
@@ -709,7 +710,6 @@ gegl_chant_constructor (GType                  type,
 #undef gegl_chant_color
 #undef gegl_chant_curve
 #undef gegl_chant_path
-#undef gegl_chant_sampler
 
   g_object_set_data_full (obj, "chant-data", obj, gegl_chant_destroy_notify);
   properties ++; /* evil hack to silence gcc */
@@ -757,6 +757,15 @@ gegl_chant_class_intern_init (gpointer klass)
                                                         G_PARAM_READWRITE |  \
                                                         G_PARAM_CONSTRUCT |  \
                                                         GEGL_PARAM_PAD_INPUT)));
+#define gegl_chant_enum(name, nick, enum, type, def, blurb)                  \
+  g_object_class_install_property (object_class, PROP_##name,                \
+                                   g_param_spec_enum (#name, nick, blurb,    \
+                                                      type,                  \
+                                                      def,                   \
+                                                      (GParamFlags) (        \
+                                                      G_PARAM_READWRITE |    \
+                                                      G_PARAM_CONSTRUCT |    \
+                                                      GEGL_PARAM_PAD_INPUT)));
 #define gegl_chant_file_path(name, nick, def, blurb)                              \
   g_object_class_install_property (object_class, PROP_##name,                \
                                    gegl_param_spec_file_path (#name, nick, blurb, \
@@ -813,15 +822,6 @@ gegl_chant_class_intern_init (gpointer klass)
                                                           G_PARAM_READWRITE |\
                                                           G_PARAM_CONSTRUCT |\
                                                           GEGL_PARAM_PAD_INPUT)));
-#define gegl_chant_sampler(name, nick, def, blurb)                           \
-  g_object_class_install_property (object_class, PROP_##name,                \
-                                   g_param_spec_enum (#name, nick, blurb,    \
-                                                      GEGL_TYPE_SAMPLER_TYPE,\
-                                                      def,                   \
-                                                      (GParamFlags) (        \
-                                                      G_PARAM_READWRITE |    \
-                                                      G_PARAM_CONSTRUCT |    \
-                                                      GEGL_PARAM_PAD_INPUT)));
 
 #include GEGL_CHANT_C_FILE
 
@@ -829,6 +829,7 @@ gegl_chant_class_intern_init (gpointer klass)
 #undef gegl_chant_double
 #undef gegl_chant_boolean
 #undef gegl_chant_string
+#undef gegl_chant_enum
 #undef gegl_chant_file_path
 #undef gegl_chant_multiline
 #undef gegl_chant_object
@@ -836,7 +837,6 @@ gegl_chant_class_intern_init (gpointer klass)
 #undef gegl_chant_color
 #undef gegl_chant_curve
 #undef gegl_chant_path
-#undef gegl_chant_sampler
 }
 
 
diff --git a/operations/common/map-absolute.c b/operations/common/map-absolute.c
index 1cc4be9..c0e444d 100644
--- a/operations/common/map-absolute.c
+++ b/operations/common/map-absolute.c
@@ -19,8 +19,8 @@
 
 #ifdef GEGL_CHANT_PROPERTIES
 
-gegl_chant_sampler (sampler_type, _("Interpolation"),
-                    GEGL_INTERPOLATION_CUBIC, _("Sampler used internaly"))
+gegl_chant_enum (sampler_type, _("Sampler"), GeglSamplerType, GEGL_TYPE_SAMPLER_TYPE,
+                 GEGL_INTERPOLATION_CUBIC, _("Sampler used internaly"))
 
 #else
 
diff --git a/operations/common/map-relative.c b/operations/common/map-relative.c
index b65841e..c9f1b1e 100644
--- a/operations/common/map-relative.c
+++ b/operations/common/map-relative.c
@@ -23,8 +23,8 @@
 gegl_chant_double (scaling, _("Scaling"), 0.0, 5000.0, 1.0,
        _("scaling factor of displacement, indicates how large spatial"
          " displacement a relative mapping value of 1.0 corresponds to."))
-gegl_chant_sampler (sampler_type, _("Interpolation"),
-                    GEGL_INTERPOLATION_CUBIC, _("Sampler used internaly"))
+gegl_chant_enum (sampler_type, _("Sampler"), GeglSamplerType, GEGL_TYPE_SAMPLER_TYPE,
+                 GEGL_INTERPOLATION_CUBIC, _("Sampler used internaly"))
 
 #else
 



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