At last... this merge should finally do the trick!
[blender.git] / source / blender / editors / space_outliner / outliner.c
index dce23eb103f1624daf1d8948af34732c61da5b64..6563a7dc7df77c8622480bbbc2dc26f232846b25 100644 (file)
@@ -50,7 +50,7 @@
 #include "DNA_modifier_types.h"
 #include "DNA_nla_types.h"
 #include "DNA_object_types.h"
-#include "DNA_oops_types.h"
+#include "DNA_outliner_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
@@ -64,6 +64,7 @@
 
 #include "IMB_imbuf_types.h"
 
+#include "BKE_animsys.h"
 #include "BKE_constraint.h"
 #include "BKE_context.h"
 #include "BKE_deform.h"
@@ -75,6 +76,7 @@
 #include "BKE_material.h"
 #include "BKE_modifier.h"
 #include "BKE_object.h"
+#include "BKE_report.h"
 #include "BKE_screen.h"
 #include "BKE_scene.h"
 #include "BKE_sequence.h"
 #include "UI_interface_icons.h"
 #include "UI_resources.h"
 #include "UI_view2d.h"
-#include "UI_text.h"
 
 #include "RNA_access.h"
 
 #include "ED_armature.h"
+#include "ED_keyframing.h"
 #include "ED_object.h"
 #include "ED_screen.h"
 
 #include "outliner_intern.h"
 
-#ifdef INTERNATIONAL
-#include "FTF_Api.h"
-#endif
-
 #include "PIL_time.h" 
 
 
 
 /* ************* XXX **************** */
 
-static void allqueue() {}
 static void BIF_undo_push() {}
 static void BIF_preview_changed() {}
 static void error() {}
@@ -616,6 +613,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                                Object *ob= (Object *)id;
                                
                                outliner_add_element(soops, &te->subtree, ob->adt, te, TSE_ANIM_DATA, 0);
+                               outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this
                                
                                if(ob->proxy && ob->id.lib==NULL)
                                        outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0);
@@ -932,14 +930,18 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                        TreeElement *ted= outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0);
                        ID *lastadded= NULL;
                        FCurve *fcu;
