Re: Creating custom widget questions



Thanks for the quick response.

On Thu, 2006-05-25 at 19:07 +0200, David NeÄas (Yeti) wrote:

On Thu, May 25, 2006 at 12:18:46PM -0400, James Scott Jr wrote:

Q1: Naming a new widget:  Is it ok to name it gtk_linegraph_new() ?
       - I named mine sk_linegraph_new(), but all the books i've read
did not hesitate to prefix their names with gtk_

sk_linegraph_new() will not cause conflicts with future Gtk+
versions while gtk_linegraph_new() violates Gtk+ namespace.
Actually, sk_line_graph_new() is the right name because your
type name is SkLineGraph not SkLinegraph.

If i want to use sk_linegraph_new() or sk_linegraph_*, I should change my type name to SkLinegraph.  I will 
make that case change



Q2: API Families: GtkObjectClass vs GObjectClass for widget properties?

       - I want the codeset to run anywhere GTK+/GDK is supported!
       - I used GObjectClass methods ( get/set_property ) rather than
GtkObjectClass get/set_arg - initially not noticing the difference; does
it matter ?

All the GtkArg stuff (as almost everything from the
pre-GObject era) is deprecated since 2.0.

Lucked out here.



Q3: Double-Destroy method calls: GtkWidgetClass->destroy get called at
least twice during shutdown and GTK_DESTROYED(widget) didn't seem to
work?

Destroy method can be invoked several times.  It has to be
idempotent (which should answer the remaining questions).

A common technique to make it idempotent is to set things to
NULL when you free them and check them for NULL before
freeing them (if they are not freed with plain g_free()
which is idempotent itself).  This has the advantage it
works equally well for things that may exist only
optionally.

Thats exactly what i did; first pass free and set to NULL, 2nd+ test for NULL.

Yeti


Thanks


--
Anonyms eat their boogers.



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