Skip to content

Commit

Permalink
indicatorStatusIcon: add polyfill for versionCheck in GNOME 40
Browse files Browse the repository at this point in the history
  • Loading branch information
3v1n0 committed Mar 26, 2021
1 parent 6108cf7 commit 5ce5c54
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
3 changes: 1 addition & 2 deletions indicatorStatusIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const Main = imports.ui.main;
const Panel = imports.ui.panel;
const PanelMenu = imports.ui.panelMenu;

const Config = imports.misc.config;
const ExtensionUtils = imports.misc.extensionUtils;
const Extension = ExtensionUtils.getCurrentExtension();

Expand Down Expand Up @@ -73,7 +72,7 @@ class AppIndicatorsIndicatorStatusIcon extends PanelMenu.Button {
if (label) {
if (!this._label || !this._labelBin) {
this._labelBin = new St.Bin({
y_align: ExtensionUtils.versionCheck(['3.34'], Config.PACKAGE_VERSION)
y_align: Util.versionCheck(['3.34'])
? St.Align.MIDDLE : Clutter.ActorAlign.CENTER,
});
this._label = new St.Label();
Expand Down
25 changes: 23 additions & 2 deletions util.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@

/* exported refreshPropertyOnProxy, getUniqueBusName, getBusNames,
introspectBusObject, dbusNodeImplementsInterfaces, waitForStartupCompletion,
connectSmart, BUS_ADDRESS_REGEX */
connectSmart, versionCheck, BUS_ADDRESS_REGEX */

const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const Main = imports.ui.main;
const GObject = imports.gi.GObject;
const Extension = imports.misc.extensionUtils.getCurrentExtension();

const Config = imports.misc.config;
const ExtensionUtils = imports.misc.extensionUtils;
const Extension = ExtensionUtils.getCurrentExtension();
const Params = imports.misc.params;
const PromiseUtils = Extension.imports.promiseUtils;
const Signals = imports.signals;
Expand Down Expand Up @@ -344,3 +347,21 @@ var Logger = class AppIndicatorsLogger {
Logger._logStructured(GLib.LogLevelFlags.LEVEL_CRITICAL, message);
}
};

function versionCheck(required) {
if (ExtensionUtils.versionCheck instanceof Function)
return ExtensionUtils.versionCheck(required, Config.PACKAGE_VERSION);

const current = Config.PACKAGE_VERSION;
let currentArray = current.split('.');
let major = currentArray[0];
let minor = currentArray[1];
for (let i = 0; i < required.length; i++) {
let requiredArray = required[i].split('.');
if (requiredArray[0] === major &&
(requiredArray[1] === undefined && isFinite(minor) ||
requiredArray[1] === minor))
return true;
}
return false;
}

0 comments on commit 5ce5c54

Please sign in to comment.