Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: the gtk stack widget bugfix #1119

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

ovalkonia
Copy link

@ovalkonia ovalkonia commented Jun 18, 2024

Description

The stack widget was essentially useless, since the :selected property had no effect and resulted in a warning stating that a child with the given name wasn't found. This exact issue has already been described here -> #1116.

I faced this problem trying to implement a clock that would change the format of the output on request. Also, I searched for configurations from other users that use this widget, but to no avail. It's as if nobody ever used it or something. Take a look at the following screenshot showing minimal configuration:
1718663452
As you can see, there's a warning and instead of the expected "1st", it shows "0th". It was tested under both Xorg and Wayland with the latest stable version of Eww from both github and AUR.

Looking at the code managing this widget, it appears that gtk_widget.set_visible_child_name(&selected.to_string()); gets called before any of the actual children in the following match statement get added, which results in unexpected behaviour (easier to just check the diff).

Fixes #1116

Usage

N/A

Showcase

Here is that same minimal configuration from before, but this time using the fixed version:
1718667805
No warnings and it shows "1st", just as expected!

Additional Notes

The very fact that this issue had gone unnoticed for almost four months seems reeeeeally weird to me, so maybe I'm just a dumbass. I have no idea how the stack widget worked in the showcase when it was added, since it seems like the issue was there from the very beginning. Anyway, let me know what you think!

P. S. Alright, it does work, but only after the variable fed to the :selected property gets updated, and it makes sense. At the time of updating the variable, all the children are already there, so it makes sense how it worked in the showcase and this widget is, in fact, not useless, that's my bad. Although, this is still a bug, and needs to be fixed

Checklist

Please make sure you can check all the boxes that apply to this PR.

  • All widgets I've added are correctly documented.
  • I added my changes to CHANGELOG.md, if appropriate.
  • The documentation in the docs/content/main directory has been adjusted to reflect my changes.
  • I used cargo fmt to automatically format all code before committing

@ovalkonia ovalkonia marked this pull request as draft June 18, 2024 00:30
@ovalkonia ovalkonia marked this pull request as ready for review June 18, 2024 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Can't control selected Stack Child using :selected
1 participant