[easytag/wip/musicbrainz-support] Build the GtkBuilder file into the binary



commit d1597b1a8afd1540177ed5edc3c2cff236e33b82
Author: David King <amigadave amigadave com>
Date:   Fri May 16 08:26:27 2014 +0100

    Build the GtkBuilder file into the binary
    
    Use GResource to store the MusicBrainz dialogue GtkBuilder file in the
    application binary.

 Makefile.am                                        |   21 +++++++++++++++++++-
 configure.ac                                       |    2 +
 ...icbrainz_dialog.glade => musicbrainz_dialog.ui} |    0
 src/musicbrainz_dialog.c                           |    8 +++++-
 4 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 2083f2b..b55c456 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,6 +17,9 @@ SUBDIRS = help po
 
 bin_PROGRAMS = easytag
 
+BUILT_SOURCES = \
+       $(nodist_easytag_SOURCES)
+
 localedir = $(prefix)/$(DATADIRNAME)/locale
 easytag_CPPFLAGS = \
        -I$(top_srcdir) \
@@ -78,6 +81,9 @@ easytag_SOURCES = \
        src/wavpack_tag.c \
        src/win32/win32dep.c
 
+nodist_easytag_SOURCES = \
+       src/resource.c
+
 easytag_headers = \
        src/id3lib/id3_bugfix.h \
        src/libapetag/apetaglib.h \
@@ -122,11 +128,20 @@ easytag_headers = \
        src/wavpack_tag.h \
        src/win32/win32dep.h
 
+nodist_easytag_headers = \
+       src/resource.h
+
 easytag_LDADD = \
        $(EASYTAG_LIBS) \
        $(ID3LIB_LIBS) \
        $(easytag_rc)
 
+noinst_resource_files = \
+       $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir=$(srcdir)/data 
$(srcdir)/data/org.gnome.EasyTAG.gresource.xml)
+
+src/resource.c src/resource.h: data/org.gnome.EasyTAG.gresource.xml Makefile $(noinst_resource_files)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/data --generate $<
+
 if WINDOWS_HOST
 ICONDIR = $(srcdir)/data/icons/win32
 MANIFESTDIR = $(srcdir)/src/win32
@@ -247,6 +262,8 @@ dist_noinst_DATA = \
        $(appdata_in_files) \
        $(desktop_in_files) \
        $(easytag_headers) \
+       data/org.gnome.EasyTAG.gresource.xml \
+       $(noinst_resource_files) \
        src/id3lib/patch_id3lib_3.8.3_UTF16_writing_bug.diff \
        src/libapetag/COPYING.LGPL \
        src/libapetag/README.apetag \
@@ -346,7 +363,9 @@ CLEANFILES = \
        $(nodist_man_MANS) \
        *.log \
        easytag-$(PACKAGE_VERSION)-setup.exe \
-       easytag-win32-installer.nsi
+       easytag-win32-installer.nsi \
+       src/resource.c \
+       src/resource.h
 
 DISTCLEANFILES = \
        po/.intltool-merge-cache
diff --git a/configure.ac b/configure.ac
index cede501..9dfd58d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,6 +40,8 @@ AC_PROG_CXXCPP
 AC_PROG_SED
 PKG_PROG_PKG_CONFIG([0.24])
 
+AC_SUBST([GLIB_COMPILE_RESOURCES], [`$PKG_CONFIG --variable glib_compile_resources gio-2.0`])
+
 dnl Man page, generated with xsltproc from DocBook XML.
 AC_ARG_ENABLE([man],
     [AS_HELP_STRING([--disable-man], [Disable building the man page])])
diff --git a/data/musicbrainz_dialog.glade b/data/musicbrainz_dialog.ui
similarity index 100%
rename from data/musicbrainz_dialog.glade
rename to data/musicbrainz_dialog.ui
diff --git a/src/musicbrainz_dialog.c b/src/musicbrainz_dialog.c
index 0a008b7..6548360 100644
--- a/src/musicbrainz_dialog.c
+++ b/src/musicbrainz_dialog.c
@@ -61,16 +61,20 @@ et_open_musicbrainz_dialog ()
 {
     entityView = et_mb_entity_view_new ();
     builder = gtk_builder_new ();
-    gtk_builder_add_from_file (builder, "data/musicbrainz_dialog.glade", NULL);
+    /* TODO: Check the error. */
+    gtk_builder_add_from_resource (builder,
+                                   "/org/gnome/EasyTAG/musicbrainz_dialog.ui",
+                                   NULL);
 
     mbDialog = GTK_WIDGET (gtk_builder_get_object (builder, "mbDialog"));
 
     gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "centralBox")),
                         entityView, TRUE, TRUE, 2);
+    /* FIXME: This should not be needed. */
     gtk_box_reorder_child (GTK_BOX (gtk_builder_get_object (builder, "centralBox")),
                            entityView, 0);
     gtk_widget_show_all (mbDialog);
     gtk_dialog_run (GTK_DIALOG (mbDialog));
     gtk_widget_destroy (mbDialog);
     g_object_unref (G_OBJECT (builder));
-}
\ No newline at end of file
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]