[gnome-sound-recorder/wip/jtojnar/run: 19/21] build: pack application.css into gresource



commit 8976076bd468e5aef239712699283c7b40d660db
Author: Jan Tojnar <jtojnar gmail com>
Date:   Fri Jan 18 02:58:35 2019 +0100

    build: pack application.css into gresource
    
    This will allow the app to easily find the stylesheet.

 data/meson.build                                | 9 ++++++---
 data/org.gnome.SoundRecorder.data.gresource.xml | 6 ++++++
 src/util.js                                     | 6 ++----
 3 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index d5d4c4e..3ab1144 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -41,9 +41,12 @@ configure_file(
   install_dir: sound_recorder_schemadir
 )
 
-install_data(
-  'application.css',
-  install_dir: sound_recoder_pkgdatadir
+gnome.compile_resources(
+  '@0@.data'.format(application_id),
+  '@0  data gresource xml'.format(application_id),
+  gresource_bundle: true,
+  install: true,
+  install_dir: sound_recoder_pkgdatadir,
 )
 
 subdir('appdata')
diff --git a/data/org.gnome.SoundRecorder.data.gresource.xml b/data/org.gnome.SoundRecorder.data.gresource.xml
new file mode 100644
index 0000000..1c19787
--- /dev/null
+++ b/data/org.gnome.SoundRecorder.data.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/SoundRecorder">
+    <file alias="css/application.css">application.css</file>
+  </gresource>
+</gresources>
diff --git a/src/util.js b/src/util.js
index a398f7e..0d2aa68 100644
--- a/src/util.js
+++ b/src/util.js
@@ -30,10 +30,8 @@ const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
 
 function loadStyleSheet() {
-    let file = 'application.css';
-    let provider = new Gtk.CssProvider();
-    provider.load_from_path(GLib.build_filenamev([pkg.pkgdatadir,
-                                                  file]));
+    var provider = new Gtk.CssProvider();
+    provider.load_from_resource('/org/gnome/SoundRecorder/css/application.css');
     Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
                                              provider,
                                              Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);


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