UI: communicate external data autopack better in the UI.

Previously there was no way to see if autopack was enabled. Now the external
data menu has 3 entries instead of 2:

* Automatically Pack Into .blend (with checkbox to indicate autopack on/off)
* Pack All Into .blend
* Unpack All Into Files

Fixes T37608, includes modifications by Brecht from the original patch.

Reviewed By: brecht

Differential Revision: http://developer.blender.org/D118
This commit is contained in:
Simon Repp 2013-12-23 18:35:32 +01:00 committed by Brecht Van Lommel
parent 3cc7978f19
commit 632c29fef3
5 changed files with 68 additions and 6 deletions

@ -161,8 +161,18 @@ class INFO_MT_file_external_data(Menu):
def draw(self, context):
layout = self.layout
layout.operator("file.pack_all", text="Pack into .blend file")
layout.operator("file.unpack_all", text="Unpack into Files")
icon = 'CHECKBOX_HLT' if bpy.data.use_autopack else 'CHECKBOX_DEHLT'
layout.operator("file.autopack_toggle", icon=icon)
layout.separator()
pack_all = layout.row()
pack_all.operator("file.pack_all")
pack_all.active = not bpy.data.use_autopack
unpack_all = layout.row()
unpack_all.operator("file.unpack_all")
unpack_all.active = not bpy.data.use_autopack
layout.separator()

@ -37,6 +37,7 @@ struct SpaceInfo;
struct wmOperatorType;
struct ReportList;
void FILE_OT_autopack_toggle(struct wmOperatorType *ot);
void FILE_OT_pack_all(struct wmOperatorType *ot);
void FILE_OT_unpack_all(struct wmOperatorType *ot);
void FILE_OT_unpack_item(struct wmOperatorType *ot);

@ -70,7 +70,7 @@
#include "info_intern.h"
/********************* pack blend file libararies operator *********************/
/********************* pack blend file libaries operator *********************/
static int pack_libraries_exec(bContext *C, wmOperator *op)
{
@ -124,6 +124,36 @@ void FILE_OT_unpack_libraries(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************* toogle auto-pack operator *********************/
static int autopack_toggle_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
if(G.fileflags & G_AUTOPACK) {
G.fileflags &= ~G_AUTOPACK;
}
else {
packAll(bmain, op->reports);
G.fileflags |= G_AUTOPACK;
}
return OPERATOR_FINISHED;
}
void FILE_OT_autopack_toggle(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Automatically Pack Into .blend";
ot->idname = "FILE_OT_autopack_toggle";
ot->description = "Automatically pack all external files into the .blend file";
/* api callbacks */
ot->exec = autopack_toggle_exec;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************* pack all operator *********************/
@ -168,7 +198,7 @@ static int pack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
void FILE_OT_pack_all(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Pack All";
ot->name = "Pack All Into .blend";
ot->idname = "FILE_OT_pack_all";
ot->description = "Pack all used external files into the .blend";
@ -214,7 +244,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
count = countPackedFiles(bmain);
if (!count) {
BKE_report(op->reports, RPT_WARNING, "No packed files (auto-pack disabled)");
BKE_report(op->reports, RPT_WARNING, "No packed files to unpack");
G.fileflags &= ~G_AUTOPACK;
return OPERATOR_CANCELLED;
}
@ -238,7 +268,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
void FILE_OT_unpack_all(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Unpack All";
ot->name = "Unpack All Into Files";
ot->idname = "FILE_OT_unpack_all";
ot->description = "Unpack all files packed into this .blend to external ones";

@ -179,6 +179,7 @@ static void info_main_area_draw(const bContext *C, ARegion *ar)
static void info_operatortypes(void)
{
WM_operatortype_append(FILE_OT_autopack_toggle);
WM_operatortype_append(FILE_OT_pack_all);
WM_operatortype_append(FILE_OT_pack_libraries);
WM_operatortype_append(FILE_OT_unpack_all);

@ -42,6 +42,22 @@
/* all the list begin functions are added manually here, Main is not in SDNA */
static int rna_Main_use_autopack_get(PointerRNA *UNUSED(ptr))
{
if (G.fileflags & G_AUTOPACK)
return 1;
return 0;
}
static void rna_Main_use_autopack_set(PointerRNA *UNUSED(ptr), int value)
{
if (value)
G.fileflags |= G_AUTOPACK;
else
G.fileflags &= ~G_AUTOPACK;
}
static int rna_Main_is_saved_get(PointerRNA *UNUSED(ptr))
{
return G.relbase_valid;
@ -356,6 +372,10 @@ void RNA_def_main(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, "rna_Main_is_saved_get", NULL);
RNA_def_property_ui_text(prop, "File is Saved", "Has the current session been saved to disk as a .blend file");
prop = RNA_def_property(srna, "use_autopack", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Main_use_autopack_get", "rna_Main_use_autopack_set");
RNA_def_property_ui_text(prop, "Use Autopack", "Automatically pack all external data into .blend file");
for (i = 0; lists[i].name; i++) {
prop = RNA_def_property(srna, lists[i].identifier, PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, lists[i].type);