Re: gtk_widget_show() and the 'size-allocate' signal



On Tue, Mar 06, 2007 at 11:41:24AM -0800, v4r4n wrote:
Since my latest efforts to minimize the number of "size-allocate"s being
thrown around by holding off on key gtk_widget_show() calls, I'll attempt to
subclass a widget, but I've never made my own custom widget before.

There is a http://www.gtk.org/tutorial/x2312.html tutorial on making your
own widgets but it seems to make a 'subclass' of a widget in GTK using C, I
have to copy the source of a widget and make changes from there.

No.  If you have to copy the source, you are either not
subclassing but creating a [similar] widget from scratch
instead -- or you are subclassing, but the original widget
was not written with the possibility of subclassing in mind
and probably you should rather write the widget from scratch.

If you subclass (define a new class with the original class
as its parent) a widget, the new one inherits everything
from the original one by default.

In fact, you may want to create a new widget from scratch.
It's hard to tell not knowing anything about how and how
much the behaviour should differ nor from what.

I would point to some tutorial but this is scattered to
too many places...

Where am I
going to get all the necessary source code for a GtkLayout from GTK 2.4?

Do you mean you were not able to find Gtk+ source code?

Using this method, what happens when different versions of GTK are compiled
against or used with my applications?  Will my old custom/'subclass' widget
eventually stop working or create an incompatibility?

No, if you do it right.  And Gtk+ devs don't screw anything.
It is not always clear what assumptions one is allowed to
make when subclassing, therefore the probability of
something going wrong increases with the complexity of the
original widget and of the changes.

I'm also a little foggy on how my custom widget will be able to solve my
problem.

Maybe I misunderstood your problem.  Do you want a container
widget that allocates space for its children differently
than existing container widgets?  Or do you just want to
perform some action in response to "size-allocate"?  And why
the bottom-to-top order is a problem then?

Is it common for people to make custom signals as well, or is that
impossible?

I can't tell what is common.  It is possible both to add
signals to existing classes and to register new signals when
you create new classes -- both with g_signal_new().

Yeti


--
Whatever.



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