code cleanup: favor braces when blocks have mixed brace use.
[blender.git] / source / blender / editors / interface / interface_templates.c
index 34f325a..9cc45f5 100644 (file)
 #include "DNA_dynamicpaint_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 
 #include "BLI_utildefines.h"
 #include "BLI_string.h"
 #include "BLI_ghash.h"
 #include "BLI_rect.h"
+#include "BLI_math.h"
+#include "BLI_listbase.h"
 
 #include "BLF_api.h"
 #include "BLF_translation.h"
 #include "BKE_animsys.h"
 #include "BKE_colortools.h"
 #include "BKE_context.h"
+#include "BKE_depsgraph.h"
+#include "BKE_displist.h"
 #include "BKE_dynamicpaint.h"
 #include "BKE_global.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
-#include "BKE_object.h"
 #include "BKE_material.h"
-#include "BKE_texture.h"
+#include "BKE_modifier.h"
+#include "BKE_object.h"
+#include "BKE_packedFile.h"
+#include "BKE_particle.h"
 #include "BKE_report.h"
-#include "BKE_displist.h"
 #include "BKE_sca.h"
 #include "BKE_scene.h"
 #include "BKE_screen.h"
+#include "BKE_texture.h"
 
 #include "ED_screen.h"
 #include "ED_object.h"
 #include "ED_render.h"
+#include "ED_util.h"
 
 #include "RNA_access.h"
 #include "RNA_enum_types.h"
@@ -273,7 +281,9 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
                                if (id->flag & LIB_FAKEUSER) id_us_plus(id);
                                else id_us_min(id);
                        }
-                       else return;
+                       else {
+                               return;
+                       }
                        break;
                case UI_ID_LOCAL:
                        if (id) {
@@ -504,7 +514,8 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
                                                 BLF_I18NCONTEXT_ID_CAMERA,
                                                 BLF_I18NCONTEXT_ID_WORLD,
                                                 BLF_I18NCONTEXT_ID_SCREEN,
-                                                BLF_I18NCONTEXT_ID_TEXT);
+                                                BLF_I18NCONTEXT_ID_TEXT,
+               );
                BLF_I18N_MSGID_MULTI_CTXT("New", BLF_I18NCONTEXT_ID_SPEAKER,
                                                 BLF_I18NCONTEXT_ID_SOUND,
                                                 BLF_I18NCONTEXT_ID_ARMATURE,
@@ -512,7 +523,8 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
                                                 BLF_I18NCONTEXT_ID_NODETREE,
                                                 BLF_I18NCONTEXT_ID_BRUSH,
                                                 BLF_I18NCONTEXT_ID_PARTICLESETTINGS,
-                                                BLF_I18NCONTEXT_ID_GPENCIL);
+                                                BLF_I18NCONTEXT_ID_GPENCIL,
+               );
                
                if (newop) {
                        but = uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN,
@@ -529,7 +541,18 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
                        uiButSetFlag(but, UI_BUT_DISABLED);
        }
 
