Re: howto compare two GTypes


Not sure why your code doesn't work, since it looks clean to me. Maybe
you have an error somewhere else in your code?

I also quickly created compilable sample that demos type comparison:

#include <gtk/gtk.h>

main (int    argc,
      char **argv)
  GList *list = NULL,
  GType  type;

  gtk_init (&argc, &argv);

  list = g_list_prepend (list, gtk_window_new (GTK_WINDOW_TOPLEVEL));
  list = g_list_prepend (list, gtk_button_new ());
  list = g_list_prepend (list, gtk_label_new ("Label"));

  type = GTK_TYPE_LABEL;

  for (iter = list; iter; iter = g_list_next (iter))
    if (G_OBJECT_TYPE (iter->data) == type)
      g_print ("Match found\n");
      g_print ("No match\n");

  return 0;


Tadej Borovšak
tadeboro gmail com
tadej borovsak gmail com

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