[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36102] trunk/blender: py api: bpy.data. is_dirty wasn't working like image is dirty, instead is would return if the file was saved or not.
Campbell Barton
ideasman42 at gmail.com
Mon Apr 11 17:31:05 CEST 2011
Revision: 36102
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36102
Author: campbellbarton
Date: 2011-04-11 15:31:05 +0000 (Mon, 11 Apr 2011)
Log Message:
-----------
py api: bpy.data.is_dirty wasn't working like image is dirty, instead is would return if the file was saved or not.
- rename to 'is_saved' (and negated).
- add 'is_dirty' which is true when the files edits are not saved to disk.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_ui/properties_physics_common.py
trunk/blender/source/blender/makesrna/intern/rna_main.c
Modified: trunk/blender/release/scripts/startup/bl_ui/properties_physics_common.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_physics_common.py 2011-04-11 15:13:06 UTC (rev 36101)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_physics_common.py 2011-04-11 15:31:05 UTC (rev 36102)
@@ -106,7 +106,7 @@
layout.label(text=cache.info)
else:
if cachetype == 'SMOKE':
- if bpy.data.is_dirty:
+ if not bpy.data.is_saved:
layout.label(text="Cache is disabled until the file is saved")
layout.enabled = False
@@ -129,7 +129,7 @@
if cachetype != 'SMOKE':
split = layout.split()
- split.enabled = enabled and (not bpy.data.is_dirty)
+ split.enabled = enabled and bpy.data.is_saved
col = split.column()
col.prop(cache, "use_disk_cache")
@@ -139,7 +139,7 @@
col.prop(cache, "use_library_path", "Use Lib Path")
row = layout.row()
- row.enabled = enabled and (not bpy.data.is_dirty)
+ row.enabled = enabled and bpy.data.is_saved
row.active = cache.use_disk_cache
row.label(text="Compression:")
row.prop(cache, "compression", expand=True)
Modified: trunk/blender/source/blender/makesrna/intern/rna_main.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_main.c 2011-04-11 15:13:06 UTC (rev 36101)
+++ trunk/blender/source/blender/makesrna/intern/rna_main.c 2011-04-11 15:31:05 UTC (rev 36102)
@@ -42,9 +42,20 @@
/* all the list begin functions are added manually here, Main is not in SDNA */
+static int rna_Main_is_saved_get(PointerRNA *ptr)
+{
+ return G.relbase_valid;
+}
+
static int rna_Main_is_dirty_get(PointerRNA *ptr)
{
- return !G.relbase_valid;
+ /* XXX, not totally nice to do it this way, should store in main ? */
+ wmWindowManager *wm;
+ for(wm= G.main->wm.first; wm; wm= wm->id.next) {
+ return !wm->file_saved;
+ }
+
+ return TRUE;
}
static void rna_Main_filepath_get(PointerRNA *ptr, char *value)
@@ -307,6 +318,11 @@
prop= RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_funcs(prop, "rna_Main_is_dirty_get", NULL);
+ RNA_def_property_ui_text(prop, "File is Saved", "Have recent edits been saved to disk");
+
+ prop= RNA_def_property(srna, "is_saved", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ 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");
for(i=0; lists[i].name; i++)
More information about the Bf-blender-cvs
mailing list