+                       DriverTarget *dtar;
                        
                        ted->name= "Drivers";
                
                        for (fcu= adt->drivers.first; fcu; fcu= fcu->next) {
-                               if (fcu->driver && fcu->driver->id) {
-                                       if (lastadded != fcu->driver->id) {
-                                               outliner_add_element(soops, &ted->subtree, fcu->driver->id, ted, TSE_LINKED_OB, 0);
-                                               lastadded= fcu->driver->id;
+                               if (fcu->driver && fcu->driver->targets.first)  {
+                                       for (dtar= fcu->driver->targets.first; dtar; dtar= dtar->next) {
+                                               if (lastadded != dtar->id) {
+                                                       // XXX this lastadded check is rather lame, and also fails quite badly...
+                                                       outliner_add_element(soops, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0);
+                                                       lastadded= dtar->id;
+                                               }
                                        }
                                }
                        }
@@ -947,7 +949,6 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                
                /* NLA Data */
                if (adt->nla_tracks.first) {
-#if 0
                        TreeElement *tenla= outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0);
                        NlaTrack *nlt;
                        int a= 0;
@@ -955,17 +956,18 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                        tenla->name= "NLA Tracks";
                        
                        for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
-                               TreeElement *tenlt= outliner_add_element(soops, &te->subtree, nlt, te, TSE_NLA_TRACK, a);
-                               bActionStrip *strip;
+                               TreeElement *tenlt= outliner_add_element(soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a);
+                               NlaStrip *strip;
                                TreeElement *ten;
                                int b= 0;
                                
-                               for (strip=nlt->strips.first; strip; strip=strip->next, a++) {
-                                       ten= outliner_add_element(soops, &tenla->subtree, strip->act, tenla, TSE_NLA_ACTION, a);
+                               tenlt->name= nlt->name;
+                               
+                               for (strip=nlt->strips.first; strip; strip=strip->next, b++) {
+                                       ten= outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b);
                                        if(ten) ten->directdata= strip;
                                }
                        }
-#endif
                }
        }
        else if(type==TSE_SEQUENCE) {
@@ -1029,7 +1031,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
        }
        else if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) {
                PointerRNA pptr, propptr, *ptr= (PointerRNA*)idv;
-               PropertyRNA *prop, *iterprop, *nameprop;
+               PropertyRNA *prop, *iterprop;
                PropertyType proptype;
                PropertySubType propsubtype;
                int a, tot;
@@ -1041,20 +1043,18 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                }
                else if(type == TSE_RNA_STRUCT) {
                        /* struct */
-                       nameprop= RNA_struct_name_property(ptr);
+                       te->name= RNA_struct_name_get_alloc(ptr, NULL, 0);
 
-                       if(nameprop) {
-                               te->name= RNA_property_string_get_alloc(ptr, nameprop, NULL, 0);
+                       if(te->name)
                                te->flag |= TE_FREE_NAME;
-                       }
                        else
-                               te->name= (char*)RNA_struct_ui_name(ptr);
+                               te->name= (char*)RNA_struct_ui_name(ptr->type);
 
-                       iterprop= RNA_struct_iterator_property(ptr);
+                       iterprop= RNA_struct_iterator_property(ptr->type);
                        tot= RNA_property_collection_length(ptr, iterprop);
 
                        /* auto open these cases */
-                       if(!parent || (RNA_property_type(&parent->rnaptr, parent->directdata)) == PROP_POINTER)
+                       if(!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER)
                                if(!tselem->used)
                                        tselem->flag &= ~TSE_CLOSED;
 
@@ -1069,13 +1069,13 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                }
                else if(type == TSE_RNA_PROPERTY) {
                        /* property */
-                       iterprop= RNA_struct_iterator_property(ptr);
+                       iterprop= RNA_struct_iterator_property(ptr->type);
                        RNA_property_collection_lookup_int(ptr, iterprop, index, &propptr);
 
                        prop= propptr.data;
-                       proptype= RNA_property_type(ptr, prop);
+                       proptype= RNA_property_type(prop);
 
-                       te->name= (char*)RNA_property_ui_name(ptr, prop);
+                       te->name= (char*)RNA_property_ui_name(prop);
                        te->directdata= prop;
                        te->rnaptr= *ptr;
 
@@ -1102,7 +1102,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                                        te->flag |= TE_LAZY_CLOSED;
                        }
                        else if(ELEM3(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) {
-                               tot= RNA_property_array_length(ptr, prop);
+                               tot= RNA_property_array_length(prop);
 
                                if(!(tselem->flag & TSE_CLOSED)) {
                                        for(a=0; a<tot; a++)
@@ -1119,9 +1119,9 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                        static char *coloritem[4]= {"  r", "  g", "  b", "  a"};
 
                        prop= parent->directdata;
-                       proptype= RNA_property_type(ptr, prop);
-                       propsubtype= RNA_property_subtype(ptr, prop);
-                       tot= RNA_property_array_length(ptr, prop);
+                       proptype= RNA_property_type(prop);
+                       propsubtype= RNA_property_subtype(prop);
+                       tot= RNA_property_array_length(prop);
 
                        te->directdata= prop;
                        te->rnaptr= *ptr;
@@ -1463,9 +1463,6 @@ void outliner_toggle_visibility(Scene *scene, SpaceOops *soops)
        
        BIF_undo_push("Outliner toggle selectability");
 
-       allqueue(REDRAWVIEW3D, 1);
-       allqueue(REDRAWOOPS, 0);
-       allqueue(REDRAWINFO, 1);
 }
 
 static void object_toggle_selectability_cb(TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
@@ -1486,9 +1483,6 @@ void outliner_toggle_selectability(Scene *scene, SpaceOops *soops)
        
        BIF_undo_push("Outliner toggle selectability");
 
-       allqueue(REDRAWVIEW3D, 1);
-       allqueue(REDRAWOOPS, 0);
-       allqueue(REDRAWINFO, 1);
 }
 
 void object_toggle_renderability_cb(TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
@@ -1509,9 +1503,6 @@ void outliner_toggle_renderability(Scene *scene, SpaceOops *soops)
        
        BIF_undo_push("Outliner toggle renderability");
 
-       allqueue(REDRAWVIEW3D, 1);
-       allqueue(REDRAWOOPS, 0);
-       allqueue(REDRAWINFO, 1);
 }
 
 void outliner_toggle_visible(SpaceOops *soops)
@@ -1639,7 +1630,6 @@ static int tree_element_active_renderlayer(TreeElement *te, TreeStoreElem *tsele
        
        if(set) {
                sce->r.actlay= tselem->nr;
-               allqueue(REDRAWBUTSSCENE, 0);
        }
        else {
                return sce->r.actlay==tselem->nr;
@@ -1731,10 +1721,6 @@ static int tree_element_active_material(Scene *scene, SpaceOops *soops, TreeElem
        if(set) {
 // XXX         extern_set_butspace(F5KEY, 0);  // force shading buttons
                BIF_preview_changed(ID_MA);
-               allqueue(REDRAWBUTSSHADING, 1);
-               allqueue(REDRAWNODE, 0);
-               allqueue(REDRAWOOPS, 0);
-               allqueue(REDRAWIPO, 0);
        }
        return 0;
 }
@@ -1762,7 +1748,7 @@ static int tree_element_active_texture(Scene *scene, SpaceOops *soops, TreeEleme
 
                if(set) {
                        if(sbuts) {
-                               sbuts->tabo= TAB_SHADING_TEX;   // hack from header_buttonswin.c
+                               // XXX sbuts->tabo= TAB_SHADING_TEX;    // hack from header_buttonswin.c
                                sbuts->texfrom= 1;
                        }
 // XXX                 extern_set_butspace(F6KEY, 0);  // force shading buttons texture
@@ -1776,7 +1762,7 @@ static int tree_element_active_texture(Scene *scene, SpaceOops *soops, TreeEleme
                Lamp *la= (Lamp *)tselemp->id;
                if(set) {
                        if(sbuts) {
-                               sbuts->tabo= TAB_SHADING_TEX;   // hack from header_buttonswin.c
+                               // XXX sbuts->tabo= TAB_SHADING_TEX;    // hack from header_buttonswin.c
                                sbuts->texfrom= 2;
                        }
 // XXX                 extern_set_butspace(F6KEY, 0);  // force shading buttons texture
@@ -1821,9 +1807,6 @@ static int tree_element_active_lamp(Scene *scene, SpaceOops *soops, TreeElement
        if(set) {
 // XXX         extern_set_butspace(F5KEY, 0);
                BIF_preview_changed(ID_LA);
-               allqueue(REDRAWBUTSSHADING, 1);
-               allqueue(REDRAWOOPS, 0);
-               allqueue(REDRAWIPO, 0);
        }
        else return 1;
        
@@ -1868,7 +1851,6 @@ static int tree_element_active_defgroup(Scene *scene, TreeElement *te, TreeStore
        if(set) {
                ob->actdef= te->index+1;
                DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-               allqueue(REDRAWVIEW3D, ob->ipowin);
        }
        else {
                if(ob==OBACT)
@@ -1884,7 +1866,6 @@ static int tree_element_active_posegroup(Scene *scene, TreeElement *te, TreeStor
        if(set) {
                if (ob->pose) {
                        ob->pose->active_group= te->index+1;
-                       allqueue(REDRAWBUTSEDIT, 0);
                }
        }
        else {
@@ -1907,9 +1888,6 @@ static int tree_element_active_posechannel(Scene *scene, TreeElement *te, TreeSt
 //                     else deselectall_posearmature(ob, 0, 0);        // 0 = deselect 
                        pchan->bone->flag |= BONE_SELECTED|BONE_ACTIVE;
                        
-                       allqueue(REDRAWVIEW3D, 0);
-                       allqueue(REDRAWOOPS, 0);
-                       allqueue(REDRAWACTION, 0);
                }
        }
        else {
@@ -1931,9 +1909,6 @@ static int tree_element_active_bone(Scene *scene, TreeElement *te, TreeStoreElem
 //                     else deselectall_posearmature(OBACT, 0, 0);
                        bone->flag |= BONE_SELECTED|BONE_ACTIVE;
                        
-                       allqueue(REDRAWVIEW3D, 0);
-                       allqueue(REDRAWOOPS, 0);
-                       allqueue(REDRAWACTION, 0);
                }
        }
        else {
@@ -1963,9 +1938,6 @@ static int tree_element_active_ebone(TreeElement *te, TreeStoreElem *tselem, int
                        // flush to parent?
                        if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL;
                        
-                       allqueue(REDRAWVIEW3D, 0);
-                       allqueue(REDRAWOOPS, 0);
-                       allqueue(REDRAWACTION, 0);
                }
        }
        else {
@@ -2051,7 +2023,6 @@ static int tree_element_active_sequence(TreeElement *te, TreeStoreElem *tselem,
 
        if(set) {
 // XXX         select_single_seq(seq, 1);
-               allqueue(REDRAWSEQ, 0);
        }
        else {
                if(seq->flag & SELECT)
@@ -2084,7 +2055,6 @@ static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeS
 // XXX                 select_single_seq(p, 0);
                p= p->next;
        }
-       allqueue(REDRAWSEQ, 0);
        return(0);
 }
 
@@ -2477,7 +2447,7 @@ void outliner_find_panel(Scene *scene, ARegion *ar, SpaceOops *soops, int again,
 //             else return; /* XXX RETURN! XXX */
        }
 
-       /* do selection and reveil */
+       /* do selection and reveal */
        if (te) {
                tselem= TREESTORE(te);
                if (tselem) {
@@ -2915,7 +2885,6 @@ static void sequence_cb(int event, TreeElement *te, TreeStoreElem *tselem)
 //     Sequence *seq= (Sequence*) te->directdata;
        if(event==1) {
 // XXX         select_single_seq(seq, 1);
-               allqueue(REDRAWSEQ, 0);
        }
 }
 
@@ -2948,7 +2917,6 @@ void outliner_del(Scene *scene, ARegion *ar, SpaceOops *soops)
 //             DAG_scene_sort(scene);
 //             BIF_undo_push("Delete Objects");
 //     }
-//     allqueue(REDRAWALL, 0); 
 }
 
 
@@ -3003,7 +2971,6 @@ void outliner_operation_menu(Scene *scene, ARegion *ar, SpaceOops *soops)
                        }
                        
                        BIF_undo_push(str);
-                       allqueue(REDRAWALL, 0);
                }
        }
        else if(idlevel) {
@@ -3021,11 +2988,9 @@ void outliner_operation_menu(Scene *scene, ARegion *ar, SpaceOops *soops)
                                        case ID_MA:
                                                outliner_do_libdata_operation(soops, &soops->tree, unlink_material_cb);
                                                BIF_undo_push("Unlink material");
-                                               allqueue(REDRAWBUTSSHADING, 1);
                                                break;
                                        case ID_TE:
                                                outliner_do_libdata_operation(soops, &soops->tree, unlink_texture_cb);
-                                               allqueue(REDRAWBUTSSHADING, 1);
                                                BIF_undo_push("Unlink texture");
                                                break;
                                        case ID_GR:
@@ -3035,12 +3000,10 @@ void outliner_operation_menu(Scene *scene, ARegion *ar, SpaceOops *soops)
                                        default:
                                                error("Not yet...");
                                }
-                               allqueue(REDRAWALL, 0);
                        }
                        else if(event==2) {
                                outliner_do_libdata_operation(soops, &soops->tree, id_local_cb);
                                BIF_undo_push("Localized Data");
-                               allqueue(REDRAWALL, 0); 
                        }
                        else if(event==3 && idlevel==ID_GR) {
                                outliner_do_libdata_operation(soops, &soops->tree, group_linkobs2scene_cb);
@@ -3079,13 +3042,471 @@ void outliner_operation_menu(Scene *scene, ARegion *ar, SpaceOops *soops)
                                }
                        }
 
-                       allqueue(REDRAWOOPS, 0);
-                       allqueue(REDRAWBUTSALL, 0);
-                       allqueue(REDRAWVIEW3D, 0);
                }
        }
 }
 
+/* ***************** ANIMATO OPERATIONS ********************************** */
+/* KeyingSet and Driver Creation - Helper functions */
+
+/* specialised poll callback for these operators to work in Datablocks view only */
+static int ed_operator_outliner_datablocks_active(bContext *C)
+{
+       ScrArea *sa= CTX_wm_area(C);
+       if ((sa) && (sa->spacetype==SPACE_OUTLINER)) {
+               SpaceOops *so= (SpaceOops *)CTX_wm_space_data(C);
+               return (so->outlinevis == SO_DATABLOCKS);
+       }
+       return 0;
+}
+
+
+/* Helper func to extract an RNA path from selected tree element 
+ * NOTE: the caller must zero-out all values of the pointers that it passes here first, as
+ * this function does not do that yet 
+ */
+static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, 
+                                                       ID **id, char **path, int *array_index, short *flag, short *groupmode)
+{
+       ListBase hierarchy = {NULL, NULL};
+       LinkData *ld;
+       TreeElement *tem, *temnext, *temsub;
+       TreeStoreElem *tse, *tsenext;
+       PointerRNA *ptr, *nextptr;
+       PropertyRNA *prop;
+       char *newpath=NULL;
+       
+       /* optimise tricks:
+        *      - Don't do anything if the selected item is a 'struct', but arrays are allowed
+        */
+       if (tselem->type == TSE_RNA_STRUCT)
+               return;
+       
+       /* Overview of Algorithm:
+        *      1. Go up the chain of parents until we find the 'root', taking note of the 
+        *         levels encountered in reverse-order (i.e. items are added to the start of the list
+        *      for more convenient looping later)
+        *      2. Walk down the chain, adding from the first ID encountered 
+        *         (which will become the 'ID' for the KeyingSet Path), and build a  
+        *              path as we step through the chain
+        */
+        
+       /* step 1: flatten out hierarchy of parents into a flat chain */
+       for (tem= te->parent; tem; tem= tem->parent) {
+               ld= MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()");
+               ld->data= tem;
+               BLI_addhead(&hierarchy, ld);
+       }
+       
+       /* step 2: step down hierarchy building the path (NOTE: addhead in previous loop was needed so that we can loop like this) */
+       for (ld= hierarchy.first; ld; ld= ld->next) {
+               /* get data */
+               tem= (TreeElement *)ld->data;
+               tse= TREESTORE(tem);
+               ptr= &tem->rnaptr;
+               prop= tem->directdata;
+               
+               /* check if we're looking for first ID, or appending to path */
+               if (*id) {
+                       /* just 'append' property to path 
+                        *      - to prevent memory leaks, we must write to newpath not path, then free old path + swap them
+                        */
+                       if(tse->type == TSE_RNA_PROPERTY) {
+                               if(RNA_property_type(prop) == PROP_POINTER) {
+                                       /* for pointer we just append property name */
+                                       newpath= RNA_path_append(*path, ptr, prop, 0, NULL);
+                               }
+                               else if(RNA_property_type(prop) == PROP_COLLECTION) {
+                                       char buf[128], *name;
+
+                                       temnext= (TreeElement*)(ld->next->data);
+                                       tsenext= TREESTORE(temnext);
+                                       
+                                       nextptr= &temnext->rnaptr;
+                                       name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf));
+                                       
+                                       if(name) {
+                                               /* if possible, use name as a key in the path */
+                                               newpath= RNA_path_append(*path, NULL, prop, 0, name);
+                                               
+                                               if(name != buf)
+                                                       MEM_freeN(name);
+                                       }
+                                       else {
+                                               /* otherwise use index */
+                                               int index= 0;
+                                               
+                                               for(temsub=tem->subtree.first; temsub; temsub=temsub->next, index++)
+                                                       if(temsub == temnext)
+                                                               break;
+                                               
+                                               newpath= RNA_path_append(*path, NULL, prop, index, NULL);
+                                       }
+                                       
+                                       ld= ld->next;
+                               }
+                       }
+                       
+                       if(newpath) {
+                               if (*path) MEM_freeN(*path);
+                               *path= newpath;
+                               newpath= NULL;
+                       }
+               }
+               else {
+                       /* no ID, so check if entry is RNA-struct, and if that RNA-struct is an ID datablock to extract info from */
+                       if (tse->type == TSE_RNA_STRUCT) {
+                               /* ptr->data not ptr->id.data seems to be the one we want, since ptr->data is sometimes the owner of this ID? */
+                               if(RNA_struct_is_ID(ptr->type)) {
+                                       *id= (ID *)ptr->data;
+                                       
+                                       /* clear path */
+                                       if(*path) {
+                                               MEM_freeN(*path);
+                                               path= NULL;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /* step 3: if we've got an ID, add the current item to the path */
+       if (*id) {
+               /* add the active property to the path */
+               ptr= &te->rnaptr;
+               prop= te->directdata;
+               
+               /* array checks */
+               if (tselem->type == TSE_RNA_ARRAY_ELEM) {
+                       /* item is part of an array, so must set the array_index */
+                       *array_index= te->index;
+               }
+               else if (RNA_property_array_length(prop)) {
+                       /* entire array was selected, so keyframe all */
+                       *flag |= KSP_FLAG_WHOLE_ARRAY;
+               }
+               
+               /* path */
+               newpath= RNA_path_append(*path, NULL, prop, 0, NULL);
+               if (*path) MEM_freeN(*path);
+               *path= newpath;
+       }
+
+       /* free temp data */
+       BLI_freelistN(&hierarchy);
+}
+
+/* ***************** KEYINGSET OPERATIONS *************** */
+
+/* These operators are only available in databrowser mode for now, as
+ * they depend on having RNA paths and/or hierarchies available.
+ */
+enum {
+       DRIVERS_EDITMODE_ADD    = 0,
+       DRIVERS_EDITMODE_REMOVE,
+} eDrivers_EditModes;
+
+/* Utilities ---------------------------------- */ 
+
+/* Recursively iterate over tree, finding and working on selected items */
+static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short mode)
+{
+       TreeElement *te;
+       TreeStoreElem *tselem;
+       
+       for (te= tree->first; te; te=te->next) {
+               tselem= TREESTORE(te);
+               
+               /* if item is selected, perform operation */
+               if (tselem->flag & TSE_SELECTED) {
+                       ID *id= NULL;
+                       char *path= NULL;
+                       int array_index= 0;
+                       short flag= 0;
+                       short groupmode= KSP_GROUP_KSNAME;
+                       
+                       /* check if RNA-property described by this selected element is an animateable prop */
+                       if ((tselem->type == TSE_RNA_PROPERTY) && RNA_property_animateable(&te->rnaptr, te->directdata)) {
+                               /* get id + path + index info from the selected element */
+                               tree_element_to_path(soops, te, tselem, 
+                                               &id, &path, &array_index, &flag, &groupmode);
+                       }
+                       
+                       /* only if ID and path were set, should we perform any actions */
+                       if (id && path) {
+                               /* action depends on mode */
+                               switch (mode) {
+                                       case DRIVERS_EDITMODE_ADD:
+                                       {
+                                               /* add a new driver with the information obtained (only if valid) */
+                                               ANIM_add_driver(id, path, array_index, flag);
+                                       }
+                                               break;
+                                       case DRIVERS_EDITMODE_REMOVE:
+                                       {
+                                               /* remove driver matching the information obtained (only if valid) */
+                                               ANIM_remove_driver(id, path, array_index, flag);
+                                       }
+                                               break;
+                               }
+                               
+                               /* free path, since it had to be generated */
+                               MEM_freeN(path);
+                       }
+                       
+                       
+               }
+               
+               /* go over sub-tree */
+               if ((tselem->flag & TSE_CLOSED)==0)
+                       do_outliner_drivers_editop(soops, &te->subtree, mode);
+       }
+}
+
+/* Add Operator ---------------------------------- */
+
+static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op)
+{
+       SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
+       
+       /* check for invalid states */
+       if (soutliner == NULL)
+               return OPERATOR_CANCELLED;
+       
+       /* recursively go into tree, adding selected items */
+       do_outliner_drivers_editop(soutliner, &soutliner->tree, DRIVERS_EDITMODE_ADD);
+       
+       /* send notifiers */
+       WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_drivers_add(wmOperatorType *ot)
+{
+       /* api callbacks */
+       ot->idname= "OUTLINER_OT_drivers_add";
+       ot->name= "Add Drivers";
+       ot->description= "Add drivers to selected items.";
+       
+       /* api callbacks */
+       ot->exec= outliner_drivers_addsel_exec;
+       ot->poll= ed_operator_outliner_datablocks_active;
+       
+       /* flags */
+       ot->flag = OPTYPE_UNDO;
+}
+
+
+/* Remove Operator ---------------------------------- */
+
+static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op)
+{
+       SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
+       
+       /* check for invalid states */
+       if (soutliner == NULL)
+               return OPERATOR_CANCELLED;
+       
+       /* recursively go into tree, adding selected items */
+       do_outliner_drivers_editop(soutliner, &soutliner->tree, DRIVERS_EDITMODE_REMOVE);
+       
+       /* send notifiers */
+       WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_drivers_delete(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->idname= "OUTLINER_OT_drivers_delete";
+       ot->name= "Delete Drivers";
+       ot->description= "Delete drivers assigned to selected items.";
+       
+       /* api callbacks */
+       ot->exec= outliner_drivers_deletesel_exec;
+       ot->poll= ed_operator_outliner_datablocks_active;
+       
+       /* flags */
+       ot->flag = OPTYPE_UNDO;
+}
+
+/* ***************** KEYINGSET OPERATIONS *************** */
+
+/* These operators are only available in databrowser mode for now, as
+ * they depend on having RNA paths and/or hierarchies available.
+ */
+enum {
+       KEYINGSET_EDITMODE_ADD  = 0,
+       KEYINGSET_EDITMODE_REMOVE,
+} eKeyingSet_EditModes;
+
+/* Utilities ---------------------------------- */ 
+/* find the 'active' KeyingSet, and add if not found (if adding is allowed) */
+// TODO: should this be an API func?
+static KeyingSet *verify_active_keyingset(Scene *scene, short add)
+{
+       KeyingSet *ks= NULL;
+       
+       /* sanity check */
+       if (scene == NULL)
+               return NULL;
+       
+       /* try to find one from scene */
+       if (scene->active_keyingset > 0)
+               ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
+               
+       /* add if none found */
+       // XXX the default settings have yet to evolve
+       if ((add) && (ks==NULL)) {
+               ks= BKE_keyingset_add(&scene->keyingsets, "Keying Set", KEYINGSET_ABSOLUTE, 0);
+               scene->active_keyingset= BLI_countlist(&scene->keyingsets);
+       }
+       
+       return ks;
+}
+
+/* Recursively iterate over tree, finding and working on selected items */
+static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBase *tree, short mode)
+{
+       TreeElement *te;
+       TreeStoreElem *tselem;
+       
+       for (te= tree->first; te; te=te->next) {
+               tselem= TREESTORE(te);
+               
+               /* if item is selected, perform operation */
+               if (tselem->flag & TSE_SELECTED) {
+                       ID *id= NULL;
+                       char *path= NULL;
+                       int array_index= 0;
+                       short flag= 0;
+                       short groupmode= KSP_GROUP_KSNAME;
+                       
+                       /* check if RNA-property described by this selected element is an animateable prop */
+                       if ((tselem->type == TSE_RNA_PROPERTY) && RNA_property_animateable(&te->rnaptr, te->directdata)) {
+                               /* get id + path + index info from the selected element */
+                               tree_element_to_path(soops, te, tselem, 
+                                               &id, &path, &array_index, &flag, &groupmode);
+                       }
+                       
+                       /* only if ID and path were set, should we perform any actions */
+                       if (id && path) {
+                               /* action depends on mode */
+                               switch (mode) {
+                                       case KEYINGSET_EDITMODE_ADD:
+                                       {
+                                               /* add a new path with the information obtained (only if valid) */
+                                               // TODO: what do we do with group name? for now, we don't supply one, and just let this use the KeyingSet name
+                                               BKE_keyingset_add_destination(ks, id, NULL, path, array_index, flag, groupmode);
+                                       }
+                                               break;
+                                       case KEYINGSET_EDITMODE_REMOVE:
+                                       {
+                                               /* find the relevant path, then remove it from the KeyingSet */
+                                               KS_Path *ksp= BKE_keyingset_find_destination(ks, id, NULL, path, array_index, groupmode);
+                                               
+                                               if (ksp) {
+                                                       /* free path's data */
+                                                       // TODO: we probably need an API method for this 
+                                                       if (ksp->rna_path) MEM_freeN(ksp->rna_path);
+                                                       
+                                                       /* remove path from set */
+                                                       BLI_freelinkN(&ks->paths, ksp);
+                                               }
+                                       }
+                                               break;
+                               }
+                               
+                               /* free path, since it had to be generated */
+                               MEM_freeN(path);
+                       }
+                       
+                       
+               }
+               
+               /* go over sub-tree */
+               if ((tselem->flag & TSE_CLOSED)==0)
+                       do_outliner_keyingset_editop(soops, ks, &te->subtree, mode);
+       }
+}
+
+/* Add Operator ---------------------------------- */
+
+static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op)
+{
+       SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
+       Scene *scene= CTX_data_scene(C);
+       KeyingSet *ks= verify_active_keyingset(scene, 1);
+       
+       /* check for invalid states */
+       if (ks == NULL) {
+               BKE_report(op->reports, RPT_ERROR, "Operation requires an Active Keying Set");
+               return OPERATOR_CANCELLED;
+       }
+       if (soutliner == NULL)
+               return OPERATOR_CANCELLED;
+       
+       /* recursively go into tree, adding selected items */
+       do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_ADD);
+       
+       /* send notifiers */
+       WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->idname= "OUTLINER_OT_keyingset_add_selected";
+       ot->name= "Keyingset Add Selected";
+       
+       /* api callbacks */
+       ot->exec= outliner_keyingset_additems_exec;
+       ot->poll= ed_operator_outliner_datablocks_active;
+       
+       /* flags */
+       ot->flag = OPTYPE_UNDO;
+}
+
+
+/* Remove Operator ---------------------------------- */
+
+static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *op)
+{
+       SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
+       Scene *scene= CTX_data_scene(C);
+       KeyingSet *ks= verify_active_keyingset(scene, 1);
+       
+       /* check for invalid states */
+       if (soutliner == NULL)
+               return OPERATOR_CANCELLED;
+       
+       /* recursively go into tree, adding selected items */
+       do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_REMOVE);
+       
+       /* send notifiers */
+       WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->idname= "OUTLINER_OT_keyingset_remove_selected";
+       ot->name= "Keyingset Remove Selected";
+       
+       /* api callbacks */
+       ot->exec= outliner_keyingset_removeitems_exec;
+       ot->poll= ed_operator_outliner_datablocks_active;
+       
+       /* flags */
+       ot->flag = OPTYPE_UNDO;
+}
 
 /* ***************** DRAW *************** */
 
@@ -3094,22 +3515,24 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
        if(tselem->type) {
                switch( tselem->type) {
                        case TSE_ANIM_DATA:
-                               UI_icon_draw(x, y, ICON_IPO_DEHLT); break; // xxx
+                               UI_icon_draw(x, y, ICON_ANIM_DATA); break; // xxx
                        case TSE_NLA:
                                UI_icon_draw(x, y, ICON_NLA); break;
+                       case TSE_NLA_TRACK:
+                               UI_icon_draw(x, y, ICON_NLA); break; // XXX
                        case TSE_NLA_ACTION:
                                UI_icon_draw(x, y, ICON_ACTION); break;
                        case TSE_DEFGROUP_BASE:
-                               UI_icon_draw(x, y, ICON_VGROUP); break;
+                               UI_icon_draw(x, y, ICON_GROUP_VERTEX); break;
                        case TSE_BONE:
                        case TSE_EBONE:
-                               UI_icon_draw(x, y, ICON_BONE_DEHLT); break;
+                               UI_icon_draw(x, y, ICON_BONE_DATA); break;
                        case TSE_CONSTRAINT_BASE:
                                UI_icon_draw(x, y, ICON_CONSTRAINT); break;
                        case TSE_MODIFIER_BASE:
                                UI_icon_draw(x, y, ICON_MODIFIER); break;
                        case TSE_LINKED_OB:
-                               UI_icon_draw(x, y, ICON_OBJECT); break;
+                               UI_icon_draw(x, y, ICON_OBJECT_DATA); break;
                        case TSE_LINKED_PSYS:
                                UI_icon_draw(x, y, ICON_PARTICLES); break;
                        case TSE_MODIFIER:
@@ -3120,11 +3543,11 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
                                        case eModifierType_Subsurf: 
                                                UI_icon_draw(x, y, ICON_MOD_SUBSURF); break;
                                        case eModifierType_Armature: 
-                                               UI_icon_draw(x, y, ICON_ARMATURE); break;
+                                               UI_icon_draw(x, y, ICON_MOD_ARMATURE); break;
                                        case eModifierType_Lattice: 
-                                               UI_icon_draw(x, y, ICON_LATTICE); break;
+                                               UI_icon_draw(x, y, ICON_MOD_LATTICE); break;
                                        case eModifierType_Curve: 
-                                               UI_icon_draw(x, y, ICON_CURVE); break;
+                                               UI_icon_draw(x, y, ICON_MOD_CURVE); break;
                                        case eModifierType_Build: 
                                                UI_icon_draw(x, y, ICON_MOD_BUILD); break;
                                        case eModifierType_Mirror: 
@@ -3140,7 +3563,7 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
                                        case eModifierType_Boolean: 
                                                UI_icon_draw(x, y, ICON_MOD_BOOLEAN); break;
                                        case eModifierType_ParticleSystem: 
-                                               UI_icon_draw(x, y, ICON_MOD_PARTICLEINSTANCE); break;
+                                               UI_icon_draw(x, y, ICON_MOD_PARTICLES); break;
                                        case eModifierType_ParticleInstance:
                                                UI_icon_draw(x, y, ICON_MOD_PARTICLES); break;
                                        case eModifierType_EdgeSplit:
@@ -3151,6 +3574,30 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
                                                UI_icon_draw(x, y, ICON_MOD_UVPROJECT); break;
                                        case eModifierType_Displace:
                                                UI_icon_draw(x, y, ICON_MOD_DISPLACE); break;
+                                       case eModifierType_Shrinkwrap:
+                                               UI_icon_draw(x, y, ICON_MOD_SHRINKWRAP); break;
+                                       case eModifierType_Cast:
+                                               UI_icon_draw(x, y, ICON_MOD_CAST); break;
+                                       case eModifierType_MeshDeform:
+                                               UI_icon_draw(x, y, ICON_MOD_MESHDEFORM); break;
+                                       case eModifierType_Bevel:
+                                               UI_icon_draw(x, y, ICON_MOD_BEVEL); break;
+                                       case eModifierType_Smooth:
+                                               UI_icon_draw(x, y, ICON_MOD_SMOOTH); break;
+                                       case eModifierType_SimpleDeform:
+                                               UI_icon_draw(x, y, ICON_MOD_SIMPLEDEFORM); break;
+                                       case eModifierType_Mask:
+                                               UI_icon_draw(x, y, ICON_MOD_MASK); break;
+                                       case eModifierType_Cloth:
+                                               UI_icon_draw(x, y, ICON_MOD_CLOTH); break;
+                                       case eModifierType_Explode:
+                                               UI_icon_draw(x, y, ICON_MOD_EXPLODE); break;
+                                       case eModifierType_Collision:
+                                               UI_icon_draw(x, y, ICON_MOD_PHYSICS); break;
+                                       case eModifierType_Fluidsim:
+                                               UI_icon_draw(x, y, ICON_MOD_FLUIDSIM); break;
+                                       case eModifierType_Multires:
+                                               UI_icon_draw(x, y, ICON_MOD_MULTIRES); break;
                                        default:
                                                UI_icon_draw(x, y, ICON_DOT); break;
                                }
@@ -3159,19 +3606,19 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
                        case TSE_SCRIPT_BASE:
                                UI_icon_draw(x, y, ICON_TEXT); break;
                        case TSE_POSE_BASE:
-                               UI_icon_draw(x, y, ICON_ARMATURE); break;
+                               UI_icon_draw(x, y, ICON_ARMATURE_DATA); break;
                        case TSE_POSE_CHANNEL:
-                               UI_icon_draw(x, y, ICON_BONE_DEHLT); break;
+                               UI_icon_draw(x, y, ICON_BONE_DATA); break;
                        case TSE_PROXY:
                                UI_icon_draw(x, y, ICON_GHOST); break;
                        case TSE_R_LAYER_BASE:
-                               UI_icon_draw(x, y, ICON_RESTRICT_RENDER_OFF); break;
+                               UI_icon_draw(x, y, ICON_RENDERLAYERS); break;
                        case TSE_R_LAYER:
-                               UI_icon_draw(x, y, ICON_IMAGE_DEHLT); break;
+                               UI_icon_draw(x, y, ICON_RENDER_RESULT); break;
                        case TSE_LINKED_LAMP:
-                               UI_icon_draw(x, y, ICON_LAMP_DEHLT); break;
+                               UI_icon_draw(x, y, ICON_LAMP_DATA); break;
                        case TSE_LINKED_MAT:
-                               UI_icon_draw(x, y, ICON_MATERIAL_DEHLT); break;
+                               UI_icon_draw(x, y, ICON_MATERIAL_DATA); break;
                        case TSE_POSEGRP_BASE:
                                UI_icon_draw(x, y, ICON_VERTEXSEL); break;
                        case TSE_SEQUENCE:
@@ -3189,13 +3636,13 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
                                        UI_icon_draw(x, y, ICON_PARTICLES);
                                break;
                        case TSE_SEQ_STRIP:
-                               UI_icon_draw(x, y, ICON_LIBRARY_DEHLT);
+                               UI_icon_draw(x, y, ICON_LIBRARY_DATA_DIRECT);
                                break;
                        case TSE_SEQUENCE_DUP:
-                               UI_icon_draw(x, y, ICON_OBJECT);
+                               UI_icon_draw(x, y, ICON_OBJECT_DATA);
                                break;
                        case TSE_RNA_STRUCT:
-                               UI_icon_draw(x, y, UI_GetIconRNA(&te->rnaptr));
+                               UI_icon_draw(x, y, RNA_struct_ui_icon(te->rnaptr.type));
                                break;
                        default:
                                UI_icon_draw(x, y, ICON_DOT); break;
@@ -3218,6 +3665,10 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
                                UI_icon_draw(x, y, ICON_OUTLINER_OB_LATTICE); break;
                        case OB_ARMATURE: 
                                UI_icon_draw(x, y, ICON_OUTLINER_OB_ARMATURE); break;
+                       case OB_FONT: 
+                               UI_icon_draw(x, y, ICON_OUTLINER_OB_FONT); break;
+                       case OB_SURF: 
+                               UI_icon_draw(x, y, ICON_OUTLINER_OB_SURFACE); break;
                        case OB_EMPTY: 
                                UI_icon_draw(x, y, ICON_OUTLINER_OB_EMPTY); break;
                
@@ -3226,7 +3677,7 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
        else {
                switch( GS(tselem->id->name)) {
                        case ID_SCE:
-                               UI_icon_draw(x, y, ICON_SCENE_DEHLT); break;
+                               UI_icon_draw(x, y, ICON_SCENE_DATA); break;
                        case ID_ME:
                                UI_icon_draw(x, y, ICON_OUTLINER_DATA_MESH); break;
                        case ID_CU:
@@ -3236,13 +3687,31 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
                        case ID_LT:
                                UI_icon_draw(x, y, ICON_OUTLINER_DATA_LATTICE); break;
                        case ID_LA:
-                               UI_icon_draw(x, y, ICON_OUTLINER_DATA_LAMP); break;
+                       {
+                               Lamp *la= (Lamp *)tselem->id;
+                               
+                               switch(la->type) {
+                                       case LA_LOCAL:
+                                               UI_icon_draw(x, y, ICON_LAMP_POINT); break;
+                                       case LA_SUN:
+                                               UI_icon_draw(x, y, ICON_LAMP_SUN); break;
+                                       case LA_SPOT:
+                                               UI_icon_draw(x, y, ICON_LAMP_SPOT); break;
+                                       case LA_HEMI:
+                                               UI_icon_draw(x, y, ICON_LAMP_HEMI); break;
+                                       case LA_AREA:
+                                               UI_icon_draw(x, y, ICON_LAMP_AREA); break;
+                                       default:
+                                               UI_icon_draw(x, y, ICON_OUTLINER_DATA_LAMP); break;
+                               }
+                               break;
+                       }
                        case ID_MA:
-                               UI_icon_draw(x, y, ICON_MATERIAL_DEHLT); break;
+                               UI_icon_draw(x, y, ICON_MATERIAL_DATA); break;
                        case ID_TE:
-                               UI_icon_draw(x, y, ICON_TEXTURE_DEHLT); break;
+                               UI_icon_draw(x, y, ICON_TEXTURE_DATA); break;
                        case ID_IM:
-                               UI_icon_draw(x, y, ICON_IMAGE_DEHLT); break;
+                               UI_icon_draw(x, y, ICON_IMAGE_DATA); break;
                        case ID_SO:
                                UI_icon_draw(x, y, ICON_SPEAKER); break;
                        case ID_AR:
@@ -3250,9 +3719,9 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
                        case ID_CA:
                                UI_icon_draw(x, y, ICON_OUTLINER_DATA_CAMERA); break;
                        case ID_KE:
-                               UI_icon_draw(x, y, ICON_SHAPEKEY); break;
+                               UI_icon_draw(x, y, ICON_SHAPEKEY_DATA); break;
                        case ID_WO:
-                               UI_icon_draw(x, y, ICON_WORLD_DEHLT); break;
+                               UI_icon_draw(x, y, ICON_WORLD_DATA); break;
                        case ID_AC:
                                UI_icon_draw(x, y, ICON_ACTION); break;
                        case ID_NLA:
@@ -3262,7 +3731,7 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
                        case ID_GR:
                                UI_icon_draw(x, y, ICON_GROUP); break;
                        case ID_LI:
-                               UI_icon_draw(x, y, ICON_LIBRARY_DEHLT); break;
+                               UI_icon_draw(x, y, ICON_LIBRARY_DATA_DIRECT); break;
                }
        }
 }
@@ -3403,9 +3872,9 @@ static void outliner_draw_tree_element(Scene *scene, ARegion *ar, SpaceOops *soo
                if(tselem->type==0 && tselem->id->lib) {
                        glPixelTransferf(GL_ALPHA_SCALE, 0.5f);
                        if(tselem->id->flag & LIB_INDIRECT)
-                               UI_icon_draw((float)startx+offsx, (float)*starty+2, ICON_LIBRARY_HLT);
+                               UI_icon_draw((float)startx+offsx, (float)*starty+2, ICON_LIBRARY_DATA_INDIRECT);
                        else
-                               UI_icon_draw((float)startx+offsx, (float)*starty+2, ICON_LIBRARY_DEHLT);
+                               UI_icon_draw((float)startx+offsx, (float)*starty+2, ICON_LIBRARY_DATA_DIRECT);
                        glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
                        offsx+= OL_X;
                }               
@@ -3415,10 +3884,10 @@ static void outliner_draw_tree_element(Scene *scene, ARegion *ar, SpaceOops *soo
                if(active==1) UI_ThemeColor(TH_TEXT_HI);
                else if(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.75f);
                else UI_ThemeColor(TH_TEXT);
-               glRasterPos2i(startx+offsx, *starty+5);
-               UI_RasterPos((float)startx+offsx, (float)*starty+5);
-               UI_DrawString(G.font, te->name, 0);
-               offsx+= (int)(OL_X + UI_GetStringWidth(G.font, te->name, 0));
+               
+               UI_DrawString(startx+offsx, *starty+5, te->name);
+               
+               offsx+= (int)(OL_X + UI_GetStringWidth(te->name));
                
                /* closed item, we draw the icons, not when it's a scene, or master-server list though */
                if(tselem->flag & TSE_CLOSED) {
@@ -3506,7 +3975,7 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase *
                if((tselem->flag & TSE_CLOSED)==0) {
                        outliner_draw_struct_marks(ar, soops, &te->subtree, starty);
                        if(tselem->type == TSE_RNA_STRUCT)
-                               fdrawline(0, *starty+OL_H-1, (int)ar->v2d.cur.xmax, *starty+OL_H-1);
+                               fdrawline(0, (float)*starty+OL_H-1, ar->v2d.cur.xmax, (float)*starty+OL_H-1);
                }
        }
 }
@@ -3536,6 +4005,9 @@ static void outliner_draw_tree(Scene *scene, ARegion *ar, SpaceOops *soops)
        float col[4];
        
 #if 0 // XXX was #ifdef INTERNATIONAL
+       /* Maybe the INTERNATIONAL was really for check about freetype2 ?
+        * anyway I think that we can remove this now - Diego
+        */
        FTF_SetFontSize('l');
        BIF_SetScale(1.0);
 #endif
@@ -3642,8 +4114,6 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2)
                }
        }
 
