Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Repp <simon@openideas.at>2013-12-23 21:35:32 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2013-12-23 21:55:48 +0400
commit632c29fef3a566d6aac9ea35e7875f08f3d1cf74 (patch)
tree5f32deb9b89406e0f1108ff389228997a5c9db2c
parent3cc7978f19f55a4f3ff7209d67bbb1b0ccb7c4ff (diff)
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
-rw-r--r--release/scripts/startup/bl_ui/space_info.py14
-rw-r--r--source/blender/editors/space_info/info_intern.h1
-rw-r--r--source/blender/editors/space_info/info_ops.c38
-rw-r--r--source/blender/editors/space_info/space_info.c1
-rw-r--r--source/blender/makesrna/intern/rna_main.c20
5 files changed, 68 insertions, 6 deletions
diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py
index 9da525d8ebb..989b0a0b6e3 100644
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@ -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()
diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h
index b5426fe15e1..967bcec57c5 100644
--- a/source/blender/editors/space_info/info_intern.h
+++ b/source/blender/editors/space_info/info_intern.h
@@ -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);
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index 6c76ba64893..6690d1ce7cb 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -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";
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 96e0de17918..c029a4bf0bc 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -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);
diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c
index 6a43fed3ac6..b7b793ebeaf 100644
--- a/source/blender/makesrna/intern/rna_main.c
+++ b/source/blender/makesrna/intern/rna_main.c
@@ -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);