bare-gtk 0.3.1 → 0.3.3
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/binding.c +2 -2
- package/lib/application.d.ts +7 -0
- package/lib/application.h +22 -0
- package/lib/application.js +5 -0
- package/lib/entry.d.ts +4 -10
- package/lib/entry.h +8 -25
- package/lib/entry.js +1 -3
- package/lib/frame-clock.d.ts +3 -0
- package/lib/frame-clock.h +11 -0
- package/lib/frame-clock.js +2 -1
- package/package.json +6 -3
- package/prebuilds/linux-arm64/bare +1 -1
- package/prebuilds/linux-arm64/bare-gtk.bare +0 -0
- package/prebuilds/linux-x64/bare +1 -1
- package/prebuilds/linux-x64/bare-gtk.bare +0 -0
package/binding.c
CHANGED
|
@@ -251,6 +251,7 @@ bare_gtk_exports(js_env_t *env, js_value_t *exports) {
|
|
|
251
251
|
V("surfaceDisplay", bare_gtk_surface_display)
|
|
252
252
|
|
|
253
253
|
V("applicationGetDefault", bare_gtk_application_get_default)
|
|
254
|
+
V("applicationActiveWindow", bare_gtk_application_active_window)
|
|
254
255
|
V("applicationHold", bare_gtk_application_hold)
|
|
255
256
|
V("applicationRelease", bare_gtk_application_release)
|
|
256
257
|
|
|
@@ -335,6 +336,7 @@ bare_gtk_exports(js_env_t *env, js_value_t *exports) {
|
|
|
335
336
|
V("GESTURE_DRAG_EVENT_CANCEL", bare_gtk_gesture_drag_event_cancel)
|
|
336
337
|
|
|
337
338
|
V("FRAME_CLOCK_EVENT_AFTER_PAINT", bare_gtk_frame_clock_event_after_paint)
|
|
339
|
+
V("FRAME_CLOCK_EVENT_UPDATE", bare_gtk_frame_clock_event_update)
|
|
338
340
|
|
|
339
341
|
V("SETTINGS_EVENT_PREFER_DARK_THEME", bare_gtk_settings_event_prefer_dark_theme)
|
|
340
342
|
V("SETTINGS_EVENT_XFT_DPI", bare_gtk_settings_event_xft_dpi)
|
|
@@ -389,8 +391,6 @@ bare_gtk_exports(js_env_t *env, js_value_t *exports) {
|
|
|
389
391
|
V("ENTRY_EVENT_CURSOR_POSITION", bare_gtk_entry_event_cursor_position)
|
|
390
392
|
V("ENTRY_EVENT_INSERT_TEXT", bare_gtk_entry_event_insert_text)
|
|
391
393
|
V("ENTRY_EVENT_DELETE_TEXT", bare_gtk_entry_event_delete_text)
|
|
392
|
-
V("ENTRY_EVENT_HAS_FOCUS", bare_gtk_entry_event_has_focus)
|
|
393
|
-
V("ENTRY_EVENT_IS_FOCUS", bare_gtk_entry_event_is_focus)
|
|
394
394
|
|
|
395
395
|
V("TEXT_VIEW_EVENT_HAS_FOCUS", bare_gtk_text_view_event_has_focus)
|
|
396
396
|
V("TEXT_VIEW_EVENT_IS_FOCUS", bare_gtk_text_view_event_is_focus)
|
package/lib/application.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import GObject = require('./object')
|
|
2
|
+
import GTKWindow = require('./window')
|
|
2
3
|
|
|
3
4
|
/** The application, as a `GtkApplication`. It quits once it has no windows and nothing holds it. */
|
|
4
5
|
interface GTKApplication extends GObject {
|
|
6
|
+
/**
|
|
7
|
+
* The window that was most recently active, or `null` if there are none. Until a window has been
|
|
8
|
+
* focused, this is the window added most recently.
|
|
9
|
+
*/
|
|
10
|
+
readonly activeWindow: GTKWindow | null
|
|
11
|
+
|
|
5
12
|
/** Keep the application running while it has no windows. */
|
|
6
13
|
hold(): this
|
|
7
14
|
|
package/lib/application.h
CHANGED
|
@@ -63,4 +63,26 @@ bare_gtk_application_release(js_env_t *env, js_callback_info_t *info) {
|
|
|
63
63
|
return NULL;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// The window that was most recently active, which is the most recently added
|
|
67
|
+
// one until any of them has been focused.
|
|
68
|
+
static js_value_t *
|
|
69
|
+
bare_gtk_application_active_window(js_env_t *env, js_callback_info_t *info) {
|
|
70
|
+
int err;
|
|
71
|
+
|
|
72
|
+
size_t argc = 1;
|
|
73
|
+
js_value_t *argv[1];
|
|
74
|
+
|
|
75
|
+
bare_gtk_state_t *state;
|
|
76
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, (void **) &state);
|
|
77
|
+
assert(err == 0);
|
|
78
|
+
|
|
79
|
+
assert(argc == 1);
|
|
80
|
+
|
|
81
|
+
GtkApplication *application;
|
|
82
|
+
err = bare_gobject_read_tag(env, state->registry, argv[0], "application", (gpointer *) &application);
|
|
83
|
+
if (err < 0) return NULL;
|
|
84
|
+
|
|
85
|
+
return bare_gtk__create_tag(env, state, gtk_application_get_active_window(application));
|
|
86
|
+
}
|
|
87
|
+
|
|
66
88
|
#endif // BARE_GTK_APPLICATION_H
|
package/lib/application.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
const binding = require('../binding')
|
|
2
2
|
const wrap = require('./wrap')
|
|
3
3
|
const GObject = require('./object')
|
|
4
|
+
const GTKWindow = require('./window')
|
|
4
5
|
|
|
5
6
|
module.exports = exports = class GTKApplication extends GObject {
|
|
6
7
|
static getDefault() {
|
|
7
8
|
return wrap(GTKApplication, binding.applicationGetDefault())
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
get activeWindow() {
|
|
12
|
+
return wrap(GTKWindow, binding.applicationActiveWindow(this._tag))
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
hold() {
|
|
11
16
|
binding.applicationHold(this._tag)
|
|
12
17
|
return this
|
package/lib/entry.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import GTKWidget = require('./widget')
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* A single line of editable text, as a `GtkEntry`. The focus goes to the text inside the entry
|
|
5
|
+
* rather than the entry itself, so follow it with a `GTKEventControllerFocus`.
|
|
6
|
+
*/
|
|
4
7
|
interface GTKEntry extends GTKWidget<GTKEntry.Events> {
|
|
5
8
|
text: string
|
|
6
9
|
|
|
@@ -78,15 +81,6 @@ declare namespace GTKEntry {
|
|
|
78
81
|
|
|
79
82
|
/** The text from `start` to `end` is about to be deleted. `text` is empty. */
|
|
80
83
|
'delete-text': [text: string, start: number, end: number]
|
|
81
|
-
|
|
82
|
-
/** The entry got or lost the keyboard. `focused` is 1 or 0. */
|
|
83
|
-
'has-focus': [focused: number]
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* The entry became or stopped being the focus widget of its window. `focused` is 1 or 0.
|
|
87
|
-
* A window that is not active still has a focus widget.
|
|
88
|
-
*/
|
|
89
|
-
'is-focus': [focused: number]
|
|
90
84
|
}
|
|
91
85
|
}
|
|
92
86
|
|
package/lib/entry.h
CHANGED
|
@@ -15,8 +15,6 @@ enum {
|
|
|
15
15
|
bare_gtk_entry_event_cursor_position = 1 << 2,
|
|
16
16
|
bare_gtk_entry_event_insert_text = 1 << 3,
|
|
17
17
|
bare_gtk_entry_event_delete_text = 1 << 4,
|
|
18
|
-
bare_gtk_entry_event_has_focus = 1 << 5,
|
|
19
|
-
bare_gtk_entry_event_is_focus = 1 << 6,
|
|
20
18
|
};
|
|
21
19
|
|
|
22
20
|
typedef struct {
|
|
@@ -31,8 +29,6 @@ typedef struct {
|
|
|
31
29
|
gulong on_cursor_position;
|
|
32
30
|
gulong on_insert_text;
|
|
33
31
|
gulong on_delete_text;
|
|
34
|
-
gulong on_has_focus;
|
|
35
|
-
gulong on_is_focus;
|
|
36
32
|
} BareEntry;
|
|
37
33
|
|
|
38
34
|
typedef struct {
|
|
@@ -73,22 +69,6 @@ bare_gtk_entry__on_cursor_position(GObject *object, GParamSpec *spec, gpointer d
|
|
|
73
69
|
bare_gtk__emit(self->state, object, "cursor-position", 0, NULL);
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
static void
|
|
77
|
-
bare_gtk_entry__on_has_focus(GObject *object, GParamSpec *spec, gpointer data) {
|
|
78
|
-
BareEntry *self = (BareEntry *) object;
|
|
79
|
-
|
|
80
|
-
bare_gtk__emit(self->state, object, "has-focus", 1, (const double[]) {gtk_widget_has_focus(GTK_WIDGET(object)) ? 1 : 0});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Whether this is the focus widget of its window. That is not the same as
|
|
84
|
-
// having the keyboard: a window that is not active still has a focus widget.
|
|
85
|
-
static void
|
|
86
|
-
bare_gtk_entry__on_is_focus(GObject *object, GParamSpec *spec, gpointer data) {
|
|
87
|
-
BareEntry *self = (BareEntry *) object;
|
|
88
|
-
|
|
89
|
-
bare_gtk__emit(self->state, object, "is-focus", 1, (const double[]) {gtk_widget_is_focus(GTK_WIDGET(object)) ? 1 : 0});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
72
|
// GTK reports an insertion and a deletion separately, where other toolkits
|
|
93
73
|
// report one replacement, so both are sent as a replacement.
|
|
94
74
|
static void
|
|
@@ -163,8 +143,6 @@ bare_gtk_entry_event_mask(js_env_t *env, js_callback_info_t *info) {
|
|
|
163
143
|
V(bare_gtk_entry_event_cursor_position, on_cursor_position, "notify::cursor-position", bare_gtk_entry__on_cursor_position)
|
|
164
144
|
V(bare_gtk_entry_event_insert_text, on_insert_text, "insert-text", bare_gtk_entry__on_insert_text)
|
|
165
145
|
V(bare_gtk_entry_event_delete_text, on_delete_text, "delete-text", bare_gtk_entry__on_delete_text)
|
|
166
|
-
V(bare_gtk_entry_event_has_focus, on_has_focus, "notify::has-focus", bare_gtk_entry__on_has_focus)
|
|
167
|
-
V(bare_gtk_entry_event_is_focus, on_is_focus, "notify::is-focus", bare_gtk_entry__on_is_focus)
|
|
168
146
|
#undef V
|
|
169
147
|
|
|
170
148
|
return NULL;
|
|
@@ -192,11 +170,16 @@ bare_gtk_entry_placeholder_text(js_env_t *env, js_callback_info_t *info) {
|
|
|
192
170
|
if (argc == 1) {
|
|
193
171
|
const char *text = gtk_entry_get_placeholder_text(entry);
|
|
194
172
|
|
|
195
|
-
|
|
196
|
-
|
|
173
|
+
if (text) {
|
|
174
|
+
err = js_create_string_utf8(env, (const utf8_t *) text, (size_t) -1, &result);
|
|
175
|
+
assert(err == 0);
|
|
176
|
+
} else {
|
|
177
|
+
err = js_get_null(env, &result);
|
|
178
|
+
assert(err == 0);
|
|
179
|
+
}
|
|
197
180
|
} else {
|
|
198
181
|
char *text;
|
|
199
|
-
err =
|
|
182
|
+
err = bare_gtk__read_string_or_null(env, argv[1], "text", &text);
|
|
200
183
|
if (err < 0) return NULL;
|
|
201
184
|
|
|
202
185
|
gtk_entry_set_placeholder_text(entry, text);
|
package/lib/entry.js
CHANGED
|
@@ -7,9 +7,7 @@ module.exports = exports = class GTKEntry extends GTKWidget {
|
|
|
7
7
|
activate: binding.ENTRY_EVENT_ACTIVATE,
|
|
8
8
|
'cursor-position': binding.ENTRY_EVENT_CURSOR_POSITION,
|
|
9
9
|
'insert-text': binding.ENTRY_EVENT_INSERT_TEXT,
|
|
10
|
-
'delete-text': binding.ENTRY_EVENT_DELETE_TEXT
|
|
11
|
-
'has-focus': binding.ENTRY_EVENT_HAS_FOCUS,
|
|
12
|
-
'is-focus': binding.ENTRY_EVENT_IS_FOCUS
|
|
10
|
+
'delete-text': binding.ENTRY_EVENT_DELETE_TEXT
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
_init(opts) {
|
package/lib/frame-clock.d.ts
CHANGED
package/lib/frame-clock.h
CHANGED
|
@@ -10,8 +10,18 @@
|
|
|
10
10
|
|
|
11
11
|
enum {
|
|
12
12
|
bare_gtk_frame_clock_event_after_paint = 1 << 0,
|
|
13
|
+
bare_gtk_frame_clock_event_update = 1 << 1,
|
|
13
14
|
};
|
|
14
15
|
|
|
16
|
+
static void
|
|
17
|
+
bare_gtk_frame_clock__on_update(GdkFrameClock *clock, gpointer data) {
|
|
18
|
+
bare_gtk_state_t *state = data;
|
|
19
|
+
|
|
20
|
+
if ((bare_gtk__observed(state, clock) & bare_gtk_frame_clock_event_update) == 0) return;
|
|
21
|
+
|
|
22
|
+
bare_gtk__emit(state, clock, "update", 0, NULL);
|
|
23
|
+
}
|
|
24
|
+
|
|
15
25
|
static void
|
|
16
26
|
bare_gtk_frame_clock__on_after_paint(GdkFrameClock *clock, gpointer data) {
|
|
17
27
|
bare_gtk_state_t *state = data;
|
|
@@ -46,6 +56,7 @@ bare_gtk_frame_clock_event_mask(js_env_t *env, js_callback_info_t *info) {
|
|
|
46
56
|
|
|
47
57
|
if (bare_gtk__observe(state, clock, events)) {
|
|
48
58
|
g_signal_connect(clock, "after-paint", G_CALLBACK(bare_gtk_frame_clock__on_after_paint), state);
|
|
59
|
+
g_signal_connect(clock, "update", G_CALLBACK(bare_gtk_frame_clock__on_update), state);
|
|
49
60
|
}
|
|
50
61
|
|
|
51
62
|
return NULL;
|
package/lib/frame-clock.js
CHANGED
|
@@ -3,7 +3,8 @@ const GObject = require('./object')
|
|
|
3
3
|
|
|
4
4
|
module.exports = exports = class GDKFrameClock extends GObject {
|
|
5
5
|
static _events = {
|
|
6
|
-
'after-paint': binding.FRAME_CLOCK_EVENT_AFTER_PAINT
|
|
6
|
+
'after-paint': binding.FRAME_CLOCK_EVENT_AFTER_PAINT,
|
|
7
|
+
update: binding.FRAME_CLOCK_EVENT_UPDATE
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
_eventMask(mask) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-gtk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "GTK bindings and runtime for Bare",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package": "./package.json",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"format": "prettier --write . && lunte --fix",
|
|
30
30
|
"lint": "prettier --check . && lunte",
|
|
31
|
-
"test": "
|
|
31
|
+
"test": "bare-native-test --runtime bare-gtk/runtime test.js"
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|
|
@@ -48,7 +48,10 @@
|
|
|
48
48
|
"bare-build": "^1.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"
|
|
51
|
+
"bare-animation-frame": "^0.1.0",
|
|
52
|
+
"bare-gtk": "file:.",
|
|
53
|
+
"bare-native-test": "^0.1.0",
|
|
54
|
+
"bare-tap": "^1.1.0",
|
|
52
55
|
"cmake-bare": "^1.6.5",
|
|
53
56
|
"cmake-fetch": "^1.4.0",
|
|
54
57
|
"lunte": "^1.8.0",
|
|
Binary file
|
package/prebuilds/linux-x64/bare
CHANGED
|
Binary file
|