Merging r39717 through r39983 from trunk into soc-2011-tomato
[blender.git] / source / blender / editors / interface / interface_templates.c
index 6384d91955f6a190b5dd308dbdc28a57618a7c37..129f921e5fc05aca91bee40343c5d64f08aa769c 100644 (file)
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_anim_types.h"
 #include "DNA_key_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_userdef_types.h"
 
 #include "BLI_string.h"
 #include "BLI_utildefines.h"
+#include "BLI_ghash.h"
 
 #include "BKE_animsys.h"
 #include "BKE_colortools.h"
@@ -57,6 +59,7 @@
 #include "ED_render.h"
 
 #include "RNA_access.h"
+#include "RNA_enum_types.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -236,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) {
@@ -286,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);
                                        }
                                }
                        }
@@ -320,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";
@@ -2126,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... */
 
@@ -2322,10 +2327,11 @@ static void operator_call_cb(bContext *C, void *UNUSED(arg1), void *arg2)
 
 static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items)
 {
-       wmOperatorType *ot = WM_operatortype_first();
-       
-       for(; ot; ot= ot->next) {
-               
+       GHashIterator *iter= WM_operatortype_iter();
+
+       for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
+               wmOperatorType *ot= BLI_ghashIterator_getValue(iter);
+
                if(BLI_strcasestr(ot->name, str)) {
                        if(WM_operator_poll((bContext*)C, ot)) {
                                char name[256];
@@ -2345,6 +2351,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
                        }
                }
        }
+       BLI_ghashIterator_free(iter);
 }
 
 void uiTemplateOperatorSearch(uiLayout *layout)
@@ -2366,6 +2373,8 @@ void uiTemplateOperatorSearch(uiLayout *layout)
 #define B_STOPCAST             2
 #define B_STOPANIM             3
 #define B_STOPCOMPO            4
+#define B_STOPSEQ              5
+#define B_STOPCLIP             6
 
 static void do_running_jobs(bContext *C, void *UNUSED(arg), int event)
 {
@@ -2382,6 +2391,12 @@ 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_STOPSEQ:
+                       WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
+                       break;
+               case B_STOPCLIP:
+                       WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
+                       break;
        }
 }
 
@@ -2403,8 +2418,15 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
                if(WM_jobs_test(wm, sa))
                   owner = sa;
                handle_event= B_STOPCOMPO;
-       } 
-       else {
+       } 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 */
                for(scene= CTX_data_main(C)->scene.first; scene; scene= scene->id.next)