Re: [gtk-list] GTK questions





On Mon, 7 Jul 1997, Chris Evans wrote:

> Being thoroughly convinced that GTK is a "Great Thing"(tm) etc., I've
> decided to write a decent music MIDI sequencing (+ maybe more)
> application, using GTK for the UI. Putting together simple (yet nice
> looking) dialogues doesn't cause me any trouble, but here are a few
> questions....

Sounds good. (But do take a look at helping out with the Rosegarden project
instead, which is a comprehensive music system, including MIDI sequencing.
They were at least considering switching to GTK at one point.)

> 1) What re-entrancy problems will I come up against? Specifically, once a
> callback is called (say a button), will pressing the button again start a
> second "thread" over the same code? Likewise, if a button press fires off
> some calculating code, will (say) a menu be able to start a different
> piece of code executing simultaneously?

There will be no concurrency unless you program it explicitlty. That is,
once a button is pressed, no further GUI processing will happen until
the callback returns. (This is normal for all toolkits I know.) If you
want background processing, you'll either have to use threads, (in which
case, you should probably make sure all GUI interaction occurs in one
thread, since GTK is not thread safe), or do your processing in chunks
in a idle procedure or timer callback.

> 2) What basic things do I need to set up to get a scrollable (horizontal
> and vertical) area in which I can scribble with basic drawing primitives
> (filled rectangle etc). Which signals do I need to respond to, to notice
> when the user scrolls or resizes the window?

You pretty much just need to create a drawing area, and attach to the
expose signal. If you need to know when the window size changes, you
can attach to configure events. (If you are drawing to a pixmap and
copying into your drawing area, this is useful). The IfsCompose plugin
might be a useful example of some code that handles this type of
stuff, though it's not completely simple. 

> 3) I tried making a gtk_drawing_area, and drawing a black filled rectangle
> in it with gdk_draw_rectangle (or similar). No output was visible. Do I
> have to "flush" drawing commands like I would have to with the
> corresponding raw X calls? Is a drawing area used for what it sounds like,
> a generic size of window in which to scribble?

I'm not sure exactly what you're doing, but one problem you might
be having is that calling drawing functions before the window is created
won't give you any output. (and should give you some errors.) If 
you do all your drawing in an expose callback, this won't be a problem.

Good luck,
                                       Owen




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