OSDN Git Service

LinGui: revert part of the resource management changes of r3382
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 17 Jun 2010 22:59:19 +0000 (22:59 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 17 Jun 2010 22:59:19 +0000 (22:59 +0000)
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://localhost/HandBrake/trunk@3386 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/module.defs
gtk/module.rules
gtk/src/Makefile.am
gtk/src/create_resources.c
gtk/src/create_resources.py
gtk/src/icons.c

index cc20a18..55f5d9a 100644 (file)
@@ -25,3 +25,33 @@ ifeq (0,$(FEATURE.gtk.update.checks))
        GTK.CONFIGURE.extra += --disable-update-checks
 endif
 
+###############################################################################
+###############################################################################
+$(eval $(call import.MODULE.defs,HGTK,hgtk))
+$(eval $(call import.GCC,HGTK))
+
+HGTK.GCC.gcc = gcc
+HGTK.GCC.args.extra = $(shell pkg-config --cflags glib-2.0)
+HGTK.GCC.args.extra += $(shell pkg-config --cflags gdk-pixbuf-2.0)
+HGTK.GCC.args.extra += $(shell pkg-config --libs glib-2.0)
+HGTK.GCC.args.extra += $(shell pkg-config --libs gdk-pixbuf-2.0)
+
+HGTK.src/ = $(SRC/)gtk/src/
+HGTK.build/ = $(BUILD/)gtk/src/
+
+HGTKCOMMON.c = \
+       $(HGTK.src/)plist.c \
+       $(HGTK.src/)values.c 
+
+CREATE_RES.c = \
+       $(HGTK.src/)create_resources.c
+
+CREATE_RES.c.o = $(patsubst $(SRC/)%.c,$(BUILD/)%-native.o,$(CREATE_RES.c))
+CREATE_RES.c.o += $(patsubst $(SRC/)%.c,$(BUILD/)%-native.o,$(HGTKCOMMON.c))
+CREATE_RES.exe = $(HGTK.build/)create_resources
+
+HGTK.out += $(HGTKCOMMON.c.o)
+HGTK.out += $(CREATE_RES.exe)
+HGTK.out += $(CREATE_RES.c.o)
+
+BUILD.out += $(HGTK.out)
index a1c1eb7..09a8c34 100644 (file)
@@ -1,10 +1,10 @@
 $(eval $(call import.MODULE.rules,GTK))
 
-build: gtk.build
+build: hgtk.build gtk.build
 install: gtk.install
 install-strip: gtk.install-strip
 uninstall: gtk.uninstall
-clean: gtk.clean
+clean: hgtk.clean gtk.clean
 xclean: gtk.xclean
 
 gtk.configure: $(GTK.CONFIGURE.stamp)
@@ -35,11 +35,31 @@ gtk.install:
 gtk.uninstall:
        $(MAKE) -C $(GTK.build/) uninstall
 
-gtk.clean:
+gtk.clean: hgtk.clean
        $(MAKE) -C $(GTK.build/) clean
 
-gtk.xclean:
+gtk.xclean: hgtk.clean
        $(MAKE) -C $(GTK.build/) distclean
        $(RM.exe) -f $(GTK.out)
        $(RM.exe) -fr $(GTK.build/)
 
+###############################################################################
+###############################################################################
+$(eval $(call import.MODULE.rules,HGTK))
+hgtk.build: $(CREATE_RES.exe)
+$(CREATE_RES.exe): | $(dir $(CREATE_RES.exe))
+$(CREATE_RES.exe): $(CREATE_RES.c.o) $(HGTKCOMMON.c.o)
+       $(call HGTK.GCC.EXE,$@,$^)
+$(HGTKCOMMON.c.o): | $(dir $(HGTKCOMMON.c.o))
+$(HGTKCOMMON.c.o): $(BUILD/)%-native.o: $(SRC/)%.c
+       $(call HGTK.GCC.C_O,$@,$<)
+$(CREATE_RES.c.o): | $(dir $(CREATE_RES.c.o))
+$(CREATE_RES.c.o): $(BUILD/)%-native.o: $(SRC/)%.c
+       $(call HGTK.GCC.C_O,$@,$<)
+hgtk.clean:
+       $(RM.exe) -f $(HGTK.out)
index 38412ea..da44339 100644 (file)
@@ -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
 
index b91def6..3a979bd 100644 (file)
@@ -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);
index 69d9e7d..5d21ba8 100644 (file)
@@ -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()
index ed55454..9054976 100644 (file)
@@ -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