How to hide widget instead removing them in GTK 4?

In GTK 3 app I use glade to create dialog at the start of application and I use same dialog until end.
Instead deleting and creating it every time, I hide it.
Until now I used hide_on_delete function which worked fine with dialog.run() method.

But there are 2 problems with this:

  • In GTK 4 there is no hide_on_delete methods
  • In GTK 3, hide_on_delete not works when using dialog.connect_response instead dialog.run()

How should I hide properly widget instead destroying it?
Creating this dialog on demand is not possible(at least for now)

Connect to the “response” signal, and if the response id is GTK_RESPONSE_DELETE_EVENT then call gtk_widget_hide().

In general, though, I would strongly recommend refactoring your code so that the dialog is created on demand and destroyed. It’ll keep your code easier to maintain.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.