Add licence and installation instructions.
[kaya.git] / lib / ext / loader.rb
blob4127813285af679ea032c7913f7d5037a8fdd8fc
1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 begin
9   require 'ext/extensions'
10 rescue LoadError => e
11   warn "ERROR: could not load extension library, some features may be missing"
12   warn e.message
13 end
15 $ext = $qApp.findChild(Qt::Object, "kaya extensions") if $qApp
16 fake = unless $ext
17   # install fake implementations of the extension functions
18   warn "Creating fake extension library"
19   $ext = Qt::Object.new
20   class << $ext
21     def exp_blur(img, radius)
22     end
23   end
24   true
25 end
26 $ext.metaclass_eval do
27   define_method(:fake) { fake }
28 end
30 # conveniently install extension functions in the appropriate places
32 class Qt::Image
33   def exp_blur(radius)
34     $ext.exp_blur(self, radius)
35   end
36 end