Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

No destroy function on Widgets #3

Open
PoSayDone opened this issue Mar 30, 2024 · 4 comments
Open

No destroy function on Widgets #3

PoSayDone opened this issue Mar 30, 2024 · 4 comments

Comments

@PoSayDone
Copy link

I'm trying to create a popup notification list, I can't handle widget destroy because there is no such function on the widget.

JS ERROR: TypeError: list.children.find(...).destroy is not a function
@PoSayDone
Copy link
Author

So, in GTK4 we should use unparent()

@PoSayDone
Copy link
Author

PoSayDone commented Mar 31, 2024

No, I'm still confused. I don't really understand how to properly destroy widgets.
I've tried:

const wdgt: Gtk.Widget = list.children.find((n) => n.attribute.id === id);
list?.remove(wdgt);
wdgt?.run_dispose();
const wdgt: Gtk.Widget = list.children.find((n) => n.attribute.id === id);
wdgt?.unparent();

It works somehow, but last appeared notification stays displayed.

recording.mp4

In addition, the box containing pop-up notifications does not shrink after children are destroyed

@PoSayDone PoSayDone reopened this Mar 31, 2024
@PoSayDone
Copy link
Author

PoSayDone commented Apr 2, 2024

I fixed the resizing problem by setting the defaultHeight: 1 option in WIndow, but the problem with the last ghost notification still exists. I can use Revealer to deal with this somehow, but there is some problem with it too, when the element is hidden, a couple of pixels remain visible. A couple of screenshots with an example:
the OSD at the bottom of the screen:
image
Notification:
image

@PoSayDone
Copy link
Author

Finally managed to figure out why this is happening.
The problem is that even if a container is sized (padding, margin, min-height) but it is fully transparent, this will happen when the last child is removed.
I can't explain the reason for this behavior, but as a solution you can make the widget as transparent as possible, like this: background: rgba(0, 0, 0, 0, 0.0039);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant