NewCaw icon indicating copy to clipboard operation
NewCaw copied to clipboard

MediaDisplay not focusing the right item

Open CodedOre opened this issue 3 years ago • 6 comments

In an ideal case MediaDisplay should initially display the item that was selected in the preview, by scrolling the used Adw.Carousel to the focused position.

However, for some reason it does not, always displaying the first media instead.

Noting this here as I don't know where exactly the bug is and as it is not a priority now, but would be glad if someone else with the time can debug this.

CodedOre avatar Jan 05 '22 15:01 CodedOre

This seems to be an issue in libadwaita.

CodedOre avatar Apr 12 '22 13:04 CodedOre

Had a quick poke and it isn't even working in the realize signal, so it's not just a constructor issue. I added this to the constructor and still see item 1:

    carousel.realize.connect_after (() => {
      print("Realized carousel - setting scroll\n");
      var widget = (Gtk.Label)carousel.get_nth_page (2);
      print("Widget text: %s\n", widget.label);
      carousel.scroll_to (widget, false);
    });

Turning the labels into buttons and putting it on the clicked signal works, though. Odd.

(Also, it took me far longer than it should to work out how to change the carousel! I tried clicking the bars, up and down arrows, left and right arrows, page up and page down…)

IBBoard avatar Apr 12 '22 19:04 IBBoard

this.show and carousel.map aren't working either. Even with connect_after. Surely they're late enough in the process that it can change the page?!

IBBoard avatar Apr 12 '22 19:04 IBBoard

Ahah! Added this:

    carousel.page_changed.connect ((page) => {
      print(@"Carousel changes to page $(page)\n");
    });

And get this:

Realized carousel - setting scroll
Widget text: Item 3
Carousel changes to page 0
Mapping carousel
Mapping carousel - setting scroll
Widget text: Item 3
Carousel changes to page 0

So it is trying to swap but getting page 0 each time. Which is odd, because I'm getting its Nth page and should get a valid object!

IBBoard avatar Apr 12 '22 19:04 IBBoard

@Exalm has mentioned on Matrix that scroll_to might only work after Adw.Carousel is allocated. My guess is it might have to do with Adw.Animation being used for scrolling...

That thing is pretty sure an upstream issue.

CodedOre avatar Apr 12 '22 19:04 CodedOre

I need to find a description of the GTK widget cycle. The class docs assume so much internal knowledge. I've never known where half of these events fit. The description for realize made it sound like it was basically the end of the process.

IBBoard avatar Apr 12 '22 19:04 IBBoard