diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-01-26 17:18:16 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-01-26 17:18:16 +0300 |
commit | 2761799c649e728f7ed219f57faa78210c1291ca (patch) | |
tree | 8fcc4bcaae82b42731ba751ef2990d9123e86cb6 /source/blender/editors/sound | |
parent | 307c10486de9fe264838b898931cae9db92f6ee9 (diff) |
Possible fix for issue #2 in [#25664] Remove Pack does not work in Texture panel
- There were 2 pack menu's, merged into 1.
- Don't attempt to unpack into // if the blend file isn't saved, would use the CWD instead.
Diffstat (limited to 'source/blender/editors/sound')
-rw-r--r-- | source/blender/editors/sound/sound_ops.c | 85 |
1 files changed, 19 insertions, 66 deletions
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index cd6c7e4305d..004fb33f0dd 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -29,6 +29,7 @@ #include <string.h> #include <stdlib.h> #include <stdio.h> +#include <stddef.h> #include "MEM_guardedalloc.h" @@ -44,6 +45,7 @@ #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_main.h" #include "BKE_report.h" #include "BKE_packedFile.h" #include "BKE_sound.h" @@ -59,6 +61,8 @@ #include "AUD_C-API.h" +#include "ED_util.h" + #include "sound_intern.h" /******************** open sound operator ********************/ @@ -202,72 +206,17 @@ void SOUND_OT_pack(wmOperatorType *ot) /********************* unpack operator *********************/ -// XXX this function is in image_ops.c too, exactly the same, should be moved to a generally accessible position -static void unpack_menu(bContext *C, const char *opname, const char *abs_name, const char *folder, PackedFile *pf) -{ - uiPopupMenu *pup; - uiLayout *layout; - char line[FILE_MAX + 100]; - char local_name[FILE_MAXDIR + FILE_MAX], fi[FILE_MAX]; - - strcpy(local_name, abs_name); - BLI_splitdirstring(local_name, fi); - sprintf(local_name, "//%s/%s", folder, fi); - - pup= uiPupMenuBegin(C, "Unpack file", ICON_NULL); - layout= uiPupMenuLayout(pup); - - uiItemEnumO(layout, opname, "Remove Pack", 0, "method", PF_REMOVE); - - if(strcmp(abs_name, local_name)) { - switch(checkPackedFile(local_name, pf)) { - case PF_NOFILE: - sprintf(line, "Create %s", local_name); - uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_LOCAL); - break; - case PF_EQUAL: - sprintf(line, "Use %s (identical)", local_name); - uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL); - break; - case PF_DIFFERS: - sprintf(line, "Use %s (differs)", local_name); - uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL); - sprintf(line, "Overwrite %s", local_name); - uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_LOCAL); - break; - } - } - - switch(checkPackedFile(abs_name, pf)) { - case PF_NOFILE: - sprintf(line, "Create %s", abs_name); - uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL); - break; - case PF_EQUAL: - sprintf(line, "Use %s (identical)", abs_name); - uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL); - break; - case PF_DIFFERS: - sprintf(line, "Use %s (differs)", local_name); - uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL); - sprintf(line, "Overwrite %s", local_name); - uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL); - break; - } - - uiPupMenuEnd(C, pup); -} - -static int unpack_exec(bContext *C, wmOperator *op) +static int sound_unpack_exec(bContext *C, wmOperator *op) { int method= RNA_enum_get(op->ptr, "method"); - Editing* ed = CTX_data_scene(C)->ed; bSound* sound; - if(!ed || !ed->act_seq || ed->act_seq->type != SEQ_SOUND) - return OPERATOR_CANCELLED; - - sound = ed->act_seq->sound; + /* find the suppplied image by name */ + if (RNA_property_is_set(op->ptr, "id")) { + char sndname[22]; + RNA_string_get(op->ptr, "id", sndname); + sound = BLI_findstring(&CTX_data_main(C)->sound, sndname, offsetof(ID, name) + 2); + } if(!sound || !sound->packedfile) return OPERATOR_CANCELLED; @@ -280,11 +229,14 @@ static int unpack_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int sound_unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { Editing* ed = CTX_data_scene(C)->ed; bSound* sound; + if(RNA_property_is_set(op->ptr, "id")) + return sound_unpack_exec(C, op); + if(!ed || !ed->act_seq || ed->act_seq->type != SEQ_SOUND) return OPERATOR_CANCELLED; @@ -296,7 +248,7 @@ static int unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) if(G.fileflags & G_AUTOPACK) BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save."); - unpack_menu(C, "SOUND_OT_unpack", sound->name, "audio", sound->packedfile); + unpack_menu(C, "SOUND_OT_unpack", sound->id.name+2, sound->name, "audio", sound->packedfile); return OPERATOR_FINISHED; } @@ -309,8 +261,8 @@ void SOUND_OT_unpack(wmOperatorType *ot) ot->idname= "SOUND_OT_unpack"; /* api callbacks */ - ot->exec= unpack_exec; - ot->invoke= unpack_invoke; + ot->exec= sound_unpack_exec; + ot->invoke= sound_unpack_invoke; ot->poll= sound_poll; /* flags */ @@ -318,6 +270,7 @@ void SOUND_OT_unpack(wmOperatorType *ot) /* properties */ RNA_def_enum(ot->srna, "method", unpack_method_items, PF_USE_LOCAL, "Method", "How to unpack."); + RNA_def_string(ot->srna, "id", "", 21, "Sound Name", "Sound datablock name to unpack."); /* XXX, weark!, will fail with library, name collisions */ } /* ******************************************************* */ |