Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / space_outliner / outliner_tools.c
index e80ba5d40df1e21d8db66cc3449982b510266e20..d6300b74aeac4e4ab21688c10c36cc4cd8799c5d 100644 (file)
@@ -57,6 +57,7 @@
 #include "BKE_fcurve.h"
 #include "BKE_group.h"
 #include "BKE_library.h"
+#include "BKE_library_query.h"
 #include "BKE_library_remap.h"
 #include "BKE_main.h"
 #include "BKE_report.h"
@@ -134,15 +135,17 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb,
        }
 }
 
-static void unlink_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
-                             TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem), void *UNUSED(user_data))
+static void unlink_action_cb(
+        bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te),
+        TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem), void *UNUSED(user_data))
 {
        /* just set action to NULL */
        BKE_animdata_set_action(CTX_wm_reports(C), tsep->id, NULL);
 }
 
-static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te,
-                               TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem), void *UNUSED(user_data))
+static void unlink_material_cb(
+        bContext *UNUSED(C), ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *te,
+        TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem), void *UNUSED(user_data))
 {
        Material **matar = NULL;
        int a, totcol = 0;
@@ -181,8 +184,9 @@ static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEl
        }
 }
 
-static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te,
-                              TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem), void *UNUSED(user_data))
+static void unlink_texture_cb(
+        bContext *UNUSED(C), ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *te,
+        TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem), void *UNUSED(user_data))
 {
        MTex **mtex = NULL;
        int a;
@@ -218,7 +222,7 @@ static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEle
 }
 
 static void unlink_group_cb(
-        bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
+        bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te),
         TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data))
 {
        Group *group = (Group *)tselem->id;
@@ -231,13 +235,14 @@ static void unlink_group_cb(
        }
        else {
                Main *bmain = CTX_data_main(C);
-               BKE_libblock_unlink(bmain, group, false);
+               BKE_libblock_unlink(bmain, group, false, false);
                BKE_libblock_free(bmain, group);
        }
 }
 
-static void unlink_world_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te),
-                            TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data))
+static void unlink_world_cb(
+        bContext *UNUSED(C), ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te),
+        TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data))
 {
        Scene *parscene = (Scene *)tsep->id;
        World *wo = (World *)tselem->id;
@@ -248,8 +253,8 @@ static void unlink_world_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEleme
 }
 
 static void outliner_do_libdata_operation(
-        bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb,
-        void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *, void *),
+        bContext *C, ReportList *reports, Scene *scene, SpaceOops *soops, ListBase *lb,
+        outliner_operation_cb operation_cb,
         void *user_data)
 {
        TreeElement *te;
@@ -260,11 +265,11 @@ static void outliner_do_libdata_operation(
                if (tselem->flag & TSE_SELECTED) {
                        if (tselem->type == 0) {
                                TreeStoreElem *tsep = te->parent ? TREESTORE(te->parent) : NULL;
-                               operation_cb(C, scene, te, tsep, tselem, user_data);
+                               operation_cb(C, reports, scene, te, tsep, tselem, user_data);
                        }
                }
                if (TSELEM_OPEN(tselem, soops)) {
-                       outliner_do_libdata_operation(C, scene, soops, &te->subtree, operation_cb, user_data);
+                       outliner_do_libdata_operation(C, reports, scene, soops, &te->subtree, operation_cb, user_data);
                }
        }
 }
@@ -354,8 +359,9 @@ void OUTLINER_OT_scene_operation(wmOperatorType *ot)
 }
 /* ******************************************** */
 
-static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
-                             TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
+static void object_select_cb(
+        bContext *UNUSED(C), ReportList *UNUSED(reports), Scene *scene, TreeElement *te,
+        TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
 {
        Base *base = (Base *)te->directdata;
        
@@ -366,19 +372,21 @@ static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
        }
 }
 
