The Artima Developer Community
Sponsored Link

PHP Buzz Forum
Gtkjs - extending objects

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Alan Knowles

Posts: 390
Nickname: alank
Registered: Sep, 2004

Alan Knowles is Freelance Developer, works on PHP extensions and PEAR.
Gtkjs - extending objects Posted: Jun 6, 2007 5:26 AM
Reply to this message Reply

This post originated from an RSS feed registered with PHP Buzz by Alan Knowles.
Original Post: Gtkjs - extending objects
Feed Title: Smoking toooo much PHP
Feed URL: http://www.akbkhome.com/blog.php/RSS.xml
Feed Description: More than just a blog :)
Latest PHP Buzz Posts
Latest PHP Buzz Posts by Alan Knowles
Latest Posts From Smoking toooo much PHP

Advertisement
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..

Read: Gtkjs - extending objects

Topic: Google Street View is Creepy Previous Topic   Next Topic Topic: Minor update on gtkjs.. anyone have a vision for this

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use