-       if (flag & UI_ID_OPEN) {
+       /* Due to space limit in UI - skip the "open" icon for packed data, and allow to unpack.
+          Only for images, sound and fonts */
+       if (id && BKE_pack_check(id)) {
+               but = uiDefIconButO(block, BUT, "FILE_OT_unpack_item", WM_OP_INVOKE_REGION_WIN, ICON_PACKAGE, 0, 0,
+                                   UI_UNIT_X, UI_UNIT_Y, TIP_("Packed File, click to unpack"));
+               uiButGetOperatorPtrRNA(but);
+               
+               RNA_string_set(but->opptr, "id_name", id->name + 2);
+               RNA_int_set(but->opptr, "id_type", GS(id->name));
+               
+       }
+       else if (flag & UI_ID_OPEN) {
                int w = id ? UI_UNIT_X : (flag & UI_ID_ADD_NEW) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
                
                if (openop) {
@@ -670,7 +693,7 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co
                        uiItemL(row, text, ICON_NONE);
        }
        else
-               uiItemL(row, "ID-Block:", ICON_NONE);
+               uiItemL(row, IFACE_("ID-Block:"), ICON_NONE);
        
        /* ID-Type Selector - just have a menu of icons */
        /* FIXME: the icon-only setting doesn't work when we supply a blank name */
@@ -714,22 +737,7 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna
 
 /************************ Modifier Template *************************/
 
-#define ERROR_LIBDATA_MESSAGE "Can't edit external libdata"
-
-#include <string.h>
-
-#include "DNA_object_force.h"
-
-#include "BKE_depsgraph.h"
-#include "BKE_modifier.h"
-#include "BKE_particle.h"
-
-#include "ED_util.h"
-
-#include "BLI_math.h"
-#include "BLI_listbase.h"
-
-#include "ED_object.h"
+#define ERROR_LIBDATA_MESSAGE IFACE_("Can't edit external libdata")
 
 static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v)
 {
@@ -829,8 +837,8 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
                block = uiLayoutGetBlock(row);
                /* VIRTUAL MODIFIER */
                /* XXX this is not used now, since these cannot be accessed via RNA */
-               BLI_snprintf(str, sizeof(str), "%s parent deform", md->name);
-               uiDefBut(block, LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name"); 
+               BLI_snprintf(str, sizeof(str), IFACE_("%s parent deform"), md->name);
+               uiDefBut(block, LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Modifier name"));
                
                but = uiDefBut(block, BUT, 0, IFACE_("Make Real"), 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0,
                               TIP_("Convert virtual modifier to a real modifier"));
@@ -937,18 +945,22 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
                                
                                if (!(ob->mode & OB_MODE_PARTICLE_EDIT) && psys->pathcache) {
                                        if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB))
-                                               uiItemO(row, "Convert", ICON_NONE, "OBJECT_OT_duplicates_make_real");
+                                               uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE,
+                                                       "OBJECT_OT_duplicates_make_real");
                                        else if (psys->part->ren_as == PART_DRAW_PATH)
-                                               uiItemO(row, "Convert", ICON_NONE, "OBJECT_OT_modifier_convert");
+                                               uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE,
+                                                       "OBJECT_OT_modifier_convert");
                                }
                        }
                        else {
                                uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
-                               uiItemEnumO(row, "OBJECT_OT_modifier_apply", IFACE_("Apply"), 0, "apply_as", MODIFIER_APPLY_DATA);
+                               uiItemEnumO(row, "OBJECT_OT_modifier_apply", CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"),
+                                           0, "apply_as", MODIFIER_APPLY_DATA);
                                
                                if (modifier_isSameTopology(md) && !modifier_isNonGeometrical(md)) {
-                                       uiItemEnumO(row, "OBJECT_OT_modifier_apply", IFACE_("Apply as Shape Key"), 0,
-                                                   "apply_as", MODIFIER_APPLY_SHAPE);
+                                       uiItemEnumO(row, "OBJECT_OT_modifier_apply",
+                                                   CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Apply as Shape Key"),
+                                                   0, "apply_as", MODIFIER_APPLY_SHAPE);
                                }
                        }
                        
@@ -958,7 +970,8 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
                        if (!ELEM5(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem,
                                   eModifierType_Cloth, eModifierType_Smoke))
                        {
-                               uiItemO(row, IFACE_("Copy"), ICON_NONE, "OBJECT_OT_modifier_copy");
+                               uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy"), ICON_NONE,
+                                       "OBJECT_OT_modifier_copy");
                        }
                }
                
@@ -1037,9 +1050,8 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event)
                case B_CONSTRAINT_CHANGETARGET:
                {
                        Main *bmain = CTX_data_main(C);
-                       Scene *scene = CTX_data_scene(C);
                        if (ob->pose) ob->pose->flag |= POSE_RECALC;  /* checks & sorts pose channels */
-                       DAG_scene_sort(bmain, scene);
+                       DAG_relations_tag_update(bmain);
                        break;
                }
 #endif
@@ -1080,10 +1092,10 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
        cti = BKE_constraint_get_typeinfo(con);
        if (cti == NULL) {
                /* exception for 'Null' constraint - it doesn't have constraint typeinfo! */
-               BLI_strncpy(typestr, (con->type == CONSTRAINT_TYPE_NULL) ? "Null" : "Unknown", sizeof(typestr));
+               BLI_strncpy(typestr, (con->type == CONSTRAINT_TYPE_NULL) ? IFACE_("Null") : IFACE_("Unknown"), sizeof(typestr));
        }
        else
