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
62
63
64
65
66
67
68
69
70
71
|
From 3a2d558aa575f0ea364c5b4e30d2eb3ee604ee58 Mon Sep 17 00:00:00 2001
From: Michael Webster <miketwebster@gmail.com>
Date: Thu, 11 Jun 2026 16:02:16 -0400
Subject: [PATCH] util.js: Adapt to GIR 2.0 (missed this bit in 3fc658559b).
---
js/misc/util.js | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/js/misc/util.js b/js/misc/util.js
index 883bba6a2b..3e92f93250 100644
--- a/js/misc/util.js
+++ b/js/misc/util.js
@@ -18,6 +18,7 @@ const Clutter = imports.gi.Clutter;
const Mainloop = imports.mainloop;
const Main = imports.ui.main;
const Params = imports.misc.params;
+const Config = imports.misc.config;
const WIGGLE_OFFSET = 6;
const WIGGLE_DURATION = 65;
@@ -600,13 +601,33 @@ function toFastProperties(obj) {
const READWRITE = GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE;
+function _girObjectInfoNProperties(info) {
+ return Config.USE_GIR20 ? info.get_n_properties() : Gir.object_info_get_n_properties(info);
+}
+
+function _girObjectInfoProperty(info, i) {
+ return Config.USE_GIR20 ? info.get_property(i) : Gir.object_info_get_property(info, i);
+}
+
+function _girPropertyInfoFlags(propertyInfo) {
+ return Config.USE_GIR20 ? propertyInfo.get_flags() : Gir.property_info_get_flags(propertyInfo);
+}
+
+function _girObjectInfoParent(info) {
+ return Config.USE_GIR20 ? info.get_parent() : Gir.object_info_get_parent(info);
+}
+
+function _girRepositoryDefault() {
+ return Config.USE_GIR20 ? Gir.Repository.dup_default() : Gir.Repository.get_default();
+}
+
// Based on https://gist.github.com/ptomato/c4245c77d375022a43c5
function _getWritablePropertyNamesForObjectInfo(info) {
let propertyNames = [];
- let propertyCount = Gir.object_info_get_n_properties(info);
+ let propertyCount = _girObjectInfoNProperties(info);
for(let i = 0; i < propertyCount; i++) {
- let propertyInfo = Gir.object_info_get_property(info, i);
- let flags = Gir.property_info_get_flags(propertyInfo);
+ let propertyInfo = _girObjectInfoProperty(info, i);
+ let flags = _girPropertyInfoFlags(propertyInfo);
if ((flags & READWRITE) == READWRITE) {
propertyNames.push(propertyInfo.get_name());
@@ -622,10 +643,10 @@ function _getWritablePropertyNamesForObjectInfo(info) {
* Returns (object): JS representation of the passed GObject
*/
function getGObjectPropertyValues(obj, r = 0) {
- let repository = Gir.Repository.get_default();
+ let repository = _girRepositoryDefault();
let baseInfo = repository.find_by_gtype(obj.constructor.$gtype);
let propertyNames = [];
- for (let info = baseInfo; info !== null; info = Gir.object_info_get_parent(info)) {
+ for (let info = baseInfo; info !== null; info = _girObjectInfoParent(info)) {
propertyNames = [...propertyNames, ..._getWritablePropertyNamesForObjectInfo(info)];
}
if (r > 0 && propertyNames.length === 0) {
|