- if (GTK_IS_BUILDER (obj))
- w = GTK_WIDGET (gtk_builder_get_object (GTK_BUILDER (obj), name));
+ o = gtk_builder_get_object (builder, name);
+
+ if ( !o )
+ g_critical ("Object \"%s\" could not be found\n", name);
+
+ if ( ! g_type_is_a (G_OBJECT_TYPE (o), type))
+ {
+ g_critical ("Object \"%s\" was expected to have type %s, but in fact has type %s",
+ name, g_type_name (type), G_OBJECT_TYPE_NAME (o));
+ }
+
+ return o;
+}