summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Sales de Andrade <qulogic@pidgin.im>2017-06-15 23:13:33 -0400
committerElliott Sales de Andrade <qulogic@pidgin.im>2017-06-15 23:13:33 -0400
commit7b74db25cba12b01c7a35f1bb5cf2bd5ecf834ce (patch)
tree85e5e3ba3752f45fa9461cd4fd2a0f6bda0b20b0
parentf66a1497aa43ed7e6050c59ee38f1ef8e4bee30b (diff)
downloadpidgin-7b74db25cba12b01c7a35f1bb5cf2bd5ecf834ce.tar.gz
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.
-rw-r--r--.hgignore2
-rw-r--r--configure.ac3
-rw-r--r--pidgin/Makefile.am21
-rw-r--r--pidgin/gtkdebug.c25
-rw-r--r--pidgin/gtkdebug.gresource.xml6
5 files changed, 45 insertions, 12 deletions
diff --git a/.hgignore b/.hgignore
index f52d89b441..e2caa4084f 100644
--- a/.hgignore
+++ b/.hgignore
@@ -108,7 +108,7 @@ pidgin-.*.tar.bz2
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$
diff --git a/configure.ac b/configure.ac
index e680c62b18..12882a01e3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,7 +109,6 @@ GNT_LT_VERSION_INFO="gnt_lt_current:gnt_micro_version:gnt_minor_version"
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 @@ AC_SUBST(GLIB_GENMARSHAL)
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
diff --git a/pidgin/Makefile.am b/pidgin/Makefile.am
index b41f00c4c9..307775a1a7 100644
--- a/pidgin/Makefile.am
+++ b/pidgin/Makefile.am
@@ -52,6 +52,7 @@ libpidgin_la_SOURCES = \
gtkconv-theme.c \
gtkconv-theme-loader.c \
gtkdebug.c \
+ gtkdebug.gresource.c \
gtkdialogs.c \
gtkdnd-hints.c \
gtkdocklet.c \
@@ -172,18 +173,22 @@ libpidginincludedir=$(includedir)/pidgin
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 \
diff --git a/pidgin/gtkdebug.c b/pidgin/gtkdebug.c
index 2d9513452e..5bc8c6991b 100644
--- a/pidgin/gtkdebug.c
+++ b/pidgin/gtkdebug.c
@@ -40,7 +40,7 @@
#include "gtk3compat.h"
-#include "gtkdebug.html.h"
+#include "gtkdebug.gresource.h"
typedef struct
{
@@ -409,7 +409,10 @@ toolbar_context(GtkWidget *toolbar, GdkEventButton *event, gpointer null)
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 @@ debug_window_new(void)
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);
diff --git a/pidgin/gtkdebug.gresource.xml b/pidgin/gtkdebug.gresource.xml
new file mode 100644
index 0000000000..bad609d00d
--- /dev/null
+++ b/pidgin/gtkdebug.gresource.xml
@@ -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>