2

I saw this post but it was for Python so that doesn't help me too much. I'm programming in C++, working on a code-base that I didn't write. I see some checks like GTK_IS_ENTRY and GTK_IS_COMBO_BOX, but I'm not sure where this person found these or what other GTK_IS_... there are. Is there a reference to these somewhere? I searched online and also on the Gtk/GLib websites but I couldn't find anything. Thanks!

Alex Eastman
  • 305
  • 1
  • 10

1 Answers1

4

The type checks macros are typically part of the API contract for a GObject, and they are conventionally provided by the library, so they don't end up in the documentation. All they do is call G_TYPE_CHECK_INSTANCE_TYPE with the given GType macro, like GTK_TYPE_ENTRY or GTK_TYPE_COMBO_BOX.

ebassi
  • 8,648
  • 27
  • 29
  • That definitely shines some light on it, but I'm still not quite sure how I would use this. If I wanted to check if something was a ComboBox, could I do `GTK_TYPE_COMBO_BOX(GtkWidget* widget)` ? Is it mostly safe to assume `GTK_TYPE ... ` where (...) is the type I'm checking? Sorry, am noob :p – Alex Eastman Aug 14 '20 at 13:32
  • `GTK_TYPE_COMBO_BOX` is the macro that gives you the type; it does not take a parameter. If you want to check that the type of a widget pointer is a `GtkComboBox`, then you have to use `GTK_IS_COMBO_BOX(widget)`. – ebassi Aug 19 '20 at 11:23