-       allqueue(REDRAWOOPS, 0);
-       allqueue(REDRAWVIEW3D, 0);
 }
 
 static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2)
@@ -3665,21 +4135,15 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2)
                }
        }
 
-       allqueue(REDRAWOOPS, 0);
-       allqueue(REDRAWVIEW3D, 0);
 }
 
 static void restrictbutton_rend_cb(bContext *C, void *poin, void *poin2)
 {
-       allqueue(REDRAWOOPS, 0);
-       allqueue(REDRAWVIEW3D, 0);
 }
 
 static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *poin2)
 {
-       allqueue(REDRAWOOPS, 0);
-       allqueue(REDRAWNODE, 0);
-       allqueue(REDRAWBUTSSCENE, 0);
+       /* XXX redraws */
 }
 
 static void restrictbutton_modifier_cb(bContext *C, void *poin, void *poin2)
@@ -3690,17 +4154,11 @@ static void restrictbutton_modifier_cb(bContext *C, void *poin, void *poin2)
        DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
        object_handle_update(scene, ob);
 
-       allqueue(REDRAWOOPS, 0);
-       allqueue(REDRAWVIEW3D, 0);
-       allqueue(REDRAWBUTSEDIT, 0);
-       allqueue(REDRAWBUTSOBJECT, 0);
 }
 
 static void restrictbutton_bone_cb(bContext *C, void *poin, void *poin2)
 {
-       allqueue(REDRAWOOPS, 0);
-       allqueue(REDRAWVIEW3D, 0);
-       allqueue(REDRAWBUTSEDIT, 0);
+       /* XXX redraws */
 }
 
 static void namebutton_cb(bContext *C, void *tep, void *oldnamep)
