- menu for selecting add scenes for the sequencer.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 16 Mar 2010 17:23:20 +0000 (17:23 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 16 Mar 2010 17:23:20 +0000 (17:23 +0000)
- update internal 'btempdir' from userprefs on changing and initializing the temp dir.
- add sequence strip operators nolonger require the sequence view to be active (better for automation).
(commit 27434 by Campbell from render25 branch)

release/scripts/ui/space_sequencer.py
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/windowmanager/intern/wm_files.c
source/creator/creator.c

index 8badf741facbde7e69d3607b6a87525099af5ee2..0bf86642b256356f1362f748b55298168b90f700 100644 (file)
@@ -185,7 +185,7 @@ class SEQUENCER_MT_add(bpy.types.Menu):
         layout.operator_context = 'INVOKE_REGION_WIN'
 
         layout.column()
-        layout.operator("sequencer.scene_strip_add", text="Scene")
+        layout.operator_menu_enum("sequencer.scene_strip_add", "scene", text="Scene...")
         layout.operator("sequencer.movie_strip_add", text="Movie")
         layout.operator("sequencer.image_strip_add", text="Image")
         layout.operator("sequencer.sound_strip_add", text="Sound")
index 7a809f7b668e9a00892cd4c449284f042970b4b1..241ab2e854d6ef7ab3cdf6c5f7a89fe69b783529 100644 (file)
@@ -191,7 +191,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
        start_frame= RNA_int_get(op->ptr, "start_frame");
        channel= RNA_int_get(op->ptr, "channel");
        
-       sce_seq= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "type"));
+       sce_seq= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene"));
        
        if (sce_seq==NULL) {
                BKE_report(op->reports, RPT_ERROR, "Scene not found");
@@ -232,6 +232,11 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
 
 static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
+       if(ED_operator_sequencer_active(C)) {
+               BKE_report(op->reports, RPT_ERROR, "Sequencer area not active");
+               return OPERATOR_CANCELLED;
+       }
+
        sequencer_generic_invoke_xy__internal(C, op, event, 0);
        return sequencer_add_scene_strip_exec(C, op);
        // needs a menu
@@ -252,14 +257,15 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot)
        ot->invoke= sequencer_add_scene_strip_invoke;
        ot->exec= sequencer_add_scene_strip_exec;
 
-       ot->poll= ED_operator_sequencer_active;
+       ot->poll= ED_operator_scene_editable;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
-       prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", "");
+       prop= RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
        RNA_def_enum_funcs(prop, RNA_scene_itemf);
+       ot->prop= prop;
 }
 
 static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoadFunc seq_load_func)
