Skip to content

Commit

Permalink
Import GioUnix with "polyfill" for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Apr 6, 2024
1 parent fd57452 commit 340ba4c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
12 changes: 11 additions & 1 deletion installed-tests/fixtures/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@
'use strict';

const Gio = imports.gi.Gio;
const GioUnix = imports.gi.GioUnix;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;

const Config = imports.config;
const Core = imports.service.core;

// Retain compatibility with GLib < 2.80, which lacks GioUnix
let GioUnix;
try {
GioUnix = imports.gi.GioUnix;
} catch (e) {
GioUnix = {
InputStream: Gio.UnixInputStream,
OutputStream: Gio.UnixOutputStream,
};
}


/**
* TCP Port Constants
Expand Down
11 changes: 10 additions & 1 deletion src/service/backends/lan.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@
'use strict';

const Gio = imports.gi.Gio;
const GioUnix = imports.gi.GioUnix;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;

const Config = imports.config;
const Core = imports.service.core;

// Retain compatibility with GLib < 2.80, which lacks GioUnix
let GioUnix;
try {
GioUnix = imports.gi.GioUnix;
} catch (e) {
GioUnix = {
InputStream: Gio.UnixInputStream,
OutputStream: Gio.UnixOutputStream,
};
}

/**
* TCP Port Constants
Expand Down
12 changes: 11 additions & 1 deletion src/service/nativeMessagingHost.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ imports.gi.versions.GLib = '2.0';
imports.gi.versions.GObject = '2.0';

const Gio = imports.gi.Gio;
const GioUnix = imports.gi.GioUnix;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const System = imports.system;

// Retain compatibility with GLib < 2.80, which lacks GioUnix
let GioUnix;
try {
GioUnix = imports.gi.GioUnix;
} catch(e) {
GioUnix = {
InputStream: Gio.UnixInputStream,
OutputStream: Gio.UnixOutputStream,
};
}


const NativeMessagingHost = GObject.registerClass({
GTypeName: 'GSConnectNativeMessagingHost',
Expand Down

0 comments on commit 340ba4c

Please sign in to comment.