@@ -3730,7 +4188,6 @@ static void namebutton_cb(bContext *C, void *tep, void *oldnamep)
                        switch(tselem->type) {
                        case TSE_DEFGROUP:
                                unique_vertexgroup_name(te->directdata, (Object *)tselem->id); //       id = object
-                               allqueue(REDRAWBUTSEDIT, 0);
                                break;
                        case TSE_NLA_ACTION:
                                test_idbutton(tselem->id->name+2);
@@ -3747,9 +4204,6 @@ static void namebutton_cb(bContext *C, void *tep, void *oldnamep)
                                        BLI_strncpy(ebone->name, oldnamep, 32);
 // XXX                                 armature_bone_rename(obedit->data, oldnamep, newname);
                                }
-                               allqueue(REDRAWOOPS, 0);
-                               allqueue(REDRAWVIEW3D, 1);
-                               allqueue(REDRAWBUTSEDIT, 0);
                        }
                                break;
 
@@ -3768,9 +4222,6 @@ static void namebutton_cb(bContext *C, void *tep, void *oldnamep)
                                        BLI_strncpy(bone->name, oldnamep, 32);
 // XXX                                 armature_bone_rename(ob->data, oldnamep, newname);
                                }
-                               allqueue(REDRAWOOPS, 0);
-                               allqueue(REDRAWVIEW3D, 1);
-                               allqueue(REDRAWBUTSEDIT, 0);
                                break;
                        case TSE_POSE_CHANNEL:
                                {
@@ -3787,22 +4238,16 @@ static void namebutton_cb(bContext *C, void *tep, void *oldnamep)
                                        BLI_strncpy(pchan->name, oldnamep, 32);
 // XXX                                 armature_bone_rename(ob->data, oldnamep, newname);
                                }