-static void object_select_hierarchy_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
-                             TreeStoreElem *UNUSED(tsep), TreeStoreElem *UNUSED(tselem), void *UNUSED(user_data))
+static void object_select_hierarchy_cb(
+        bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te),
+        TreeStoreElem *UNUSED(tsep), TreeStoreElem *UNUSED(tselem), void *UNUSED(user_data))
 {
        /* From where do i get the x,y coordinate of the mouse event ? */
        wmWindow *win = CTX_wm_window(C);
        int x = win->eventstate->mval[0];
        int y = win->eventstate->mval[1];
-       outliner_item_do_activate(C, x, y, true, true);
+       outliner_item_activate_or_toggle_closed(C, x, y, true, true);
 }
 
 
-static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
-                               TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
+static void object_deselect_cb(
+        bContext *UNUSED(C), ReportList *UNUSED(reports), Scene *scene, TreeElement *te,
+        TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
 {
        Base *base = (Base *)te->directdata;
        
@@ -389,14 +397,27 @@ static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *t
        }
 }
 
-static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te,
-                             TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
+static void object_delete_cb(
+        bContext *C, ReportList *reports, Scene *scene, TreeElement *te,
+        TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
 {
        Base *base = (Base *)te->directdata;
        
        if (base == NULL)
                base = BKE_scene_base_find(scene, (Object *)tselem->id);
        if (base) {
+               Main *bmain = CTX_data_main(C);
+               if (base->object->id.tag & LIB_TAG_INDIRECT) {
+                       BKE_reportf(reports, RPT_WARNING, "Cannot delete indirectly linked object '%s'", base->object->id.name + 2);
+                       return;
+               }
+               else if (BKE_library_ID_is_indirectly_used(bmain, base->object) && ID_REAL_USERS(base->object) <= 1) {
+                       BKE_reportf(reports, RPT_WARNING,
+                                   "Cannot delete object '%s' from scene '%s', indirectly used objects need at least one user",
+                                   base->object->id.name + 2, scene->id.name + 2);
+                       return;
+               }
+
                // check also library later
                if (scene->obedit == base->object)
                        ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO);
@@ -410,45 +431,53 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te,
        }
 }
 
-static void id_local_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
-                        TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
+static void id_local_cb(
+        bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te),
+        TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
 {
-       if (tselem->id->lib && (tselem->id->tag & LIB_TAG_EXTERN)) {
+       if (ID_IS_LINKED_DATABLOCK(tselem->id) && (tselem->id->tag & LIB_TAG_EXTERN)) {
+               Main *bmain = CTX_data_main(C);
                /* if the ID type has no special local function,
                 * just clear the lib */
-               if (id_make_local(tselem->id, false) == false) {
-                       Main *bmain = CTX_data_main(C);
+               if (id_make_local(bmain, tselem->id, false, false) == false) {
                        id_clear_lib_data(bmain, tselem->id);
                }
+               else {
+                       BKE_main_id_clear_newpoins(bmain);
+               }
        }
 }
 
-static void id_fake_user_set_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te),
-                                TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
+static void id_fake_user_set_cb(
+        bContext *UNUSED(C), ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te),
+        TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
 {
        ID *id = tselem->id;
        
        id_fake_user_set(id);
 }
 
-static void id_fake_user_clear_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te),
-                                  TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
+static void id_fake_user_clear_cb(
+        bContext *UNUSED(C), ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te),
+        TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
 {
        ID *id = tselem->id;
        
        id_fake_user_clear(id);
 }
 
-static void id_select_linked_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
-                                TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
+static void id_select_linked_cb(
+        bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te),
+        TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
 {
        ID *id = tselem->id;
 
        ED_object_select_linked_by_id(C, id);
 }
 
-static void singleuser_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
-                                 TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data))
+static void singleuser_action_cb(
+        bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te),
+        TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data))
 {
        ID *id = tselem->id;
        
@@ -464,8 +493,9 @@ static void singleuser_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement
        }
 }
 
