diff options
Diffstat (limited to 'gtk/src')
-rw-r--r-- | gtk/src/Makefile.am | 12 | ||||
-rw-r--r-- | gtk/src/data_res.gresource.xml | 9 | ||||
-rw-r--r-- | gtk/src/resources.c | 37 | ||||
-rw-r--r-- | gtk/src/resources.list | 4 |
4 files changed, 57 insertions, 5 deletions
diff --git a/gtk/src/Makefile.am b/gtk/src/Makefile.am index 3bbd57bb8..52ab1499a 100644 --- a/gtk/src/Makefile.am +++ b/gtk/src/Makefile.am @@ -53,6 +53,8 @@ ghb_SOURCES = \ presets.c \ presets.h \ preview.c \ + data_res.c \ + data_res.h \ icon_res.c \ icon_res.h \ icons.c \ @@ -88,7 +90,15 @@ ghb_LDADD = $(HB_LIBS) $(GHB_LIBS) ghb_DEPENDENCIES = $(HB_DIR)/libhb/libhandbrake.a -resources.o: resource_data.h +data_res.c : data_res.gresource.xml internal_defaults.json standard_presets.json + cp $(srcdir)/internal_defaults.json $(srcdir)/standard_presets.json . + glib-compile-resources --generate --target=$@ --c-name ghb_data --manual-register $< + +data_res.h : data_res.gresource.xml internal_defaults.json standard_presets.json + cp $(srcdir)/internal_defaults.json $(srcdir)/standard_presets.json . + glib-compile-resources --generate --target=$@ --c-name ghb_data --manual-register $< + +resources.o: resource_data.h data_res.h resource_data.h: resources.json python2 $(srcdir)/quotestring.py resources.json resource_data.h diff --git a/gtk/src/data_res.gresource.xml b/gtk/src/data_res.gresource.xml new file mode 100644 index 000000000..5570e4bea --- /dev/null +++ b/gtk/src/data_res.gresource.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/handbrake/data"> + <file>internal_defaults.json</file> + <file>standard_presets.json</file> + <file>widget.deps</file> + <file>widget_reverse.deps</file> + </gresource> +</gresources> diff --git a/gtk/src/resources.c b/gtk/src/resources.c index 420795dc7..afc578c32 100644 --- a/gtk/src/resources.c +++ b/gtk/src/resources.c @@ -19,6 +19,7 @@ #include "settings.h" #include "resources.h" #include "values.h" +#include "data_res.h" static const gchar resource_str[] = #include "resource_data.h" @@ -29,7 +30,43 @@ static GhbValue *resources; void ghb_resource_init() { + GhbValue *val; + gsize data_size; + GBytes *gbytes; + gconstpointer data; + resources = ghb_json_parse(resource_str, sizeof(resource_str)-1); + + ghb_data_register_resource(); + GResource *data_res = ghb_data_get_resource(); + + gbytes = g_resource_lookup_data(data_res, + "/org/handbrake/data/internal_defaults.json", 0, NULL); + data = g_bytes_get_data(gbytes, &data_size); + val = ghb_json_parse(data, data_size); + g_bytes_unref(gbytes); + ghb_dict_insert(resources, "internal-defaults", val); + + gbytes = g_resource_lookup_data(data_res, + "/org/handbrake/data/standard_presets.json", 0, NULL); + data = g_bytes_get_data(gbytes, &data_size); + val = ghb_json_parse(data, data_size); + g_bytes_unref(gbytes); + ghb_dict_insert(resources, "standard-presets", val); + + gbytes = g_resource_lookup_data(data_res, + "/org/handbrake/data/widget.deps", 0, NULL); + data = g_bytes_get_data(gbytes, &data_size); + val = ghb_json_parse(data, data_size); + g_bytes_unref(gbytes); + ghb_dict_insert(resources, "widget-deps", val); + + gbytes = g_resource_lookup_data(data_res, + "/org/handbrake/data/widget_reverse.deps", 0, NULL); + data = g_bytes_get_data(gbytes, &data_size); + val = ghb_json_parse(data, data_size); + g_bytes_unref(gbytes); + ghb_dict_insert(resources, "widget-reverse-deps", val); } GhbValue* diff --git a/gtk/src/resources.list b/gtk/src/resources.list index a99d280b8..a0812c8a6 100644 --- a/gtk/src/resources.list +++ b/gtk/src/resources.list @@ -1,8 +1,4 @@ <resources> - <json name="internal-defaults" file="internal_defaults.json" /> - <json name="standard-presets" file="standard_presets.json" /> - <json name="widget-deps" file="widget.deps" /> - <json name="widget-reverse-deps" file="widget_reverse.deps" /> <string version="3.10" name="ghb-ui" file="ghb.ui" /> <string version="3.12" name="ghb-ui" file="ghb-3.12.ui" /> <string version="3.14" name="ghb-ui" file="ghb-3.14.ui" /> |