-               BLI_strncpy(typestr, cti->name, sizeof(typestr));
+               BLI_strncpy(typestr, IFACE_(cti->name), sizeof(typestr));
                
        /* determine whether constraint is proxy protected or not */
        if (BKE_proxylocked_constraints_owner(ob, pchan))
@@ -1188,7 +1200,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
 
        /* Set but-locks for protected settings (magic numbers are used here!) */
        if (proxy_protected)
-               uiBlockSetButLock(block, 1, "Cannot edit Proxy-Protected Constraint");
+               uiBlockSetButLock(block, 1, IFACE_("Cannot edit Proxy-Protected Constraint"));
 
        /* Draw constraint data */
        if ((con->flag & CONSTRAINT_EXPAND) == 0) {
@@ -1472,7 +1484,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
                RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr);
                row = uiLayoutRow(layout, FALSE);
 
-               uiItemR(row, &ptr, "position", 0, "Pos", ICON_NONE);
+               uiItemR(row, &ptr, "position", 0, IFACE_("Pos"), ICON_NONE);
                bt = block->buttons.last;
                uiButSetFunc(bt, colorband_update_cb, bt, coba);
 
@@ -1554,6 +1566,90 @@ void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname
        MEM_freeN(cb);
 }
 
+
+/********************* Icon viewer Template ************************/
+
+/* ID Search browse menu, open */
+static uiBlock *icon_view_menu(bContext *C, ARegion *ar, void *arg_litem)
+{
+       static RNAUpdateCb cb;
+       uiBlock *block;
+       uiBut *but;
+       int icon;
+       EnumPropertyItem *item;
+       int a, free;
+
+       /* arg_litem is malloced, can be freed by parent button */
+       cb = *((RNAUpdateCb *)arg_litem);
+       
+       /* unused */
+       // icon = RNA_property_enum_get(&cb.ptr, cb.prop);
+       
+       block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
+       uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW);
+       
+       
+       RNA_property_enum_items(C, &cb.ptr, cb.prop, &item, NULL, &free);
+       
+       for (a = 0; item[a].identifier; a++) {
+               int x, y;
+               
+               /* XXX hardcoded size to 5 x unit */
+               x = (a % 8) * UI_UNIT_X * 5;
+               y = (a / 8) * UI_UNIT_X * 5;
+               
+               icon = item[a].icon;
+               but = uiDefIconButR_prop(block, ROW, 0, icon, x, y, UI_UNIT_X * 5, UI_UNIT_Y * 5, &cb.ptr, cb.prop, -1, 0, icon, -1, -1, NULL);
+               uiButSetFlag(but, UI_HAS_ICON | UI_ICON_PREVIEW);
+       }
+
+       uiBoundsBlock(block, 0.3f * U.widget_unit);
+       uiBlockSetDirection(block, UI_TOP);
+       uiEndBlock(C, block);
+               
+       if (free) {
+               MEM_freeN(item);
+       }
+       
+       return block;
+}
+
+void uiTemplateIconView(uiLayout *layout, PointerRNA *ptr, const char *propname)
+{
+       PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
+       RNAUpdateCb *cb;
+       uiBlock *block;
+       uiBut *but;
+//     rctf rect;  /* UNUSED */
+       int icon;
+       
+       if (!prop || RNA_property_type(prop) != PROP_ENUM)
+               return;
+       
+       icon = RNA_property_enum_get(ptr, prop);
+       
+       cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
+       cb->ptr = *ptr;
+       cb->prop = prop;
+       
+//     rect.xmin = 0; rect.xmax = 10.0f * UI_UNIT_X;
+//     rect.ymin = 0; rect.ymax = 10.0f * UI_UNIT_X;
+       
+       block = uiLayoutAbsoluteBlock(layout);
+
+       but = uiDefBlockButN(block, icon_view_menu, MEM_dupallocN(cb), "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6, "");
+
+       
+//     but = uiDefIconButR_prop(block, ROW, 0, icon, 0, 0, BLI_rctf_size_x(&rect), BLI_rctf_size_y(&rect), ptr, prop, -1, 0, icon, -1, -1, NULL);
+       
+       but->icon = icon;
+       uiButSetFlag(but, UI_HAS_ICON | UI_ICON_PREVIEW);
+       
+       uiButSetNFunc(but, rna_update_cb, MEM_dupallocN(cb), NULL);
+       
+       MEM_freeN(cb);
+}
+
 /********************* Histogram Template ************************/
 
 void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname)
