forked from optimisme/gjs-examples
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathegIcon.js
executable file
·61 lines (46 loc) · 1.47 KB
/
egIcon.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
55
56
57
58
59
60
61
#!/usr/bin/env jsgtk
/*
JSGtk+ example showing how to build Gtk javascript applications
setting the application icon from the 'assets' folder and if
not available from the 'stock icons'
Run it with:
jsgtk egIcon.js
*/
const
Gtk = require('Gtk'),
GLib = require('GLib')
;
const App = function () {
this.title = 'Example Icon';
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.showAll();
};
App.prototype.onStartup = function() {
this.buildUI();
};
App.prototype.buildUI = function() {
let result = false;
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.label = new Gtk.Label({ label: "Hello icon" });
this.window.add(this.label);
};
//Run the application
let app = new App();
app.run();