Merging r39717 through r39983 from trunk into soc-2011-tomato
[blender.git] / source / blender / editors / interface / interface_templates.c
index 1613b073ed65dee88430b9c58853207083ed8e5a..129f921e5fc05aca91bee40343c5d64f08aa769c 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_anim_types.h"
 #include "DNA_key_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_userdef_types.h"
@@ -58,6 +59,7 @@
 #include "ED_render.h"
 
 #include "RNA_access.h"
+#include "RNA_enum_types.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -237,7 +239,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
 {
        TemplateID *template= (TemplateID*)arg_litem;
        PointerRNA idptr= RNA_property_pointer_get(&template->ptr, template->prop);
-       ID *id= idptr.data, *newid;
+       ID *id= idptr.data;
        int event= GET_INT_FROM_POINTER(arg_event);
        
        switch(event) {
@@ -287,17 +289,8 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
                                        WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene);
                                }
                                else {
-                                       if(id_copy(id, &newid, 0) && newid) {
-                                               /* copy animation actions too */
-                                               BKE_copy_animdata_id_action(id);
-                                               /* us is 1 by convention, but RNA_property_pointer_set
-                                                  will also incremement it, so set it to zero */
-                                               newid->us= 0;
-
-                                               /* assign copy */
-                                               RNA_id_pointer_create(newid, &idptr);
-                                               RNA_property_pointer_set(&template->ptr, template->prop, idptr);
-                                               RNA_property_update(C, &template->ptr, template->prop);
+                                       if(id) {
+                                               id_single_user(C, id, &template->ptr, template->prop);
                                        }
                                }
                        }
@@ -321,11 +314,13 @@ static const char *template_id_browse_tip(StructRNA *type)
                        case ID_MA: return "Browse Material to be linked";
                        case ID_TE: return "Browse Texture to be linked";
                        case ID_IM: return "Browse Image to be linked";
-                       case ID_LA: return "Browse Lattice Data to be linked";
+                       case ID_LT: return "Browse Lattice Data to be linked";
+                       case ID_LA: return "Browse Lamp Data to be linked";
                        case ID_CA: return "Browse Camera Data to be linked";
                        case ID_WO: return "Browse World Settings to be linked";
                        case ID_SCR: return "Choose Screen lay-out";
                        case ID_TXT: return "Browse Text to be linked";
+                       case ID_SPK: return "Browse Speaker Data to be linked";
                        case ID_SO: return "Browse Sound to be linked";
                        case ID_AR: return "Browse Armature data to be linked";
                        case ID_AC: return "Browse Action to be linked";
@@ -2127,6 +2122,15 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
                //uiItemR(row, itemptr, "mute", 0, "", ICON_MUTE_IPO_OFF);
                uiBlockSetEmboss(block, UI_EMBOSS);
        }
+       else if(itemptr->type == &RNA_KeyingSetPath) {
+               KS_Path *ksp = (KS_Path*)itemptr->data;
+               
+               /* icon needs to be the type of ID which is currently active */
+               RNA_enum_icon_from_value(id_type_items, ksp->idtype, &icon);
+               
+               /* nothing else special to do... */
+               uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */
+       }
        else
                uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */
 
@@ -2369,8 +2373,8 @@ void uiTemplateOperatorSearch(uiLayout *layout)
 #define B_STOPCAST             2
 #define B_STOPANIM             3
 #define B_STOPCOMPO            4
-#define B_STOPCLIP             5
-#define B_STOPSEQ              6
+#define B_STOPSEQ              5
+#define B_STOPCLIP             6
 
 static void do_running_jobs(bContext *C, void *UNUSED(arg), int event)
 {
@@ -2387,10 +2391,10 @@ static void do_running_jobs(bContext *C, void *UNUSED(arg), int event)
                case B_STOPCOMPO:
                        WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
                        break;
-               case B_STOPCLIP:
+               case B_STOPSEQ:
                        WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
                        break;
-               case B_STOPSEQ:
+               case B_STOPCLIP:
                        WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
                        break;
        }
@@ -2414,15 +2418,14 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
                if(WM_jobs_test(wm, sa))
                   owner = sa;
                handle_event= B_STOPCOMPO;
-       } 
-       if(sa->spacetype==SPACE_CLIP) {
-               if(WM_jobs_test(wm, sa))
-                  owner = sa;
-               handle_event= B_STOPCLIP;
        } else if (sa->spacetype==SPACE_SEQ) {
                if(WM_jobs_test(wm, sa))
                        owner = sa;
                handle_event = B_STOPSEQ;
+       } else if(sa->spacetype==SPACE_CLIP) {
+               if(WM_jobs_test(wm, sa))
+                  owner = sa;
+               handle_event= B_STOPCLIP;
        } else {
                Scene *scene;
                /* another scene can be rendering too, for example via compositor */