Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2010-05-06 11:19:55 +0400
committerMatt Ebb <matt@mke3.net>2010-05-06 11:19:55 +0400
commit600d22fd8fe13776c2f342972bd1a3f4322d3cec (patch)
tree2195752b853a7e7b77b6cf021b37724110cbbca0 /source/blender/editors/space_sequencer/sequencer_edit.c
parent16e628023c1a88ebb1df249923c0edfa8fcb654b (diff)
Fix [#22256] bpy.ops.sequencer.delete.poll() not working
Just about all sequencer operator poll functions were requiring an active sequence editor space type. This wasn't necessary for most of them, and prevented use from scripts, console, etc.
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_edit.c')
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c102
1 files changed, 27 insertions, 75 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 11a55ebb421..1154ed02a3e 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -1270,6 +1270,11 @@ static int seq_get_snaplimit(View2D *v2d)
#endif
/* Operator functions */
+int sequencer_edit_poll(bContext *C)
+{
+ return (seq_give_editing(CTX_data_scene(C), FALSE) != NULL);
+}
+
/* snap operator*/
static int sequencer_snap_exec(bContext *C, wmOperator *op)
@@ -1279,8 +1284,6 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op)
Editing *ed= seq_give_editing(scene, FALSE);
Sequence *seq;
int snap_frame;
-
- if(ed==NULL) return OPERATOR_CANCELLED;
snap_frame= RNA_int_get(op->ptr, "frame");
@@ -1354,8 +1357,7 @@ void SEQUENCER_OT_snap(struct wmOperatorType *ot)
/* api callbacks */
ot->invoke= sequencer_snap_invoke;
ot->exec= sequencer_snap_exec;
-
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1371,9 +1373,6 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op)
Sequence *seq;
int selected;
- if(ed==NULL)
- return OPERATOR_CANCELLED;
-
selected= !RNA_boolean_get(op->ptr, "unselected");
for(seq= ed->seqbasep->first; seq; seq= seq->next) {
@@ -1404,8 +1403,7 @@ void SEQUENCER_OT_mute(struct wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_mute_exec;
-
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1422,9 +1420,6 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op)
Sequence *seq;
int selected;
- if(ed==NULL)
- return OPERATOR_CANCELLED;
-
selected= !RNA_boolean_get(op->ptr, "unselected");
for(seq= ed->seqbasep->first; seq; seq= seq->next) {
@@ -1449,14 +1444,13 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_unmute(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name= "UnMute Strips";
+ ot->name= "Un-Mute Strips";
ot->idname= "SEQUENCER_OT_unmute";
- ot->description="UnMute unselected rather than selected strips";
+ ot->description="Un-Mute unselected rather than selected strips";
/* api callbacks */
ot->exec= sequencer_unmute_exec;
-
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1472,9 +1466,6 @@ static int sequencer_lock_exec(bContext *C, wmOperator *op)
Editing *ed= seq_give_editing(scene, FALSE);
Sequence *seq;
- if(ed==NULL)
- return OPERATOR_CANCELLED;
-
for(seq= ed->seqbasep->first; seq; seq= seq->next) {
if (seq->flag & SELECT) {
seq->flag |= SEQ_LOCK;
@@ -1495,8 +1486,7 @@ void SEQUENCER_OT_lock(struct wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_lock_exec;
-
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1509,9 +1499,6 @@ static int sequencer_unlock_exec(bContext *C, wmOperator *op)
Editing *ed= seq_give_editing(scene, FALSE);
Sequence *seq;
- if(ed==NULL)
- return OPERATOR_CANCELLED;
-
for(seq= ed->seqbasep->first; seq; seq= seq->next) {
if (seq->flag & SELECT) {
seq->flag &= ~SEQ_LOCK;
@@ -1532,8 +1519,7 @@ void SEQUENCER_OT_unlock(struct wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_unlock_exec;
-
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1546,9 +1532,6 @@ static int sequencer_reload_exec(bContext *C, wmOperator *op)
Editing *ed= seq_give_editing(scene, FALSE);
Sequence *seq;
- if(ed==NULL)
- return OPERATOR_CANCELLED;
-
for(seq= ed->seqbasep->first; seq; seq= seq->next) {
if(seq->flag & SELECT) {
update_changed_seq_and_deps(scene, seq, 0, 1);
@@ -1569,8 +1552,7 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_reload_exec;
-
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1581,9 +1563,6 @@ static int sequencer_refresh_all_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Editing *ed= seq_give_editing(scene, FALSE);
-
- if(ed==NULL)
- return OPERATOR_CANCELLED;
free_imbuf_seq(scene, &ed->seqbase, FALSE);
@@ -1601,8 +1580,7 @@ void SEQUENCER_OT_refresh_all(struct wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_refresh_all_exec;
-
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1623,9 +1601,6 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op)
ListBase newlist;
int changed;
-
- if(ed==NULL)
- return OPERATOR_CANCELLED;
cut_frame= RNA_int_get(op->ptr, "frame");
cut_hard= RNA_enum_get(op->ptr, "type");
@@ -1678,7 +1653,8 @@ static int sequencer_cut_invoke(bContext *C, wmOperator *op, wmEvent *event)
int cut_side, cut_frame;
cut_frame= CFRA;
- cut_side= mouse_frame_side(v2d, event->x - ar->winrct.xmin, cut_frame);
+ if (ED_operator_sequencer_active(C) && v2d)
+ cut_side= mouse_frame_side(v2d, event->x - ar->winrct.xmin, cut_frame);
RNA_int_set(op->ptr, "frame", cut_frame);
RNA_enum_set(op->ptr, "side", cut_side);
@@ -1698,8 +1674,7 @@ void SEQUENCER_OT_cut(struct wmOperatorType *ot)
/* api callbacks */
ot->invoke= sequencer_cut_invoke;
ot->exec= sequencer_cut_exec;
-
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1749,7 +1724,6 @@ static int sequencer_add_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *
void SEQUENCER_OT_duplicate(wmOperatorType *ot)
{
-
/* identifiers */
ot->name= "Duplicate";
ot->idname= "SEQUENCER_OT_duplicate";
@@ -1758,7 +1732,6 @@ void SEQUENCER_OT_duplicate(wmOperatorType *ot)
/* api callbacks */
ot->invoke= sequencer_add_duplicate_invoke;
ot->exec= sequencer_add_duplicate_exec;
-
ot->poll= ED_operator_sequencer_active;
/* flags */
@@ -1777,9 +1750,6 @@ static int sequencer_delete_exec(bContext *C, wmOperator *op)
MetaStack *ms;
int nothingSelected = TRUE;
- if(ed==NULL)
- return OPERATOR_CANCELLED;
-
seq=active_seq_get(scene);
if (seq && seq->flag & SELECT) { /* avoid a loop since this is likely to be selected */
nothingSelected = FALSE;
@@ -1840,8 +1810,7 @@ void SEQUENCER_OT_delete(wmOperatorType *ot)
/* api callbacks */
ot->invoke= WM_operator_confirm;
ot->exec= sequencer_delete_exec;
-
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1932,8 +1901,7 @@ void SEQUENCER_OT_images_separate(wmOperatorType *ot)
/* api callbacks */
ot->invoke= WM_operator_props_popup;
ot->exec= sequencer_separate_images_exec;
-
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1952,9 +1920,6 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *op)
Sequence *last_seq= active_seq_get(scene);
MetaStack *ms;
- if(ed==NULL)
- return OPERATOR_CANCELLED;
-
if(last_seq && last_seq->type==SEQ_META && last_seq->flag & SELECT) {
/* Enter Metastrip */
ms= MEM_mallocN(sizeof(MetaStack), "metastack");
@@ -2008,8 +1973,7 @@ void SEQUENCER_OT_meta_toggle(wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_meta_toggle_exec;
-
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2026,9 +1990,6 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
int channel_max= 1;
- if(ed==NULL)
- return OPERATOR_CANCELLED;
-
if(seqbase_isolated_sel_check(ed->seqbasep)==FALSE) {
BKE_report(op->reports, RPT_ERROR, "Please select all related strips");
return OPERATOR_CANCELLED;
@@ -2081,8 +2042,7 @@ void SEQUENCER_OT_meta_make(wmOperatorType *ot)
/* api callbacks */
ot->invoke= WM_operator_confirm;
ot->exec= sequencer_meta_make_exec;
-
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2153,8 +2113,7 @@ void SEQUENCER_OT_meta_separate(wmOperatorType *ot)
/* api callbacks */
ot->invoke= WM_operator_confirm;
ot->exec= sequencer_meta_separate_exec;
-
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2186,7 +2145,6 @@ void SEQUENCER_OT_view_all(wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_view_all_exec;
-
ot->poll= ED_operator_sequencer_active;
/* flags */
@@ -2253,7 +2211,6 @@ void SEQUENCER_OT_view_all_preview(wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_view_all_preview_exec;
-
ot->poll= ED_operator_sequencer_active;
/* flags */
@@ -2370,7 +2327,6 @@ void SEQUENCER_OT_view_selected(wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_view_selected_exec;
-
ot->poll= ED_operator_sequencer_active;
/* flags */
@@ -2456,7 +2412,7 @@ void SEQUENCER_OT_next_edit(wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_next_edit_exec;
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2486,7 +2442,7 @@ void SEQUENCER_OT_previous_edit(wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_previous_edit_exec;
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2531,7 +2487,6 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op)
Sequence *seq, *iseq;
int side= RNA_enum_get(op->ptr, "side");
- if(ed==NULL) return OPERATOR_CANCELLED;
if(active_seq==NULL) return OPERATOR_CANCELLED;
seq = find_next_prev_sequence(scene, active_seq, side, -1);
@@ -2591,7 +2546,7 @@ void SEQUENCER_OT_swap(wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_swap_exec;
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2641,7 +2596,7 @@ void SEQUENCER_OT_rendersize(wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_rendersize_exec;
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2670,9 +2625,6 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op)
Editing *ed= seq_give_editing(scene, FALSE);
Sequence *seq;
- if(ed==NULL)
- return OPERATOR_CANCELLED;
-
seq_free_clipboard();
if(seqbase_isolated_sel_check(ed->seqbasep)==FALSE) {
@@ -2700,7 +2652,7 @@ void SEQUENCER_OT_copy(wmOperatorType *ot)
/* api callbacks */
ot->exec= sequencer_copy_exec;
- ot->poll= ED_operator_sequencer_active;
+ ot->poll= sequencer_edit_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;