Re: Widget Type Checking



On Wed, Apr 05, 2006 at 02:02:02PM -0700, Leon Ross wrote:

I have a vbox that contains x number of hboxs. Each hbox contains 2 items, a
label and either a GTK_COMBO or a GTK_ENTRY.

GtkCombo is deprecated (and superseded by GtkComboBox).
Moreover, your layout seems to call for a GtkTable.

I need to gather all of these "text fields" (using gtk_entry_get_text(..))
 in the GTK_COMBO or GTK_ENTRY and just print them to the terminal.

My question is: is there a way to check whether the second item in the hbox
is either a GTK_COMBO or GTK_ENTRY? by doing this I would know whether to
use
GTK_ENTRY(GTK_COMBO(item->entry)) or just GTK_ENTRY(item) for the parameter
of gtk_entry_get_text.

You can use GTK_IS_ENTRY(), GTK_IS_COMBO_BOX() to check for
a type (or any subclass) -- or G_TYPE_FROM_INSTANCE() to get
the exact type of an object.

But if you have to scan the hierarchy to access your
widgets it can be a sign of not well designed code.

Yeti


--
That's enough.



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