[gnome-sound-recorder] application: bundle the css file in gresources



commit d80f125f3ccc8bf103348d2ae1926e52917f4951
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Fri Jan 11 16:33:04 2019 +0100

    application: bundle the css file in gresources

 .gitignore                                      |  4 ++++
 data/meson.build                                | 10 +++++++---
 data/org.gnome.SoundRecorder.data.gresource.xml |  7 +++++++
 src/application.js                              | 16 ++++++++++++----
 src/gnome-sound-recorder.in                     | 10 ----------
 src/mainWindow.js                               |  2 +-
 src/meson.build                                 |  2 +-
 src/org.gnome.SoundRecorder.in                  |  2 +-
 src/org.gnome.SoundRecorder.src.gresource.xml   |  1 -
 9 files changed, 33 insertions(+), 21 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 31c8999..5773b23 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,8 @@
+<<<<<<< HEAD
 _build
 **/*.swp
 **/*.*~
 **/tags.*
+=======
+_build/
+>>>>>>> application: bundle the css file in gresources
diff --git a/data/meson.build b/data/meson.build
index d5d4c4e..5d90c4f 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -41,9 +41,13 @@ configure_file(
   install_dir: sound_recorder_schemadir
 )
 
-install_data(
-  'application.css',
-  install_dir: sound_recoder_pkgdatadir
+gnome.compile_resources(
+  application_id + '.data',
+  application_id + '.data.gresource.xml',
+  gresource_bundle: true,
+  source_dir: '.',
+  install_dir: sound_recoder_pkgdatadir,
+  install: true
 )
 
 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..1112863
--- /dev/null
+++ b/data/org.gnome.SoundRecorder.data.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/SoundRecorder/Application">
+    <file>application.css</file>
+  </gresource>
+</gresources>
+
diff --git a/src/application.js b/src/application.js
index b15f8e9..f129467 100644
--- a/src/application.js
+++ b/src/application.js
@@ -26,7 +26,6 @@ const Gtk = imports.gi.Gtk;
 
 const MainWindow = imports.mainWindow;
 const Preferences = imports.preferences;
-const Util = imports.util;
 
 var SIGINT = 2;
 var SIGTERM = 15;
@@ -64,7 +63,7 @@ var Application = GObject.registerClass(class Application extends Gtk.Applicatio
     vfunc_startup() {
         super.vfunc_startup();
 
-        Util.loadStyleSheet();
+        this._loadStyleSheet();
         log(_("Sound Recorder started"));
         Gst.init(null);
         this._initAppMenu();
@@ -140,8 +139,17 @@ var Application = GObject.registerClass(class Application extends Gtk.Applicatio
          settings.set_double("speaker-volume", level);
     }
 
-    _showAbout() {
-        let aboutDialog = new Gtk.AboutDialog();
+    _loadStyleSheet: function() {
+        var resource = 'resource:///org/gnome/SoundRecorder/Application/application.css';
+        var provider = new Gtk.CssProvider();
+        provider.load_from_resource(resource);
+        Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
+                                                 provider,
+                                                 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+    },
+
+    _showAbout: function() {
+        var aboutDialog = new Gtk.AboutDialog();
         aboutDialog.artists = [ 'Reda Lazri <the red shortcut gmail com>',
                                 'Garrett LeSage <garrettl gmail com>',
                                 'Hylke Bons <hylkebons gmail com>',
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 2946cef..37194c5 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -104,7 +104,7 @@ var MainWindow = GObject.registerClass(class MainWindow extends Gtk.ApplicationW
             width_request: 640,
             hexpand: true,
             vexpand: true,
-            icon_name: "org.gnome.SoundRecorder"
+            icon_name: pkg.name
         }, params));
 
         header = new Gtk.HeaderBar({ hexpand: true,
diff --git a/src/meson.build b/src/meson.build
index 518ebf1..23b181b 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -9,7 +9,6 @@ sound_recorder_sources = files(
   'play.js',
   'preferences.js',
   'record.js',
-  'util.js',
   'waveform.js',
 )
 
@@ -18,6 +17,7 @@ app_conf.set('prefix', sound_recorder_prefix)
 app_conf.set('libdir', sound_recorder_libdir)
 app_conf.set('PACKAGE_VERSION', meson.project_version())
 app_conf.set('GJS', gjs_console)
+app_conf.set('APPLICATION_ID', application_id)
 
 configure_file(
   input: 'org.gnome.SoundRecorder.in',
diff --git a/src/org.gnome.SoundRecorder.in b/src/org.gnome.SoundRecorder.in
index 25eee28..5cb796a 100755
--- a/src/org.gnome.SoundRecorder.in
+++ b/src/org.gnome.SoundRecorder.in
@@ -3,4 +3,4 @@ imports.package.init({ name: "gnome-sound-recorder",
                         version: "@PACKAGE_VERSION@",
                         prefix: "@prefix@",
                         libdir: "@libdir@" });
-imports.package.run(imports.main);
\ No newline at end of file
+imports.package.run(imports.main);
diff --git a/src/org.gnome.SoundRecorder.src.gresource.xml b/src/org.gnome.SoundRecorder.src.gresource.xml
index c72fdd1..ee9296c 100644
--- a/src/org.gnome.SoundRecorder.src.gresource.xml
+++ b/src/org.gnome.SoundRecorder.src.gresource.xml
@@ -11,7 +11,6 @@
     <file>play.js</file>
     <file>preferences.js</file>
     <file>record.js</file>
-    <file>util.js</file>
     <file>waveform.js</file>
   </gresource>
 </gresources>


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