diff options
author | jstebbins <[email protected]> | 2010-06-17 22:59:19 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2010-06-17 22:59:19 +0000 |
commit | 66e0b095b658b047bb155ec9cdcb0a3d1b4fa466 (patch) | |
tree | 6e98da80c6ffd30832b89cd3ef55bba4c64ead7e /gtk/src | |
parent | 39628d490ff1c87c8ec45f24bb128a52e7fd2fbd (diff) |
LinGui: revert part of the resource management changes of r3382
Since fedora's pygtk is broken, I can't parse gdk_pixbuf's with python.
So revert to doing this in C code.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3386 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src')
-rw-r--r-- | gtk/src/Makefile.am | 4 | ||||
-rw-r--r-- | gtk/src/create_resources.c | 40 | ||||
-rw-r--r-- | gtk/src/create_resources.py | 5 | ||||
-rw-r--r-- | gtk/src/icons.c | 29 |
4 files changed, 40 insertions, 38 deletions
diff --git a/gtk/src/Makefile.am b/gtk/src/Makefile.am index 38412ea18..da44339c8 100644 --- a/gtk/src/Makefile.am +++ b/gtk/src/Makefile.am @@ -124,8 +124,8 @@ widget_reverse.deps: makedeps.py widget.deps: makedeps.py python $(srcdir)/makedeps.py -resources.plist: create_resources.py resources.list $(icons_dep) internal_defaults.xml standard_presets.xml ghb.ui widget.deps widget_reverse.deps - python $(srcdir)/create_resources.py -I$(srcdir) $(srcdir)/resources.list resources.plist +resources.plist: create_resources resources.list $(icons_dep) internal_defaults.xml standard_presets.xml ghb.ui widget.deps widget_reverse.deps + ./create_resources -I$(srcdir) $(srcdir)/resources.list resources.plist ghbcellrenderertext.$(OBJEXT): marshalers.h diff --git a/gtk/src/create_resources.c b/gtk/src/create_resources.c index b91def6f2..3a979bd87 100644 --- a/gtk/src/create_resources.c +++ b/gtk/src/create_resources.c @@ -7,6 +7,8 @@ #include "icon_tools.h" #include "plist.h" #include "values.h" +#include <gdk-pixbuf/gdk-pixbuf.h> +#include <gdk-pixbuf/gdk-pixdata.h> enum { @@ -177,12 +179,42 @@ start_element( if (filename && name) { ghb_rawdata_t *rd; - guint size; + GdkPixbuf *pb; + GError *err = NULL; + + pb = gdk_pixbuf_new_from_file(filename, &err); + if (pb == NULL) + { + g_warning("Failed to open icon file %s: %s", filename, err->message); + break; + } + gval = ghb_dict_value_new(); + int colorspace = gdk_pixbuf_get_colorspace(pb); + gboolean alpha = gdk_pixbuf_get_has_alpha(pb); + int width = gdk_pixbuf_get_width(pb); + int height = gdk_pixbuf_get_height(pb); + int bps = gdk_pixbuf_get_bits_per_sample(pb); + int rowstride = gdk_pixbuf_get_rowstride(pb); + + ghb_dict_insert(gval, g_strdup("colorspace"), + ghb_int_value_new(colorspace)); + ghb_dict_insert(gval, g_strdup("alpha"), + ghb_boolean_value_new(alpha)); + ghb_dict_insert(gval, g_strdup("width"), + ghb_int_value_new(width)); + ghb_dict_insert(gval, g_strdup("height"), + ghb_int_value_new(height)); + ghb_dict_insert(gval, g_strdup("bps"), + ghb_int_value_new(bps)); + ghb_dict_insert(gval, g_strdup("rowstride"), + ghb_int_value_new(rowstride)); rd = g_malloc(sizeof(ghb_rawdata_t)); - rd->data = icon_file_serialize(filename, &size); - rd->size = size; - gval = ghb_rawdata_value_new(rd); + rd->data = gdk_pixbuf_get_pixels(pb); + rd->size = height * rowstride * bps / 8; + GValue *data = ghb_rawdata_value_new(rd); + ghb_dict_insert(gval, g_strdup("data"), data); + if (pd->key) g_free(pd->key); pd->key = g_strdup(name); g_free(filename); diff --git a/gtk/src/create_resources.py b/gtk/src/create_resources.py index 69d9e7d30..5d21ba809 100644 --- a/gtk/src/create_resources.py +++ b/gtk/src/create_resources.py @@ -1,7 +1,6 @@ #! /bin/python # -import gtk import types import os import sys @@ -10,7 +9,7 @@ import datetime import plistlib import getopt from xml.parsers import expat - +from gtk import gdk pl = dict() stack = list() @@ -41,7 +40,7 @@ def start_element_handler(tag, attr): key = attr["name"] if fname != None and key != None: val = dict() - pb = gtk.gdk.pixbuf_new_from_file(fname) + 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() diff --git a/gtk/src/icons.c b/gtk/src/icons.c index ed5545451..905497631 100644 --- a/gtk/src/icons.c +++ b/gtk/src/icons.c @@ -3,7 +3,6 @@ #include "values.h" #include "resources.h" -#if 1 void ghb_load_icons() { @@ -40,31 +39,3 @@ ghb_load_icons() gdk_pixbuf_unref(pb); } } - -#else - -void -ghb_load_icons() -{ - GdkPixbuf *pb; - GHashTableIter iter; - gchar *name; - GValue *gval; - ghb_rawdata_t *rd; - gint size; - - GValue *icons = ghb_resource_get("icons"); - ghb_dict_iter_init(&iter, icons); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&name, (gpointer*)(void*)&gval)) - { - rd = g_value_get_boxed(gval); - pb = icon_deserialize(rd->data, rd->size); - size = gdk_pixbuf_get_height(pb); - gtk_icon_theme_add_builtin_icon(name, size, pb); - gdk_pixbuf_unref(pb); - } -} -#endif |