diff options
author | Matt Watson <mattdangerw@gmail.com> | 2014-01-13 15:39:25 -0800 |
---|---|---|
committer | Matt Watson <mattdangerw@gmail.com> | 2014-01-22 13:43:04 -0800 |
commit | 011fffcedfa2845179355052f69a2f0ceabd5852 (patch) | |
tree | 67a302e246e04459bd7b64031ad41579da8607b1 /test/smoke-tests | |
parent | 63dae1af95255ec96b17e829e6e15545595347ce (diff) |
Added EosCustomContainer C class for gjs containers
forall cannot be overridden in gjs. There's an upstream bug here
https://bugzilla.gnome.org/show_bug.cgi?id=701567
but that does not look like it will be fixed soon. So for now
added a small c class that take care of GtkContainers add, remove
and forall methods. This makes it possible to write generic containers
in gjs. See docs for an example
[endlessm/eos-sdk#481]
Diffstat (limited to 'test/smoke-tests')
-rw-r--r-- | test/smoke-tests/custom-container.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/smoke-tests/custom-container.js b/test/smoke-tests/custom-container.js new file mode 100644 index 0000000..679e0be --- /dev/null +++ b/test/smoke-tests/custom-container.js @@ -0,0 +1,44 @@ +// Copyright 2014 Endless Mobile, Inc. + +const Lang = imports.lang; +const Endless = imports.gi.Endless; +const Gtk = imports.gi.Gtk; +const GObject = imports.gi.GObject; + +const TEST_APPLICATION_ID = 'com.endlessm.example.test'; + +const TestContainer = Lang.Class({ + Name: 'TestContainer', + Extends: Endless.CustomContainer, + + _init: function() { + this.parent(); + + this._frame = new Gtk.Frame(); + this.add(this._frame); + }, + + vfunc_size_allocate: function (alloc) { + this.parent(alloc); + alloc.width = alloc.width / 2; + alloc.height = alloc.height / 2; + this._frame.size_allocate(alloc); + } +}); + +const TestApplication = new Lang.Class ({ + Name: 'TestApplication', + Extends: Gtk.Application, + + vfunc_startup: function() { + this.parent(); + let window = new Gtk.Window(); + window.add(new TestContainer()); + window.show_all(); + this.add_window(window); + } +}); + +let app = new TestApplication({ application_id: TEST_APPLICATION_ID, + flags: 0 }); +app.run(ARGV); |