pidgin/pidgin

Move gtkdebug.html into a GResource.

2017-06-15, Elliott Sales de Andrade
d27109ba6626
Move gtkdebug.html into a GResource.

This was added in GLib 2.32, which we can use now. Now there's no need
for complicated xxd + sed transformations and it will work better with
Meson.
--- a/.hgignore Wed Jun 14 23:13:00 2017 -0500
+++ b/.hgignore Thu Jun 15 23:13:33 2017 -0400
@@ -108,7 +108,7 @@
pidgin-.*.tar.gz
pidgin-[0-9a-z.-]+/
pidgin.apspec$
-pidgin/.*\.html\.h$
+pidgin/.*\.gresource\.[ch]$
pidgin/pidgin$
pidgin/data/pidgin.appdata.xml$
pidgin/data/pidgin.desktop$
--- a/configure.ac Wed Jun 14 23:13:00 2017 -0500
+++ b/configure.ac Thu Jun 15 23:13:33 2017 -0400
@@ -109,7 +109,6 @@
AC_SUBST(GNT_LT_VERSION_INFO)
AC_PATH_PROG(sedpath, sed)
-AC_PATH_PROG(xxdpath, xxd)
dnl Storing configure arguments
AC_DEFINE_UNQUOTED(CONFIG_ARGS, "$ac_configure_args", [configure arguments])
@@ -488,6 +487,8 @@
GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
AC_SUBST(GLIB_MKENUMS)
+AC_PATH_PROG(GLIB_COMPILE_RESOURCES, [glib-compile-resources])
+
AC_PATH_PROG(GTESTER, gtester)
GLIB_TESTS
--- a/pidgin/Makefile.am Wed Jun 14 23:13:00 2017 -0500
+++ b/pidgin/Makefile.am Thu Jun 15 23:13:33 2017 -0400
@@ -52,6 +52,7 @@
gtkconv-theme.c \
gtkconv-theme-loader.c \
gtkdebug.c \
+ gtkdebug.gresource.c \
gtkdialogs.c \
gtkdnd-hints.c \
gtkdocklet.c \
@@ -172,18 +173,22 @@
libpidgininclude_HEADERS = \
$(libpidgin_la_headers)
-libpidgin_la_builtheaders = gtkdebug.html.h
+libpidgin_la_builtheaders = gtkdebug.gresource.h
+libpidgin_la_builtsources = gtkdebug.gresource.c
-BUILT_SOURCES = $(libpidgin_la_builtheaders)
+BUILT_SOURCES = $(libpidgin_la_builtheaders) $(libpidgin_la_builtsources)
-CLEANFILES = gtkdebug.html.h
+CLEANFILES = gtkdebug.gresource.h gtkdebug.gresource.c
-%.html.h: %.html
- $(AM_V_GEN)echo "static const char $*_html[] = {" > $@
- $(AM_V_at)$(sedpath) -e 's/^[ ]\+//g' -e 's/[ ]\+/ /g' $< | $(xxdpath) -i | sed -e 's/\(0x[0-9a-f][0-9a-f]\)$$/\1, 0x00/' >> $@
- $(AM_V_at)echo "};" >> $@
+%.gresource.h: %.gresource.xml
+ $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --generate-header --target $@ --c-name gtkdebug $<
-gtkdebug.c: gtkdebug.html.h
+%.gresource.c: %.gresource.xml
+ $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --generate-source --target $@ --c-name gtkdebug $<
+
+gtkdebug.gresource.c: gtkdebug.html
+gtkdebug.gresource.h: gtkdebug.html
+gtkdebug.c: gtkdebug.gresource.h
libpidgin_la_DEPENDENCIES = @LIBOBJS@ $(LIBPIDGIN_WIN32RES)
libpidgin_la_LDFLAGS = -export-dynamic -no-undefined \
--- a/pidgin/gtkdebug.c Wed Jun 14 23:13:00 2017 -0500
+++ b/pidgin/gtkdebug.c Thu Jun 15 23:13:33 2017 -0400
@@ -40,7 +40,7 @@
#include "gtk3compat.h"
-#include "gtkdebug.html.h"
+#include "gtkdebug.gresource.h"
typedef struct
{
@@ -409,7 +409,10 @@
static DebugWindow *
debug_window_new(void)
{
+ GError *error;
DebugWindow *win;
+ GResource *resource;
+ GBytes *resource_bytes;
GtkWidget *vbox;
GtkWidget *toolbar;
GtkWidget *frame;
@@ -586,7 +589,25 @@
frame = pidgin_create_webview(FALSE, &win->text, NULL);
pidgin_webview_set_format_functions(PIDGIN_WEBVIEW(win->text),
PIDGIN_WEBVIEW_ALL ^ PIDGIN_WEBVIEW_SMILEY ^ PIDGIN_WEBVIEW_IMAGE);
- pidgin_webview_load_html_string(PIDGIN_WEBVIEW(win->text), gtkdebug_html);
+ resource = gtkdebug_get_resource();
+ error = NULL;
+ resource_bytes = g_resource_lookup_data(resource,
+ "/im/pidgin/Pidgin/gtkdebug.html",
+ G_RESOURCE_LOOKUP_FLAGS_NONE,
+ &error);
+ if (G_UNLIKELY(resource_bytes == NULL || error != NULL)) {
+ gchar *msg = g_strdup_printf("Unable to load debug window HTML: %s\n",
+ error ? error->message : "Unknown error");
+ g_clear_error(&error);
+ pidgin_webview_load_html_string(PIDGIN_WEBVIEW(win->text), msg);
+ g_free(msg);
+ } else {
+ gconstpointer gtkdebug_html;
+ gtkdebug_html = g_bytes_get_data(resource_bytes, NULL);
+ pidgin_webview_load_html_string(PIDGIN_WEBVIEW(win->text),
+ gtkdebug_html);
+ }
+ g_bytes_unref(resource_bytes);
gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
gtk_widget_show(frame);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/gtkdebug.gresource.xml Thu Jun 15 23:13:33 2017 -0400
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/im/pidgin/Pidgin">
+ <file compressed="true">gtkdebug.html</file>
+ </gresource>
+</gresources>