forked from optimisme/gjs-examples
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathegAsset.js
executable file
·54 lines (45 loc) · 1.41 KB
/
egAsset.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env jsgtk
/*
JSGtk+ example showing how to build Gtk javascript applications
using Gtk.Image
Run it with:
jsgtk egAsset.js
*/
const
Gio = require('Gio'),
GLib = require('GLib'),
Gtk = require('Gtk')
;
const App = function () {
this.title = 'Example Asset';
GLib.setPrgname(this.title);
};
App.prototype.run = function () {
this.application = new Gtk.Application();
this.application.on('activate', this.onActivate.bind(this));
this.application.on('startup', this.onStartup.bind(this));
this.application.run([]);
};
App.prototype.onActivate = function () {
this.window.show_all();
};
App.prototype.onStartup = function() {
this.buildUI();
};
App.prototype.buildUI = function() {
this.window = new Gtk.ApplicationWindow({ application: this.application,
title: this.title,
defaultHeight: 200,
defaultWidth: 200,
windowPosition: Gtk.WindowPosition.CENTER });
try {
this.window.setIconFromFile(__dirname + '/assets/appIcon.png');
} catch (err) {
this.window.setIconName('application-x-executable');
}
this.image = new Gtk.Image ({ file: __dirname + '/assets/egAsset.png' });
this.window.add(this.image);
};
//Run the application
let app = new App();
app.run();