Re: GTK function to test whether GETWidget is a button/edit/columned list/whatever



On Sun, Oct 24, 2004 at 01:12:41AM +0500, Zeeshan Ali wrote:

I wonder whether GTK has a function to test a given widget to see
whether it is a
button/edit/columned list/whatever.

   G_OBJECT_TYPE (G_OBJECT (widget)) == GTK_TYPE_BUTTON

  G_OBJECT_TYPE (G_OBJECT (widget)) == GTK_TYPE_EDITABLE 

This is something you almost never want -- to test an exact
type.  Leaving aside that GtkEditable is an interface, so
the second example can never work and that G_OBJECT() cast
is redundant.

To find out whether something is a button, i.e., it is
GtkButton or its subclass (which is the thing you normally
want), use GTK_IS_BUTTON().  Most code can and should work
with subclasses.

Yeti


--
Dynamic IP address is not a crime.



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