-static void singleuser_world_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
-                                TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data))
+static void singleuser_world_cb(
+        bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te),
+        TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data))
 {
        ID *id = tselem->id;
        
@@ -482,34 +512,29 @@ static void singleuser_world_cb(bContext *C, Scene *UNUSED(scene), TreeElement *
        }
 }
 
-static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te),
-                                   TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
+static void group_linkobs2scene_cb(
+        bContext *UNUSED(C), ReportList *UNUSED(reports), Scene *scene, TreeElement *UNUSED(te),
+        TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
 {
        Group *group = (Group *)tselem->id;
        GroupObject *gob;
        Base *base;
-       
+
        for (gob = group->gobject.first; gob; gob = gob->next) {
                base = BKE_scene_base_find(scene, gob->ob);
-               if (base) {
-                       base->object->flag |= SELECT;
-                       base->flag |= SELECT;
-               }
-               else {
+               if (!base) {
                        /* link to scene */
-                       base = MEM_callocN(sizeof(Base), "add_base");
-                       BLI_addhead(&scene->base, base);
-                       base->lay = gob->ob->lay;
-                       gob->ob->flag |= SELECT;
-                       base->flag = gob->ob->flag;
-                       base->object = gob->ob;
+                       base = BKE_scene_base_add(scene, gob->ob);
                        id_lib_extern((ID *)gob->ob); /* in case these are from a linked group */
                }
+               base->object->flag |= SELECT;
+               base->flag |= SELECT;
        }
 }
 
-static void group_instance_cb(bContext *C, Scene *scene, TreeElement *UNUSED(te),
-                              TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
+static void group_instance_cb(
+        bContext *C, ReportList *UNUSED(reports), Scene *scene, TreeElement *UNUSED(te),
+        TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
 {
        Group *group = (Group *)tselem->id;
 
@@ -523,9 +548,8 @@ static void group_instance_cb(bContext *C, Scene *scene, TreeElement *UNUSED(te)
  * \param select_recurse: Set to false for operations which are already recursively operating on their children.
  */
 void outliner_do_object_operation_ex(
-        bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb,
-        void (*operation_cb)(bContext *, Scene *, TreeElement *, TreeStoreElem *, TreeStoreElem *, void *),
-        bool select_recurse)
+        bContext *C, ReportList *reports, Scene *scene_act, SpaceOops *soops, ListBase *lb,
+        outliner_operation_cb operation_cb, bool select_recurse)
 {
        TreeElement *te;
        
@@ -542,23 +566,24 @@ void outliner_do_object_operation_ex(
                                /* important to use 'scene_owner' not scene_act else deleting objects can crash.
                                 * only use 'scene_act' when 'scene_owner' is NULL, which can happen when the
                                 * outliner isn't showing scenes: Visible Layer draw mode for eg. */
-                               operation_cb(C, scene_owner ? scene_owner : scene_act, te, NULL, tselem, NULL);
+                               operation_cb(C, reports, scene_owner ? scene_owner : scene_act, te, NULL, tselem, NULL);
                                select_handled = true;
                        }
                }
                if (TSELEM_OPEN(tselem, soops)) {
                        if ((select_handled == false) || select_recurse) {
-                               outliner_do_object_operation_ex(C, scene_act, soops, &te->subtree, operation_cb, select_recurse);
+                               outliner_do_object_operation_ex(
+                                           C, reports, scene_act, soops, &te->subtree, operation_cb, select_recurse);
                        }
                }
        }
 }
 
 void outliner_do_object_operation(
-        bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb,
-        void (*operation_cb)(bContext *, Scene *, TreeElement *, TreeStoreElem *, TreeStoreElem *, void *))
+        bContext *C, ReportList *reports, Scene *scene_act, SpaceOops *soops, ListBase *lb,
+        outliner_operation_cb operation_cb)
 {
-       outliner_do_object_operation_ex(C, scene_act, soops, lb, operation_cb, true);
+       outliner_do_object_operation_ex(C, reports, scene_act, soops, lb, operation_cb, true);
 }
 
 /* ******************************************** */
@@ -793,7 +818,7 @@ static void outliner_do_data_operation(SpaceOops *soops, int type, int event, Li
        }
 }
 
-static Base *outline_delete_hierarchy(bContext *C, Scene *scene, Base *base)
+static Base *outline_delete_hierarchy(bContext *C, ReportList *reports, Scene *scene, Base *base)
 {
        Base *child_base, *base_next;
        Object *parent;
@@ -806,17 +831,30 @@ static Base *outline_delete_hierarchy(bContext *C, Scene *scene, Base *base)
                base_next = child_base->next;
                for (parent = child_base->object->parent; parent && (parent != base->object); parent = parent->parent);
                if (parent) {
-                       base_next = outline_delete_hierarchy(C, scene, child_base);
+                       base_next = outline_delete_hierarchy(C, reports, scene, child_base);
                }
        }
 
        base_next = base->next;
+
+       Main *bmain = CTX_data_main(C);
+       if (base->object->id.tag & LIB_TAG_INDIRECT) {
+               BKE_reportf(reports, RPT_WARNING, "Cannot delete indirectly linked object '%s'", base->object->id.name + 2);
+               return base_next;
+       }
+       else if (BKE_library_ID_is_indirectly_used(bmain, base->object) && ID_REAL_USERS(base->object) <= 1) {
+               BKE_reportf(reports, RPT_WARNING,
+                           "Cannot delete object '%s' from scene '%s', indirectly used objects need at least one user",
+                           base->object->id.name + 2, scene->id.name + 2);
+               return base_next;
+       }
        ED_base_object_free_and_unlink(CTX_data_main(C), scene, base);
        return base_next;
 }
 
 static void object_delete_hierarchy_cb(
-        bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
+        bContext *C, ReportList *reports, Scene *scene,
+        TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
 {
        Base *base = (Base *)te->directdata;
        Object *obedit = scene->obedit;
@@ -831,7 +869,7 @@ static void object_delete_hierarchy_cb(
                        ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO);
                }
 
-               outline_delete_hierarchy(C, scene, base);
+               outline_delete_hierarchy(C, reports, scene, base);
                /* leave for ED_outliner_id_unref to handle */
 #if 0
                te->directdata = NULL;
@@ -865,7 +903,7 @@ static EnumPropertyItem prop_object_op_types[] = {
        {OL_OP_DELETE, "DELETE", 0, "Delete", ""},
        {OL_OP_DELETE_HIERARCHY, "DELETE_HIERARCHY", 0, "Delete Hierarchy", ""},
        {OL_OP_REMAP, "REMAP",   0, "Remap Users",
-        "Make all users of selected datablocks to use instead a new chosen one"},
+        "Make all users of selected data-blocks to use instead a new chosen one"},
        {OL_OP_TOGVIS, "TOGVIS", 0, "Toggle Visible", ""},
        {OL_OP_TOGSEL, "TOGSEL", 0, "Toggle Selectable", ""},
        {OL_OP_TOGREN, "TOGREN", 0, "Toggle Renderable", ""},
@@ -889,7 +927,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
 
        if (event == OL_OP_SELECT) {
                Scene *sce = scene;  // to be able to delete, scenes are set...
-               outliner_do_object_operation(C, scene, soops, &soops->tree, object_select_cb);
+               outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_select_cb);
                if (scene != sce) {
                        ED_screen_set_scene(C, CTX_wm_screen(C), sce);
                }
@@ -899,7 +937,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
        }
        else if (event == OL_OP_SELECT_HIERARCHY) {
                Scene *sce = scene;  // to be able to delete, scenes are set...
-               outliner_do_object_operation_ex(C, scene, soops, &soops->tree, object_select_hierarchy_cb, false);
+               outliner_do_object_operation_ex(C, op->reports, scene, soops, &soops->tree, object_select_hierarchy_cb, false);
                if (scene != sce) {
                        ED_screen_set_scene(C, CTX_wm_screen(C), sce);
                }       
@@ -907,12 +945,12 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
                WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
        }
        else if (event == OL_OP_DESELECT) {
-               outliner_do_object_operation(C, scene, soops, &soops->tree, object_deselect_cb);
+               outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_deselect_cb);
                str = "Deselect Objects";
                WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
        }
        else if (event == OL_OP_DELETE) {
-               outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb);
+               outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_delete_cb);
 
                /* XXX: tree management normally happens from draw_outliner(), but when
                 *      you're clicking to fast on Delete object from context menu in
@@ -926,7 +964,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
                WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
        }
        else if (event == OL_OP_DELETE_HIERARCHY) {
-               outliner_do_object_operation_ex(C, scene, soops, &soops->tree, object_delete_hierarchy_cb, false);
+               outliner_do_object_operation_ex(C, op->reports, scene, soops, &soops->tree, object_delete_hierarchy_cb, false);
 
                /* XXX: See OL_OP_DELETE comment above. */
                outliner_cleanup_tree(soops);