@@ -1585,7 +1681,7 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname
 
        hist = (Histogram *)cptr.data;
 
-       hist->height = (hist->height <= UI_UNIT_Y) ? UI_UNIT_Y : hist->height;
+       hist->height = (hist->height <= 20) ? 20 : hist->height;
 
        bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), UI_DPI_FAC * hist->height,
                      hist, 0, 0, 0, 0, "");
@@ -1624,7 +1720,7 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname)
        
        block = uiLayoutAbsoluteBlock(layout);
        
-       scopes->wavefrm_height = (scopes->wavefrm_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->wavefrm_height;
+       scopes->wavefrm_height = (scopes->wavefrm_height <= 20) ? 20 : scopes->wavefrm_height;
 
        bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), UI_DPI_FAC * scopes->wavefrm_height,
                      scopes, 0, 0, 0, 0, "");
@@ -1662,7 +1758,7 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna
        
        block = uiLayoutAbsoluteBlock(layout);
 
-       scopes->vecscope_height = (scopes->vecscope_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->vecscope_height;
+       scopes->vecscope_height = (scopes->vecscope_height <= 20) ? 20 : scopes->vecscope_height;
        
        bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect),
                      UI_DPI_FAC * scopes->vecscope_height, scopes, 0, 0, 0, 0, "");
@@ -1759,7 +1855,7 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v)
        /* use this for a fake extra empy space around the buttons */
        uiDefBut(block, LABEL, 0, "",           -4, 16, width + 8, 6 * UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
 
-       bt = uiDefButBitI(block, TOG, CUMA_DO_CLIP, 1, "Use Clipping",
+       bt = uiDefButBitI(block, TOG, CUMA_DO_CLIP, 1, IFACE_("Use Clipping"),
                          0, 5 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->flag, 0.0, 0.0, 10, 0, "");
        uiButSetFunc(bt, curvemap_buttons_setclip, cumap, NULL);
 
@@ -2020,16 +2116,22 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe
        }
 
        if (cmp) {
-               const float range_clamp[2]   = {0.0f, 1.0f};
-               const float range_unclamp[2] = {-1000.0f, 1000.0f};  /* arbitrary limits here */
-               const float *range = (cumap->flag & CUMA_DO_CLIP) ? range_clamp : range_unclamp;
+               rctf bounds;
+
+               if (cumap->flag & CUMA_DO_CLIP) {
+                       bounds = cumap->clipr;
+               }
+               else {
+                       bounds.xmin = bounds.ymin = -1000.0;
+                       bounds.xmax = bounds.ymax =  1000.0;
+               }
 
                uiLayoutRow(layout, TRUE);
                uiBlockSetNFunc(block, curvemap_buttons_update, MEM_dupallocN(cb), cumap);
                bt = uiDefButF(block, NUM, 0, "X", 0, 2 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y,
-                              &cmp->x, range[0], range[1], 1, 5, "");
+                              &cmp->x, bounds.xmin, bounds.xmax, 1, 5, "");
                bt = uiDefButF(block, NUM, 0, "Y", 0, 1 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y,
-                              &cmp->y, range[0], range[1], 1, 5, "");
+                              &cmp->y, bounds.ymin, bounds.ymax, 1, 5, "");
        }
 
        /* black/white levels */
