Re: How to reparent GtkSocket?



Andy Stewart <lazycat manatee gmail com> writes:

> 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:
> (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
>
> After many times warning, i will got below error:
> (Socket:9812): Gtk-CRITICAL **: gtk_widget_get_display: assertion `GTK_IS_WIDGET (widget)' failed
>
> 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) ?
For current situation of Gtk+, haven't explicit mechanism for reparent
GtkSocket or unplug GtkPlug. 

In my case, I want re-use GtkPlug when do split-window action, because
I don't want lost GtkPlug state when i do split action.

I think a better solution to around above problems:

The point of split action is "keep widget status", and not keep GtkPlug
status, because GtkPlug just container that contain real widget.
Why not reparent child widget from *old* GtkPlug to *new* GtkPlug?

So for my case, perfect solution is create new pair GtkSocket/GtkPlug
when i need split action, and move child widget to new GtkPlug.

Please let me know if you have better solution or suggestion!

Cheers,

  -- Andy



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