@@ -936,30 +974,30 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
                WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
        }
        else if (event == OL_OP_REMAP) {
-               outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_remap_cb, NULL);
+               outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_remap_cb, NULL);
                str = "Remap ID";
        }
        else if (event == OL_OP_LOCALIZED) {    /* disabled, see above enum (ton) */
-               outliner_do_object_operation(C, scene, soops, &soops->tree, id_local_cb);
+               outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, id_local_cb);
                str = "Localized Objects";
        }
        else if (event == OL_OP_TOGVIS) {
-               outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb);
+               outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_toggle_visibility_cb);
                str = "Toggle Visibility";
                WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene);
        }
        else if (event == OL_OP_TOGSEL) {
-               outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb);
+               outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_toggle_selectability_cb);
                str = "Toggle Selectability";
                WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
        }
        else if (event == OL_OP_TOGREN) {
-               outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb);
+               outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_toggle_renderability_cb);
                str = "Toggle Renderability";
                WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, scene);
        }
        else if (event == OL_OP_RENAME) {
-               outliner_do_object_operation(C, scene, soops, &soops->tree, item_rename_cb);
+               outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, item_rename_cb);
                str = "Rename Object";
        }
        else {
@@ -1011,7 +1049,7 @@ static EnumPropertyItem prop_group_op_types[] = {
        {OL_GROUPOP_LINK, "LINK",         0, "Link Group Objects to Scene", ""},
        {OL_GROUPOP_DELETE, "DELETE",     0, "Delete Group", "WARNING: no undo"},
        {OL_GROUPOP_REMAP, "REMAP",       0, "Remap Users",
-        "Make all users of selected datablocks to use instead current (clicked) one"},
+        "Make all users of selected data-blocks to use instead current (clicked) one"},
        {OL_GROUPOP_INSTANCE, "INSTANCE", 0, "Instance Groups in Scene", ""},
        {OL_GROUPOP_TOGVIS, "TOGVIS",     0, "Toggle Visible Group", ""},
        {OL_GROUPOP_TOGSEL, "TOGSEL",     0, "Toggle Selectable", ""},
@@ -1034,16 +1072,16 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op)
 
        switch (event) {
                case OL_GROUPOP_UNLINK:
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_group_cb, NULL);
                        break;
                case OL_GROUPOP_LOCAL:
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_local_cb, NULL);
                        break;
                case OL_GROUPOP_LINK:
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, group_linkobs2scene_cb, NULL);
                        break;
                case OL_GROUPOP_INSTANCE:
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_instance_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, group_instance_cb, NULL);
                        /* works without this except if you try render right after, see: 22027 */
                        DAG_relations_tag_update(CTX_data_main(C));
                        break;
