[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27838] branches/render25: patch by Wahooney, so new template' s are internal text and dont get saved over by mistake.
Campbell Barton
ideasman42 at gmail.com
Mon Mar 29 16:05:21 CEST 2010
Revision: 27838
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27838
Author: campbellbarton
Date: 2010-03-29 16:05:21 +0200 (Mon, 29 Mar 2010)
Log Message:
-----------
patch by Wahooney, so new template's are internal text and dont get saved over by mistake.
Modified Paths:
--------------
branches/render25/release/scripts/modules/bpy_types.py
branches/render25/release/scripts/ui/space_text.py
branches/render25/source/blender/editors/space_text/text_ops.c
Modified: branches/render25/release/scripts/modules/bpy_types.py
===================================================================
--- branches/render25/release/scripts/modules/bpy_types.py 2010-03-29 13:27:31 UTC (rev 27837)
+++ branches/render25/release/scripts/modules/bpy_types.py 2010-03-29 14:05:21 UTC (rev 27838)
@@ -490,7 +490,7 @@
class Menu(StructRNA, _GenericUI):
__slots__ = ()
- def path_menu(self, searchpaths, operator):
+ def path_menu(self, searchpaths, operator, props_default={}):
layout = self.layout
# hard coded to set the operators 'path' to the filename.
@@ -511,8 +511,13 @@
if f.startswith("."):
continue
- layout.operator(operator, text=bpy.utils.display_name(f)).path = path
+ props = layout.operator(operator, text=bpy.utils.display_name(f))
+ for attr, value in props_default.items():
+ setattr(props, attr, value)
+
+ props.path = path
+
def draw_preset(self, context):
"""Define these on the subclass
- preset_operator
Modified: branches/render25/release/scripts/ui/space_text.py
===================================================================
--- branches/render25/release/scripts/ui/space_text.py 2010-03-29 13:27:31 UTC (rev 27837)
+++ branches/render25/release/scripts/ui/space_text.py 2010-03-29 14:05:21 UTC (rev 27838)
@@ -177,7 +177,7 @@
bl_label = "Script Templates"
def draw(self, context):
- self.path_menu(bpy.utils.script_paths("templates"), "text.open")
+ self.path_menu(bpy.utils.script_paths("templates"), "text.open", {"internal": True})
class TEXT_MT_edit_view(bpy.types.Menu):
Modified: branches/render25/source/blender/editors/space_text/text_ops.c
===================================================================
--- branches/render25/source/blender/editors/space_text/text_ops.c 2010-03-29 13:27:31 UTC (rev 27837)
+++ branches/render25/source/blender/editors/space_text/text_ops.c 2010-03-29 14:05:21 UTC (rev 27838)
@@ -215,6 +215,7 @@
PropertyPointerRNA *pprop;
PointerRNA idptr;
char str[FILE_MAX];
+ short internal = RNA_int_get(op->ptr, "internal");
RNA_string_get(op->ptr, "path", str);
@@ -244,6 +245,13 @@
st->text= text;
st->top= 0;
}
+
+ if (internal) {
+ if(text->name)
+ MEM_freeN(text->name);
+
+ text->name = NULL;
+ }
WM_event_add_notifier(C, NC_TEXT|NA_ADDED, text);
@@ -282,6 +290,7 @@
/* properties */
WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE, FILE_SPECIAL, FILE_OPENFILE);
+ RNA_def_boolean(ot->srna, "internal", 0, "Make internal", "Make text file internal after loading");
}
/******************* reload operator *********************/
More information about the Bf-blender-cvs
mailing list