maweki / twitchlive-extension

TwitchLive-Panel Gnome Shell Extension displaying your favorite streamers
GNU General Public License v3.0
39 stars 8 forks source link

Use streamers' icons ? #2

Closed RaphaelRochet closed 8 years ago

RaphaelRochet commented 8 years ago

Hi, do you think we could add streamers' icons in the menu ? I'd love also to show all active streamers' icons instead of the number !

maweki commented 8 years ago

That's a great idea. It might take a week or two though.

I think I'd rework the Extension that you can choose between three display modes (number, all, cycle) and for all/cycle you can decide between icon only, name only or both.

And the icon in the streamer list view is a good idea anyways.

maweki commented 8 years ago

For posterity and because of lack of any documentation besides arcane knowledge handed down from extension to extension:

(2016-05-08 21:32:23) maweki: is there a widget like St.Icon that can hold custom images (jpeg) in the top panel of the gnome-shell? (2016-05-08 21:33:43) maweki: or can I (ab)use St.Icon to show custom images? (2016-05-08 21:37:14) ebassi: maweki: You could use a Clutter.Actor with a Clutter.Image content, and load the image data using GdkPixbuf. (2016-05-08 21:37:39) ebassi: maweki: You could also use St.TextureCache

RaphaelRochet commented 8 years ago

I would try to stick with St.Icon and create a custom icons subfolder, where I'd cache streamers' icons, named with some prefix to be sure not to create any confusion with system icons. Icons being Jpeg, PNG or even Gif should not be a problem.

maweki commented 8 years ago

That was my first idea as well.

But how does one change the folder St.Icon does icon-lookup?

RaphaelRochet commented 8 years ago

You can add a path where Gtk will look for icons :

const Gtk = imports.gi.Gtk;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
Gtk.IconTheme.get_default().append_search_path(Me.dir.get_child('icons').get_path());
maweki commented 8 years ago

Are you sure this works with jpegs? I don't seem to get it to work. Is there any special naming scheme?

I've put a sample jpeg into /tmp/icons, added /tmp/icons to the search path and set 'sample' as icon_name and no Icon is being shown.

RaphaelRochet commented 8 years ago

Did a little research : only "png" bitmap format is supported (along with "svg", and "xpm"). Still, we can continue that way and depend on third-party package like convert (imagemagick) to make PNG's out of jpegs. Or go the GDK way. Never tried that thought. But sounds like the right way.

maweki commented 8 years ago

Quite a few Streamer Icons seem already to be pngs. So St.Icon would be the easiest, given that we also can just add a fallback-icon and we're good, and we use convert if neccessary and possible. I think I will have finished some prototype by tomorrow.

maweki commented 8 years ago

I've added basic support now, lacking error/sanity checking. Feedback welcome :)

RaphaelRochet commented 8 years ago

Looks nice. capture Can you prevent streamer name and viewer count to be ellipsized ? ( Maybe something like StLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE; )

maweki commented 8 years ago

It should never be ellipsized. The algorithm is to let them all layout/fill their labels and then retrieve the max of the widths and apply it to all. This is very strange behaviour.

maweki commented 8 years ago

I fixed a possible race condition that might have been responsible, even though I am not sure about this behaviour. As far as I can see it, the code does not allow for stuff to be ellipsized because we only once set widths and that was obtained via Math.max

RaphaelRochet commented 8 years ago

Still not good : capture d ecran de 2016-05-10 23-10-23

maweki commented 8 years ago

Can you add

.streamer-menuitem {
  border: 1px solid #fff;
}

into your stylesheet.css and post a screenshot?

RaphaelRochet commented 8 years ago

Sure : capture d ecran de 2016-05-10 23-23-45

maweki commented 8 years ago

In which gnome-version are you living in arch-land?

RaphaelRochet commented 8 years ago

It's 3.20

maweki commented 8 years ago

I am trying to get a current Arch running in a VM but could you try add the rules

margin-left: 0; padding-left: 0; margin-right:0; padding-right: 0; and look whether that has any impact. It seems that the space inbetween the fields would be necessary to not ellipsize.

RaphaelRochet commented 8 years ago

That didn't change anything :(

RaphaelRochet commented 8 years ago

Hey, I was working on major code change and suddently : capture d ecran de 2016-05-12 10-52-18

maweki commented 8 years ago

This is ... strange. I am just getting my jhbuild up to date. Maybe running the newest gnome-shell with the newest clutter lets me reproduce it and I can bisect clutter maybe. But if you find the issue or a workaround in the extension's codebase, that would be fine as well.

RaphaelRochet commented 8 years ago

In fact, this was the promise.all().then() not working : all the size-related code wasn't run and the menu was adjusting itself.

maweki commented 8 years ago

Then it's either get_width reporting the wrong width, set_width setting the wrong width or both. That was the layouting idea, to let the labels layout themselves and get the maximum width over all of them and apply that across the board.

maweki commented 8 years ago

I might have solved the mystery. What's your font-scaling-factor in gnome-tweak-tool. Setting it to 1.10 results in the following:

bildschirmfoto von 2016-05-12 14-10-11

maweki commented 8 years ago

If this is indeed the issue, we have to read text-scaling-factor in org.gnome.desktop.interface and multiply that with the retrieved size. But I will also open an issue with clutter/investigate.

RaphaelRochet commented 8 years ago

Sorry, but by font-scaling factor is 1.00 ! However I do not use default font. capture d ecran de 2016-05-12 15-02-38

maweki commented 8 years ago

I think I might have fixed it.

RaphaelRochet commented 8 years ago

Example without and with apply sizes : capture d ecran de 2016-05-12 17-42-41 capture d ecran de 2016-05-12 17-41-52

You can see the missing space is quite huge for "..lator 2".

maweki commented 8 years ago

I just don't understand how any of the retrieved sizes could be so small that set_width leads to that behaviour. And why on your system but not on mine, even with the same clutter/gnome-shell version?

If you have the time, maybe you could log the reported and set sizes, and check if they compare to the actual sizes the Widgets are set to?

RaphaelRochet commented 8 years ago

The size reported by get_size_info (the highlight here) : test Edit : this is the max size reported, not individual sizes.

RaphaelRochet commented 8 years ago

I tried to log this._layout.game.get_width(); before adding the label to the boxlayout, and it returns the same; so it's definitely about the label not computing the right width.

maweki commented 8 years ago

Ok. I have not been able to reproduce it with jhbuild even with gnome-shell 3.20 and clutter 1.26 (which I assume you have). I'll do a release now with the icon support we have. I'll add a new issue to track the sizing problem down. It would be nice if you could add your Distribution, gnome-shell and clutter versions there.

maweki commented 8 years ago

We now have a framework in place to retrieve and show streamer icons. Everything else has to be done in #12