Moon-0xff / gnome-mpris-label

A music related GNOME extension.
GNU General Public License v3.0
51 stars 10 forks source link

Implement Menu for player selection #23

Closed Batwam closed 1 year ago

Batwam commented 1 year ago

as per item 4 in Development Roadmap #4 , this is a working version to implement a menu selection for the active player.

Todo List:

known issue:

Auto Selection Mode: tick for Auto, dot to indicate active source. sources in italic to indicate that they are listed for info only image Manual Selection Mode: tick mark for selected source image

Batwam commented 1 year ago

See current version and roadmap above. Feel free to provide any comments/pointer. I have now managed to get the menu to indicate the playing source. Next step is to work on the actions connected to each item. (Edit, I have now also implemented the source switching upon item selection...)

For example, I can read this.settings.get_boolean('auto-switch-to-most-recent') but what's the easiest way to change the value to true/false?

also, I'm implemented a bunch of functions into players.js which we could probably do without but for some reason, I can't really get this to work without it... Feel free to review/clean if you see a better way of implementing this.

Moon-0xff commented 1 year ago

I pushed my changes, i didn't really changed the implementation, just switched how the values are accessed. Inspect the commits for more details. I also removed a lot of the comments, for brevity.

I also connected the auto-switch button to the setting, the auto-switch prevents changing the source manually.

Regarding compatibility, the dot appears now on 3.38, along with the italics and the check.

Batwam commented 1 year ago

That's excellent, thanks!

I have also updated the todo list at the top with some design decisions we might need to make (e.g. saving selected player) feel free to review/add/remove as you see fit or comment here.

Batwam commented 1 year ago

Ah, I was working on this but my github personal token expired! At least it shows we are on the same page. I had some other changes too so I'll try to push that once I've figured out how to update my credentials!

Moon-0xff commented 1 year ago

It should only be a matter of deleting the key from your github account, deleting the expired keys from your .ssh folder, and generating a new key pair

Batwam commented 1 year ago

It should only be a matter of deleting the key from your github account, deleting the expired keys from your .ssh folder, and generating a new key pair

yeah, I had the new token but still needed to re-register it with git remote set-url origin https://user:key@...

Batwam commented 1 year ago

alright, see commit above. I have added grey colour to the source names when in Auto mode. This still allow selection for direct switch to Manual mode without having to disable Auto_Switch first. (Decided to only change colour to grey to allow direct selection rather than set as settingsMenuItem.sensitive = false). I was tempted to make them non-sensitive but selecting a specific source would have required to first untick Switch Automatically and then go back to select the source which I felt was a bit cumbersome.

The colour is hard coded grey and I would have preferred system colour but I checked with Light mode and it looks fine. image

Moon-0xff commented 1 year ago

It looks good but i wonder if we can get the color from the theme, as if someone has a custom theme installed it might blend with the background.

Also, line 138 to 142 are repeated statements.

Batwam commented 1 year ago

Thanks for that, there were some merge conflicts as I merged my changes into yours since they overlapped and it looks like I forgot to clean that part out.

Yeah, there is probably a neater way to call the colour actually recommended by the theme, I'll add this to the todo list. I had a look on this page and just tried settingsMenuItem.set_style('style_class:popup-inactive-menu-item') but that didn't work.

Moon-0xff commented 1 year ago

I had a look on this page And insensitive_fg_color might be the one to use. I don't know how to add it to the style though.

Custom styles should have the same name i suppose.

Batwam commented 1 year ago

Yeah, custom themes should have consistent naming. If they are missing there is hopefully some sort of built-in fallback mechanism. Now the challenge is to find how to make use of either this colour, or the style it is included in.

I think that referencing a style might be preferable in case a theme used a different colour than the standard one but let's see what we can get to work and we can take it from there...

Moon-0xff commented 1 year ago

I did some detective work on the gnome-shell source code and learned some things. In a nutshell:

We can, however, get the foreground and background color and mix them in our own, so I did just that.

