From 2f047ce341df41d2d34801dc6262a5ae77487a31 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 26 May 2017 12:49:44 +0100 Subject: Allow running examples in non-srcdir builds If we build the examples in a build directory we still want to be able to access the ancillary data files. --- examples/Makefile.am | 3 ++- examples/gtk-clutter-events.c | 6 +++++- examples/gtk-clutter-test.c | 6 +++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/Makefile.am b/examples/Makefile.am index b7959fb..01b17f1 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -13,7 +13,8 @@ AM_CPPFLAGS = \ -I$(srcdir) -I$(top_srcdir) -I$(top_builddir)/clutter-gtk \ -DGLIB_DISABLE_DEPRECATION_WARNINGS \ -DGDK_DISABLE_DEPRECATION_WARNINGS \ - -DCLUTTER_DISABLE_DEPRECATION_WARNINGS + -DCLUTTER_DISABLE_DEPRECATION_WARNINGS \ + -DEXAMPLES_DATADIR=\"$(srcdir)\" AM_CFLAGS = $(MAINTAINER_CFLAGS) $(CLUTTER_GTK_DEPS_CFLAGS) common_deps = \ diff --git a/examples/gtk-clutter-events.c b/examples/gtk-clutter-events.c index d357b78..a433af5 100644 --- a/examples/gtk-clutter-events.c +++ b/examples/gtk-clutter-events.c @@ -3,6 +3,10 @@ #include +#ifndef EXAMPLES_DATADIR +#define EXAMPLES_DATADIR "." +#endif + typedef struct { GtkWidget *window; @@ -181,7 +185,7 @@ main (gint argc, gchar **argv) NULL); /* Create the main texture that the spin buttons manipulate */ - pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL); + pixbuf = gdk_pixbuf_new_from_file (EXAMPLES_DATADIR G_DIR_SEPARATOR_S "redhand.png", NULL); if (pixbuf == NULL) g_error ("Unable to load pixbuf\n"); diff --git a/examples/gtk-clutter-test.c b/examples/gtk-clutter-test.c index f15c265..e61cd84 100644 --- a/examples/gtk-clutter-test.c +++ b/examples/gtk-clutter-test.c @@ -11,6 +11,10 @@ #define WINHEIGHT 400 #define RADIUS 150 +#ifndef EXAMPLES_DATADIR +#define EXAMPLES_DATADIR "." +#endif + typedef struct SuperOH { ClutterActor *stage; @@ -146,7 +150,7 @@ main (int argc, char *argv[]) /* calling gtk_clutter_init* multiple times should be safe */ g_assert (gtk_clutter_init (NULL, NULL) == CLUTTER_INIT_SUCCESS); - pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL); + pixbuf = gdk_pixbuf_new_from_file (EXAMPLES_DATADIR G_DIR_SEPARATOR_S "redhand.png", NULL); if (!pixbuf) g_error("pixbuf load failed"); -- cgit v1.2.1