Search code examples
cgtk3glade

How to clone GtkWindow with its content?


I am using C and Glade with GTK 3. I want to create a simple programming language. I created the basics: code editor, output window etc. But when the user closes the output window, and tries to re-open, this message shows:

(ltc:3443): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GObject'
(ltc:3443): GLib-GObject-CRITICAL **: g_object_class_list_properties: assertion 'G_IS_OBJECT_CLASS (class)' failed

I think the problem is caused by that when the user closes the window, its structure also gets destroyed on the memory.

How do I clone the window? I tried the simple GObject cloning algorithm, but it doesn't clone window content.

Is it possible to make the window not get destroyed when closing or clone it?


Solution

  • Probably what you want, instead of cloning the window, is to make sure that it is not destroyed when closed, and instead hidden.

    Try connecting to the delete-event signal and using gtk_widget_hide_on_delete() as the signal handler, or calling it in your signal handler.