Merged in qulogic/pidgin (pull request #217)

Tue, 20 Jun 2017 01:49:19 +0000

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 20 Jun 2017 01:49:19 +0000
changeset 38379
1b7a2d4e197e
parent 38375
42b2ee893358 (current diff)
parent 38378
7fed48292d93 (diff)
child 38380
19e137cf32f5
child 38381
0f253504b9dd
child 38383
0ceb576f5617
child 38385
2b5c96a9dd53
child 38513
24e16b0137d0

Merged in qulogic/pidgin (pull request #217)

Move gtkdebug.html into a GResource.

Approved-by: Mike Ruprecht <cmaiku@gmail.com>
Approved-by: Gary Kramlich <grim@reaperworld.com>

.hgignore file | annotate | diff | comparison | revisions
--- a/.hgignore	Mon Jun 19 17:40:20 2017 -0500
+++ b/.hgignore	Tue Jun 20 01:49:19 2017 +0000
@@ -105,7 +105,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	Mon Jun 19 17:40:20 2017 -0500
+++ b/configure.ac	Tue Jun 20 01:49:19 2017 +0000
@@ -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	Mon Jun 19 17:40:20 2017 -0500
+++ b/pidgin/Makefile.am	Tue Jun 20 01:49:19 2017 +0000
@@ -4,6 +4,7 @@
 		getopt1.c \
 		gtk3compat.h \
 		gtkdebug.html \
+		pidgin.gresource.xml \
 		Makefile.mingw \
 		data/pidgin.appdata.xml.in \
 		data/pidgin.desktop.in \
@@ -85,6 +86,7 @@
 	gtkxfer.c \
 	libpidgin.c \
 	minidialog.c \
+	pidgin.gresource.c \
 	pidgintooltip.c
 
 libpidgin_la_headers = \
@@ -172,18 +174,22 @@
 libpidgininclude_HEADERS = \
 	$(libpidgin_la_headers)
 
-libpidgin_la_builtheaders = gtkdebug.html.h
+libpidgin_la_builtheaders = pidgin.gresource.h
+libpidgin_la_builtsources = pidgin.gresource.c
 
-BUILT_SOURCES = $(libpidgin_la_builtheaders)
+BUILT_SOURCES = $(libpidgin_la_builtheaders) $(libpidgin_la_builtsources)
 
-CLEANFILES = gtkdebug.html.h
+CLEANFILES = pidgin.gresource.h pidgin.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 $* --sourcedir $(srcdir) $<
 
-gtkdebug.c: gtkdebug.html.h
+%.gresource.c: %.gresource.xml
+	$(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --generate-source --target $@ --c-name $* --sourcedir $(srcdir) $<
+
+pidgin.gresource.c: gtkdebug.html
+pidgin.gresource.h: gtkdebug.html
+gtkdebug.c: pidgin.gresource.h
 
 libpidgin_la_DEPENDENCIES = @LIBOBJS@ $(LIBPIDGIN_WIN32RES)
 libpidgin_la_LDFLAGS = -export-dynamic -no-undefined \
--- a/pidgin/gtkdebug.c	Mon Jun 19 17:40:20 2017 -0500
+++ b/pidgin/gtkdebug.c	Tue Jun 20 01:49:19 2017 +0000
@@ -40,7 +40,7 @@
 
 #include "gtk3compat.h"
 
-#include "gtkdebug.html.h"
+#include "pidgin.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 = pidgin_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/pidgin.gresource.xml	Tue Jun 20 01:49:19 2017 +0000
@@ -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>

mercurial