Fixed "cleaning" of some menu labels (those with all the ugly %t/|), wasn't working...
authorBastien Montagne <montagne29@wanadoo.fr>
Wed, 19 Sep 2012 19:42:01 +0000 (19:42 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Wed, 19 Sep 2012 19:42:01 +0000 (19:42 +0000)
Also cleaned some old, no more used piece of code.

source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c

index 7bef69c61ecff5f592a32065ae2114a40bc94753..e343b1f98508ef2566f5702f346d994d7505f6ab 100644 (file)
@@ -3790,15 +3790,16 @@ void uiButGetStrInfo(bContext *C, uiBut *but, int nbr, ...)
                if (type == BUT_GET_LABEL) {
                        if (but->str) {
                                /* Menu labels can have some complex formating stuff marked by pipes or %t, we don't want those here! */
-                               const char *tc;
-                               
-                               if (but->type == MENU)
-                                       tc = strstr(but->str, "%t");
-                               else
-                                       tc = strchr(but->str, '|');
-                               
-                               if (tc)
-                                       tmp = BLI_strdupn(but->str, tc - but->str);
+                               const char *tc1, *tc2;
+
+                               tc1 = strstr(but->str, "%t");
+                               tc2 = strstr(but->str, "|"); /* XXX For some reason strchr seems to not work here? */
+
+                               if (tc2 && (!tc1 || tc1 > tc2))
+                                       tc1 = tc2;
+
+                               if (tc1)
+                                       tmp = BLI_strdupn(but->str, tc1 - but->str);
                                else
                                        tmp = BLI_strdup(but->str);
                        }
index 6d9fdde3b0aa39cac3cc3ff5d36791d210e1c508..d370dfe1abf2decdc71782f6d77b4803a85cdcb3 100644 (file)
@@ -4513,17 +4513,8 @@ static int ui_but_menu(bContext *C, uiBut *but)
        
        button_timers_tooltip_remove(C, but);
 
-#if 0
-       if (but->rnaprop)
-               name = RNA_property_ui_name(but->rnaprop);
-       else if (but->optype && but->optype->srna)
-               name = RNA_struct_ui_name(but->optype->srna);
-       else
-               name = IFACE_("<needs_name>");  // XXX - should never happen.
-#else
        uiButGetStrInfo(C, but, 1, &label);
        name = label.strinfo;
-#endif
 
        pup = uiPupMenuBegin(C, name, ICON_NONE);
        layout = uiPupMenuLayout(pup);