@@ -318,7 +324,12 @@ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op)
 
 
 static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{      
+{
+       if(ED_operator_sequencer_active(C)) {
+               BKE_report(op->reports, RPT_ERROR, "Sequencer area not active");
+               return OPERATOR_CANCELLED;
+       }
+
        sequencer_generic_invoke_xy__internal(C, op, event, 0);
        return WM_operator_filesel(C, op, event);
        //return sequencer_add_movie_strip_exec(C, op);
@@ -337,7 +348,7 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot)
        ot->invoke= sequencer_add_movie_strip_invoke;
        ot->exec= sequencer_add_movie_strip_exec;
 
-       ot->poll= ED_operator_sequencer_active;
+       ot->poll= ED_operator_scene_editable;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -355,7 +366,12 @@ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op)
 }
 
 static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{      
+{
+       if(ED_operator_sequencer_active(C)) {
+               BKE_report(op->reports, RPT_ERROR, "Sequencer area not active");
+               return OPERATOR_CANCELLED;
+       }
+
        sequencer_generic_invoke_xy__internal(C, op, event, 0);
        return WM_operator_filesel(C, op, event);
        //return sequencer_add_sound_strip_exec(C, op);
@@ -374,7 +390,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
        ot->invoke= sequencer_add_sound_strip_invoke;
        ot->exec= sequencer_add_sound_strip_exec;
 
-       ot->poll= ED_operator_sequencer_active;
+       ot->poll= ED_operator_scene_editable;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -442,6 +458,11 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
 
 static int sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
+       if(ED_operator_sequencer_active(C)) {
+               BKE_report(op->reports, RPT_ERROR, "Sequencer area not active");
+               return OPERATOR_CANCELLED;
+       }
+
        sequencer_generic_invoke_xy__internal(C, op, event, SEQPROP_ENDFRAME);
        return WM_operator_filesel(C, op, event);       
        //return sequencer_add_image_strip_exec(C, op);
@@ -460,7 +481,7 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot)
        ot->invoke= sequencer_add_image_strip_invoke;
        ot->exec= sequencer_add_image_strip_exec;
 
-       ot->poll= ED_operator_sequencer_active;
+       ot->poll= ED_operator_scene_editable;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -581,6 +602,11 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
 /* add color */
 static int sequencer_add_effect_strip_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
+       if(ED_operator_sequencer_active(C)) {
+               BKE_report(op->reports, RPT_ERROR, "Sequencer area not active");
+               return OPERATOR_CANCELLED;
+       }
+
        sequencer_generic_invoke_xy__internal(C, op, event, SEQPROP_ENDFRAME);
 
        if (RNA_property_is_set(op->ptr, "type") && RNA_enum_get(op->ptr, "type")==SEQ_PLUGIN) {
@@ -603,7 +629,7 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot)
        ot->invoke= sequencer_add_effect_strip_invoke;
        ot->exec= sequencer_add_effect_strip_exec;
 
-       ot->poll= ED_operator_sequencer_active;
+       ot->poll= ED_operator_scene_editable;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
index 8a1b37c2ecfb595ffb2e9b45dd7b1cb8872c350f..2e1352eaa8e817e63f5455fce907c0ea141de8e4 100644 (file)
@@ -228,7 +228,12 @@ static void rna_userdef_addon_remove(bAddon *bext)
        BLI_freelinkN(&U.addons, bext);
 }
 
-
+static void rna_userdef_temp_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+       extern char btempdir[];
+       UserDef *userdef = (UserDef*)ptr->data;
+       strncpy(btempdir, userdef->tempdir, FILE_MAXDIR+FILE_MAXFILE);
+}
 
 #else
 
@@ -2709,6 +2714,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
        prop= RNA_def_property(srna, "temporary_directory", PROP_STRING, PROP_DIRPATH);
        RNA_def_property_string_sdna(prop, NULL, "tempdir");
        RNA_def_property_ui_text(prop, "Temporary Directory", "The directory for storing temporary save files");
+       RNA_def_property_update(prop, 0, "rna_userdef_temp_update");
 
        prop= RNA_def_property(srna, "image_editor", PROP_STRING, PROP_DIRPATH);
        RNA_def_property_string_sdna(prop, NULL, "image_editor");
index 2a8091c1aa2c39c85d6912e02029fb0cb08c4faf..d535d8f5ea10a7c0a402179d047d1b358b8797a8 100644 (file)
@@ -238,6 +238,8 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
 /* in case UserDef was read, we re-initialize all, and do versioning */
 static void wm_init_userdef(bContext *C)
 {
+       extern char btempdir[];
+
        UI_init_userdef();
        MEM_CacheLimiter_set_maximum(U.memcachelimit * 1024 * 1024);
        sound_init(CTX_data_main(C));
@@ -245,6 +247,8 @@ static void wm_init_userdef(bContext *C)
        /* set the python auto-execute setting from user prefs */
        if (U.flag & USER_SCRIPT_AUTOEXEC_DISABLE)      G.f &= ~G_SCRIPT_AUTOEXEC;
        else                                                                            G.f |=  G_SCRIPT_AUTOEXEC;
+
+       if(U.tempdir[0]) strncpy(btempdir, U.tempdir, FILE_MAXDIR+FILE_MAXFILE);
 }
 
 void WM_read_file(bContext *C, char *name, ReportList *reports)
index 3eb2cad1f65c4399d0d0ac98dec2bd485c2fe7ea..a3a43a4629dfc3103336f63f60ce3d5e0ad7e928 100644 (file)
@@ -1000,7 +1000,7 @@ int main(int argc, char **argv)
 
                WM_init(C, argc, argv);
                
-               // XXX BRECHT SOLVE
+               /* this is properly initialized with user defs, but this is default */
                BLI_where_is_temp( btempdir, 1 ); /* call after loading the .B.blend so we can read U.tempdir */
 
 #ifndef DISABLE_SDL