I am getting state using:
let state = global.get_persistent_state('n', 'align_windows_state');
if (state === null) {
state = 0;
}
I am setting state using:
global.set_persistent_state('align_windows_state', new GLib.Variant.new_int16(state + 1));
however, state always return 0.
Why is this happening?
andyholmes
(Andy Holmes)
August 10, 2023, 10:02pm
2
try {
const v = new GLib.Variant.new_int16(0);
} catch (e) {
// TypeError: GLib.Variant.new_int16 is not a constructor
console.log(e.message);
}
Either use new GLib.Variant('n', 0)
or GLib.Variant.new_int16(0)
.
2 Likes
For future reference, the code that is working:
let state = global.get_persistent_state('n', 'align_windows_state').get_int16();
if ( state === null ) {
state = 0;
}
log(`state: ${state}`);
global.set_persistent_state('align_windows_state', GLib.Variant.new_int16(state+1));
2 Likes
@andyholmes Thank you very much.
2 Likes
system
(system)
Closed
September 9, 2023, 11:34pm
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.