Bugfix #20382
authorTon Roosendaal <ton@blender.org>
Fri, 12 Nov 2010 17:35:51 +0000 (17:35 +0000)
committerTon Roosendaal <ton@blender.org>
Fri, 12 Nov 2010 17:35:51 +0000 (17:35 +0000)
Fixed old annoyance in Search menu, with a load of object-mode
operators showing up in editmode.
It's much cleaner now, but it will take further work and
investigation to have context & polls work satisfying for all cases.

source/blender/editors/include/ED_screen.h
source/blender/editors/object/object_add.c
source/blender/editors/object/object_group.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_select.c
source/blender/editors/screen/screen_ops.c

index 07fae14..4d3e402 100644 (file)
@@ -125,6 +125,7 @@ int         ED_operator_areaactive(struct bContext *C);
 int            ED_operator_regionactive(struct bContext *C);
 
 int            ED_operator_scene_editable(struct bContext *C);
+int            ED_operator_objectmode(struct bContext *C);
 
 int            ED_operator_view3d_active(struct bContext *C);
 int            ED_operator_region_view3d_active(struct bContext *C);
index b87792d..88072d7 100644 (file)
@@ -332,7 +332,7 @@ void OBJECT_OT_add(wmOperatorType *ot)
        ot->invoke= ED_object_add_generic_invoke;
        ot->exec= object_add_exec;
        
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -422,7 +422,7 @@ void OBJECT_OT_effector_add(wmOperatorType *ot)
        ot->invoke= WM_menu_invoke;
        ot->exec= effector_add_exec;
        
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -473,7 +473,7 @@ void OBJECT_OT_camera_add(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= object_camera_add_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -557,7 +557,7 @@ void OBJECT_OT_metaball_add(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke= object_metaball_add_invoke;
        ot->exec= object_metaball_add_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
 
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -597,7 +597,7 @@ void OBJECT_OT_text_add(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke= ED_object_add_generic_invoke;
        ot->exec= object_add_text_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -652,7 +652,7 @@ void OBJECT_OT_armature_add(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke= ED_object_add_generic_invoke;
        ot->exec= object_armature_add_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -712,7 +712,7 @@ void OBJECT_OT_lamp_add(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= object_lamp_add_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -769,7 +769,7 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot)
        ot->invoke= WM_enum_search_invoke;
        ot->exec= group_instance_add_exec;
 
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
 
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -835,7 +835,7 @@ void OBJECT_OT_delete(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke= WM_operator_confirm;
        ot->exec= object_delete_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1027,7 +1027,7 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot)
        /* api callbacks */
        ot->exec= object_duplicates_make_real_exec;
        
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1690,7 +1690,7 @@ void OBJECT_OT_duplicate(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= duplicate_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1703,20 +1703,6 @@ void OBJECT_OT_duplicate(wmOperatorType *ot)
 
 /* **************** add named object, for dragdrop ************* */
 
-/* contextual operator dupli */
-
-static int add_named_poll(bContext *C)
-{
-       if(!ED_operator_scene_editable(C)) {
-               return 0;
-       } else {
-               Object *ob= CTX_data_active_object(C);
-               if(ob && ob->mode != OB_MODE_OBJECT)
-                       return 0;
-               else
-                       return 1;
-       }
-}
 
 static int add_named_exec(bContext *C, wmOperator *op)
 {
@@ -1775,7 +1761,7 @@ void OBJECT_OT_add_named(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= add_named_exec;
-       ot->poll= add_named_poll;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
index 99e27d8..3b50499 100644 (file)
@@ -96,7 +96,7 @@ void GROUP_OT_objects_add_active(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= objects_add_active_exec;      
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
 
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -143,7 +143,7 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= objects_remove_active_exec;   
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -177,7 +177,7 @@ void GROUP_OT_objects_remove(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= group_objects_remove_exec;    
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -214,7 +214,7 @@ void GROUP_OT_create(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= group_create_exec;    
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
index a30fdcf..b8edbb8 100644 (file)
@@ -928,7 +928,7 @@ void OBJECT_OT_track_clear(wmOperatorType *ot)
        ot->invoke= WM_menu_invoke;
        ot->exec= object_track_clear_exec;
        
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1033,7 +1033,7 @@ void OBJECT_OT_track_set(wmOperatorType *ot)
        ot->invoke= WM_menu_invoke;
        ot->exec= track_set_exec;
        
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1143,7 +1143,7 @@ void OBJECT_OT_move_to_layer(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke= move_to_layer_invoke;
        ot->exec= move_to_layer_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1346,7 +1346,7 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot)
 
        /* api callbacks */
        ot->exec= make_links_data_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
 
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1850,7 +1850,7 @@ void OBJECT_OT_make_local(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= make_local_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1902,7 +1902,7 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= make_single_user_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
 
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1949,7 +1949,7 @@ void OBJECT_OT_drop_named_material(wmOperatorType *ot)
        
        /* api callbacks */
        ot->invoke= drop_named_material_invoke;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_UNDO;
index 29c3ee5..b131a35 100644 (file)
@@ -148,7 +148,7 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= object_select_by_type_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -330,7 +330,7 @@ void OBJECT_OT_select_linked(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= object_select_linked_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -618,7 +618,7 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke= WM_menu_invoke;
        ot->exec= object_select_grouped_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -667,7 +667,7 @@ void OBJECT_OT_select_by_layer(wmOperatorType *ot)
        /* api callbacks */
        /*ot->invoke = XXX - need a int grid popup*/
        ot->exec= object_select_by_layer_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -705,7 +705,7 @@ void OBJECT_OT_select_inverse(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= object_select_inverse_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -766,7 +766,7 @@ void OBJECT_OT_select_all(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= object_select_all_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -815,7 +815,7 @@ void OBJECT_OT_select_same_group(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= object_select_same_group_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -863,7 +863,7 @@ void OBJECT_OT_select_mirror(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= object_select_mirror_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -920,7 +920,7 @@ void OBJECT_OT_select_name(wmOperatorType *ot)
 
        /* api callbacks */
        ot->exec= object_select_name_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
 
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -968,7 +968,7 @@ void OBJECT_OT_select_random(wmOperatorType *ot)
        /* api callbacks */
        /*ot->invoke= object_select_random_invoke XXX - need a number popup ;*/
        ot->exec = object_select_random_exec;
-       ot->poll= ED_operator_scene_editable;
+       ot->poll= ED_operator_objectmode;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
index d85746d..4fac0ab 100644 (file)
@@ -116,6 +116,24 @@ int ED_operator_scene_editable(bContext *C)
        return 0;
 }
 
+int ED_operator_objectmode(bContext *C)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *obact= CTX_data_active_object(C);
+
+       if(scene==NULL || scene->id.lib)
+               return 0;
+       if( CTX_data_edit_object(C) )
+               return 0;
+       
+       /* add a check for ob->mode too? */
+       if(obact && obact->mode)
+               return 0;
+       
+       return 1;
+}
+
+
 static int ed_spacetype_test(bContext *C, int type)
 {
        if(ED_operator_areaactive(C)) {