@@ -1051,19 +1089,19 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op)
                        WM_operator_name_call(C, "OUTLINER_OT_id_delete", WM_OP_INVOKE_REGION_WIN, NULL);
                        break;
                case OL_GROUPOP_REMAP:
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_remap_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_remap_cb, NULL);
                        break;
                case OL_GROUPOP_TOGVIS:
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, group_toggle_visibility_cb, NULL);
                        break;
                case OL_GROUPOP_TOGSEL:
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, group_toggle_selectability_cb, NULL);
                        break;
                case OL_GROUPOP_TOGREN:
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, group_toggle_renderability_cb, NULL);
                        break;
                case OL_GROUPOP_RENAME:
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, item_rename_cb, NULL);
                        break;
                default:
                        BLI_assert(0);
@@ -1118,9 +1156,9 @@ static EnumPropertyItem prop_id_op_types[] = {
        {OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""},
        {OUTLINER_IDOP_DELETE, "DELETE", 0, "Delete", "WARNING: no undo"},
        {OUTLINER_IDOP_REMAP, "REMAP", 0, "Remap Users",
-        "Make all users of selected datablocks to use instead current (clicked) one"},
+        "Make all users of selected data-blocks to use instead current (clicked) one"},
        {OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User",
-        "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"},
+        "Ensure data-block gets saved even if it isn't in use (e.g. for motion and material libraries)"},
        {OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""},
        {OUTLINER_IDOP_RENAME, "RENAME", 0, "Rename", ""},
        {OUTLINER_IDOP_SELECT_LINKED, "SELECT_LINKED", 0, "Select Linked", ""},
