Published 2007-06-06 19:27:09

As I dig away at the Gtk wrappings, I'm testing the ideas that should make the bindings interesting.

One of the ideas is that extending core Gtk Objects should enable easier usage. I started with the basics of interface design, Making a Menubar as  simple as possible to build, and bind..

var menuBar = new Gtk.MenuBar.quick([
new Gtk.MenuItem.quick("File" , function () {
println("File");
}),
new Gtk.MenuItem.quick("Edit" , function () {
println("Edit");
}),
new Gtk.MenuItem.quick("Search" , function () {
println("Search");
})
]);
In the above example, I've created an extended class Gtk.MenuItem.quick, and Gtk.MenuBar.quick (it could just be Ext.MenuBar / Ext.MenuItem...) - Just adding it to the Gtk.Menubar Class namespace seemed clever at the time.

As you can see, creating the menu, along with adding the handlers is very simple. - I could even use a standard Javascript object as the constructor (even more like ExtJs): eg.

new Gtk.MenuItem.quick({
title: "Search" ,
icon: Gtk.Stock.SEARCH, // this doesnt work yet!
handler: function () {
println("Search");
}
})
This morphing of the Gtk bindings is all done in the Javascript code,

Gtk.MenuItem.quick = function(label, activate) {
Gtk.MenuItem.quick.superclass.constructor.call(this,label);
this.connect("activate", activate);
}
Ext.extend(Gtk.MenuItem.quick, Gtk.MenuItem, {});


Gtk.MenuBar.quick = function(ar)
{
Gtk.MenuBar.quick.superclass.constructor.call(this,label);
for (var i in ar) {
this.append(ar[i]);
}
}

Ext.extend(Gtk.MenuBar.quick , Gtk.MenuBar, {});

(using snippets of code from Extjs) to implement the extending.

On the backend however, I had to make a few changes to dmdscript, both the DObject definition (which is the class that handles Javascript objects in the script engine). Noteably adding generic support for bound void*'s to all Javascript objects. (so binding things like curl, mysql, sqlite etc. should be considerably easier..)

Along with this, dmdscript as available from digitalmars did not support  the {function}.call(this, args) syntax, a stub was there, and it was pretty simple to add.

Anyway the next big challange is understanding GtkTreeView, GtkTreeModel and GtkTreeIter so that building Trees can be made  more Javascript (and Extjs) like..
Mentioned By:
google.com : april (91 referals)
google.com : december (53 referals)
google.com : gtkjs (51 referals)
google.com : extjs extend (35 referals)
swik.net : Gtkjs - extending objects - SWiK (14 referals)
www.planet-php.net : Planet PHP (13 referals)
google.com : extjs menubar (11 referals)
www.digitalmars.com : Digital Mars - digitalmars.D.announce - Gtk bindings to dmdscript (10 referals)
google.com : php extend object (10 referals)
google.com : ExtJS extending (9 referals)
google.com : ExtJS menu bar (6 referals)
blog.astrumfutura.com : Maugrim The Reaper's Blog (6 referals)
google.com : extjs extend object (5 referals)
google.com : php extending object (5 referals)
google.com : extending php objects (4 referals)
google.com : ExtJs GTK (4 referals)
google.com : php extend objects (4 referals)
www.phpeye.com : Gtkjs - extending objects - Alan Knowles|PHP教程|PHP新闻|PHP5|PEAR|PHP框架|PHPEye - Powered by HappyCMS (3 referals)
google.com : extending extjs (3 referals)
google.com : extjs extending object (3 referals)

Add Your Comment

Follow us on