diff options
-rw-r--r-- | gtk/configure.ac | 5 | ||||
-rw-r--r-- | gtk/src/Makefile.am | 40 | ||||
-rw-r--r-- | gtk/src/create_resources.c | 614 | ||||
-rw-r--r-- | gtk/src/create_resources.py | 163 | ||||
-rw-r--r-- | gtk/src/main.c | 11 | ||||
-rw-r--r-- | gtk/src/quotestring.c | 78 | ||||
-rw-r--r-- | gtk/src/quotestring.py | 62 | ||||
-rw-r--r-- | gtk/src/resources.c | 6 | ||||
-rw-r--r-- | gtk/src/resources.list | 5 | ||||
-rw-r--r-- | gtk/src/ui_res.gresource.xml | 6 |
10 files changed, 42 insertions, 948 deletions
diff --git a/gtk/configure.ac b/gtk/configure.ac index 88fdf65df..33b76b38f 100644 --- a/gtk/configure.ac +++ b/gtk/configure.ac @@ -142,6 +142,11 @@ else CFLAGS="$CFLAGS -D_NO_UPDATE_CHECK" fi +PKG_CHECK_MODULES([GHB_GTK_3_14], [gtk+-3.0 >= 3.14], [HAVE_GTK_314=1], [HAVE_GTK_314=0]) +PKG_CHECK_MODULES([GHB_GTK_3_12], [gtk+-3.0 >= 3.12], [HAVE_GTK_312=1], [HAVE_GTK_312=0]) +AM_CONDITIONAL([GHB_GTK_3_14], [test "$HAVE_GTK_314" -eq 1]) +AM_CONDITIONAL([GHB_GTK_3_12], [test "$HAVE_GTK_312" -eq 1]) + AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"]) PKG_CHECK_MODULES(GHB, [$GHB_PACKAGES]) diff --git a/gtk/src/Makefile.am b/gtk/src/Makefile.am index 7f073e393..dc9f48941 100644 --- a/gtk/src/Makefile.am +++ b/gtk/src/Makefile.am @@ -55,6 +55,8 @@ ghb_SOURCES = \ preview.c \ data_res.c \ data_res.h \ + ui_res.c \ + ui_res.h \ icon_res.c \ icon_res.h \ icons.c \ @@ -106,30 +108,32 @@ data_res.h : data_res.gresource.xml $(srcdir)/internal_defaults.json $(srcdir)/s 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 +if GHB_GTK_3_14 +UI=ghb-3.14.ui +else +if GHB_GTK_3_12 +UI=ghb-3.12.ui +else +UI=ghb.ui +endif +endif -widget_reverse.deps: makedeps.py -widget.deps: makedeps.py - python2 $(srcdir)/makedeps.py +ui_res.c : ui_res.gresource.xml ui_res.h $(srcdir)/$(UI) + glib-compile-resources --generate --target=$@ --c-name ghb_ui --manual-register $< -resources.json: create_resources resources.list ghb.ui ghb-3.14.ui - ./create_resources -I$(srcdir) $(srcdir)/resources.list resources.json +ui_res.h : ui_res.gresource.xml $(srcdir)/$(UI) + cp $(srcdir)/$(UI) ghb.ui + glib-compile-resources --generate --target=$@ --c-name ghb_ui --manual-register $< -CREATE_RES.c = \ - create_resources.c \ - plist.c \ - values.c +ui_res.o: ui_res.h ui_res.c -CREATE_RES.c.o = $(patsubst %.c,%-native.o,$(CREATE_RES.c)) +main.o : ui_res.o -create_resources: $(CREATE_RES.c.o) - $(CC_FOR_BUILD) -g -o $@ $^ $(GHB_TOOLS_LIBS) +resources.o: data_res.h -$(CREATE_RES.c.o): %-native.o: %.c - $(CC_FOR_BUILD) $(GHB_TOOLS_CFLAGS) -g -c -o $@ $< +widget_reverse.deps: makedeps.py +widget.deps: makedeps.py + python2 $(srcdir)/makedeps.py ghbcellrenderertext.$(OBJEXT): marshalers.h diff --git a/gtk/src/create_resources.c b/gtk/src/create_resources.c deleted file mode 100644 index c21fb5626..000000000 --- a/gtk/src/create_resources.c +++ /dev/null @@ -1,614 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <unistd.h> -#include <string.h> -#include <glib.h> -#include <glib/gstdio.h> -#include "plist.h" -#include "values.h" -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gdk-pixbuf/gdk-pixdata.h> -#include <gtk/gtk.h> - -enum -{ - R_NONE = 0, - R_RESOURCES, - R_SECTION, - R_ICON, - R_PLIST, - R_JSON, - R_STRING, -}; - -typedef struct -{ - gchar *tag; - gint id; -} tag_map_t; - -static tag_map_t tag_map[] = -{ - {"resources", R_RESOURCES}, - {"section", R_SECTION}, - {"icon", R_ICON}, - {"plist", R_PLIST}, - {"json", R_JSON}, - {"string", R_STRING}, -}; -#define TAG_MAP_SZ (sizeof(tag_map)/sizeof(tag_map_t)) - -typedef struct -{ - gchar *key; - gchar *value; - GhbValue *dict; - GQueue *stack; - GQueue *tag_stack; - gboolean closed_top; -} parse_data_t; - -GList *inc_list = NULL; - -static gchar* -find_file(GList *list, const gchar *name) -{ - gchar *str; - GList *link = list; - - while (link != NULL) - { - gchar *inc; - - inc = (gchar*)link->data; - str = g_strdup_printf("%s/%s", inc, name); - if (g_file_test(str, G_FILE_TEST_IS_REGULAR)) - { - return str; - } - g_free(str); - link = g_list_next(link); - } - if (g_file_test(name, G_FILE_TEST_IS_REGULAR)) - { - return g_strdup(name); - } - return NULL; -} - -static const gchar* -lookup_attr_value( - const gchar *name, - const gchar **attr_names, - const gchar **attr_values) -{ - gint ii; - - if (attr_names == NULL) return NULL; - for (ii = 0; attr_names[ii] != NULL; ii++) - { - if (strcmp(name, attr_names[ii]) == 0) - return attr_values[ii]; - } - return NULL; -} - -static GhbValue* -read_string_from_file(const gchar *fname) -{ - gchar *buffer; - size_t size; - GhbValue *gval; - FILE *fd; - - fd = g_fopen(fname, "r"); - if (fd == NULL) - return NULL; - fseek(fd, 0, SEEK_END); - size = ftell(fd); - fseek(fd, 0, SEEK_SET); - buffer = g_malloc(size+1); - size = fread(buffer, 1, size, fd); - buffer[size] = 0; - gval = ghb_string_value_new(buffer); - g_free(buffer); - fclose(fd); - return gval; -} - -static void add_icon(GhbValue *dict, const char *fname) -{ - FILE *f; - - GdkPixbufFormat *pbf; - int width, height; - gboolean svg; - - pbf = gdk_pixbuf_get_file_info(fname, &width, &height); - svg = gdk_pixbuf_format_is_scalable(pbf); - - f = fopen(fname, "rb"); - if (f == NULL) - { - fprintf(stderr, "open failed: %s\n", fname); - return; - } - - char* base64; - guint8 *data; - gsize data_size; - - fseek(f, 0, SEEK_END); - data_size = ftell(f); - fseek(f, 0, SEEK_SET); - - data = g_malloc(data_size); - fread(data, 1, data_size, f); - base64 = g_base64_encode(data, data_size); - - GhbValue *icon = ghb_string_value_new(base64); - ghb_dict_insert(dict, "svg", ghb_boolean_value_new(svg)); - ghb_dict_insert(dict, "data", icon); - - g_free(base64); - g_free(data); -} - -static void insert_value(GhbValue *container, const char *key, GhbValue *element) -{ - GhbType gtype; - - gtype = ghb_value_type(container); - if (gtype == GHB_ARRAY) - { - ghb_array_append(container, element); - } - else if (gtype == GHB_DICT) - { - if (key == NULL) - { - g_warning("No key for dictionary item"); - ghb_value_free(element); - } - else - { - ghb_dict_insert(container, key, element); - } - } - else - { - g_error("Invalid container type. This shouldn't happen"); - } -} - -static void -start_element( - GMarkupParseContext *ctx, - const gchar *tag, - const gchar **attr_names, - const gchar **attr_values, - gpointer ud, - GError **error) -{ - parse_data_t *pd = (parse_data_t*)ud; - union - { - gint id; - gpointer pid; - } id; - gint ii; - - // Check to see if the first element found has been closed - // If so, ignore any junk following it. - if (pd->closed_top) - return; - - for (ii = 0; ii < TAG_MAP_SZ; ii++) - { - if (strcmp(tag, tag_map[ii].tag) == 0) - { - id.id = tag_map[ii].id; - break; - } - } - if (ii == TAG_MAP_SZ) - { - g_warning("Unrecognized start tag (%s)", tag); - return; - } - g_queue_push_head(pd->tag_stack, id.pid); - GhbValue *gval = NULL; - GhbValue *current = g_queue_peek_head(pd->stack); - switch (id.id) - { - case R_SECTION: - { - const gchar *key; - - key = lookup_attr_value("name", attr_names, attr_values); - if (key == NULL) - { - g_warning("section: missing a requried *name* attribute"); - exit(EXIT_FAILURE); - } - if (strcmp(key, "icons") == 0) - { - gval = ghb_dict_value_new(); - if (pd->key) g_free(pd->key); - pd->key = g_strdup(key); - g_queue_push_head(pd->stack, gval); - } - } break; - case R_ICON: - { - gchar *fname; - const gchar *name, *key; - - name = lookup_attr_value("file", attr_names, attr_values); - if (name == NULL) - { - g_warning("icon: missing a requried *file* attribute"); - exit(EXIT_FAILURE); - } - fname = find_file(inc_list, name); - if (fname == NULL) - { - g_warning("icon: no such file %s", name); - exit(EXIT_FAILURE); - } - key = lookup_attr_value("name", attr_names, attr_values); - if (key == NULL) - { - g_warning("icon: missing a requried *name* attribute"); - g_free(fname); - exit(EXIT_FAILURE); - } - gval = ghb_dict_value_new(); - add_icon(gval, fname); - - g_free(pd->key); - pd->key = g_strdup(key); - g_free(fname); - } break; - case R_PLIST: - { - gchar *fname; - const gchar *name, *key; - - name = lookup_attr_value("file", attr_names, attr_values); - if (name == NULL) - { - g_warning("plist: missing a requried *file* attribute"); - exit(EXIT_FAILURE); - } - fname = find_file(inc_list, name); - if (fname == NULL) - { - g_warning("plist: no such file %s", name); - exit(EXIT_FAILURE); - } - key = lookup_attr_value("name", attr_names, attr_values); - if (key == NULL) - { - g_warning("plist: missing a requried *name* attribute"); - g_free(fname); - exit(EXIT_FAILURE); - } - gval = ghb_plist_parse_file(fname); - if (pd->key) g_free(pd->key); - pd->key = g_strdup(key); - g_free(fname); - } break; - case R_JSON: - { - gchar *fname; - const gchar *name, *key; - - name = lookup_attr_value("file", attr_names, attr_values); - if (name == NULL) - { - g_warning("json: missing a requried *file* attribute"); - exit(EXIT_FAILURE); - } - fname = find_file(inc_list, name); - if (fname == NULL) - { - g_warning("json: no such file %s", name); - exit(EXIT_FAILURE); - } - key = lookup_attr_value("name", attr_names, attr_values); - if (key == NULL) - { - g_warning("json: missing a requried *name* attribute"); - g_free(fname); - exit(EXIT_FAILURE); - } - gval = ghb_json_parse_file(fname); - if (pd->key) g_free(pd->key); - pd->key = g_strdup(key); - g_free(fname); - } break; - case R_STRING: - { - gchar *fname; - const gchar *name, *key; - const gchar *version; - char *end; - int major = 0, minor = 0, micro = 0; - - name = lookup_attr_value("file", attr_names, attr_values); - if (name == NULL) - { - g_warning("string: missing a requried *file* attribute"); - exit(EXIT_FAILURE); - } - fname = find_file(inc_list, name); - if (fname == NULL) - { - g_warning("string: no such file %s", name); - exit(EXIT_FAILURE); - } - key = lookup_attr_value("name", attr_names, attr_values); - if (key == NULL) - { - g_warning("string: missing a requried *name* attribute"); - g_free(fname); - exit(EXIT_FAILURE); - } - version = lookup_attr_value("version", attr_names, attr_values); - if (version != NULL) - { - major = strtol(version, &end, 10); - if (end != version && *end != 0) - { - version = end + 1; - minor = strtol(version, &end, 10); - if (end != version && *end != 0) - { - version = end + 1; - micro = strtol(version, &end, 10); - if (end != version && *end != 0) - { - version = end + 1; - } - } - } - } - if (GTK_CHECK_VERSION(major, minor, micro)) - { - gval = read_string_from_file(fname); - if (pd->key) g_free(pd->key); - pd->key = g_strdup(key); - } - g_free(fname); - } break; - } - // Add the element to the current container - if (gval) - { // There's an element to add - if (current == NULL) - { - pd->dict = gval; - return; - } - insert_value(current, pd->key, gval); - } -} - -static void -end_element( - GMarkupParseContext *ctx, - const gchar *name, - gpointer ud, - GError **error) -{ - parse_data_t *pd = (parse_data_t*)ud; - gint id; - union - { - gint id; - gpointer pid; - } start_id; - gint ii; - - // Check to see if the first element found has been closed - // If so, ignore any junk following it. - if (pd->closed_top) - return; - - for (ii = 0; ii < TAG_MAP_SZ; ii++) - { - if (strcmp(name, tag_map[ii].tag) == 0) - { - id = tag_map[ii].id; - break; - } - } - if (ii == TAG_MAP_SZ) - { - g_warning("Unrecognized start tag (%s)", name); - return; - } - start_id.pid = g_queue_pop_head(pd->tag_stack); - if (start_id.id != id) - g_warning("start tag != end tag: (%s %d) %d", name, id, id); - - GhbValue *gval = NULL; - GhbValue *current = g_queue_peek_head(pd->stack); - switch (id) - { - case R_SECTION: - { - g_queue_pop_head(pd->stack); - } break; - } - if (gval) - { - // Get the top of the data structure stack and if it's an array - // or dict, add the current element - if (current == NULL) - { - pd->dict = gval; - pd->closed_top = TRUE; - return; - } - insert_value(current, pd->key, gval); - } - if (g_queue_is_empty(pd->tag_stack)) - pd->closed_top = TRUE; -} - -static void -text_data( - GMarkupParseContext *ctx, - const gchar *text, - gsize len, - gpointer ud, - GError **error) -{ - parse_data_t *pd = (parse_data_t*)ud; - if (pd->value) g_free(pd->value); - pd->value = g_strdup(text); -} - -static void -passthrough( - GMarkupParseContext *ctx, - const gchar *text, - gsize len, - gpointer ud, - GError **error) -{ - //parse_data_t *pd = (parse_data_t*)ud; - - //g_debug("passthrough %s", text); -} - -static void -parse_error(GMarkupParseContext *ctx, GError *error, gpointer ud) -{ - g_warning("Resource parse error: %s", error->message); -} - -// This is required or the parser crashes -static void -destroy_notify(gpointer data) -{ // Do nothing - //g_debug("destroy parser"); -} - -GhbValue* -ghb_resource_parse(const gchar *buf, gssize len) -{ - GMarkupParseContext *ctx; - GMarkupParser parser; - parse_data_t pd; - GError *err = NULL; - - pd.stack = g_queue_new(); - pd.tag_stack = g_queue_new(); - pd.key = NULL; - pd.value = NULL; - pd.dict = ghb_dict_value_new(); - g_queue_push_head(pd.stack, pd.dict); - pd.closed_top = FALSE; - - parser.start_element = start_element; - parser.end_element = end_element; - parser.text = text_data; - parser.passthrough = passthrough; - parser.error = parse_error; - ctx = g_markup_parse_context_new(&parser, 0, &pd, destroy_notify); - - g_markup_parse_context_parse(ctx, buf, len, &err); - g_markup_parse_context_end_parse(ctx, &err); - g_markup_parse_context_free(ctx); - g_queue_free(pd.stack); - g_queue_free(pd.tag_stack); - return pd.dict; -} - -GhbValue* -ghb_resource_parse_file(FILE *fd) -{ - gchar *buffer; - size_t size; - GhbValue *gval; - - if (fd == NULL) - return NULL; - fseek(fd, 0, SEEK_END); - size = ftell(fd); - fseek(fd, 0, SEEK_SET); - buffer = g_malloc(size+1); - size = fread(buffer, 1, size, fd); - buffer[size] = 0; - gval = ghb_resource_parse(buffer, (gssize)size); - g_free(buffer); - return gval; -} - -static void -usage(char *cmd) -{ - fprintf(stderr, -"Usage: %s [-I <inc path>] <in resource list> <out resource dict>\n" -"Summary:\n" -" Creates a resource dict from a resource list\n" -"Options:\n" -" I - Include path to search for files\n" -" <in resource list> Input resources file\n" -" <out resource dict> Output resources dict file\n" -, cmd); - - exit(EXIT_FAILURE); -} - -#define OPTS "I:" - -gint -main(gint argc, gchar *argv[]) -{ - FILE *file; - GhbValue *gval; - int opt; - const gchar *src, *dst; - - do - { - opt = getopt(argc, argv, OPTS); - switch (opt) - { - case -1: break; - - case 'I': - inc_list = g_list_prepend(inc_list, g_strdup(optarg)); - break; - } - } while (opt != -1); - - if (optind != argc - 2) - { - usage(argv[0]); - return EXIT_FAILURE; - } - src = argv[optind++]; - dst = argv[optind++]; - -#if !GLIB_CHECK_VERSION(2, 36, 0) - g_type_init(); -#endif - - file = g_fopen(src, "r"); - if (file == NULL) - { - fprintf(stderr, "Error: failed to open %s\n", src); - return EXIT_FAILURE; - } - - gval = ghb_resource_parse_file(file); - ghb_json_write_file(dst, gval); - fclose(file); - return 0; -} - diff --git a/gtk/src/create_resources.py b/gtk/src/create_resources.py deleted file mode 100644 index 0767513aa..000000000 --- a/gtk/src/create_resources.py +++ /dev/null @@ -1,163 +0,0 @@ -#! /bin/python -# - -import types -import os -import sys -import time -import datetime -import plistlib -import getopt -from xml.parsers import expat -from gtk import gdk - -pl = dict() -stack = list() -stack.append(pl) - -def top(ss): - return ss[len(ss)-1] - -def end_element_handler(tag): - global stack - - if tag == "section": - stack.pop() - -def start_element_handler(tag, attr): - global pl, stack - - current = top(stack) - key = val = None - if tag == "section": - key = attr["name"] - if key == "icons": - val = dict() - stack.append(val) - elif tag == "icon": - fbase = attr["file"] - fname = find_file(fbase) - key = attr["name"] - if fname != None and key != None: - val = dict() - pb = gdk.pixbuf_new_from_file(fname) - val["colorspace"] = pb.get_colorspace() - val["alpha"] = pb.get_has_alpha() - val["bps"] = pb.get_bits_per_sample() - val["width"] = pb.get_width() - val["height"] = pb.get_height() - val["rowstride"] = pb.get_rowstride() - val["data"] = plistlib.Data(pb.get_pixels()) - elif fname == None: - print >> sys.stderr, ( "Error: No such icon file %s" % fbase ) - sys.exit(1) - elif tag == "plist": - fbase = attr["file"] - fname = find_file(fbase) - key = attr["name"] - if fname != None and key != None: - val = plistlib.readPlist(fname) - elif fname == None: - print >> sys.stderr, ( "Error: No such plist file %s" % fbase ) - sys.exit(1) - elif tag == "string": - fbase = attr["file"] - fname = find_file(fbase) - key = attr["name"] - if fname != None and key != None: - try: - ff = open(fname) - val = ff.read() - except Exception, err: - print >> sys.stderr, ( "Error: %s" % str(err) ) - sys.exit(1) - elif fname == None: - print >> sys.stderr, ( "Error: No such string file %s" % fbase ) - sys.exit(1) - - if val != None: - if type(current) == types.DictType: - current[key] = val - elif type(current) == types.TupleType: - current.append(val) - - -def cdata_handler(str): - return - -def resource_parse_file(infile): - parser = expat.ParserCreate() - parser.StartElementHandler = start_element_handler - parser.EndElementHandler = end_element_handler - parser.CharacterDataHandler = cdata_handler - parser.ParseFile(infile) - -def usage(): - print >> sys.stderr, ( - "Usage: %s [-I <inc path>] <resource list> [resource plist]\n" - "Summary:\n" - " Creates a resource plist from a resource list\n\n" - "Options:\n" - " I - Include path to search for files\n" - " <resource list> Input resources file\n" - " <resource plist> Output resources plist file\n" - % sys.argv[0] - ) - -inc_list = list() - -def find_file(name): - global inc_list - - for inc_dir in inc_list: - inc = "%s/%s" % (inc_dir, name) - if os.path.isfile(inc): - return inc - - if os.path.isfile(name): - return name - - return None - -def main(): - global inc_list - - OPTS = "I:" - try: - opts, args = getopt.gnu_getopt(sys.argv[1:], OPTS) - except getopt.GetoptError, err: - print >> sys.stderr, str(err) - usage() - sys.exit(2) - - for o, a in opts: - if o == "-I": - # add to include list - inc_list.append(a) - else: - assert False, "unhandled option" - - if len(args) > 2 or len(args) < 1: - usage() - sys.exit(2) - - try: - infile = open(args[0]) - except Exception, err: - print >> sys.stderr, ( "Error: %s" % str(err) ) - sys.exit(1) - - if len(args) > 1: - try: - outfile = open(args[1], "w") - except Exception, err: - print >> sys.stderr, ( "Error: %s" % str(err)) - sys.exit(1) - else: - outfile = sys.stdout - - resource_parse_file(infile) - plistlib.writePlist(pl, outfile) - -main() - diff --git a/gtk/src/main.c b/gtk/src/main.c index ad4be4561..d50dbc891 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -67,6 +67,7 @@ #include "presets.h" #include "preview.h" #include "ghbcompositor.h" +#include "ui_res.h" /* @@ -89,9 +90,15 @@ GtkBuilder* create_builder_or_die(const gchar * name) { guint res = 0; - GhbValue *gval; GError *error = NULL; const gchar *ghb_ui; + gsize data_size; + + ghb_ui_register_resource(); + GResource *ui_res = ghb_ui_get_resource(); + GBytes *gbytes = g_resource_lookup_data(ui_res, "/org/handbrake/ui/ghb.ui", + 0, NULL); + ghb_ui = g_bytes_get_data(gbytes, &data_size); const gchar *markup = N_("<b><big>Unable to create %s.</big></b>\n" @@ -100,8 +107,6 @@ create_builder_or_die(const gchar * name) "%s"); g_debug("create_builder_or_die()\n"); GtkBuilder *xml = gtk_builder_new(); - gval = ghb_resource_get("ghb-ui"); - ghb_ui = ghb_value_const_string(gval); if (xml != NULL) res = gtk_builder_add_from_string(xml, ghb_ui, -1, &error); if (!xml || !res) diff --git a/gtk/src/quotestring.c b/gtk/src/quotestring.c deleted file mode 100644 index f29969bd2..000000000 --- a/gtk/src/quotestring.c +++ /dev/null @@ -1,78 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <libgen.h> - -#define BUF_SIZE 72 - -void -usage(char *cmd) -{ - printf("%s\n", cmd); - char *base = basename(cmd); - fprintf(stderr, "Usage: %s infile [outfile]\n", base); -} - -int -main(int argc, char *argv[]) -{ - FILE *infile, *outfile; - char in_buffer[BUF_SIZE]; - char out_buffer[2*BUF_SIZE]; - - if (argc < 2 || argc > 3) - { - usage(argv[0]); - return 1; - } - infile = fopen(argv[1], "r"); - if (argc < 3) - { - outfile = stdout; - } - else - { - outfile = fopen(argv[2], "w"); - } - while (fgets(in_buffer, BUF_SIZE, infile) != NULL) - { - int ii, jj; - int len; - int eol = 0; - // Step on any CR LF at end of line - len = strlen(in_buffer); - if (len > 1 && in_buffer[len-1] == '\n' && in_buffer[len-2] == '\r') - { - in_buffer[len-1] = 0; - in_buffer[len-2] = 0; - eol = 1; - } - else if (len > 0 && in_buffer[len-1] == '\n') - { - in_buffer[len-1] = 0; - eol = 1; - } - for (jj = 0, ii = 0; ii < len; ii++) - { - if (in_buffer[ii] == '"') - { - out_buffer[jj++] = '\\'; - out_buffer[jj++] = in_buffer[ii]; - } - else if (in_buffer[ii] == '\r') - { // Skip it - } - else - { - out_buffer[jj++] = in_buffer[ii]; - } - } - out_buffer[jj] = 0; - if (eol) - fprintf(outfile, "\"%s\\n\"\n", out_buffer); - else - fprintf(outfile, "\"%s\"\n", out_buffer); - } - fclose(infile); - fclose(outfile); - return 0; -} diff --git a/gtk/src/quotestring.py b/gtk/src/quotestring.py deleted file mode 100644 index 1038719e7..000000000 --- a/gtk/src/quotestring.py +++ /dev/null @@ -1,62 +0,0 @@ -#! /usr/bin/python - -import re -import getopt -import sys - -def usage(): - print >> sys.stderr, ( - "Usage: %s <input> [output]\n" - "Summary:\n" - " Creates a quoted string suitable for inclusion in a C char*\n\n" - "Options:\n" - " <input> Input file to quote\n" - " <output> Output quoted string [stdout]\n" - % sys.argv[0] - ) - -def main(): - global inc_list - - OPTS = "" - try: - opts, args = getopt.gnu_getopt(sys.argv[1:], OPTS) - except getopt.GetoptError, err: - print >> sys.stderr, str(err) - usage() - sys.exit(2) - - for o, a in opts: - usage() - assert False, "unhandled option" - - if len(args) > 2 or len(args) < 1: - usage() - sys.exit(2) - - try: - infile = open(args[0]) - except Exception, err: - print >> sys.stderr, ( "Error: %s" % str(err) ) - sys.exit(1) - - if len(args) > 1: - try: - outfile = open(args[1], "w") - except Exception, err: - print >> sys.stderr, ( "Error: %s" % str(err)) - sys.exit(1) - else: - outfile = sys.stdout - - ss = infile.read() - ss = re.sub(r'\\', r'\\\\', ss) - ss = re.sub(r'"', r'\\"', ss) - pattern = re.compile("$", re.M) - ss = re.sub(pattern, r'\\n"', ss) - pattern = re.compile("^", re.M) - ss = re.sub(pattern, "\"", ss) - outfile.write(ss) - -main() - diff --git a/gtk/src/resources.c b/gtk/src/resources.c index afc578c32..c0caddf72 100644 --- a/gtk/src/resources.c +++ b/gtk/src/resources.c @@ -21,10 +21,6 @@ #include "values.h" #include "data_res.h" -static const gchar resource_str[] = -#include "resource_data.h" -; - static GhbValue *resources; void @@ -35,7 +31,7 @@ ghb_resource_init() GBytes *gbytes; gconstpointer data; - resources = ghb_json_parse(resource_str, sizeof(resource_str)-1); + resources = ghb_dict_value_new(); ghb_data_register_resource(); GResource *data_res = ghb_data_get_resource(); diff --git a/gtk/src/resources.list b/gtk/src/resources.list deleted file mode 100644 index a0812c8a6..000000000 --- a/gtk/src/resources.list +++ /dev/null @@ -1,5 +0,0 @@ -<resources> - <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" /> -</resources> diff --git a/gtk/src/ui_res.gresource.xml b/gtk/src/ui_res.gresource.xml new file mode 100644 index 000000000..214aa8ce7 --- /dev/null +++ b/gtk/src/ui_res.gresource.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/handbrake/ui"> + <file>ghb.ui</file> + </gresource> +</gresources> |