@@ -1148,25 +1186,25 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
                        /* unlink datablock from its parent */
                        switch (idlevel) {
                                case ID_AC:
-                                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_action_cb, NULL);
+                                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_action_cb, NULL);
                                        
                                        WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
                                        ED_undo_push(C, "Unlink action");
                                        break;
                                case ID_MA:
-                                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_material_cb, NULL);
+                                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_material_cb, NULL);
                                        
                                        WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL);
                                        ED_undo_push(C, "Unlink material");
                                        break;
                                case ID_TE:
-                                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_texture_cb, NULL);
+                                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_texture_cb, NULL);
                                        
                                        WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL);
                                        ED_undo_push(C, "Unlink texture");
                                        break;
                                case ID_WO:
-                                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_world_cb, NULL);
+                                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_world_cb, NULL);
                                        
                                        WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL);
                                        ED_undo_push(C, "Unlink world");
@@ -1180,7 +1218,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
                case OUTLINER_IDOP_LOCAL:
                {
                        /* make local */
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_local_cb, NULL);
                        ED_undo_push(C, "Localized Data");
                        break;
                }
@@ -1189,14 +1227,14 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
                        /* make single user */
                        switch (idlevel) {
                                case ID_AC:
-                                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_action_cb, NULL);
+                                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, singleuser_action_cb, NULL);
                                        
                                        WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
                                        ED_undo_push(C, "Single-User Action");
                                        break;
                                        
                                case ID_WO:
-                                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_world_cb, NULL);
+                                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, singleuser_world_cb, NULL);
                                        
                                        WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL);
                                        ED_undo_push(C, "Single-User World");
@@ -1211,21 +1249,21 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
                case OUTLINER_IDOP_DELETE:
                {
                        if (idlevel > 0) {
-                               outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_delete_cb, NULL);
+                               outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_delete_cb, NULL);
                        }
                        break;
                }
                case OUTLINER_IDOP_REMAP:
                {
                        if (idlevel > 0) {
-                               outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_remap_cb, NULL);
+                               outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_remap_cb, NULL);
                        }
                        break;
                }
                case OUTLINER_IDOP_FAKE_ADD:
                {
                        /* set fake user */
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_set_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_fake_user_set_cb, NULL);
                        
                        WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
                        ED_undo_push(C, "Add Fake User");
@@ -1234,7 +1272,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
                case OUTLINER_IDOP_FAKE_CLEAR:
                {
                        /* clear fake user */
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_clear_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_fake_user_clear_cb, NULL);
                        
                        WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
                        ED_undo_push(C, "Clear Fake User");
