If all you want is a popup, then you might as well create a new process
instead of a new thread. There is no advantage of using a thread as it does
not seem like you want to pass any info between the window and the
monitoring loop. Further, the way you described it, if more than one event
occurs, then you will be spawning two threads that does calls into GUI. This
is a big no-no as gtk is not multi-threaded, and only a single thread may do
graphics related calls.

Regards,
Dov

On Wed, Nov 24, 2010 at 15:01, Jaroslav Šmíd <jardas...@gmail.com> wrote:

> GTK is not smart toolkit and is unable to work without X display and is not
> even able to reconnect to different display (or to the same later) when the
> connection get lost. This is with all X based toolkits I know of - it just
> seems easier for developers to just call exit() then to install like timer
> to event loop which would try to reconnect. This way it works on Windows -
> GUI applications are able to work without GUI subsystem being active (e.g.
> when it crashes because of driver failure). When the GUI subsystem is
> restarted (either with the same driver or geeric vesa driver), GUI
> applications still works, because WindowsAPI takes care of this. GTK on
> X-based systems does not, even if that is not too much work (just catch X
> server error, discard all X id's for every top level windows, pixmaps, ...,
> and then when it gets reconnected, create them again and in the meanwhile
> use stubs).
>
>
> On 11/24/2010 03:41 AM, Champ Clark III [Softwink] wrote:
>
>>
>>        Hello all!
>>
>>        I have a multi-threaded application written in C that I'm a
>> bit stumped on.  It's not the 'multithreaded' portion of the code I'm
>> having issues with.  That seems to be functional.  It's the GTK error
>> and warning handling.
>>
>>        The application is constantly processing data (syslog).  When a
>> rule is 'satisfied',  a thread is spawned which builds a simple GTK
>> window (popup) with the information about the 'event.'   So far,  so
>> good.  However,  I'm not sure how to handle certain error events.  For
>> example,   let's say I'm sending 'popups' to a workstation across a
>> network.   The remote workstation goes off line (the user leaves,
>> powers it down, whatever).  My application,  of course,  won't be able
>> to send the GTK 'popup'.  I'll likely get the error:
>>
>> Gtk-WARNING **: cannot open display: 10.10.10.10:0.0
>>
>>        Here's my problem.   This error/warning causes termination of
>> the over all application.  Even though the 'error/warning' gets generated
>> from within my 'GTK thread',  it terminates the whole application.  That's
>> not good.   Is there any way I could intercept or use a callback with
>> the warnings/errors?  That is,  I'd like to log the warnings/errors,  but
>> I don't want termination of my software due to a GTK/X11 problem.
>> Basically,  some method to let me deal with the GTK/X11 errors the way I
>> see fit.
>>
>>        I hope this makes sense.  Let me know if you have any questions.
>>
>>
>>
>>
>> _______________________________________________
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>>
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to