From: jstebbins Date: Thu, 26 Mar 2015 22:56:25 +0000 (+0000) Subject: LinGui: move data resources into GResource X-Git-Tag: 1.0.0~1325 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=213c51f63a58d76f07c1a5e518877d32365b5d06;p=handbrake LinGui: move data resources into GResource git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7022 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- 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 @@ + + + + internal_defaults.json + standard_presets.json + widget.deps + widget_reverse.deps + + 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 @@ - - - -