[gegl-qt] Build: Fix build with GEGL 0.2+



commit 93b6eaafaa0c3ecc5d7bab79bb47db26eb880618
Author: Jon Nordby <jononor gmail com>
Date:   Sun May 13 18:30:39 2012 -0700

    Build: Fix build with GEGL 0.2+
    
    Newly added operation listing examples was using old API.
    gegl_list_properties was renamed to gegl_operation_list_properties
    Categories and description is now accessed through gegl_operation_get_key
    
    Also store categories and description on the Operation object.

 examples/common/operations.cpp |   30 +++++++++++++++++++++++++++---
 examples/common/operations.h   |    7 ++++++-
 2 files changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/examples/common/operations.cpp b/examples/common/operations.cpp
index bccd8cd..335d7e7 100644
--- a/examples/common/operations.cpp
+++ b/examples/common/operations.cpp
@@ -76,7 +76,11 @@ getPropertyMap(const QString &operationName)
     guint prop_no;
     guint n_properties;
 
+#if GEGL_MINOR_VERSION >= 2
+    properties = gegl_operation_list_properties(operationName.toUtf8(), &n_properties);
+#else
     properties = gegl_list_properties(operationName.toUtf8(), &n_properties);
+#endif
 
     for (prop_no = 0; prop_no < n_properties; prop_no++)
     {
@@ -134,10 +138,17 @@ Operations::all()
 
     foreach (GeglOperationClass *op_class, *operations) {
         QString name = QString::fromUtf8(op_class->name);
-        QStringList categories = QString::fromUtf8(op_class->categories).split(":");
+
+#if GEGL_MINOR_VERSION >= 2
+        QString categories = QString::fromUtf8(gegl_operation_get_key(op_class->name, "categories"));
+        QString description = QString::fromUtf8(gegl_operation_get_key(op_class->name, "description"));
+#else
+        QString categories = QString::fromUtf8(op_class->categories);
         QString description = QString::fromUtf8(op_class->description);
+#endif
 
-        Operation *operation = new Operation(name, getPropertyMap(name));
+        QStringList categoryList = categories.split(":");
+        Operation *operation = new Operation(name, description, categoryList, getPropertyMap(name));
         operationMap.insert(name, operation);
     }
 
@@ -184,9 +195,12 @@ QVariant OperationProperty::defaultValue()
 
 
 /* Operation */
-Operation::Operation(QString name, QMap<QString, OperationProperty *> properties)
+Operation::Operation(QString name, QString description,
+                     QStringList categoryList, QMap<QString, OperationProperty *> properties)
     : QObject()
     , mName(name)
+    , mCategories(categoryList)
+    , mDescription(description)
     , mProperties(properties)
 {
 }
@@ -196,6 +210,16 @@ QString Operation::name()
     return mName;
 }
 
+QString Operation::description()
+{
+    return mDescription;
+}
+
+QStringList Operation::categories()
+{
+    return mCategories;
+}
+
 QObjectList Operation::properties()
 {
     QObjectList list;
diff --git a/examples/common/operations.h b/examples/common/operations.h
index 2cd9900..14a4952 100644
--- a/examples/common/operations.h
+++ b/examples/common/operations.h
@@ -47,13 +47,18 @@ class Operation : public QObject
 {
     Q_OBJECT
 public:
-    explicit Operation(QString name, QMap<QString, OperationProperty *> properties);
+    explicit Operation(QString name, QString description, QStringList categoryList,
+                       QMap<QString, OperationProperty *> properties);
 
     QString name();
     QObjectList properties();
+    QString description();
+    QStringList categories();
 
     Q_PROPERTY (QString name READ name CONSTANT)
     Q_PROPERTY (QObjectList properties READ properties CONSTANT)
+    Q_PROPERTY (QString description READ description CONSTANT)
+    Q_PROPERTY (QStringList categories READ categories CONSTANT)
 
 private:
     QString mName;



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