gtk questions




Hi,

    I've been developing an application using GTK+, and questioning
day has finally arrived.

First some background.  My app needs to place certain widgets on a
more-or-less infanitely sized window (dynamically sized might be a
better word), and allow the user to drag around those widgets as he
sees fit.  This is similar to how the windows explorer works when you
are exploring through files on a windows box, if you have had the
misfortune of using such a machine (I hear they do exist).

Anyway.  So I came across the "gtklayout" widget, which seems to be
well suited for what I do.  I built up some routines which let me
put an arbitrary widget on it, to drag them around, to remove them,
to query for positions, to do dynamic sizing, and all that jazz.

Now the fun part.  I also have to draw on this widget (the layout,
that is).  The layout does some weird trickery behind the scenes,
and I've discovered that I have to draw to the "bin_window" drawable
in the layout's structure, and not the actual widget->layout.  Ugh.
Also, I have to reposition my draw requests based on some offsets
stored in the layout.  As you can tell, I'm probably thoroughly
abusing this widget, and everyone is gonna tell me I will burn in
hell and my app will surely break on previous and future versions
of GTK+.

So all that works pretty well, so far, warts and all.  Now the
problem.  Sometimes the layout seems to shuffle around its bin_window
or do something that causes it to trigger a bunch of refresh operations.
The problem is, it doesn't always send me every refresh that happens
(I'm hooked into the expose event callback so I can refresh all the
things I've drawn on the gtklayout as appropriate).  So, occasionally
all the things I've drawn to the gtklayout disappear and I get no
expose event.  Probably some internal optimization.  So what do I do?
Do I just take apart GtkLayout and hack it up into the creature I
need it to be?

I also notice another problem.  I need to detect button presses in
the gtklayout.  I have a handler for detecting button presses on the
widgets that are put into the layout, as well as a handler for detecting
arbitrary button presses.  The problem is that when I click on a
widget, I get both events, and I really need to distinguish when the
user clicks on a widget and when he just clicks on blank space where
there is no widget.  I can probably hack away at it with a bunch of
state being stored after each press, but I'd really rather not.  I
was under the impression that my event handler could just return TRUE
to say that it has handled the event and no further event processing
should occur, but when I tried this, I still get both event callbacks
being called.  Even when both return TRUE.  So what gives?  What
can I do to distinguish these two cases?

And finally:  This seems like a fairly useful type of widget.  I
will probably need such a widget around again in the future, so I've
been coding it to be fairly general, so far.  My question though:  am
I wasting my time?  Has someone else already written a widget that
does what I am doing?  If not, why not?

feelin verbose tonight, thanks for your time...

                                           Tim N.





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