Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
Things are basically working, although there does need to be tweaking.
  • Loading branch information
mx-moth committed Feb 5, 2011
0 parents commit 494a725
Show file tree
Hide file tree
Showing 34 changed files with 2,264 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Makefile
@@ -0,0 +1,10 @@
all:
node-waf configure build
pre:
node-waf configure prebuild
tests:
node ./test.js
install:
cp ./build/default/node-gtk.node ~/.node_libraries/node-gtk.node
clean:
rm -rf ./build
46 changes: 46 additions & 0 deletions README.md
@@ -0,0 +1,46 @@
NodeGTK
========

Node.js bindings for GTK 2.6.

Using NodeGTK, you can create fully functional GUI applications in Node.js.

Awesome advantages over C++ etc.
--------------------------------

Well, you are using JavaScript, which is pretty sweet. It allows you to do things like

var button = gtk.button_new("Click me!")
gtk.signal_connect(button, 'click', function() {
console.log("Clicked the button");
});

var window = gtk.window_new(gtk.WINDOW_TYPE);
gtk.window_set_title(window, "Welcome to NodeGTK");
gtk.container_add(window, button);
gtk.widget_show_all(window);

Anonymous function signal callbacks. Life has never been sweeter.

Todo
----

Quite a bit. This is an initial work in progress release. Many things work, but many things are yet to be implemented.

* Implement all GTK classes
* Implement all GTK signals
* Create an object oriented set up:

var button = new gtk.Button({label: "Click me!"});
button.signalConnect('click', function() {
console.log("Clicked the button");
});

var window = new gtk.Window({type: gtk.WINDOW_TYPE});
window.set('title', 'Welcome to NodeGTK');
window.add(button);
window.showAll();

See the [TODO][] list for more details

[TODO]: https://github.com/maelstrom/node-gtk/blob/master/TODO.md
44 changes: 44 additions & 0 deletions TODO.md
@@ -0,0 +1,44 @@
TODO
====

This is only an alpha release, and as such there is still plenty of things to do.

Classes to implement
--------------------

Instead of listing all of the classes left to implement, the currently implemented classes are:

* GtkButton
* GtkWindow
* GtkLabel
* GtkInput
* GtkBox
* GtkBin
* GtkContainer
* GtkWidget
* GtkObject
* GObject

These classes are not yet fully implemented, but there is enough functionality to create a basic 'log in' style window with inputs. See [login.coffee][] for an example.

[login.coffee]: https://github.com/maelstrom/node-gtk/blog/master/examples/login.coffee

Signals to implement
--------------------

Because each different signal potentially has a unique callback signature, a new C++ callback needs to be created for each unique function signature required. This is not a difficult process as such, just a really tedious one. As such, many of the more obscure signals are not yet implemented. They are being implemented as someone requires them. If you require a signal to be connected, but do not have the requisite C++ skills to accomplish this, please create an issue and someone will do it at when they get a chance.

Object oriented approach
------------------------

Unsurprisingly, the GTK library functions are designed to work in C++, and not so much in JavaScript. There are much better ways of implementing all of the classes in JavaScript. The final goal of this project is to create wrapper classes for the GTK classes and their associated functions. This will allow code such as the following:

var button = new gtk.Button({label: "Click me!"});
button.signalConnect('click', function() {
console.log("Clicked the button");
});

var window = new gtk.Window({type: gtk.WINDOW_TYPE});
window.set('title', 'Welcome to NodeGTK');
window.add(button);
window.showAll();
41 changes: 41 additions & 0 deletions examples/login.coffee
@@ -0,0 +1,41 @@
gtk = require '../build/default/gtk'

showLogin = ->

usernameHbox = gtk.hbox_new true, 5
usernameLabel = gtk.label_new "Username"
gtk.misc_set_alignment usernameLabel, 1.0, 0.5
usernameEntry = gtk.entry_new()
gtk.container_add usernameHbox, control for control in [usernameLabel, usernameEntry]

passwordHbox = gtk.hbox_new true, 5
passwordLabel = gtk.label_new "Password"
gtk.misc_set_alignment passwordLabel, 1.0, 0.5
passwordEntry = gtk.entry_new()
gtk.entry_set_visibility passwordEntry, false
gtk.container_add passwordHbox, control for control in [passwordLabel, passwordEntry]

submit = gtk.button_new()
gtk.button_set_label submit, "Submit"
gtk.signal_connect submit, "clicked", ->
console.log "Logging in with", (gtk.entry_get_text usernameEntry), ":", (gtk.entry_get_text passwordEntry)
gtk.widget_destroy window
setTimeout showLogin, 1000

vbox = gtk.vbox_new false, 2
gtk.container_add vbox, control for control in [usernameHbox, passwordHbox, submit]

window = gtk.window_new 0
gtk.window_set_title window, "Enter your log in details"
gtk.container_add window, vbox

gtk.signal_connect window, "destroy", gtk.main_quit

gtk.widget_set_can_default submit, true
gtk.widget_grab_default submit
gtk.widget_show_all window
gtk.main()

process.nextTick ->
gtk.init()
showLogin()
3 changes: 3 additions & 0 deletions package.json
@@ -0,0 +1,3 @@
{
"name": "NodeGTK"
}
6 changes: 6 additions & 0 deletions src/g_object.cc
@@ -0,0 +1,6 @@
#include "g_object.h"
#include <ev.h>

namespace nodeGtk {

} // namespace ngtk
20 changes: 20 additions & 0 deletions src/g_object.h
@@ -0,0 +1,20 @@
#ifndef G_OBJECT_H_
#define G_OBJECT_H_

#include <node_object_wrap.h> // node::ObjectWrap
#include "gtk.h"
#include <vector>

namespace nodeGtk {

class GObject : public node::ObjectWrap {
public:

GtkWidget *widget;
v8::Local<v8::Object> obj;

};

} // namespace ngtk

#endif

0 comments on commit 494a725

Please sign in to comment.