-                               allqueue(REDRAWOOPS, 0);
-                               allqueue(REDRAWVIEW3D, 1);
-                               allqueue(REDRAWBUTSEDIT, 0);
                                break;
                        case TSE_POSEGRP:
                                {
                                        Object *ob= (Object *)tselem->id; // id = object
                                        bActionGroup *grp= te->directdata;
                                        
-                                       BLI_uniquename(&ob->pose->agroups, grp, "Group", offsetof(bActionGroup, name), 32);
-                                       allqueue(REDRAWBUTSEDIT, 0);
+                                       BLI_uniquename(&ob->pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), 32);
                                }
                                break;
                        case TSE_R_LAYER:
-                               allqueue(REDRAWOOPS, 0);
-                               allqueue(REDRAWBUTSSCENE, 0);
                                break;
                        }
                }
@@ -3824,20 +4269,17 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                ob = (Object *)tselem->id;
                                
                                uiBlockSetEmboss(block, UI_EMBOSSN);
-                               bt= uiDefIconButBitS(block, ICONTOG, OB_RESTRICT_VIEW, REDRAWALL, ICON_RESTRICT_VIEW_OFF, 
+                               bt= uiDefIconButBitS(block, ICONTOG, OB_RESTRICT_VIEW, 0, ICON_RESTRICT_VIEW_OFF, 
                                                (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(ob->restrictflag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
                                uiButSetFunc(bt, restrictbutton_view_cb, scene, ob);
-                               uiButSetFlag(bt, UI_NO_HILITE);
                                
-                               bt= uiDefIconButBitS(block, ICONTOG, OB_RESTRICT_SELECT, REDRAWALL, ICON_RESTRICT_SELECT_OFF, 
+                               bt= uiDefIconButBitS(block, ICONTOG, OB_RESTRICT_SELECT, 0, ICON_RESTRICT_SELECT_OFF, 
                                                (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(ob->restrictflag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
                                uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob);
-                               uiButSetFlag(bt, UI_NO_HILITE);
                                
-                               bt= uiDefIconButBitS(block, ICONTOG, OB_RESTRICT_RENDER, REDRAWALL, ICON_RESTRICT_RENDER_OFF, 
+                               bt= uiDefIconButBitS(block, ICONTOG, OB_RESTRICT_RENDER, 0, ICON_RESTRICT_RENDER_OFF, 
                                                (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (short)te->ys, 17, OL_H-1, &(ob->restrictflag), 0, 0, 0, 0, "Restrict/Allow renderability");
                                uiButSetFunc(bt, restrictbutton_rend_cb, NULL, NULL);
-                               uiButSetFlag(bt, UI_NO_HILITE);
                                
                                uiBlockSetEmboss(block, UI_EMBOSS);
                        }
@@ -3845,7 +4287,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                        else if(tselem->type==TSE_R_LAYER) {
                                uiBlockSetEmboss(block, UI_EMBOSSN);
                                
-                               bt= uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, REDRAWBUTSSCENE, ICON_CHECKBOX_HLT-1, 
+                               bt= uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT-1, 
                                                                         (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer");
                                uiButSetFunc(bt, restrictbutton_r_lay_cb, NULL, NULL);
                                
@@ -3856,13 +4298,13 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                uiBlockSetEmboss(block, UI_EMBOSSN);
                                
                                /* NOTE: tselem->nr is short! */
-                               bt= uiDefIconButBitI(block, ICONTOG, tselem->nr, REDRAWBUTSSCENE, ICON_CHECKBOX_HLT-1, 
+                               bt= uiDefIconButBitI(block, ICONTOG, tselem->nr, 0, ICON_CHECKBOX_HLT-1, 
                                                                         (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, layflag, 0, 0, 0, 0, "Render this Pass");
                                uiButSetFunc(bt, restrictbutton_r_lay_cb, NULL, NULL);
                                
                                layflag++;      /* is lay_xor */
                                if(ELEM6(tselem->nr, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_RADIO))
-                                       bt= uiDefIconButBitI(block, TOG, tselem->nr, REDRAWBUTSSCENE, (*layflag & tselem->nr)?ICON_DOT:ICON_BLANK1, 
+                                       bt= uiDefIconButBitI(block, TOG, tselem->nr, 0, (*layflag & tselem->nr)?ICON_DOT:ICON_BLANK1, 
                                                                         (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined");
                                uiButSetFunc(bt, restrictbutton_r_lay_cb, NULL, NULL);
                                
@@ -3873,34 +4315,30 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                ob = (Object *)tselem->id;
                                
                                uiBlockSetEmboss(block, UI_EMBOSSN);
-                               bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, REDRAWALL, ICON_RESTRICT_VIEW_OFF, 
+                               bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, 
                                                (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
                                uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob);
-                               uiButSetFlag(bt, UI_NO_HILITE);
                                
-                               bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, REDRAWALL, ICON_RESTRICT_RENDER_OFF, 
+                               bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, 
                                                (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (short)te->ys, 17, OL_H-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability");
                                uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob);
-                               uiButSetFlag(bt, UI_NO_HILITE);
                        }
                        else if(tselem->type==TSE_POSE_CHANNEL)  {
                                bPoseChannel *pchan= (bPoseChannel *)te->directdata;
                                Bone *bone = pchan->bone;
 
                                uiBlockSetEmboss(block, UI_EMBOSSN);
-                               bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, REDRAWALL, ICON_RESTRICT_VIEW_OFF, 
+                               bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, 
                                                (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
                                uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL);
-                               uiButSetFlag(bt, UI_NO_HILITE);
                        }
                        else if(tselem->type==TSE_EBONE)  {
                                EditBone *ebone= (EditBone *)te->directdata;
 
                                uiBlockSetEmboss(block, UI_EMBOSSN);
-                               bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, REDRAWALL, ICON_RESTRICT_VIEW_OFF, 
+                               bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, 
                                                (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
                                uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL);
-                               uiButSetFlag(bt, UI_NO_HILITE);
                        }
                }
                
@@ -3915,14 +4353,14 @@ static void outliner_draw_rnacols(ARegion *ar, SpaceOops *soops, int sizex)
        UI_ThemeColorShadeAlpha(TH_BACK, -15, -200);
 
        /* draw column separator lines */
-       fdrawline(sizex,
+       fdrawline((float)sizex,
                v2d->cur.ymax,
-               sizex,
+               (float)sizex,
                v2d->cur.ymin);
 
-       fdrawline(sizex+OL_RNA_COL_SIZEX,
+       fdrawline((float)sizex+OL_RNA_COL_SIZEX,
                v2d->cur.ymax,
-               sizex+OL_RNA_COL_SIZEX,
+               (float)sizex+OL_RNA_COL_SIZEX,
                v2d->cur.ymin);
 }
 
@@ -3941,15 +4379,15 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
                        if(tselem->type == TSE_RNA_PROPERTY) {
                                ptr= &te->rnaptr;
                                prop= te->directdata;
-
-                               if(!(RNA_property_type(ptr, prop) == PROP_POINTER && (tselem->flag & TSE_CLOSED)==0))
-                                       uiDefAutoButR(block, ptr, prop, -1, "", sizex, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
+                               
+                               if(!(RNA_property_type(prop) == PROP_POINTER && (tselem->flag & TSE_CLOSED)==0))
+                                       uiDefAutoButR(block, ptr, prop, -1, "", 0, sizex, (int)te->ys, OL_RNA_COL_SIZEX, OL_H-1);
                        }
                        else if(tselem->type == TSE_RNA_ARRAY_ELEM) {
                                ptr= &te->rnaptr;
                                prop= te->directdata;
-
-                               uiDefAutoButR(block, ptr, prop, te->index, "", sizex, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
+                               
+                               uiDefAutoButR(block, ptr, prop, te->index, "", 0, sizex, (int)te->ys, OL_RNA_COL_SIZEX, OL_H-1);
                        }
                }
                
@@ -3979,7 +4417,7 @@ static void outliner_buttons(uiBlock *block, ARegion *ar, SpaceOops *soops, List
                                else if(tselem->id && GS(tselem->id->name)==ID_LI) len = sizeof(((Library*) 0)->name);
                                else len= sizeof(((ID*) 0)->name)-2;
                                
-                               dx= (int)UI_GetStringWidth(G.font, te->name, 0);
+                               dx= (int)UI_GetStringWidth(te->name);
                                if(dx<50) dx= 50;
                                
                                bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "",  (short)te->xs+2*OL_X-4, (short)te->ys, dx+10, OL_H-1, te->name, 1.0, (float)len-1, 0, 0, "");
@@ -4050,7 +4488,7 @@ void draw_outliner(const bContext *C)
        outliner_draw_tree(scene, ar, soops);
 
        /* draw icons and names */
-       block= uiBeginBlock(C, ar, "outliner buttons", UI_EMBOSS, UI_HELV);
+       block= uiBeginBlock(C, ar, "outliner buttons", UI_EMBOSS);
        outliner_buttons(block, ar, soops, &soops->tree);
        
        if(ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) {