hellomouse / gnome-shell-extensions-mediaplayer

A mediaplayer indicator for GNOME Shell versions that support ES6
https://extensions.gnome.org/extension/2102/media-player-indicator/
GNU General Public License v2.0
11 stars 4 forks source link

Not compatible with 3.34 #1

Open bdaase opened 5 years ago

bdaase commented 5 years ago

When you try to enable this extension running gnome-shell 3.34 the extension does not work and you always get

Sep 16 13:13:41 xps-9370 gnome-shell[1578]: JS ERROR: TypeError: this.hidePlayStatusIcon is not a function
                                            PlayerUI@/home/bjoern/.local/share/gnome-shell/extensions/mediaplayer@hellomouse.net/extension.js:2516:5
                                            ./src/manager.js/_addPlayer/this._addPlayerTimeOutIds[busName]<@/home/bjoern/.local/share/gnome-shell/extensions/mediaplayer@hellomouse.net/extension.js:768:18
iczero commented 5 years ago

Sorry for being late. Are there any other related errors or warnings in the log related to the extension? I am not sure why this breakage happened between versions. As I currently do not have gnome-shell 3.34, I am not able to test it.

mlmilliman commented 5 years ago

Ubuntu 19.10 is out that includes GNOME 3.34.1 so you should be able to test your extension. It actually runs so much better than 3.32 and almost everything I use is compatible with it except for this and another extension.

iczero commented 5 years ago

OK. So this is actually apparently a really big problem that I have no clue how to fix besides rewriting a bunch of the classes to not use inheritance.

In src/widget.js, the class PlayerMenu is declared as:

export class PlayerMenu extends PopupMenu.PopupSubMenuMenuItem { ... }

where PopupMenu comes from imports.ui.popupMenu.

Now let's construct the class in question:

(new (imports['mediaplayer@hellomouse.net'].extension.extension.require('./src/widget.js').PlayerMenu)('', true))

The method hidePlayStatusIcon can be found in PlayerMenu.prototype. However, after constructing the class, we find that it is gone. It's not in .constructor.prototype either. Upon further inspection, it can be seen that said object is actually an instance of PopupSubMenuMenuItem, instead of a PlayerMenu, as would be expected, which would explain why hidePlayStatusIcon and other PlayerMenu methods are gone.

Assuming gjs or gnome-shell or something in the middle just really doesn't like es6 classes, I attempted to get webpack to dumb down the code to es5 using babel. Except PopupSubMenuMenuItem cannot be constructed without new, and babel transpiles construction to:

_possibleConstructorReturn(this, _getPrototypeOf(PlayerUI).call(this, '', true));

I do not understand why this happens, and I cannot fix it, at least without a significant amount of work. Considering that it worked before, it might be a bug in gjs.

I apologize.

iczero commented 5 years ago

Simplest test case:

class Test extends imports.ui.popupMenu.PopupSubMenuMenuItem {
  method1() {
    return true;
  }
}
let a = new Test('', true);
a.method1();

Output:

TypeError: a.method1 is not a function
iczero commented 5 years ago

Never mind, It's something to do with GObject which I know next to nothing about.

Edit: and there appears to be almost no documentation about GObjects in gjs either ... or the rest of gnome-shell

glitsj16 commented 5 years ago

Edit: and there appears to be almost no documentation about GObjects in gjs either ... or the rest of gnome-shell

https://developer.gnome.org/gobject/stable/

bdaase commented 5 years ago

Otherwise, maybe https://discourse.gnome.org/ could help

iczero commented 5 years ago

@glitsj16 That's for GObjects in C. Nothing there pertains to gjs or javascript at all.

webmastak commented 5 years ago

Maybe this will could help you: API PopupMenu, popupMenu.js

tiboroche commented 4 years ago

I think this issue relates to the problem you are dealing with : https://gitlab.gnome.org/GNOME/gnome-shell/issues/1069

You need to modify the inheritance of your classes.

webmastak commented 4 years ago

It seems that the author abandoned the fork.

Silarn commented 4 years ago

I have some experience with converting extensions lately. I'll try to look at this when I have some time.