[gnome-books/wip/hadess/app-provided-pixbuf-loader: 4/5] main: Load application provided pixbuf loaders



commit 24a7571b76a6f989d61f8517b21377800f0b576d
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Feb 28 15:10:44 2019 +0100

    main: Load application provided pixbuf loaders
    
    See https://gitlab.gnome.org/GNOME/gdk-pixbuf/merge_requests/34

 meson.build                           |  3 +++
 src/application.js                    |  9 +++++++++
 src/config.js.in                      |  1 +
 src/meson.build                       | 10 +++-------
 src/org.gnome.Books.src.gresource.xml |  1 +
 5 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/meson.build b/meson.build
index fb7e5204..e7d15247 100644
--- a/meson.build
+++ b/meson.build
@@ -52,6 +52,9 @@ add_project_arguments('-DHAVE_CONFIG_H', language: 'c')
 evince_req_version = '>= 3.13.3'
 tracker_req_version = '>= 0.17.3'
 
+gdk_pixbuf_dep = dependency('gdk-pixbuf-2.0', version: '>= 2.39.1')
+extra_gdk_pixbuf_loaders_dir = join_paths (books_pkglibdir, 'gdk-pixbuf', 
gdk_pixbuf_dep.get_pkgconfig_variable('gdk_pixbuf_binary_version'))
+
 gjs_dep = dependency('gjs-1.0', version: '>= 1.48.0')
 gjs_console = gjs_dep.get_pkgconfig_variable('gjs_console')
 
diff --git a/src/application.js b/src/application.js
index 79b824c1..2e049c48 100644
--- a/src/application.js
+++ b/src/application.js
@@ -29,9 +29,11 @@ const Gio = imports.gi.Gio;
 const Gtk = imports.gi.Gtk;
 const GLib = imports.gi.GLib;
 const GObject = imports.gi.GObject;
+const GdkPixbuf = imports.gi.GdkPixbuf;
 const Tracker = imports.gi.Tracker;
 const TrackerControl = imports.gi.TrackerControl;
 
+const config = imports.config;
 const ChangeMonitor = imports.changeMonitor;
 const Format = imports.format;
 const MainWindow = imports.mainWindow;
@@ -107,6 +109,13 @@ var Application = new Lang.Class({
         // needed by data/ui/view-menu.ui
         GObject.type_ensure(Gio.ThemedIcon);
 
+        // init our pixbuf loaders
+        try {
+          GdkPixbuf.Pixbuf.init_modules (config.EXTRA_GDK_PIXBUF_LOADERS_DIR);
+        } catch (e) {
+            // ignore error
+        }
+
         this.parent({ application_id: appid,
                       inactivity_timeout: 12000 });
 
diff --git a/src/config.js.in b/src/config.js.in
new file mode 100644
index 00000000..3156153c
--- /dev/null
+++ b/src/config.js.in
@@ -0,0 +1 @@
+var EXTRA_GDK_PIXBUF_LOADERS_DIR = '@EXTRA_GDK_PIXBUF_LOADERS_DIR@';
diff --git a/src/meson.build b/src/meson.build
index a1f57b47..d0de13ca 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,17 +1,13 @@
-'''
 js_conf = configuration_data()
-js_conf.set('PACKAGE_NAME', meson.project_name())
-js_conf.set('PACKAGE_VERSION', books_version)
-js_conf.set('GETTEXT_PACKAGE', meson.project_name())
+js_conf.set('EXTRA_GDK_PIXBUF_LOADERS_DIR', extra_gdk_pixbuf_loaders_dir)
 
 js = 'config.js'
 
-configure_file(
+config_js = configure_file(
   input: js + '.in',
   output: js,
   configuration: js_conf
 )
-'''
 
 headers = files(
   'lib/gd-bookmark.h',
@@ -100,7 +96,7 @@ sources += gnome.compile_resources(
   resource,
   resource + '.gresource.xml',
   source_dir: '.',
-  dependencies: resource_data,
+  dependencies: [ resource_data, config_js ],
   gresource_bundle: true,
   install: true,
   install_dir: books_pkgdatadir
diff --git a/src/org.gnome.Books.src.gresource.xml b/src/org.gnome.Books.src.gresource.xml
index ab2afe5c..99df793a 100644
--- a/src/org.gnome.Books.src.gresource.xml
+++ b/src/org.gnome.Books.src.gresource.xml
@@ -3,6 +3,7 @@
   <gresource prefix="/org/gnome/Books/js">
     <file>application.js</file>
     <file>changeMonitor.js</file>
+    <file>config.js</file>
     <file>documents.js</file>
     <file>epubview.js</file>
     <file>embed.js</file>


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