Created
January 11, 2009 21:03
-
-
Save segphault/45804 to your computer and use it in GitHub Desktop.
Monkey patching in Seed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Seed.import_namespace("Gtk"); | |
Gtk.init(null, null); | |
Gtk.Container.prototype.clear = function() { | |
var container = this; | |
container.foreach(function(i) {container.remove(i)}); | |
} | |
Gtk.Container.prototype._add = Gtk.Container.prototype.add; | |
Gtk.Container.prototype.add = function(obj) { | |
Seed.print("Adding an object to " + this); | |
this._add(obj); | |
} | |
var win = new Gtk.Window({title: "Monkey patch test"}); | |
win.signal.hide.connect(Gtk.main_quit); | |
var vb = new Gtk.VBox({spacing: 5}); | |
var frame = new Gtk.Frame(); | |
var btn = new Gtk.Button({label: "Click Me!"}); | |
btn.signal.clicked.connect(function(w) {vb.clear()}); | |
frame.add(btn); | |
vb.pack_start(frame); | |
win.add(vb); | |
win.show_all(); | |
Gtk.main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment