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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-06-02 21:52:06 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-06-02 21:52:06 +0400
commitd8c2709414ec3b25c2bdaeea57eb26c2ff91f977 (patch)
tree590b4a6151a11ad2618a834aea2dfc4eafe49761 /source/blender/makesrna
parent5506ab080d1f03acd9e0e09a43b244b2ccece544 (diff)
Better API design for making text datablocks after loading.
An optional 'internal' argument was added to the bpy.data.texts.load() operator. The changes in revision 57153 were reverted, so that the is_in_memory and is_dirty properties of text datablocks are not editable again. In the C API layer, BKE_text_load_ex() was introduced to allow for optionally making text datablocks internal after loading.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c5
-rw-r--r--source/blender/makesrna/intern/rna_text.c2
2 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index 1e77a799cd4..4c652770e3f 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -725,12 +725,12 @@ static void rna_Main_texts_remove(Main *bmain, PointerRNA *text_ptr)
RNA_POINTER_INVALIDATE(text_ptr);
}
-static Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath)
+static Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath, int is_internal)
{
Text *txt;
errno = 0;
- txt = BKE_text_load(bmain, filepath, bmain->name);
+ txt = BKE_text_load_ex(bmain, filepath, bmain->name, is_internal);
if (!txt)
BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath,
@@ -1701,6 +1701,7 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Add a new text to the main database from a file");
parm = RNA_def_string_file_path(func, "filepath", "Path", FILE_MAX, "", "path for the datablock");
RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm = RNA_def_boolean(func, "internal", 0, "Make internal", "Make text file internal after loading");
/* return type */
parm = RNA_def_pointer(func, "text", "Text", "", "New text datablock");
RNA_def_function_return(func, parm);
diff --git a/source/blender/makesrna/intern/rna_text.c b/source/blender/makesrna/intern/rna_text.c
index b1eb0bb2228..df6181af4b2 100644
--- a/source/blender/makesrna/intern/rna_text.c
+++ b/source/blender/makesrna/intern/rna_text.c
@@ -148,6 +148,7 @@ static void rna_def_text(BlenderRNA *brna)
prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", TXT_ISDIRTY);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Dirty", "Text file has been edited since last save");
prop = RNA_def_property(srna, "is_modified", PROP_BOOLEAN, PROP_NONE);
@@ -157,6 +158,7 @@ static void rna_def_text(BlenderRNA *brna)
prop = RNA_def_property(srna, "is_in_memory", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", TXT_ISMEM);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Memory", "Text file is in memory, without a corresponding file on disk");
prop = RNA_def_property(srna, "use_module", PROP_BOOLEAN, PROP_NONE);