- Added Blender.UpdateMenus() + doc: so scripts can automatically update Blender menus when they create (or download or whatever) new scripts to be registered.
- Removed a long deprecated function from the Blender module (release dict).

Matt (broken) mentioned the UpdateMenus function a couple weeks ago.  I also updated the Save Current Theme script to use it.  This is all related to his ideas to use scripts to save and restore themes and e.g. render presets.
This commit is contained in:
Willian Padovani Germano 2005-01-13 19:19:05 +00:00
parent bb0da8a7aa
commit 3ba66e20b9
4 changed files with 46 additions and 28 deletions

@ -2,14 +2,14 @@
"""
Name: 'Save Current Theme'
Blender: 234
Blender: 236
Group: 'Export'
Tooltip: 'Save current theme as a bpython script'
"""
__author__ = "Willian P. Germano"
__url__ = ("blender", "elysiun")
__version__ = "1.0 11/05/04"
__version__ = "1.1 2005/13/01"
__bpydoc__ = """\
This script saves the current Theme in Blender as a Blender Python script.
@ -114,3 +114,8 @@ theme = Theme.New('%s')
fout.close()
FileSelector(write_theme, "Save Current Theme", default_fname)
try:
Blender.UpdateMenus()
except:
Blender.Draw.PupMenu("Warning - check console!%t|Menus could not be automatically updated")

@ -65,6 +65,7 @@
#include "gen_utils.h"
#include "modules.h"
#include "../BPY_extern.h" /* for bpy_gethome() */
#include "../BPY_menus.h" /* to update menus */
/**********************************************************/
@ -73,10 +74,10 @@
static PyObject *Blender_Set( PyObject * self, PyObject * args );
static PyObject *Blender_Get( PyObject * self, PyObject * args );
static PyObject *Blender_Redraw( PyObject * self, PyObject * args );
static PyObject *Blender_ReleaseGlobalDict( PyObject * self, PyObject * args );
static PyObject *Blender_Quit( PyObject * self );
static PyObject *Blender_Load( PyObject * self, PyObject * args );
static PyObject *Blender_Save( PyObject * self, PyObject * args );
static PyObject *Blender_UpdateMenus( PyObject * self);
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
@ -105,9 +106,6 @@ static char Blender_Get_doc[] = "(request) - Retrieve settings from Blender\n\
static char Blender_Redraw_doc[] = "() - Redraw all 3D windows";
static char Blender_ReleaseGlobalDict_doc[] =
"Deprecated, please use the Blender.Registry module solution instead.";
static char Blender_Quit_doc[] =
"() - Quit Blender. The current data is saved as 'quit.blend' before leaving.";
@ -134,6 +132,10 @@ Note 2: only .blend raises an error if file wasn't saved.\n\
\tYou can use Blender.sys.exists(filename) to make sure the file was saved\n\
\twhen writing to one of the other formats.";
static char Blender_UpdateMenus_doc[] =
"() - Update the menus where scripts are registered. Only needed for\n\
scripts that save other new scripts in the default or user defined folders.";
/*****************************************************************************/
/* Python method structure definition. */
/*****************************************************************************/
@ -144,8 +146,8 @@ static struct PyMethodDef Blender_methods[] = {
{"Quit", ( PyCFunction ) Blender_Quit, METH_NOARGS, Blender_Quit_doc},
{"Load", Blender_Load, METH_VARARGS, Blender_Load_doc},
{"Save", Blender_Save, METH_VARARGS, Blender_Save_doc},
{"ReleaseGlobalDict", &Blender_ReleaseGlobalDict,
METH_VARARGS, Blender_ReleaseGlobalDict_doc},
{"UpdateMenus", ( PyCFunction ) Blender_UpdateMenus, METH_NOARGS,
Blender_UpdateMenus_doc},
{NULL, NULL, 0, NULL}
};
@ -307,17 +309,6 @@ static PyObject *Blender_Redraw( PyObject * self, PyObject * args )
return M_Window_Redraw( self, Py_BuildValue( "(i)", wintype ) );
}
/*****************************************************************************/
/* Function: Blender_ReleaseGlobalDict */
/* Python equivalent: Blender.ReleaseGlobalDict */
/* Description: Deprecated function. */
/*****************************************************************************/
static PyObject *Blender_ReleaseGlobalDict( PyObject * self, PyObject * args )
{
Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************/
/* Function: Blender_Quit */
/* Python equivalent: Blender.Quit */
@ -497,6 +488,19 @@ static PyObject *Blender_Save( PyObject * self, PyObject * args )
return Py_None;
}
static PyObject * Blender_UpdateMenus( PyObject * self )
{
BPyMenu_RemoveAllEntries();
if (BPyMenu_Init(1) == -1)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"invalid scripts dir");
Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************/
/* Function: initBlender */
/*****************************************************************************/

@ -14,12 +14,12 @@ The Blender Python API Reference
- L{Armature}
- L{Bone}
- L{NLA}
- L{BGL} (*)
- L{BGL}
- L{Camera}
- L{Curve}
- L{Draw}
- L{Effect} (*)
- L{Image}
- L{Effect}
- L{Image} (*)
- L{Ipo}
- L{Lamp}
- L{Lattice}
@ -29,18 +29,18 @@ The Blender Python API Reference
- L{Metaball}
- L{NMesh}
- L{Noise}
- L{Object} (*)
- L{Object}
- L{Registry}
- L{Scene} (*)
- L{Scene}
- L{Radio}
- L{Render}
- L{Sound} (new)
- L{Sound}
- L{Text}
- L{Texture}
- L{Types}
- L{Window} (*)
- L{Window}
- L{Theme} (new)
- L{World} (*)
- L{World}
- L{sys<Sys>}
(*) - marks updated.

@ -10,7 +10,7 @@
"""
The main Blender module.
B{New}: 'homedir', 'scriptsdir' and 'uscriptsdir' parameters in L{Get}.
B{New}: L{UpdateMenus}.
Blender
=======
@ -108,6 +108,15 @@ def Save (filename, overwrite = 0):
@note: DXF, STL and Videoscape export only B{selected} meshes.
"""
def UpdateMenus ():
"""
Update the menus that list registered scripts. This will scan the default
and user defined (if available) folder(s) for scripts that have registration
data and will make them accessible via menus.
@note: only scripts that save other new scripts in the default or user
defined folders need to call this function.
"""
def Quit ():
"""
Exit from Blender immediately.