note: I pushed commits with wrong user.name and email (twice) so i had to force-push 😅

Batwam commented 1 year ago

Nice one, i also did an excessive amount of research on this and did notice yesterday that the colour was actually made of a mix of bg and fg colour $insensitive_fg_color: mix($fg_color, $bg_color, 50%); from the colors.scss file so even if we are not pulling insensitive_fg_color directly, your method would be consistent with the standard method.

Seems like this is as good as it's going to get!

Batwam commented 1 year ago

ok, I had a look at 2 of the 3 outstanding actions and don't think that they need to be addressed:

This basically leaves us with the last step which it to let things settle down for a while and see if we encounter any issues.

I haven't had any so far. In fact, it works quite nicely. I was playing around with the filters to test what it would do and since we are refreshing everything on each iteration as soon as the filter is removed, next time I click, the sources re-appears in the greyed out source list without any need to close the Settings window or reload the extension.

Batwam commented 1 year ago

quick one. I know that this is out of scope but is there any chance I could slip in some code to remove the "(feat. ...)" and other "Featuring ...)" texts in the label which take too much room and drive me mad? I'd add this as an extra option under the one for Remaster..

Moved to #24

Moon-0xff commented 1 year ago

Sure, but submit a new PR for that, as this one is almost ready to be merged into main

Regarding the leftover actions, i agree with your thoughts.

Batwam commented 1 year ago

No worries, I'll park this for now.

Moon-0xff commented 1 year ago

I tried to connect the new method to an event, but it looks like there isn't an event for "color scheme changes", I also learned that the foreground and background colors changes depending of where or when in the code we get the theme node.

I would say we are done now, so if you agree i will merge it.

Batwam commented 1 year ago

look fine to me. I just had to remove a leftover log statement.

I just pulled the latest change and it's working. Did you re-test on gnome 3.38 considering the recent colour hack?

Moon-0xff commented 1 year ago

I develop the extension on GNOME 3.38 so the question should be about 3.36

Moon-0xff commented 1 year ago

Well, we are done here, regarding 3.36 let's test it when we are ready for release.

Batwam commented 1 year ago

I just fired up the old laptop with Ubuntu 20.04 (Gnome 3.36.8) and everything is working as expected 👍

By the way, the vlc icon shows up too.

Batwam commented 1 year ago

One last thing, will you be taking care of the changelog update?

Once uploaded, you should probably also update the screenshot (or add a new screenshot) to show the menu and maybe also the settings menu if EGO allows multiple screenshots?

Moon-0xff commented 1 year ago

Updating the changelog is a trivial change, regarding the screenshot, i would like to change it for a GIF showcasing the extension, but on my end that would be quite tedious to do.

Batwam commented 1 year ago

I can give it a go. I'll revert back to the normal Gnome layout with panel at the top for it. What do you want to show?

Screencast from 2023-02-01 10-56-23

PS: for some reason, the screengrab doesn't show the mouse. This seems to be a reported bug.... I guess it's still ok, even without it.

Moon-0xff commented 1 year ago

I would say it's important that the mouse pointer is shown, also that the resolution is high so the text doesn't look strangely multicolor.

I want to show the extension changing between 3 different sources, showcasing that:

  1. The extension supports multiple players
  2. You can select between players running simultaneously
  3. The icon support
  4. Missing/empty fields are simply not displayed

If you leave the controllers of a player in shot you might be able to showcase something else, but the idea is to keep it short.

Batwam commented 1 year ago

Ok, I'll see what I can do. I'm not sure what's going on with the pointer. I tried on X11 and Wayland and it's the same. Others seem to be having similar issues... i might need to try another app than the default one.

For the resolution, I'll check what I get if I do a video of the entire screen. If I zoom in on 10% of my screen, it makes sense that the resolution would be low as it would be 10% of my screen res and I don't have a high DPI display. By the way, is there a resolution limit for the EGO screenshot/screencast?

Moon-0xff commented 1 year ago

There's definitely a size limit (in mb)