@@ -2328,7 +2430,7 @@ void uiTemplateGameStates(uiLayout *layout, PointerRNA *ptr, const char *propnam
 
 
 /************************* List Template **************************/
-static void uilist_draw_item_default(struct uiList *uilst, struct bContext *UNUSED(C), struct uiLayout *layout,
+static void uilist_draw_item_default(struct uiList *ui_list, struct bContext *UNUSED(C), struct uiLayout *layout,
                                      struct PointerRNA *UNUSED(dataptr), struct PointerRNA *itemptr, int icon,
                                      struct PointerRNA *UNUSED(active_dataptr), const char *UNUSED(active_propname),
                                      int UNUSED(index))
@@ -2340,7 +2442,7 @@ static void uilist_draw_item_default(struct uiList *uilst, struct bContext *UNUS
        name = (namebuf) ? namebuf : "";
 
        /* Simplest one! */
-       switch (uilst->layout_type) {
+       switch (ui_list->layout_type) {
        case UILST_LAYOUT_GRID:
                uiItemL(layout, "", icon);
                break;
@@ -2361,8 +2463,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                     PointerRNA *dataptr, const char *propname, PointerRNA *active_dataptr,
                     const char *active_propname, int rows, int maxrows, int layout_type)
 {
-       uiListType *ult;
-       uiList *uilst = NULL;
+       uiListType *ui_list_type;
+       uiList *ui_list = NULL;
        ARegion *ar;
        uiListDrawItemFunc draw_item;
 
@@ -2373,7 +2475,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
        uiBlock *block, *subblock;
        uiBut *but;
 
-       char uilst_id[UI_MAX_NAME_STR];
+       char ui_list_id[UI_MAX_NAME_STR];
        char numstr[32];
        int rnaicon = ICON_NONE, icon = ICON_NONE;
        int i = 0, activei = 0;
@@ -2383,6 +2485,13 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
        int min, max;
 
        /* validate arguments */
+       /* Forbid default UI_UL_DEFAULT_CLASS_NAME list class without a custom list_id! */
+       if (!strcmp(UI_UL_DEFAULT_CLASS_NAME, listtype_name) && !(list_id && list_id[0])) {
+               RNA_warning("template_list using default '%s' UIList class must provide a custom list_id",
+                           UI_UL_DEFAULT_CLASS_NAME);
+               return;
+       }
+
        block = uiLayoutGetBlock(layout);
 
        if (!active_dataptr->data) {
@@ -2428,31 +2537,31 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
        activei = RNA_property_int_get(active_dataptr, activeprop);
 
        /* Find the uiList type. */
-       ult = WM_uilisttype_find(listtype_name, FALSE);
+       ui_list_type = WM_uilisttype_find(listtype_name, FALSE);
 
-       if (ult == NULL) {
+       if (ui_list_type == NULL) {
                RNA_warning("List type %s not found", listtype_name);
                return;
        }
 
-       draw_item = ult->draw_item ? ult->draw_item : uilist_draw_item_default;
+       draw_item = ui_list_type->draw_item ? ui_list_type->draw_item : uilist_draw_item_default;
 
        /* Find or add the uiList to the current Region. */
        /* We tag the list id with the list type... */
-       BLI_snprintf(uilst_id, sizeof(uilst_id), "%s_%s", ult->idname, list_id ? list_id : "");
+       BLI_snprintf(ui_list_id, sizeof(ui_list_id), "%s_%s", ui_list_type->idname, list_id ? list_id : "");
 
        ar = CTX_wm_region(C);
-       uilst = BLI_findstring(&ar->uiLists, uilst_id, offsetof(uiList, list_id));
+       ui_list = BLI_findstring(&ar->ui_lists, ui_list_id, offsetof(uiList, list_id));
 
-       if (!uilst) {
-               uilst = MEM_callocN(sizeof(uiList), __func__);
-               BLI_strncpy(uilst->list_id, uilst_id, sizeof(uilst->list_id));
-               BLI_addtail(&ar->uiLists, uilst);
+       if (!ui_list) {
+               ui_list = MEM_callocN(sizeof(uiList), __func__);
+               BLI_strncpy(ui_list->list_id, ui_list_id, sizeof(ui_list->list_id));
+               BLI_addtail(&ar->ui_lists, ui_list);
        }
 
        /* Because we can't actually pass type across save&load... */
-       uilst->type = ult;
-       uilst->layout_type = layout_type;
+       ui_list->type = ui_list_type;
+       ui_list->layout_type = layout_type;
 
        switch (layout_type) {
        case UILST_LAYOUT_DEFAULT:
@@ -2461,11 +2570,11 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                        rows = 5;
                if (maxrows == 0)
                        maxrows = 5;
-               if (uilst->list_grip_size != 0)
-                       rows = uilst->list_grip_size;
+               if (ui_list->list_grip_size != 0)
+                       rows = ui_list->list_grip_size;
 
                /* layout */
-               box = uiLayoutListBox(layout, uilst, dataptr, prop, active_dataptr, activeprop);
+               box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop);
                row = uiLayoutRow(box, FALSE);
                col = uiLayoutColumn(row, TRUE);
 
@@ -2477,21 +2586,22 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                items = CLAMPIS(len, rows, MAX2(rows, maxrows));
 
                /* if list length changes and active is out of view, scroll to it */
-               if ((uilst->list_last_len != len) &&
-                   (activei < uilst->list_scroll || activei >= uilst->list_scroll + items)) {
-                       uilst->list_scroll = activei;
+               if ((ui_list->list_last_len != len) &&
+                   (activei < ui_list->list_scroll || activei >= ui_list->list_scroll + items))
+               {
+                       ui_list->list_scroll = activei;
                }
 
-               uilst->list_scroll = MIN2(uilst->list_scroll, len - items);
-               uilst->list_scroll = MAX2(uilst->list_scroll, 0);
-               uilst->list_size = items;
-               uilst->list_last_len = len;
+               ui_list->list_scroll = min_ii(ui_list->list_scroll, len - items);
+               ui_list->list_scroll = max_ii(ui_list->list_scroll, 0);
+               ui_list->list_size = items;
+               ui_list->list_last_len = len;
 
                if (dataptr->data && prop) {
                        /* create list items */
                        RNA_PROP_BEGIN (dataptr, itemptr, prop)
                        {
-                               if (i >= uilst->list_scroll && i < uilst->list_scroll + items) {
+                               if (i >= ui_list->list_scroll && i < ui_list->list_scroll + items) {
                                        subblock = uiLayoutGetBlock(col);
                                        overlap = uiLayoutOverlap(col);
 
@@ -2507,7 +2617,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                                        icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, FALSE);
                                        if (icon == ICON_DOT)
                                                icon = ICON_NONE;
-                                       draw_item(uilst, C, sub, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
+                                       draw_item(ui_list, C, sub, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
                                }
                                i++;
                        }
@@ -2515,8 +2625,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                }
 
                /* add dummy buttons to fill space */
-               while (i < uilst->list_scroll + items) {
-                       if (i >= uilst->list_scroll)
+               while (i < ui_list->list_scroll + items) {
+                       if (i >= ui_list->list_scroll)
                                uiItemL(col, "", ICON_NONE);
                        i++;
                }
@@ -2524,7 +2634,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                /* add scrollbar */
                if (len > items) {
                        col = uiLayoutColumn(row, FALSE);
-                       uiDefButI(block, SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * items, &uilst->list_scroll,
+                       uiDefButI(block, SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * items, &ui_list->list_scroll,
                                  0, len - items, items, 0, "");
                }
                break;
@@ -2541,7 +2651,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                                        icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, FALSE);
                                        if (icon == ICON_DOT)
                                                icon = ICON_NONE;
-                                       draw_item(uilst, C, row, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
+                                       draw_item(ui_list, C, row, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
                                }
 
                                i++;
@@ -2561,7 +2671,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                        uiButSetFlag(but, UI_BUT_DISABLED);
                break;
        case UILST_LAYOUT_GRID:
-               box = uiLayoutListBox(layout, uilst, dataptr, prop, active_dataptr, activeprop);
+               box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop);
                col = uiLayoutColumn(box, TRUE);
                row = uiLayoutRow(col, FALSE);
 
@@ -2586,7 +2696,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                                sub = uiLayoutRow(overlap, FALSE);
 
                                icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon, FALSE);
-                               draw_item(uilst, C, sub, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
+                               draw_item(ui_list, C, sub, dataptr, &itemptr, icon, active_dataptr, active_propname, i);
 
                                i++;
                        }
@@ -2610,7 +2720,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
 {
        GHashIterator *iter = WM_operatortype_iter();
 
-       for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
+       for (; BLI_ghashIterator_notDone(iter); BLI_ghashIterator_step(iter)) {
                wmOperatorType *ot = BLI_ghashIterator_getValue(iter);
 
                if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0)
@@ -2906,7 +3016,7 @@ void uiTemplateColorspaceSettings(uiLayout *layout, PointerRNA *ptr, const char
 
        colorspace_settings_ptr = RNA_property_pointer_get(ptr, prop);
 
-       uiItemL(layout, "Input Color Space:", ICON_NONE);
+       uiItemL(layout, IFACE_("Input Color Space:"), ICON_NONE);
        uiItemR(layout, &colorspace_settings_ptr, "name", 0, "", ICON_NONE);
 }