How to reparent GtkSocket?



Hi all,

I develop a Gtk+ program that use two processes: A and B, A for GtkSocket, and
B for GtkPlug.

In A process, i add notebook in top-level window.
Everytime, B create new GtkPlug, i will send PlugId to process A, and
create new GtkSocket tab in notebook.
Works well.

For some situation, such as Split-Window action, i need create two
notebooks.
So i need reparent GtkSocket from one notebook to another notebook.

But i lost GtkPlug after reparent GtkSocket, i can't see anything in GtkSocket.

I have search this problem by Google.

Solution (1): 

And i found GtkPlug will destroy if GtkSocket remove from it's container.
We can return True in "delete-event" signal of GtkPlug, then GtkPlug
will hide when GtkSocket reparent, and create new GtkSocket add GtkPlug
again, but this solution not perfect.

Solution (2):

And i found another solution, use "gtk_socket_add_id" with *new* GtkSocket widget.

Example, under toplevel window have two Notebooks: NA and NB, i have
add GtkSocket in NA, and i want NB GtkSocket Tab "steal" GtkPlug from NA.

So i create new GtkSocket under NB, and use "gtk_socket_add_id" add PlugId
same as NA, looks works well.

But problem is, when i remove *old* GtkSocket under NA, will case
warning:
------------------------------> warning start <------------------------------
(Socket:30547): Gdk-WARNING **: /build/buildd/gtk+2.0-2.18.3/gdk/x11/gdkdrawable-x11.c:952 drawable is not a pixmap or window
------------------------------> warning end   <------------------------------

After many times warning, i will got below error:
------------------------------> erro start <------------------------------
(Socket:9812): Gtk-CRITICAL **: gtk_widget_get_display: assertion `GTK_IS_WIDGET (widget)' failed
------------------------------> erro end   <------------------------------

Then above error crash my GtkSocket process.
In my case, GtkSocket and GtkPlug running in separate processes always.

Have better solution than aboves solution?
Or someone tell me how to fix solution (2) ?

Thanks for your help!

  -- Andy







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]