diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-07-03 00:09:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-07-03 00:09:42 +0400 |
commit | 15be7b215f0ea53e68e114430267823e2b3fd37d (patch) | |
tree | 86b8ce182305c977bc5f5d78096572a15f913ea8 /source | |
parent | 213a45bed83bcb8afdc8ada8fd69b229a4a522f9 (diff) |
- changes to the sequencer so new strips use the data name.
- removed the name option for the sequence operators.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 11 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 12 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_add.c | 87 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 6 |
5 files changed, 63 insertions, 55 deletions
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 4241f481c30..ddbe748ede9 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3909,7 +3909,7 @@ int seq_active_pair_get(Scene *scene, Sequence **seq_act, Sequence **seq_other) void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load) { if(seq) { - strcpy(seq->name, seq_load->name); + BLI_strncpy(seq->name+2, seq_load->name, sizeof(seq->name)-2); seqbase_unique_name_recursive(&scene->ed->seqbase, seq); if(seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) { @@ -3963,8 +3963,6 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel); seq->type= SEQ_IMAGE; - BLI_strncpy(seq->name+2, "Image", SEQ_NAME_MAXSTR-2); - seqbase_unique_name_recursive(&scene->ed->seqbase, seq); /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); @@ -3972,8 +3970,8 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo strip->len = seq->len = seq_load->len ? seq_load->len : 1; strip->us= 1; strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - BLI_split_dirfile(seq_load->path, strip->dir, se->name); - + BLI_strncpy(strip->dir, seq_load->path, sizeof(strip->dir)); + seq_load_apply(scene, seq, seq_load); return seq; @@ -4085,6 +4083,9 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo seq_load->channel--; } + if(seq_load->name[0] == '\0') + BLI_strncpy(seq_load->name, se->name, sizeof(seq_load->name)); + /* can be NULL */ seq_load_apply(scene, seq, seq_load); diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 045ac5a013f..2d5234aee34 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -107,20 +107,14 @@ int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *nu if (found) break; } } - if (found){ + if (found) { if (tail) strcpy(tail, &string[nume+1]); - if (head) { - strcpy(head,string); - head[nums]=0; - } + if (head) BLI_strncpy(head, string, nums); if (numlen) *numlen = nume-nums+1; return ((int)atoi(&(string[nums]))); } if (tail) strcpy(tail, string + len); - if (head) { - strncpy(head, string, len); - head[len] = '\0'; - } + if (head) BLI_strncpy(head, string, nums); if (numlen) *numlen=0; return 0; } diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 508521c972e..cfcc3b6e81d 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -86,8 +86,6 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) { - RNA_def_string(ot->srna, "name", "", MAX_ID_NAME-2, "Name", "Name of the new sequence strip"); - if(flag & SEQPROP_STARTFRAME) RNA_def_int(ot->srna, "frame_start", 0, INT_MIN, INT_MAX, "Start Frame", "Start frame of the sequence strip", INT_MIN, INT_MAX); @@ -102,6 +100,20 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); } +static void sequencer_generic_invoke_path__internal(bContext *C, wmOperator *op, const char *identifier) +{ + if(RNA_struct_find_property(op->ptr, identifier)) { + Scene *scene= CTX_data_scene(C); + Sequence *last_seq= seq_active_get(scene); + if(last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) { + char path[sizeof(last_seq->strip->dir)]; + BLI_strncpy(path, last_seq->strip->dir, sizeof(path)); + BLI_path_abs(path, G.sce); + RNA_string_set(op->ptr, identifier, path); + } + } +} + static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, wmEvent *event, int flag) { ARegion *ar= CTX_wm_region(C); @@ -122,21 +134,13 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, w if ((flag & SEQPROP_ENDFRAME) && RNA_property_is_set(op->ptr, "frame_end")==0) RNA_int_set(op->ptr, "frame_end", (int)mval_v2d[0] + 25); // XXX arbitary but ok for now. - if(RNA_struct_find_property(op->ptr, "filepath")) { - Scene *scene= CTX_data_scene(C); - Sequence *last_seq= seq_active_get(scene); - if(last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) { - RNA_string_set(op->ptr, "filepath", last_seq->strip->dir); - } - // // TODO - // else { - // RNA_string_set(op->ptr, "filepath", ed->act_imagedir); - // } - } + sequencer_generic_invoke_path__internal(C, op, "filepath"); + sequencer_generic_invoke_path__internal(C, op, "directory"); } static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op) { + int is_file= -1; memset(seq_load, 0, sizeof(SeqLoadInfo)); seq_load->start_frame= RNA_int_get(op->ptr, "frame_start"); @@ -145,12 +149,13 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op) seq_load->channel= RNA_int_get(op->ptr, "channel"); seq_load->len= 1; // images only, if endframe isnt set! - RNA_string_get(op->ptr, "name", seq_load->name+2); - - if(RNA_struct_find_property(op->ptr, "filepath")) + if(RNA_struct_find_property(op->ptr, "filepath")) { RNA_string_get(op->ptr, "filepath", seq_load->path); /* full path, file is set by the caller */ - else if (RNA_struct_find_property(op->ptr, "filepath")) + is_file= 1; + } else if (RNA_struct_find_property(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", seq_load->path); /* full path, file is set by the caller */ + is_file= 0; + } if (RNA_struct_find_property(op->ptr, "frame_end")) { seq_load->end_frame = RNA_int_get(op->ptr, "frame_end"); @@ -167,6 +172,20 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op) /* always use this for ops */ seq_load->flag |= SEQ_LOAD_FRAME_ADVANCE; + + + if(is_file==1) { + BLI_strncpy(seq_load->name, BLI_path_basename(seq_load->path), sizeof(seq_load->name)); + } + else if(RNA_struct_find_property(op->ptr, "files")) { + /* used for image strip */ + /* best guess, first images name */ + RNA_BEGIN(op->ptr, itemptr, "files") { + RNA_string_get(&itemptr, "name", seq_load->name); + break; + } + RNA_END; + } } /* add scene operator */ @@ -206,11 +225,9 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - if(RNA_property_is_set(op->ptr, "name")) - RNA_string_get(op->ptr, "name", seq->name+2); - else - strcpy(seq->name+2, sce_seq->id.name+2); - + strcpy(seq->name+2, sce_seq->id.name+2); + seqbase_unique_name_recursive(&ed->seqbase, seq); + seq->scene_sound = sound_scene_add_scene_sound(scene, seq, start_frame, start_frame + strip->len, 0); calc_sequence_disp(scene, seq); @@ -429,26 +446,24 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) seq_load.len= RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); if(seq_load.len==0) - seq_load.len= 1; + return OPERATOR_CANCELLED; if(seq_load.flag & SEQ_LOAD_REPLACE_SEL) deselect_all_seq(scene); - + /* main adding function */ seq= sequencer_add_image_strip(C, ed->seqbasep, &seq_load); strip= seq->strip; se= strip->stripdata; - if(seq_load.len > 1) { - RNA_BEGIN(op->ptr, itemptr, "files") { - RNA_string_get(&itemptr, "name", se->name); - se++; - } - RNA_END; + RNA_BEGIN(op->ptr, itemptr, "files") { + RNA_string_get(&itemptr, "name", se->name); + se++; } - else { - BLI_strncpy(se->name, BLI_path_basename(seq_load.path), sizeof(se->name)); + RNA_END; + + if(seq_load.len == 1) { if(seq_load.start_frame < seq_load.end_frame) { seq->endstill= seq_load.end_frame - seq_load.start_frame; } @@ -502,7 +517,7 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME|SEQPROP_FILES); } @@ -545,11 +560,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) seq = alloc_sequence(ed->seqbasep, start_frame, channel); seq->type= type; - if(RNA_property_is_set(op->ptr, "name")) - RNA_string_get(op->ptr, "name", seq->name+2); - else - strcpy(seq->name+2, give_seqname(seq)); - + BLI_strncpy(seq->name+2, give_seqname(seq), sizeof(seq->name)-2); seqbase_unique_name_recursive(&ed->seqbase, seq); sh = get_sequence_effect(seq); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 680c5165575..000d428e40f 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -231,6 +231,8 @@ void BPY_start_python( int argc, char **argv ) BPY_start_python_path(); /* allow to use our own included python */ + // Py_SetProgramName(); // extern char bprogname[FILE_MAXDIR+FILE_MAXFILE]; + Py_Initialize( ); // PySys_SetArgv( argc, argv); // broken in py3, not a huge deal diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 330244e910e..8355684ac75 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1219,7 +1219,6 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa { /* XXX validate area and region? */ bScreen *screen= CTX_wm_screen(C); - char *path= RNA_string_get_alloc(handler->op->ptr, "filepath", NULL, 0); if(screen != handler->filescreen) ED_screen_full_prevspace(C, CTX_wm_area(C)); @@ -1238,8 +1237,11 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa /* XXX also extension code in image-save doesnt work for this yet */ if (RNA_struct_find_property(handler->op->ptr, "check_existing") && RNA_boolean_get(handler->op->ptr, "check_existing")) { + char *path= RNA_string_get_alloc(handler->op->ptr, "filepath", NULL, 0); /* this gives ownership to pupmenu */ uiPupMenuSaveOver(C, handler->op, (path)? path: ""); + if(path) + MEM_freeN(path); } else { int retval; @@ -1299,8 +1301,6 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa CTX_wm_area_set(C, NULL); wm_event_free_handler(handler); - if(path) - MEM_freeN(path); action= WM_HANDLER_BREAK; } |