[aisleriot] sol: Use a resource for the slot image



commit 9cc01c4f4be0b9a8f9253feb0aa76ff260ecbb3a
Author: Christian Persch <chpe gnome org>
Date:   Wed Jan 18 21:31:01 2012 +0100

    sol: Use a resource for the slot image

 configure.ac                     |   13 ++++++++++---
 data/Makefile.am                 |    5 +----
 src/Makefile.am                  |   13 +++++++++++++
 src/aisleriot.gresource.xml.in   |   22 ++++++++++++++++++++++
 src/lib/ar-card-theme-preimage.c |   16 +++++-----------
 src/lib/ar-svg.c                 |   29 +++++++++++++++++++++++++++++
 src/lib/ar-svg.h                 |    4 ++++
 src/window.c                     |    2 +-
 8 files changed, 85 insertions(+), 19 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 40f5408..2f82c49 100644
--- a/configure.ac
+++ b/configure.ac
@@ -290,8 +290,8 @@ case "$with_gtk" in
 esac
 
 GCONF_REQUIRED=2.0
-GLIB_REQUIRED=2.26.0
-GIO_REQUIRED=2.26.0
+GLIB_REQUIRED=2.31.10
+GIO_REQUIRED=2.31.10
 
 # Check for common modules
 
@@ -393,12 +393,18 @@ AM_CONDITIONAL([ENABLE_SOUND],[test "$enable_sound" = "yes"])
 # Extra build tools
 # *****************
 
-AC_ARG_VAR([GLIB_GENMARSHAL],[the glib-genmarschal programme])
+AC_ARG_VAR([GLIB_GENMARSHAL],[the glib-genmarshal programme])
 AC_PATH_PROG([GLIB_GENMARSHAL],[glib-genmarshal],[])
 if test -z "$GLIB_GENMARSHAL"; then
   AC_MSG_ERROR([glib-genmarshal not found])
 fi
 
+AC_ARG_VAR([GLIB_COMPILE_RESOURCES],[the glib-compile-resources programme])
+AC_PATH_PROG([GLIB_COMPILE_RESOURCES],[glib-compile-resources],[])
+if test -z "$GLIB_COMPILE_RESOURCES"; then
+  AC_MSG_ERROR([glib-compile-resources not found])
+fi
+
 AC_ARG_VAR([GZIP],[the gzip programme])
 AC_PATH_PROG([GZIP],[gzip],[])
 if test -z "$GZIP"; then
@@ -616,6 +622,7 @@ help/Makefile
 po/Makefile.in
 src/Makefile
 src/lib/Makefile
+src/aisleriot.gresource.xml
 ])
 AC_OUTPUT
 
diff --git a/data/Makefile.am b/data/Makefile.am
index 1e18d2e..bd2d8fc 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -6,10 +6,7 @@ if ENABLE_SOUND
 SUBDIRS += sounds
 endif
 
-if HAVE_RSVG
-slotdir = $(pkgdatadir)/pixmaps
-dist_slot_DATA = slot.svg
-endif # HAVE_RSVG
+dist_noinst_DATA = slot.svg
 
 pkcatalogdir = $(pkgdatadir)
 pkcatalog_DATA = aisleriot.catalog
diff --git a/src/Makefile.am b/src/Makefile.am
index cf9ea38..5fec7e9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,6 +18,8 @@ sol_SOURCES = \
 	ar-cursor.h	\
 	ar-game-chooser.c \
 	ar-game-chooser.h \
+	ar-resources.c	\
+	ar-resources.h	\
 	ar-stock.c	\
 	ar-stock.h	\
 	ar-style.c	\
@@ -100,6 +102,8 @@ sol_clutter_SOURCES = \
 	ar-cursor.h	\
 	ar-game-chooser.c \
 	ar-game-chooser.h \
+	ar-resources.c	\
+	ar-resources.h	\
 	ar-stock.c	\
 	ar-stock.h	\
 	ar-style.c	\
@@ -142,6 +146,13 @@ sol_clutter_LDADD = $(sol_LDADD) $(CLUTTER_GTK_LIBS) $(CLUTTER_LIBS)
 
 endif # HAVE_CLUTTER
 
