static int rna_ui_get_enum_icon(bContext *C, PointerRNA *ptr, const char *propname, const char *identifier) { PropertyRNA *prop = NULL; EnumPropertyItem *items = NULL, *item; bool free; int icon = ICON_NONE; prop = RNA_struct_find_property(ptr, propname); if (!prop || (RNA_property_type(prop) != PROP_ENUM)) { RNA_warning("Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname); return icon; } RNA_property_enum_items(C, ptr, prop, &items, NULL, &free); if (items) { for (item = items; item->identifier; item++) { if (item->identifier[0] && STREQ(item->identifier, identifier)) { icon = item->icon; break; } } if (free) { MEM_freeN(items); } } return icon; }
static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { PropertyRNA *prop= (PropertyRNA*)ptr->data; // EnumPropertyRNA *eprop; // UNUSED EnumPropertyItem *item= NULL; int totitem, free= 0; rna_idproperty_check(&prop, ptr); // eprop= (EnumPropertyRNA*)prop; RNA_property_enum_items(NULL, ptr, prop, &item, &totitem, &free); rna_iterator_array_begin(iter, (void*)item, sizeof(EnumPropertyItem), totitem, free, rna_enum_check_separator); }