From 16411da41e40cc5205adef6052e95f6e587daf2c Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 27 Dec 2012 15:07:19 +0000 Subject: New features! - Packing .blend files If you work a lot with dynamic linked .blend files ("Libraries"), it's always hard to share your work with others (or for bug reports!). This new option packs all used external .blend files, and - on save - combines it together in one .blend file. You can save that file on any location. Loading a packed .blend file then loads all library data usual - not editable. Just use unpack to save out all linked .blend files. This will only save out the files according the directory structure as was used on linking - relative to the current .blend. It will create new directories, so be careful with unpacking when relative paths go up. This feature also works fine for linked compressed .blend files. It also works for many levels deep linked .blend hierarchies. Access is hidden for now - I need to get some people to give it serious testing first. You can find the options via spacebar search (try pack or unpack). - Packed data and Undo Now all packed data is excluded from the Undo buffer storage. Keeps undo memory smaller and makes faster redo possible. --- source/blender/editors/space_info/info_intern.h | 4 ++ source/blender/editors/space_info/info_ops.c | 70 ++++++++++++++++++++++--- source/blender/editors/space_info/space_info.c | 3 ++ 3 files changed, 70 insertions(+), 7 deletions(-) (limited to 'source/blender/editors/space_info') diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h index 80018e849d3..62e9a3a7f73 100644 --- a/source/blender/editors/space_info/info_intern.h +++ b/source/blender/editors/space_info/info_intern.h @@ -39,11 +39,15 @@ struct ReportList; void FILE_OT_pack_all(struct wmOperatorType *ot); void FILE_OT_unpack_all(struct wmOperatorType *ot); +void FILE_OT_pack_libraries(struct wmOperatorType *ot); +void FILE_OT_unpack_libraries(struct wmOperatorType *ot); + void FILE_OT_make_paths_relative(struct wmOperatorType *ot); void FILE_OT_make_paths_absolute(struct wmOperatorType *ot); void FILE_OT_report_missing_files(struct wmOperatorType *ot); void FILE_OT_find_missing_files(struct wmOperatorType *ot); + void INFO_OT_reports_display_update(struct wmOperatorType *ot); /* info_draw.c */ diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index e902a4ea6f4..104349e172a 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -66,15 +66,70 @@ #include "info_intern.h" +/********************* pack blend file libararies operator *********************/ + +static int pack_libraries_exec(bContext *C, wmOperator *op) +{ + Main *bmain = CTX_data_main(C); + + packLibraries(bmain, op->reports); + + return OPERATOR_FINISHED; +} + +void FILE_OT_pack_libraries(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Pack Blender Libraries"; + ot->idname = "FILE_OT_pack_libraries"; + ot->description = "Pack all used Blender library files into the current .blend"; + + /* api callbacks */ + ot->exec = pack_libraries_exec; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +static int unpack_libraries_exec(bContext *C, wmOperator *op) +{ + Main *bmain = CTX_data_main(C); + + unpackLibraries(bmain, op->reports); + + return OPERATOR_FINISHED; +} + +static int unpack_libraries_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + return WM_operator_confirm_message(C, op, "Unpack Blender Libraries - creates directories, all new paths should work"); +} + +void FILE_OT_unpack_libraries(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Unpack Blender Libraries"; + ot->idname = "FILE_OT_unpack_libraries"; + ot->description = "Unpack all used Blender library files from this .blend file"; + + /* api callbacks */ + ot->invoke = unpack_libraries_invoke; + ot->exec = unpack_libraries_exec; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + + /********************* pack all operator *********************/ static int pack_all_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - + packAll(bmain, op->reports); G.fileflags |= G_AUTOPACK; - + return OPERATOR_FINISHED; } @@ -83,7 +138,7 @@ static int pack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) Main *bmain = CTX_data_main(C); Image *ima; ImBuf *ibuf; - + // first check for dirty images for (ima = bmain->image.first; ima; ima = ima->id.next) { if (ima->ibufs.first) { /* XXX FIX */ @@ -93,16 +148,16 @@ static int pack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) BKE_image_release_ibuf(ima, ibuf, NULL); break; } - + BKE_image_release_ibuf(ima, ibuf, NULL); } } - + if (ima) { uiPupMenuOkee(C, "FILE_OT_pack_all", "Some images are painted on. These changes will be lost. Continue?"); return OPERATOR_CANCELLED; } - + return pack_all_exec(C, op); } @@ -116,11 +171,12 @@ void FILE_OT_pack_all(wmOperatorType *ot) /* api callbacks */ ot->exec = pack_all_exec; ot->invoke = pack_all_invoke; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } + /********************* unpack all operator *********************/ static const EnumPropertyItem unpack_all_method_items[] = { diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index db9be22eedb..60b04f7b029 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -178,7 +178,10 @@ static void info_main_area_draw(const bContext *C, ARegion *ar) static void info_operatortypes(void) { WM_operatortype_append(FILE_OT_pack_all); + WM_operatortype_append(FILE_OT_pack_libraries); WM_operatortype_append(FILE_OT_unpack_all); + WM_operatortype_append(FILE_OT_unpack_libraries); + WM_operatortype_append(FILE_OT_make_paths_relative); WM_operatortype_append(FILE_OT_make_paths_absolute); WM_operatortype_append(FILE_OT_report_missing_files); -- cgit v1.2.3