diff options
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/module.defs | 30 | ||||
-rw-r--r-- | gtk/module.rules | 28 | ||||
-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 |
6 files changed, 94 insertions, 42 deletions
diff --git a/gtk/module.defs b/gtk/module.defs index cc20a18ef..55f5d9acc 100644 --- a/gtk/module.defs +++ b/gtk/module.defs @@ -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) diff --git a/gtk/module.rules b/gtk/module.rules index a1c1eb76f..09a8c34c7 100644 --- a/gtk/module.rules +++ b/gtk/module.rules @@ -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) 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 |