@@ -1243,14 +1281,14 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
                case OUTLINER_IDOP_RENAME:
                {
                        /* rename */
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, item_rename_cb, NULL);
                        
                        WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
                        ED_undo_push(C, "Rename");
                        break;
                }
                case OUTLINER_IDOP_SELECT_LINKED:
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_select_linked_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_select_linked_cb, NULL);
                        ED_undo_push(C, "Select");
                        break;
                        
@@ -1310,7 +1348,7 @@ static int outliner_lib_operation_exec(bContext *C, wmOperator *op)
        Scene *scene = CTX_data_scene(C);
        SpaceOops *soops = CTX_wm_space_outliner(C);
        int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
-       eOutlinerIdOpTypes event;
+       eOutlinerLibOpTypes event;
 
        /* check for invalid states */
        if (soops == NULL)
@@ -1324,7 +1362,7 @@ static int outliner_lib_operation_exec(bContext *C, wmOperator *op)
                case OL_LIB_RENAME:
                {
                        /* rename */
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, item_rename_cb, NULL);
 
                        WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
                        ED_undo_push(C, "Rename");
@@ -1332,19 +1370,19 @@ static int outliner_lib_operation_exec(bContext *C, wmOperator *op)
                }
                case OL_LIB_DELETE:
                {
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_delete_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_delete_cb, NULL);
                        break;
                }
                case OL_LIB_RELOCATE:
                {
                        /* rename */
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, lib_relocate_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, lib_relocate_cb, NULL);
                        break;
                }
                case OL_LIB_RELOAD:
                {
                        /* rename */
-                       outliner_do_libdata_operation(C, scene, soops, &soops->tree, lib_reload_cb, NULL);
+                       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, lib_reload_cb, NULL);
                        break;
                }
                default:
@@ -1441,8 +1479,8 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op)
        else if (act->idroot == 0) {
                /* hopefully in this case (i.e. library of userless actions), the user knows what they're doing... */
                BKE_reportf(op->reports, RPT_WARNING,
-                           "Action '%s' does not specify what datablocks it can be used on "
-                           "(try setting the 'ID Root Type' setting from the Datablocks Editor "
+                           "Action '%s' does not specify what data-blocks it can be used on "
+                           "(try setting the 'ID Root Type' setting from the data-blocks editor "
                            "for this action to avoid future problems)",
                            act->id.name + 2);
        }
@@ -1797,8 +1835,8 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot)
 /* ******************** */
 
 
-static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops,
-                                       TreeElement *te, const wmEvent *event, const float mval[2])
+static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOops *soops,
+                                       TreeElement *te, const float mval[2])
 {
        ReportList *reports = CTX_wm_reports(C); // XXX...
        
@@ -1809,8 +1847,8 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S
                /* select object that's clicked on and popup context menu */
                if (!(tselem->flag & TSE_SELECTED)) {
                        
-                       if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1))
-                               outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0);
+                       if (outliner_has_one_flag(&soops->tree, TSE_SELECTED, 1))
+                               outliner_set_flag(&soops->tree, TSE_SELECTED, 0);
                        
                        tselem->flag |= TSE_SELECTED;
                        /* redraw, same as outliner_select function */
@@ -1881,7 +1919,7 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S
        }
        
        for (te = te->subtree.first; te; te = te->next) {
-               if (do_outliner_operation_event(C, scene, ar, soops, te, event, mval))
+               if (do_outliner_operation_event(C, ar, soops, te, mval))
                        return 1;
        }
        return 0;
@@ -1890,7 +1928,6 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S
 
 static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 {
-       Scene *scene = CTX_data_scene(C);
        ARegion *ar = CTX_wm_region(C);
        SpaceOops *soops = CTX_wm_space_outliner(C);
        uiBut *but = UI_context_active_but_get(C);
@@ -1904,7 +1941,7 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent
        UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
        
        for (te = soops->tree.first; te; te = te->next) {
-               if (do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) {
+               if (do_outliner_operation_event(C, ar, soops, te, fmval)) {
                        break;
                }
        }