[gnome-klotski] resource: Move our assets file into the resource



commit 40c5f12a5949613a3e44c24524e10915df5cb644
Author: Jeremy Bicha <jbicha ubuntu com>
Date:   Fri Jan 11 21:05:05 2019 -0500

    resource: Move our assets file into the resource
    
    Rename the .svg we use for our game art to assets.svg
    to try to make it more clear what it is.
    
    Move it into the gresource so that it's better hidden from players

 data/{gnome-klotski.svg => assets.svg} | 0
 data/meson.build                       | 6 ------
 src/klotski.gresource.xml              | 1 +
 src/puzzle-view.vala                   | 7 +++----
 4 files changed, 4 insertions(+), 10 deletions(-)
---
diff --git a/data/gnome-klotski.svg b/data/assets.svg
similarity index 100%
rename from data/gnome-klotski.svg
rename to data/assets.svg
diff --git a/data/meson.build b/data/meson.build
index 89211a4..7a968a9 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -18,12 +18,6 @@ install_data(
   install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', 'symbolic', 'apps')
 )
 
-# Install extra icon
-install_data(
-  '@0@.svg'.format(meson.project_name()),
-  install_dir : datadir
-)
-
 # Install gschema
 install_data(
   '@0  gschema xml'.format(project_id),
diff --git a/src/klotski.gresource.xml b/src/klotski.gresource.xml
index 6d53446..0ddc10a 100644
--- a/src/klotski.gresource.xml
+++ b/src/klotski.gresource.xml
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource prefix="/org/gnome/klotski/ui">
+    <file preprocess="xml-stripblanks" alias="assets.svg">../data/assets.svg</file>
     <file preprocess="xml-stripblanks" alias="klotski.ui">../data/klotski.ui</file>
     <file alias="klotski.css">../data/klotski.css</file>
   </gresource>
diff --git a/src/puzzle-view.vala b/src/puzzle-view.vala
index 0c3ba11..cbb4f5f 100644
--- a/src/puzzle-view.vala
+++ b/src/puzzle-view.vala
@@ -36,7 +36,7 @@ public class PuzzleView : Gtk.DrawingArea
     private double ky = 0;
 
     private Rsvg.Handle tiles_handle = null;
-    private string image_filepath = "";
+    private File image_file = null;
     private Cairo.Surface surface = null;
 
     private Puzzle? _puzzle = null;
@@ -77,11 +77,11 @@ public class PuzzleView : Gtk.DrawingArea
 
     private void load_image ()
     {
-        image_filepath = Path.build_filename (DATA_DIRECTORY, "gnome-klotski.svg", null);
+        image_file = File.new_for_uri("resource:///org/gnome/klotski/ui/assets.svg");
 
         try
         {
-            tiles_handle = new Rsvg.Handle.from_file (image_filepath);
+            tiles_handle = new Rsvg.Handle.from_gfile_sync (image_file, FLAGS_NONE);
         }
         catch (Error e)
         {
@@ -93,7 +93,6 @@ public class PuzzleView : Gtk.DrawingArea
                                                 e.message);
             dialog.run ();*/
             stderr.printf ("%s %s\n", "Error in puzzle-view.vala load image:", e.message);
-            stderr.printf ("%s %s\n", "image path:", image_filepath);
             Posix.exit (Posix.EXIT_FAILURE);
         }
     }


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