diff options
author | matt <mattdangerw@gmail.com> | 2013-05-09 19:58:27 -0700 |
---|---|---|
committer | P. F. Chimento <philip.chimento@gmail.com> | 2013-05-16 11:08:14 +0200 |
commit | dd110019a1c00fcfbb532f50d9978761a04272d9 (patch) | |
tree | 818efebea610abb684352958ea247156a4a771cc | |
parent | 3d90c34af665131f15b5e37763521da5d8d220f2 (diff) |
Added javascript override to the page manager add function
Added the autotooling to get our overrides installing as well.
[endlessm/eos-sdk#70]
-rw-r--r-- | Makefile.am | 8 | ||||
-rw-r--r-- | overrides/Endless.js | 18 | ||||
-rw-r--r-- | test/smoke-tests/app-window.js | 8 |
3 files changed, 26 insertions, 8 deletions
diff --git a/Makefile.am b/Makefile.am index a9f56f2..b04dad6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -106,6 +106,14 @@ CLEANFILES += \ docs/reference/endless-js/html/*.js endif +# # # GJS OVERRIDES # # # + +gjsoverridedir = ${datadir}/gjs-1.0/overrides + +# Put override files here for custom js API outside of normal introspection +dist_gjsoverride_DATA = \ + overrides/Endless.js + # # # TESTS # # # include $(top_srcdir)/test/Makefile.am diff --git a/overrides/Endless.js b/overrides/Endless.js new file mode 100644 index 0000000..00315a3 --- /dev/null +++ b/overrides/Endless.js @@ -0,0 +1,18 @@ +let Endless; + +function _init() { + // this is imports.gi.Endless + Endless = this; + + // Override Endless.PageManager.add() so that you can set child properties + // at the same time + Endless.PageManager.prototype._add_real = Endless.PageManager.prototype.add; + Endless.PageManager.prototype.add = function(child, props) { + this._add_real(child); + if(typeof(props) !== 'undefined') { + for(let prop_id in props) { + this.child_set_property(child, prop_id, props[prop_id]); + } + } + } +} diff --git a/test/smoke-tests/app-window.js b/test/smoke-tests/app-window.js index 32b1736..1114c76 100644 --- a/test/smoke-tests/app-window.js +++ b/test/smoke-tests/app-window.js @@ -6,14 +6,6 @@ const Gtk = imports.gi.Gtk; const TEST_APPLICATION_ID = 'com.endlessm.example.test'; -/* Override Endless.PageManager.add() */ -Endless.PageManager.prototype.add_real = Endless.PageManager.prototype.add -Endless.PageManager.prototype.add = function(child, props) { - this.add_real(child); - for(let prop_id in props) { - this.child_set_property(child, prop_id, props[prop_id]); - } -} const TestApplication = new Lang.Class ({ Name: 'TestApplication', |