+# FIXME autogen the dependencies from the gresource file too?
+ar-resources.c: aisleriot.gresource.xml Makefile
+	$(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir . --generate-source --c-name aisleriot $<
+
+ar-resources.h: aisleriot.gresource.xml Makefile
+	$(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir . --generate-header --c-name aisleriot $<
+
 schema_in_files = aisleriot.schemas.in
 if HAVE_GNOME
 schemadir = $(GCONF_SCHEMA_FILE_DIR)
@@ -176,6 +187,8 @@ EXTRA_DIST = \
 	game-names.h
 
 CLEANFILES = \
+	ar-resources.c \
+	ar-resources.h \
 	$(schema_DATA)	\
 	$(service_DATA)
 
diff --git a/src/aisleriot.gresource.xml.in b/src/aisleriot.gresource.xml.in
new file mode 100644
index 0000000..041f588
--- /dev/null
+++ b/src/aisleriot.gresource.xml.in
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright  2012 Christian Persch
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3, or (at your option)
+  any later version.
+
+  This program is distributed in the hope conf it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+-->
+<gresources>
+  <gresource prefix="/org/gnome/aisleriot">
+    <file alias="art/slot.svg" compressed="true" preprocess="xml-stripblanks">@top_srcdir@/data/slot.svg</file>
+  </gresource>
+</gresources>
diff --git a/src/lib/ar-card-theme-preimage.c b/src/lib/ar-card-theme-preimage.c
index 226b242..2bbaa70 100644
--- a/src/lib/ar-card-theme-preimage.c
+++ b/src/lib/ar-card-theme-preimage.c
@@ -61,19 +61,9 @@ ar_card_theme_preimage_load (ArCardTheme *card_theme,
 {
   ArCardThemePreimage *theme = (ArCardThemePreimage *) card_theme;
   ArCardThemeInfo *theme_info = card_theme->theme_info;
-  const char *slot_dir;
+  GError *err;
   char *path;
 
-  /* First the slot image */
-  /* FIXMEchpe: use uninstalled data dir for rendering the card theme! */
-  slot_dir = ar_runtime_get_directory (AR_RUNTIME_PIXMAP_DIRECTORY);
-  path = g_build_filename (slot_dir, "slot.svg", NULL);
-  theme->slot_preimage = ar_svg_new_from_filename_sync (path, NULL, error);
-  g_free (path);
-  if (!theme->slot_preimage)
-    return FALSE;
-
-
   /* Now the main course */
   path = g_build_filename (theme_info->path, theme_info->filename, NULL);
   theme->cards_svg = ar_svg_new_from_filename_sync (path, NULL, error);
@@ -86,6 +76,10 @@ ar_card_theme_preimage_load (ArCardTheme *card_theme,
     ar_svg_set_font_options (theme->cards_svg, theme->font_options);
   }
 
+  err = NULL;
+  theme->slot_preimage = ar_svg_new_from_uri_sync ("resource:///org/gnome/aisleriot/art/slot.svg", NULL, &err);
+  g_assert_no_error (err);
+
   return TRUE;
 }
 
diff --git a/src/lib/ar-svg.c b/src/lib/ar-svg.c
index 543c445..196db99 100644
--- a/src/lib/ar-svg.c
+++ b/src/lib/ar-svg.c
@@ -274,6 +274,35 @@ ar_svg_render_cairo_sub (ArSvg *svg,
 }
 
 /**
+ * ar_svg_new_from_uri_sync:
+ * @file: an URI
+ * @cancellable: (allow-none): a #GCancellable, or %NULL
+ * @error: (allow-none): a location to store a #GError, or %NULL
+ *
+ * Creates a new #ArSvg and synchronously loads its contents from @uri.
+ *
+ * Returns: (allow-none): a new #ArSvg, or %NULL on error with @error
+ *   filled in
+ */
+ArSvg *
+ar_svg_new_from_uri_sync (const char *uri,
+                          GCancellable *cancellable,
+                          GError **error)
+{
+  GFile *file;
+  ArSvg *svg;
+
+  g_return_val_if_fail (uri != NULL, NULL);
+
+  file = g_file_new_for_uri (uri);
+  svg = ar_svg_new_from_gfile_sync (file, cancellable, error);
+  g_object_unref (file);
+
+  return svg;
+}
+
+
+/**
  * ar_svg_new_from_gfile_sync:
  * @file: a #GFile
  * @cancellable: (allow-none): a #GCancellable, or %NULL
diff --git a/src/lib/ar-svg.h b/src/lib/ar-svg.h
index 9c3631e..1453a1e 100644
--- a/src/lib/ar-svg.h
+++ b/src/lib/ar-svg.h
@@ -43,6 +43,10 @@ GType ar_svg_get_type (void);
 
 ArSvg *ar_svg_new (void);
 
+ArSvg *ar_svg_new_from_uri_sync (const char *uri,
+                                 GCancellable *cancellable,
+                                 GError ** error);
+
 ArSvg *ar_svg_new_from_gfile_sync (GFile *file,
                                    GCancellable *cancellable,
                                    GError ** error);
diff --git a/src/window.c b/src/window.c
index 2a721da..4229051 100644
--- a/src/window.c
+++ b/src/window.c
@@ -422,7 +422,7 @@ help_about_cb (GtkAction *action,
                              "card engine that allows many different "
                              "games to be played."),
                          "copyright", "Copyright  1998-2006 Jonathan Blandford\n"
-                                      "Copyright  2007, 2008, 2009, 2010, 2011 Christian Persch",
+                                      "Copyright  2007, 2008, 2009, 2010, 2011, 2012 Christian Persch",
                          "license", licence,
                          "authors", authors,
                          "artists", artists,



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