Re: Dialog Problem



I am new to the GTK. I created one dialog window and openining in my code. The execution should not go to the next line unitl the user close the Dialog. Is it possible in C?

I haven't yet had my morning coffee today, so I might very well be misinterpreting what you're asking, but I think you may have the wrong idea about the way programs built with gtk+ (and a lot of other graphical toolkits) work.

Normally, when you write a console-only application, your code starts at the beginning of main and executes each statement in turn -- this sequential execution controls the flow of your program. If your program prompts the user for input, the program will "stop executing" until the user types something in. Then it will go to the next line.

GTK+ programs, on the other hand, are user driven. You tell gtk how your user interface should look and what should happen when a user performs some action (clicks a button, opens a menu, etc...), and then you pass off control to gtk. Later, when gtk detects that the user performed some action, it calls a function you specified in your code to deal with it.

A typical console application might look like:

Put a prompt on the screen ("Please enter a line of text:")
Get a line of text from the console.
Do stuff with the text.

An equivalent gtk program might look like:

Tell gtk that there should be a window containing a text box and a button labeled ("Done") Tell gtk that when the user clicks the Done button, the function called getTextAndDoStuffWithIt() should be called. Define getTextAndDoStuffWithIt() to snag the contents of the text box and put it into variable X, and then tell gtk that the window should disappear.
Pass off control to gtk itself.

Running this program will create a window with a text box and a Done button. When the user enters some text and clicks Done, getTextAndDoStuffWithIt() will be called to do whatever is needed, but it will not be called before the user clicks Done.

In this sense, you can have the program "pause" (meaning wait for a user action) before going to the next "line" (meaning whatever code is executed in response to a user action).

There's a very helpful set of GTK+ tutorials (1.2 and 2.0) on gtk.org if you want to learn more of the basics. I'm still charging toward completion of my first real gtk application so I'm not an expert by any means, but I did find the "suggested exercises" section at the end of some lessons in the 2.0 tutorial to be a great (and fun!) way to practice new skills.

Hope that helps.

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail




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