Re: Can I mix Xlib and Gtk+ in one app?



 Ingo Krabbe wrote:


On Mon, 17 Dec 2001, Paul Davis wrote:

I'm writing an app using xlib, but I need some buttons and menus.

you should use a proper toolkit. nobody uses xlib on its own these days
unless they are themselves writing a toolkit.


I'm interested in this topic too. It would be nice to write some modules
which aren't specified as gtk widgets or other gtk objects. Assume you
write an application with a proprietary internet protocol. You surely want
to open this protocol to any toolkit. So we need a mixed event handling,
one for our module and one for lets say a gtk application.

X isn't far away from such a network event handler since you can even
select on the filedescriptor to the X-Server in Xlib.

Can I mix my own event loop (while(true) { XNextEvent(Display *,
XEvent*); switch(event.type) ...})
with Gtk+'s main loop?

No.


Aren't there functions in gtk which, like XNextEvent select exactly one event
from the gtk event loop and dispatch it ? Of course we have to care about gtk
not catching our events. Shouldn't that be easy to distinguish by opening the
DISPLAY two times ? That may not be very, optimized but shouldn't it work ?
I will surely track this problem down the next months.

	   Can I mix bare Xlib Window  with Gtk+ widgets?

Sometimes, but its not easy and there are many pitfalls.

--p


So lets try it:

	init gtk ... create some widgets ...
	init Xlib Display ... create some windows ...
	while ( !exit_application )
	{
		Try first event source ... handle and dispatch events
		Try second event source ... and so on ...
	}

Why shouldn't this work ? The two parts don't hurt each other ?

CU INGO




Hi,

Thank you all for advance. Basically, I'd like to see that gtk+ is friendly to bare Xlib. (like Motif?). But I don't have a clear idea for now, because I'm actually not familiar with gtk+. Well, I'll try to play with it.
Davix





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