summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Nordby <jononor@gmail.com>2015-01-20 00:49:08 +0100
committerJon Nordby <jononor@gmail.com>2015-01-20 02:41:25 +0100
commit4a3f0f2b2b2e90f302a0feba189b9172bb545e46 (patch)
treedec5837c5678c36826e6f80ea9644e5ef04d4364
parent3893559f25fde7b94211b12f59e37d6de830b4fa (diff)
meta-json: Follow normal module paths for loading
-rw-r--r--operations/core/json.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/operations/core/json.c b/operations/core/json.c
index 593af7d1..9bb9be7c 100644
--- a/operations/core/json.c
+++ b/operations/core/json.c
@@ -38,6 +38,10 @@ dropshadow a good initial testcase?
#include <json-glib/json-glib.h>
#include <gegl-plugin.h>
+// For module paths
+#include <gegl-init-private.h>
+#include <gegldatafiles.h>
+
/* JsonOp: Meta-operation base class for ops defined by .json file */
#include <operation/gegl-operation-meta-json.h>
typedef struct _JsonOp
@@ -520,13 +524,30 @@ json_op_register_type_for_file (GTypeModule *type_module, const gchar *filepath)
}
/* JSON operation enumeration */
-#define JSON_OP_DIR "/home/jon/contrib/code/imgflo-server/runtime/dependencies/gegl/operations/json"
+static void
+load_file(const GeglDatafileData *file_data, gpointer user_data)
+{
+ GTypeModule *module = (GTypeModule *)user_data;
+ if (!g_str_has_suffix(file_data->filename, ".json")) {
+ return;
+ }
+ g_message("%s: %s", __PRETTY_FUNCTION__, file_data->filename);
+
+ json_op_register_type_for_file(module, file_data->filename);
+}
+
+static void
+load_path(gchar *path, gpointer user_data)
+{
+ gegl_datafiles_read_directories (path, G_FILE_TEST_EXISTS, load_file, user_data);
+}
+
static void
json_register_operations(GTypeModule *module)
{
- // FIXME: unhardcode, follow GEGL_PATH properly
-// json_op_register_type_for_file (module, JSON_OP_DIR "/dropshadow2.json");
- json_op_register_type_for_file (module, JSON_OP_DIR "/grey2.json");
+ GSList *paths = gegl_get_default_module_paths();
+ g_slist_foreach(paths, (GFunc)load_path, module);
+ g_slist_free_full(paths, g_free);
}