From 4d08ef822ce291744d40e0fef47975e7f61826e8 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 29 Dec 2017 12:13:47 -0200 Subject: Outliner/Collection: Operator to delete selected collections This is part of T53495. This operator is actually using existing code. The only new thing about it is that it has a shortcut. It will be exposed in the UI soon together with the nested collection operator. --- .../editors/space_outliner/outliner_collections.c | 21 +++++++++++++++++++++ .../editors/space_outliner/outliner_intern.h | 1 + .../blender/editors/space_outliner/outliner_ops.c | 2 ++ 3 files changed, 24 insertions(+) (limited to 'source/blender/editors/space_outliner') diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c index 35d0a34b984..a01cfa4812a 100644 --- a/source/blender/editors/space_outliner/outliner_collections.c +++ b/source/blender/editors/space_outliner/outliner_collections.c @@ -51,6 +51,9 @@ #include "outliner_intern.h" /* own include */ +/* Prototypes. */ +static int collection_delete_exec(struct bContext *C, struct wmOperator *op); + /* -------------------------------------------------------------------- */ static LayerCollection *outliner_collection_active(bContext *C) @@ -421,6 +424,24 @@ void OUTLINER_OT_collection_nested_new(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/**********************************************************************************/ +/* Delete selected collection. */ + +void OUTLINER_OT_collection_delete_selected(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Delete Selected Collections"; + ot->idname = "OUTLINER_OT_collection_delete_selected"; + ot->description = "Delete all the selected collections"; + + /* api callbacks */ + ot->exec = collection_delete_exec; + ot->poll = collections_editor_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + /**********************************************************************************/ /** diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 0025631c85f..c73e4f4aadd 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -341,6 +341,7 @@ void OUTLINER_OT_collection_objects_select(struct wmOperatorType *ot); void OUTLINER_OT_collection_objects_deselect(struct wmOperatorType *ot); void OUTLINER_OT_collection_nested_new(struct wmOperatorType *ot); +void OUTLINER_OT_collection_delete_selected(struct wmOperatorType *ot); /* outliner_utils.c ---------------------------------------------- */ diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 925d7a83b36..98e8aca0e1f 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -337,6 +337,7 @@ void outliner_operatortypes(void) WM_operatortype_append(OUTLINER_OT_collection_objects_deselect); WM_operatortype_append(OUTLINER_OT_collection_nested_new); + WM_operatortype_append(OUTLINER_OT_collection_delete_selected); } static wmKeyMap *outliner_item_drag_drop_modal_keymap(wmKeyConfig *keyconf) @@ -435,6 +436,7 @@ void outliner_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_delete_selected", DKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OUTLINER_OT_collection_nested_new", CKEY, KM_PRESS, 0, 0); + WM_keymap_verify_item(keymap, "OUTLINER_OT_collection_delete_selected", XKEY, KM_PRESS, 0, 0); outliner_item_drag_drop_modal_keymap(keyconf); } -- cgit v1.2.3