Created
April 1, 2013 00:10
-
-
Save arian/5282553 to your computer and use it in GitHub Desktop.
Using Prime in gjs to create Gtk Applications.
This file contains hidden or 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
# use the split-generics branch of prime. | |
wrup -r prime ../../www/prime/index.js -r bind ../../www/prime/function/bind -o prime.js |
This file contains hidden or 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
#!/usr/bin/gjs | |
const Lang = imports.lang; | |
const Gtk = imports.gi.Gtk; | |
imports.searchPath.push ('.'); | |
var prime = imports.prime.prime; | |
var bind = imports.prime.bind; | |
const Application = prime({ | |
//create the application | |
constructor: function() { | |
this.application = new Gtk.Application(); | |
//connect to 'activate' and 'startup' signals to handlers. | |
this.application.connect('activate', bind(this.onActivate, this)); | |
this.application.connect('startup', bind(this.onStartup, this)); | |
}, | |
//create the UI | |
buildUI: function() { | |
this.window = new Gtk.ApplicationWindow({ | |
application: this.application, | |
title: "Hello World!" | |
}); | |
this.label = new Gtk.Label({ | |
label: "Hello World" | |
}); | |
this.window.add(this.label); | |
}, | |
//handler for 'activate' signal | |
onActivate: function() { | |
//show the window and all child widgets | |
this.window.show_all(); | |
}, | |
//handler for 'startup' signal | |
onStartup: function() { | |
this.buildUI(); | |
} | |
}); | |
//run the application | |
let app = new Application(); | |
app.application.run(ARGV); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment