Maybe I need to use threads. I've been using gtk_main_iteration_do() but having problems



To start, I'm using C++, Suse 10.1.

I'm writing programs that mostly do work without the user's interaction.
But I want to make a simple gui class to make simple gui's with limited
capability.  

Basically, I have some programs that don't have use gtk at all, and
already have their own structure and flow.  Then I want to add things
like this pseudo code:

MyClass plot;

while (something)
{
...
do something
...
    plot.SetImage(image);

    plot.MakePoint(x,y);

    plot.UpdateDisplay();
}

Simple right?  I don't want to call gtk_main in my class, because it
will relinquish control to gtk.  I want my display to update things, and
then give me back the control to do things.

What I tried to do, which works pretty well, is to set everything up
except I don't ever call gtk_main().  I instead call
gtk_main_iterations_do().  It mostly works well, except for a few
problems.

First is that the display doesn't do anything when my program is doing
it's thing.  So it looks like it freezes.  I'm okay with that.  I've
never used threads before, and I'm not sure this is the best project to
start with.  

Second is the most annoying part.  Since there is no loop,
gtk_main_quit() doesn't work, and when I click the little [X] in the
corner, the destruction begins, calls my WindowDestroyEvent that I set
up in the signals, but my program has no idea that the window has been
destroyed.  Then the program keeps making the same calls to gtk.  So gtk
spits out a bunch of messages about how everything is failing.  

Is there a way to check to see if the window has been destroyed?  I
could put a member boolean that changes when WindowDestroyEvent gets
called but that seems like a suspicious hack.  

Is there a better way to do this?  My guess is there are larger problems
for doing it this way.

Jeff



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