Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Things are basically working, although there does need to be tweaking.
- Loading branch information
0 parents
commit 494a725
Showing
34 changed files
with
2,264 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "NodeGTK" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "g_object.h" | ||
#include <ev.h> | ||
|
||
namespace nodeGtk { | ||
|
||
} // namespace ngtk |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.