node-gtk 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -53
- package/binding.gyp +0 -1
- package/lib/binding/node-v102-linux-x64/node_gtk.node +0 -0
- package/lib/binding/node-v108-linux-x64/node_gtk.node +0 -0
- package/lib/binding/node-v115-linux-x64/node_gtk.node +0 -0
- package/lib/binding/node-v93-linux-x64/node_gtk.node +0 -0
- package/lib/overrides/Gtk-3.0.js +8 -0
- package/lib/overrides/Gtk-4.0.js +16 -0
- package/lib/register-class.js +24 -25
- package/package.json +12 -12
- package/scripts/ci.sh +5 -1
- package/src/callback.cc +2 -3
- package/src/util.h +1 -3
- package/src/value.cc +0 -2
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@ Node-Gtk is a [gobject-introspection](https://gi.readthedocs.io/en/latest) libra
|
|
|
19
19
|
use any introspected library, such as Gtk+, usable. It is similar in essence to [GJS](https://wiki.gnome.org/action/show/Projects/Gjs) or [PyGObject](https://pygobject.readthedocs.io). Please note this project is currently in a _beta_ state and is being developed. Any contributors willing to help
|
|
20
20
|
will be welcomed.
|
|
21
21
|
|
|
22
|
-
Supported Node.js versions: **
|
|
23
|
-
Pre-built binaries available for: **Linux**, **macOS**
|
|
22
|
+
Supported Node.js versions: **16**, **18** (other versions should work but are untested)<br>
|
|
23
|
+
Pre-built binaries available for: **Linux**, **macOS** (all supported versions except 18)
|
|
24
24
|
|
|
25
25
|
### Table of contents
|
|
26
26
|
|
|
@@ -32,8 +32,8 @@ Pre-built binaries available for: **Linux**, **macOS**
|
|
|
32
32
|
- [How to build on Ubuntu](#how-to-build-on-ubuntu)
|
|
33
33
|
- [How to build on Fedora](#how-to-build-on-fedora)
|
|
34
34
|
- [How to build on ArchLinux](#how-to-build-on-archlinux)
|
|
35
|
-
- [How to build on macOS](#how-to-build-on-
|
|
36
|
-
- [
|
|
35
|
+
- [How to build on macOS](#how-to-build-on-macos)
|
|
36
|
+
- [How to build on Windows](#how-to-build-on-windows)
|
|
37
37
|
- [Testing the project](#testing-the-project)
|
|
38
38
|
- [Browser demo](#browser-demo)
|
|
39
39
|
- [Contributing](#contributing)
|
|
@@ -88,17 +88,15 @@ Note that prebuilt binaries are available for common systems, in those cases bui
|
|
|
88
88
|
|
|
89
89
|
- **Linux**: prebuilt binaries available
|
|
90
90
|
- **macOS**: prebuilt binaries available
|
|
91
|
-
- **Windows**:
|
|
91
|
+
- **Windows**: no prebuilt binaries
|
|
92
92
|
|
|
93
93
|
### Requirements
|
|
94
94
|
|
|
95
95
|
- `git`
|
|
96
96
|
- `nodejs@10` or higher
|
|
97
|
-
- `
|
|
97
|
+
- `python3` (for `node-gyp`)
|
|
98
98
|
- C compiler (`gcc@8` or higher, or `clang`)
|
|
99
99
|
|
|
100
|
-
In the _not-working-yet_ Windows platform, all dependencies must be available under [MSYS2 shell](https://msys2.github.io).
|
|
101
|
-
|
|
102
100
|
### How to build on Ubuntu
|
|
103
101
|
|
|
104
102
|
Install basic dependencies.
|
|
@@ -155,48 +153,11 @@ brew install git node gobject-introspection gtk+3 cairo
|
|
|
155
153
|
|
|
156
154
|
At this point `npm install node-gtk` should already install, fallback and build `node-gtk` without problems.
|
|
157
155
|
|
|
158
|
-
###
|
|
159
|
-
|
|
160
|
-
If you'd like to test everything builds and work properly, after installing and building you can run any of the
|
|
161
|
-
examples:
|
|
162
|
-
|
|
163
|
-
```sh
|
|
164
|
-
node ./examples/hello-gtk.js
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
If you'll see a little window saying hello that's it: it works!
|
|
168
|
-
|
|
169
|
-
Please note in macOS the window doesn't automatically open above other windows.
|
|
170
|
-
Try <kbd>Cmd</kbd> + <kbd>Tab</kbd> if you don't see it.
|
|
171
|
-
|
|
172
|
-
#### Browser demo
|
|
173
|
-
|
|
174
|
-
If you'd like to test `./examples/browser.js` you'll need [WebKit2 GTK+](http://webkitgtk.org/) libary.
|
|
175
|
-
|
|
176
|
-
- in **Ubuntu**, you can `apt-get install libwebkit2gtk-3.0` (`4.0` works too) and try it out.
|
|
177
|
-
- in **Fedora**, you should run `sudo dnf install webkit2gtk3`
|
|
178
|
-
- in **ArchLinux**, you can `pacman -S --needed webkitgtk` and try it out.
|
|
179
|
-
- in **macOS**, there is no way to run it right now because `webkitgtk` was removed from homebrew
|
|
180
|
-
|
|
181
|
-
Once installed, you can `./examples/browser.js google.com` or any other page, and you might try the _dark theme_ out too:
|
|
182
|
-
|
|
183
|
-
```sh
|
|
184
|
-
# macOS needs to have the Adwaita theme installed
|
|
185
|
-
# brew install adwaita-icon-theme
|
|
186
|
-
|
|
187
|
-
# Usage: ./examples/browser.js <url> [theme]
|
|
188
|
-
./examples/browser.js google.com dark
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Experimental platforms
|
|
156
|
+
### How to build on Windows
|
|
192
157
|
|
|
193
|
-
|
|
158
|
+
Mandatory dependency is Visual C++ Build Environment: Visual Studio Build Tools (using "Visual C++ build tools" workload) or Visual Studio Community (using the "Desktop development with C++" workload).
|
|
194
159
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
Mandatory dependency is _[Visual Studio Community](https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx)_ or _Express_ with a C++ compiler (open a new C++ project and install it via IDE if necessary).
|
|
198
|
-
|
|
199
|
-
The easiest/tested way to at least try building this repository is within a _MinGW shell_ provided by the [MSYS2 installer](https://msys2.github.io/).
|
|
160
|
+
The easiest/tested way to build this repository is within a _MinGW shell_ provided by the [MSYS2 installer](https://msys2.github.io/).
|
|
200
161
|
|
|
201
162
|
Once VS and its C++ compiler is available and MSYS2 installed, launch the MinGW shell.
|
|
202
163
|
|
|
@@ -226,12 +187,18 @@ cd node-gtk
|
|
|
226
187
|
export MINGW_WINDOWS_PATH=$(./windows/mingw_windows_path.sh)
|
|
227
188
|
|
|
228
189
|
# first run might take a while
|
|
229
|
-
GYP_MSVS_VERSION=
|
|
190
|
+
GYP_MSVS_VERSION=2017 npm install
|
|
230
191
|
```
|
|
231
192
|
|
|
232
|
-
The `GYP_MSVS_VERSION` could be
|
|
193
|
+
The `GYP_MSVS_VERSION` could be 2017 or above.
|
|
233
194
|
Please verify [which version you should use](https://github.com/nodejs/node-gyp#installation)
|
|
234
195
|
|
|
196
|
+
The below blog post series will help you get started:
|
|
197
|
+
|
|
198
|
+
1. [Node.js GTK Hello World on Windows](https://ten0s.github.io/blog/2022/07/22/nodejs-gtk-hello-world-on-windows)
|
|
199
|
+
2. [Find DLLs and Typelibs dependencies for Node.js GTK Application on Windows](https://ten0s.github.io/blog/2022/07/25/find-dlls-and-typelibs-dependencies-for-nodejs-gtk-application-on-windows)
|
|
200
|
+
3. [Package Node.js GTK Application on Windows](https://ten0s.github.io/blog/2022/07/27/package-nodejs-gtk-application-on-windows)
|
|
201
|
+
|
|
235
202
|
#### Possible issue on MinGW shell
|
|
236
203
|
|
|
237
204
|
In case you are launching the general executable without knowing the correct platform,
|
|
@@ -249,11 +216,38 @@ npm run install
|
|
|
249
216
|
|
|
250
217
|
This should do the trick. You can also check if there is any python at all via `pacman -Qs python`.
|
|
251
218
|
|
|
252
|
-
|
|
219
|
+
### Testing the project
|
|
220
|
+
|
|
221
|
+
If you'd like to test everything builds and work properly, after installing and building you can run any of the
|
|
222
|
+
examples:
|
|
223
|
+
|
|
224
|
+
```sh
|
|
225
|
+
node ./examples/hello-gtk.js
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
If you'll see a little window saying hello that's it: it works!
|
|
229
|
+
|
|
230
|
+
Please note in macOS the window doesn't automatically open above other windows.
|
|
231
|
+
Try <kbd>Cmd</kbd> + <kbd>Tab</kbd> if you don't see it.
|
|
232
|
+
|
|
233
|
+
#### Browser demo
|
|
253
234
|
|
|
254
|
-
|
|
235
|
+
If you'd like to test `./examples/browser.js` you'll need [WebKit2 GTK+](http://webkitgtk.org/) libary.
|
|
255
236
|
|
|
256
|
-
|
|
237
|
+
- in **Ubuntu**, you can `apt-get install libwebkit2gtk-3.0` (`4.0` works too) and try it out.
|
|
238
|
+
- in **Fedora**, you should run `sudo dnf install webkit2gtk3`
|
|
239
|
+
- in **ArchLinux**, you can `pacman -S --needed webkitgtk` and try it out.
|
|
240
|
+
- in **macOS**, there is no way to run it right now because `webkitgtk` was removed from homebrew
|
|
241
|
+
|
|
242
|
+
Once installed, you can `./examples/browser.js google.com` or any other page, and you might try the _dark theme_ out too:
|
|
243
|
+
|
|
244
|
+
```sh
|
|
245
|
+
# macOS needs to have the Adwaita theme installed
|
|
246
|
+
# brew install adwaita-icon-theme
|
|
247
|
+
|
|
248
|
+
# Usage: ./examples/browser.js <url> [theme]
|
|
249
|
+
./examples/browser.js google.com dark
|
|
250
|
+
```
|
|
257
251
|
|
|
258
252
|
## Contributing
|
|
259
253
|
|
package/binding.gyp
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/overrides/Gtk-3.0.js
CHANGED
|
@@ -32,6 +32,14 @@ exports.apply = (Gtk) => {
|
|
|
32
32
|
process._tickCallback()
|
|
33
33
|
|
|
34
34
|
const loopStack = internal.GetLoopStack()
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* To keep the nodejs event loop alive, we need to have something running.
|
|
38
|
+
*/
|
|
39
|
+
if (placeholderIntervalID === undefined) {
|
|
40
|
+
placeholderIntervalID = setInterval(() => { /* noop */ }, 60 * 60 * 1000)
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
loopStack.push(originalQuit)
|
|
36
44
|
|
|
37
45
|
originalMain()
|
package/lib/overrides/Gtk-4.0.js
CHANGED
|
@@ -11,6 +11,22 @@ exports.apply = (Gtk) => {
|
|
|
11
11
|
Gtk.EVENT_CONTINUE = false
|
|
12
12
|
Gtk.EVENT_STOP = true
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Gtk.Widget.prototype.containsChild
|
|
16
|
+
* @param {Gtk.Widget} child
|
|
17
|
+
* @returns {bool}
|
|
18
|
+
*/
|
|
19
|
+
Gtk.Widget.prototype.containsChild = function containsChild(child) {
|
|
20
|
+
let current = child
|
|
21
|
+
while (current) {
|
|
22
|
+
if (current === this)
|
|
23
|
+
return true
|
|
24
|
+
current = current.getParent()
|
|
25
|
+
}
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
14
30
|
Gtk.Widget.prototype._addCssClass = Gtk.Widget.prototype.addCssClass
|
|
15
31
|
Gtk.Widget.prototype._removeCssClass = Gtk.Widget.prototype.removeCssClass
|
|
16
32
|
|
package/lib/register-class.js
CHANGED
|
@@ -72,17 +72,14 @@ function setupVirtualFunctions(klass, klassGtype, parentGtype) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
function findVFunc(gtype, parentInfo, name) {
|
|
75
|
-
let
|
|
75
|
+
let vfuncInfo = findVFuncOnParents(parentInfo, name)
|
|
76
76
|
if (!vfuncInfo) {
|
|
77
77
|
vfuncInfo = findVFuncOnInterfaces(gtype, name)
|
|
78
|
-
// definedByParent = false
|
|
79
78
|
}
|
|
80
79
|
return vfuncInfo
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
function findVFuncOnParents(info, name) {
|
|
84
|
-
let definedByParent = false;
|
|
85
|
-
|
|
86
83
|
let parent = info
|
|
87
84
|
|
|
88
85
|
/* Since it isn't possible to override a vfunc on
|
|
@@ -91,15 +88,32 @@ function findVFuncOnParents(info, name) {
|
|
|
91
88
|
let [vfunc, _] =
|
|
92
89
|
GI.object_info_find_vfunc_using_interfaces(parent, name, null)
|
|
93
90
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
if (vfunc) {
|
|
92
|
+
return vfunc
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
while (parent) {
|
|
96
|
+
vfunc = GI.object_info_find_vfunc(info, name)
|
|
97
|
+
|
|
98
|
+
if (vfunc) {
|
|
99
|
+
return vfunc
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* HACK: object_info_find_vfunc sometimes fail, so we also search for
|
|
103
|
+
* the matching entry manually. */
|
|
104
|
+
const n = GI.object_info_get_n_vfuncs(parent)
|
|
105
|
+
for (let i = 0; i < n; i++) {
|
|
106
|
+
const vfunc = GI.object_info_get_vfunc(parent, i)
|
|
107
|
+
const currentName = GI.BaseInfo_get_name.call(vfunc)
|
|
108
|
+
if (currentName === name) {
|
|
109
|
+
return vfunc
|
|
110
|
+
}
|
|
111
|
+
}
|
|
97
112
|
|
|
98
113
|
parent = GI.object_info_get_parent(parent)
|
|
99
|
-
|
|
100
|
-
} while (!vfunc && parent)
|
|
114
|
+
}
|
|
101
115
|
|
|
102
|
-
return
|
|
116
|
+
return null
|
|
103
117
|
}
|
|
104
118
|
|
|
105
119
|
function findVFuncOnInterfaces(gtype, name) {
|
|
@@ -163,18 +177,3 @@ function createGTypeName(klass) {
|
|
|
163
177
|
function sanitizeGType(s) {
|
|
164
178
|
return s.replace(/[^a-z0-9+_-]/gi, '_');
|
|
165
179
|
}
|
|
166
|
-
|
|
167
|
-
function getParents(klass) {
|
|
168
|
-
const parents = []
|
|
169
|
-
|
|
170
|
-
let current = klass
|
|
171
|
-
do {
|
|
172
|
-
let proto = Object.getPrototypeOf(current.prototype)
|
|
173
|
-
current = proto ? proto.constructor : null
|
|
174
|
-
if (!current)
|
|
175
|
-
break
|
|
176
|
-
parents.push(current)
|
|
177
|
-
} while (current)
|
|
178
|
-
|
|
179
|
-
return parents
|
|
180
|
-
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-gtk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "GNOME Gtk+ bindings for NodeJS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"install": "npx node-pre-gyp install --fallback-to-build",
|
|
8
|
+
"test": "mocha tests/__run__.js",
|
|
9
|
+
"build": "npx node-pre-gyp build",
|
|
10
|
+
"build:full": "npx node-pre-gyp rebuild",
|
|
11
|
+
"configure": "npx node-pre-gyp configure --debug"
|
|
12
|
+
},
|
|
6
13
|
"repository": {
|
|
7
14
|
"type": "git",
|
|
8
15
|
"url": "git+https://github.com/romgrk/node-gtk.git"
|
|
@@ -25,12 +32,12 @@
|
|
|
25
32
|
},
|
|
26
33
|
"homepage": "https://github.com/romgrk/node-gtk#readme",
|
|
27
34
|
"dependencies": {
|
|
28
|
-
"@mapbox/node-pre-gyp": "^1.0.
|
|
35
|
+
"@mapbox/node-pre-gyp": "^1.0.10",
|
|
29
36
|
"lodash.camelcase": "4.3.0",
|
|
30
37
|
"lodash.isequal": "4.5.0",
|
|
31
38
|
"lodash.snakecase": "^4.1.1",
|
|
32
|
-
"nan": "2.
|
|
33
|
-
"node-gyp": "^
|
|
39
|
+
"nan": "^2.17.0",
|
|
40
|
+
"node-gyp": "^9.3.1",
|
|
34
41
|
"remove-trailing-spaces": "^1.0.7",
|
|
35
42
|
"unindent": "^2.0.0"
|
|
36
43
|
},
|
|
@@ -55,12 +62,5 @@
|
|
|
55
62
|
"remote_path": "./{module_name}/v{version}/",
|
|
56
63
|
"package_name": "{module_name}-{node_abi}-{platform}-{arch}.tar.gz",
|
|
57
64
|
"host": "https://node-gtk-1.s3.amazonaws.com"
|
|
58
|
-
},
|
|
59
|
-
"scripts": {
|
|
60
|
-
"install": "npx node-pre-gyp install --fallback-to-build",
|
|
61
|
-
"test": "mocha tests/__run__.js",
|
|
62
|
-
"build": "npx node-pre-gyp build",
|
|
63
|
-
"build:full": "npx node-pre-gyp rebuild",
|
|
64
|
-
"configure": "npx node-pre-gyp configure --debug"
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
}
|
package/scripts/ci.sh
CHANGED
|
@@ -41,7 +41,11 @@ function npm_test() {
|
|
|
41
41
|
echo "### Running tests ###";
|
|
42
42
|
|
|
43
43
|
if [[ $(uname -s) == 'Darwin' ]]; then
|
|
44
|
-
|
|
44
|
+
export GST_PLUGIN_SYSTEM_PATH=/usr/local/lib/gstreamer-1.0;
|
|
45
|
+
npx mocha \
|
|
46
|
+
--skip=callback \
|
|
47
|
+
--skip=error \
|
|
48
|
+
tests/__run__.js
|
|
45
49
|
else
|
|
46
50
|
xvfb-run -a npm test;
|
|
47
51
|
fi;
|
package/src/callback.cc
CHANGED
|
@@ -18,7 +18,6 @@ using v8::Isolate;
|
|
|
18
18
|
using v8::Local;
|
|
19
19
|
using v8::Object;
|
|
20
20
|
using v8::Value;
|
|
21
|
-
using Nan::TryCatch;
|
|
22
21
|
|
|
23
22
|
namespace GNodeJS {
|
|
24
23
|
|
|
@@ -33,13 +32,13 @@ static Local<Object> GetSelfInstance(GIArgument **args) {
|
|
|
33
32
|
Callback::Callback(Local<Function> fn, GICallableInfo* callback_info, GIScopeType scope_type_) {
|
|
34
33
|
persistent.Reset(fn);
|
|
35
34
|
info = g_base_info_ref (callback_info);
|
|
36
|
-
closure =
|
|
35
|
+
closure = g_callable_info_create_closure(info, &cif, Callback::Call, this);
|
|
37
36
|
scope_type = scope_type_;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
Callback::~Callback() {
|
|
41
40
|
persistent.Reset();
|
|
42
|
-
|
|
41
|
+
g_callable_info_destroy_closure (this->info, this->closure);
|
|
43
42
|
g_base_info_unref (this->info);
|
|
44
43
|
}
|
|
45
44
|
|
package/src/util.h
CHANGED
package/src/value.cc
CHANGED
|
@@ -877,8 +877,6 @@ bool V8ToOutGIArgument(GITypeInfo *type_info, GIArgument *arg, Local<Value> valu
|
|
|
877
877
|
*/
|
|
878
878
|
GITypeTag type_tag = g_type_info_get_tag (type_info);
|
|
879
879
|
|
|
880
|
-
memset(arg, 0, sizeof(GIArgument));
|
|
881
|
-
|
|
882
880
|
if (value->IsUndefined () || value->IsNull ()) {
|
|
883
881
|
arg->v_pointer = NULL;
|
|
884
882
|
|