[four-in-a-row] Use GResource more.



commit ef585be8cf8f95f1b34244b0dd01c72f39a3225d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Sep 28 02:19:43 2019 +0200

    Use GResource more.

 data/meson.build                        | 11 -----------
 data/themes/tileset_50x50_hcinverse.svg |  2 +-
 data/themes/tileset_50x50_hcontrast.svg |  2 +-
 src/four-in-a-row.gresource.xml         |  8 ++++++++
 src/game-board-view.vala                |  8 ++++----
 5 files changed, 14 insertions(+), 17 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index c13c747..3bbb8a6 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -46,17 +46,6 @@ install_data(
   '@0  gschema xml'.format(application_id),
   install_dir : join_paths(get_option('datadir'), 'glib-2.0', 'schemas')
 )
-install_data(
-    [
-        'themes/tileset_50x50_faenza-glines-icon1.svg',
-        'themes/tileset_50x50_faenza-glines-icon2.svg',
-        'themes/tileset_50x50_faenza-gnect-icon.svg',
-        'themes/tileset_50x50_hcinverse.svg',
-        'themes/tileset_50x50_hcontrast.svg',
-        'bg_toplight.png'
-    ],
-    install_dir: datadir
-)
 
 install_data(
     [
diff --git a/data/themes/tileset_50x50_hcinverse.svg b/data/themes/tileset_50x50_hcinverse.svg
index 503c9a9..538a650 100644
--- a/data/themes/tileset_50x50_hcinverse.svg
+++ b/data/themes/tileset_50x50_hcinverse.svg
@@ -17,7 +17,7 @@
    You should have received a copy of the GNU General Public License along
    with GNOME Four-in-a-row.  If not, see <https://www.gnu.org/licenses/>.
 -->
-<svg width="300" height="50">
+<svg width="300" height="50" xmlns:xlink="http://www.w3.org/1999/xlink";>
   <defs>
     <rect id="square" x="0" y="0" width="50" height="50" fill="black" stroke-width="0"/>
     <g id="nought" fill="none" stroke="white" stroke-linecap="round">
diff --git a/data/themes/tileset_50x50_hcontrast.svg b/data/themes/tileset_50x50_hcontrast.svg
index 58d5e2c..c506712 100644
--- a/data/themes/tileset_50x50_hcontrast.svg
+++ b/data/themes/tileset_50x50_hcontrast.svg
@@ -17,7 +17,7 @@
    You should have received a copy of the GNU General Public License along
    with GNOME Four-in-a-row.  If not, see <https://www.gnu.org/licenses/>.
 -->
-<svg width="300" height="50">
+<svg width="300" height="50" xmlns:xlink="http://www.w3.org/1999/xlink";>
   <defs>
     <rect id="square" x="0" y="0" width="50" height="50" fill="white" stroke-width="0" />
     <g id="nought" fill="none" stroke="black" stroke-linecap="round">
diff --git a/src/four-in-a-row.gresource.xml b/src/four-in-a-row.gresource.xml
index f3d549c..ed6911a 100644
--- a/src/four-in-a-row.gresource.xml
+++ b/src/four-in-a-row.gresource.xml
@@ -1,5 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
+  <gresource prefix="/org/gnome/Four-in-a-row/images">
+    <file preprocess="xml-stripblanks" compressed="true" 
alias="tileset_50x50_faenza-glines-icon1.svg">../data/themes/tileset_50x50_faenza-glines-icon1.svg</file>
+    <file preprocess="xml-stripblanks" compressed="true" 
alias="tileset_50x50_faenza-glines-icon2.svg">../data/themes/tileset_50x50_faenza-glines-icon2.svg</file>
+    <file preprocess="xml-stripblanks" compressed="true" 
alias="tileset_50x50_faenza-gnect-icon.svg">../data/themes/tileset_50x50_faenza-gnect-icon.svg</file>
+    <file preprocess="xml-stripblanks" compressed="true" 
alias="tileset_50x50_hcinverse.svg">../data/themes/tileset_50x50_hcinverse.svg</file>
+    <file preprocess="xml-stripblanks" compressed="true" 
alias="tileset_50x50_hcontrast.svg">../data/themes/tileset_50x50_hcontrast.svg</file>
+    <file alias="bg_toplight.png">../data/bg_toplight.png</file>
+  </gresource>
   <gresource prefix="/org/gnome/Four-in-a-row/ui">
     <file preprocess="xml-stripblanks" compressed="true" 
alias="four-in-a-row.ui">../data/ui/four-in-a-row.ui</file>
   </gresource>
diff --git a/src/game-board-view.vala b/src/game-board-view.vala
index 006206b..266e93b 100644
--- a/src/game-board-view.vala
+++ b/src/game-board-view.vala
@@ -208,9 +208,9 @@ private class GameBoardView : Gtk.DrawingArea {
 
         /* Try the theme pixmaps, fallback to the default and then give up */
         while (true) {
-            fname = Path.build_filename(DATA_DIRECTORY, theme[Prefs.instance.theme_id].fname_tileset, null);
+            fname = "/org/gnome/Four-in-a-row/images/" + theme[Prefs.instance.theme_id].fname_tileset;
             try {
-                pb_tileset_tmp = new Gdk.Pixbuf.from_file(fname);
+                pb_tileset_tmp = new Gdk.Pixbuf.from_resource(fname);
             } catch (Error e) {
                 if (Prefs.instance.theme_id != 0) {
                     Prefs.instance.theme_id = 0;
@@ -226,9 +226,9 @@ private class GameBoardView : Gtk.DrawingArea {
         pb_tileset_raw = pb_tileset_tmp;
 
         if (theme[Prefs.instance.theme_id].fname_bground != null) {
-            fname = Path.build_filename(DATA_DIRECTORY, theme[Prefs.instance.theme_id].fname_bground, null);
+            fname = "/org/gnome/Four-in-a-row/images/" + theme[Prefs.instance.theme_id].fname_bground;
             try {
-                pb_bground_tmp = new Gdk.Pixbuf.from_file(fname);
+                pb_bground_tmp = new Gdk.Pixbuf.from_resource(fname);
             } catch (Error e) {
                 load_error(fname);
                 return false;


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