nls1729 / acme-code

Gnome Shell Extensions etc...
https://nls1729.github.io
GNU General Public License v2.0
66 stars 25 forks source link

Gobject will not work below version 3.32 #52

Closed cinatic closed 5 years ago

cinatic commented 5 years ago

i just figured out that https://github.com/nls1729/acme-code/blob/7ef2b63675fa2499df7a466835f443ce5bd4dbce/extension-reloader/extension.js#L116

will fail for version < 3.32, it looks like something like this would work:

function getAsGObject(classObject) {
    if (ExtensionUtils.versionCheck(['3.32'], Config.PACKAGE_VERSION)) {
        return new GObject.registerClass(classObject)();
    } else {
        return new classObject();
    }
}
nls1729 commented 5 years ago

Javascript does not provide an ifdef feature like some other languages (C being a good example). Your suggestion has one problem. The code that is declared for the GObject.register is different from the javascript class which would otherwise be returned. The GObject.register code uses initialization; whereas, the code for the javascript class uses a constructor. You can use version checking in functions and methods but there is no way to modify a class declaration with some logical construct. See https://github.com/nls1729/acme-code/commit/85f7edf4f1745e7e2bf601b47565ef372bee6d7c which shows the different methods of instantiation. I try to maintain compatibility for mulitiple Gnome Shell releases in the same extenions version, but sometimes a new release does things which make it impracticule. Version 8 of the extension supports GS3.30 and is available at extensions.gnome.org.

cinatic commented 5 years ago

thanks for the explanation, I was not aware that there are more other es6 things not supported. The only way i can imagine might work is to have a shared code and a version specific code. But I am sure this is way too much effort just for supporting older shell Versions

Best regards and thanks for this nice extension