2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2010-01-31 23:41:46 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-01-31 23:41:46 +00:00
|
|
|
*
|
|
|
|
* Contributor(s): Campbell Barton
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:10:08 +00:00
|
|
|
/** \file blender/python/intern/bpy_app.c
|
|
|
|
* \ingroup pythonintern
|
2011-11-05 08:21:12 +00:00
|
|
|
*
|
|
|
|
* This file defines a 'PyStructSequence' accessed via 'bpy.app', mostly
|
|
|
|
* exposing static applications variables such as version and buildinfo
|
|
|
|
* however some writable variables have been added such as 'debug' and 'tempdir'
|
2011-02-27 20:10:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-02-14 04:15:25 +00:00
|
|
|
#include <Python.h>
|
|
|
|
|
2010-01-31 23:41:46 +00:00
|
|
|
#include "bpy_app.h"
|
2011-12-28 12:35:58 +00:00
|
|
|
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
#include "bpy_app_alembic.h"
|
2011-12-28 12:35:58 +00:00
|
|
|
#include "bpy_app_ffmpeg.h"
|
2013-12-08 15:03:17 +06:00
|
|
|
#include "bpy_app_ocio.h"
|
|
|
|
#include "bpy_app_oiio.h"
|
2017-06-07 12:16:48 +02:00
|
|
|
#include "bpy_app_opensubdiv.h"
|
Implementation of OpenVDB as a possible cache format for smoke
simulations.
This commits implements OpenVDB as an extra cache format in the Point
Cache system for smoke simulations. Compilation with the library is
turned off by default for now, and shall be enabled when the library is
present.
A documentation of its doings is available here: http://
wiki.blender.org/index.php/User:Kevindietrich/OpenVDBSmokeExport.
A guide to compile OpenVDB can be found here (Linux): http://
wiki.blender.org/index.php?title=Dev:Doc/Building_Blender/Linux/
Dependencies_From_Source#OpenVDB
Reviewers: sergey, lukastoenne, brecht, campbellbarton
Reviewed By: brecht, campbellbarton
Subscribers: galenb, Blendify, robocyte, Lapineige, bliblubli,
jtheninja, lukasstockner97, dingto, brecht
Differential Revision: https://developer.blender.org/D1721
2016-01-23 08:39:29 +01:00
|
|
|
#include "bpy_app_openvdb.h"
|
2015-02-18 12:07:48 +01:00
|
|
|
#include "bpy_app_sdl.h"
|
2012-12-18 18:02:20 +00:00
|
|
|
#include "bpy_app_build_options.h"
|
2011-12-28 12:35:58 +00:00
|
|
|
|
2013-01-21 15:10:22 +00:00
|
|
|
#include "bpy_app_translations.h"
|
Python i18n API. Many thanks to Campbell and Brecht for the reviews and suggestions!
This commit adds:
* A new bpy.app.translations module giving some info about locales/translation stuff (current active locale, all locales currently known by blender, all translation contexts currently defined, etc.).
* The ability for addons to feature translations, using the (un)register functions of above module.
* Also cleans up "translate py string when storing into RNA prop" by removing "PROP_TRANSLATE" string's subtype, and adding a PROP_STRING_PY_TRANSLATE flag instead (this way it is no more exposed to python...).
Addon translations work with py dictionaries: each addon features a dict {lang: {(context, message): translation, ...}, ...}, which is registered when the addon is enabled (and unregistered when disabled).
Then, when a key (context, message) is not found in regular mo catalog, a cache dict for current locale is built from all registered addon translations, and key is searched in it.
Note: currently addons writers have to do all the work by hand, will add something (probably extend "edit translation" addon) to automate messages extraction from addons soon(ish)! To get a look to expected behavior from addons, have a look at render_copy_settings/__init__.py and render_copy_settings/translations.py (rather stupid example currently, but...). Once we have a complete process, I'll also update relevant wiki pages.
2013-01-20 17:29:07 +00:00
|
|
|
|
2011-06-24 16:54:30 +00:00
|
|
|
#include "bpy_app_handlers.h"
|
2011-02-14 04:15:25 +00:00
|
|
|
#include "bpy_driver.h"
|
2010-01-31 23:41:46 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2014-11-23 14:37:13 +01:00
|
|
|
#include "BKE_appdir.h"
|
2016-04-24 22:42:41 +10:00
|
|
|
#include "BKE_blender_version.h"
|
2010-01-31 23:41:46 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
|
2015-08-10 17:26:37 +02:00
|
|
|
#include "DNA_ID.h"
|
|
|
|
|
|
|
|
#include "UI_interface_icons.h"
|
|
|
|
|
2016-01-09 22:48:50 +11:00
|
|
|
/* for notifiers */
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
2010-10-13 14:14:22 +00:00
|
|
|
#include "../generic/py_capi_utils.h"
|
2015-01-06 16:42:22 +11:00
|
|
|
#include "../generic/python_utildefines.h"
|
2010-10-13 14:14:22 +00:00
|
|
|
|
2010-01-31 23:41:46 +00:00
|
|
|
#ifdef BUILD_DATE
|
2010-03-14 17:18:36 +00:00
|
|
|
extern char build_date[];
|
|
|
|
extern char build_time[];
|
2013-11-15 17:11:59 +06:00
|
|
|
extern unsigned long build_commit_timestamp;
|
|
|
|
extern char build_commit_date[];
|
|
|
|
extern char build_commit_time[];
|
2013-11-04 13:21:39 +00:00
|
|
|
extern char build_hash[];
|
|
|
|
extern char build_branch[];
|
2010-03-14 17:18:36 +00:00
|
|
|
extern char build_platform[];
|
|
|
|
extern char build_type[];
|
2010-10-18 12:56:14 +00:00
|
|
|
extern char build_cflags[];
|
|
|
|
extern char build_cxxflags[];
|
|
|
|
extern char build_linkflags[];
|
2010-10-19 05:00:36 +00:00
|
|
|
extern char build_system[];
|
2010-01-31 23:41:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static PyTypeObject BlenderAppType;
|
|
|
|
|
2011-12-26 12:26:11 +00:00
|
|
|
static PyStructSequence_Field app_info_fields[] = {
|
2010-12-03 17:05:21 +00:00
|
|
|
{(char *)"version", (char *)"The Blender version as a tuple of 3 numbers. eg. (2, 50, 11)"},
|
|
|
|
{(char *)"version_string", (char *)"The Blender version formatted as a string"},
|
2011-04-01 15:13:58 +00:00
|
|
|
{(char *)"version_char", (char *)"The Blender version character (for minor releases)"},
|
|
|
|
{(char *)"version_cycle", (char *)"The release status of this build alpha/beta/rc/release"},
|
2010-12-03 17:05:21 +00:00
|
|
|
{(char *)"binary_path", (char *)"The location of blenders executable, useful for utilities that spawn new instances"},
|
|
|
|
{(char *)"background", (char *)"Boolean, True when blender is running without a user interface (started with -b)"},
|
2017-07-25 20:50:12 +10:00
|
|
|
{(char *)"factory_startup", (char *)"Boolean, True when blender is running with --factory-startup)"},
|
2010-01-31 23:41:46 +00:00
|
|
|
|
|
|
|
/* buildinfo */
|
2010-12-03 17:05:21 +00:00
|
|
|
{(char *)"build_date", (char *)"The date this blender instance was built"},
|
|
|
|
{(char *)"build_time", (char *)"The time this blender instance was built"},
|
2013-11-15 17:11:59 +06:00
|
|
|
{(char *)"build_commit_timestamp", (char *)"The unix timestamp of commit this blender instance was built"},
|
|
|
|
{(char *)"build_commit_date", (char *)"The date of commit this blender instance was built"},
|
|
|
|
{(char *)"build_commit_time", (char *)"The time of commit this blender instance was built"},
|
2013-11-04 13:21:39 +00:00
|
|
|
{(char *)"build_hash", (char *)"The commit hash this blender instance was built with"},
|
|
|
|
{(char *)"build_branch", (char *)"The branch this blender instance was built from"},
|
2010-12-03 17:05:21 +00:00
|
|
|
{(char *)"build_platform", (char *)"The platform this blender instance was built for"},
|
|
|
|
{(char *)"build_type", (char *)"The type of build (Release, Debug)"},
|
2010-12-06 12:36:55 +00:00
|
|
|
{(char *)"build_cflags", (char *)"C compiler flags"},
|
|
|
|
{(char *)"build_cxxflags", (char *)"C++ compiler flags"},
|
|
|
|
{(char *)"build_linkflags", (char *)"Binary linking flags"},
|
|
|
|
{(char *)"build_system", (char *)"Build system used"},
|
2011-06-24 16:54:30 +00:00
|
|
|
|
|
|
|
/* submodules */
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
{(char *)"alembic", (char *)"Alembic library information backend"},
|
2011-12-28 12:35:58 +00:00
|
|
|
{(char *)"ffmpeg", (char *)"FFmpeg library information backend"},
|
2013-12-08 15:03:17 +06:00
|
|
|
{(char *)"ocio", (char *)"OpenColorIO library information backend"},
|
|
|
|
{(char *)"oiio", (char *)"OpenImageIO library information backend"},
|
2017-06-07 12:16:48 +02:00
|
|
|
{(char *)"opensubdiv", (char *)"OpenSubdiv library information backend"},
|
Implementation of OpenVDB as a possible cache format for smoke
simulations.
This commits implements OpenVDB as an extra cache format in the Point
Cache system for smoke simulations. Compilation with the library is
turned off by default for now, and shall be enabled when the library is
present.
A documentation of its doings is available here: http://
wiki.blender.org/index.php/User:Kevindietrich/OpenVDBSmokeExport.
A guide to compile OpenVDB can be found here (Linux): http://
wiki.blender.org/index.php?title=Dev:Doc/Building_Blender/Linux/
Dependencies_From_Source#OpenVDB
Reviewers: sergey, lukastoenne, brecht, campbellbarton
Reviewed By: brecht, campbellbarton
Subscribers: galenb, Blendify, robocyte, Lapineige, bliblubli,
jtheninja, lukasstockner97, dingto, brecht
Differential Revision: https://developer.blender.org/D1721
2016-01-23 08:39:29 +01:00
|
|
|
{(char *)"openvdb", (char *)"OpenVDB library information backend"},
|
2015-02-18 12:07:48 +01:00
|
|
|
{(char *)"sdl", (char *)"SDL library information backend"},
|
2012-12-18 18:02:20 +00:00
|
|
|
{(char *)"build_options", (char *)"A set containing most important enabled optional build features"},
|
2011-06-24 16:54:30 +00:00
|
|
|
{(char *)"handlers", (char *)"Application handler callbacks"},
|
Python i18n API. Many thanks to Campbell and Brecht for the reviews and suggestions!
This commit adds:
* A new bpy.app.translations module giving some info about locales/translation stuff (current active locale, all locales currently known by blender, all translation contexts currently defined, etc.).
* The ability for addons to feature translations, using the (un)register functions of above module.
* Also cleans up "translate py string when storing into RNA prop" by removing "PROP_TRANSLATE" string's subtype, and adding a PROP_STRING_PY_TRANSLATE flag instead (this way it is no more exposed to python...).
Addon translations work with py dictionaries: each addon features a dict {lang: {(context, message): translation, ...}, ...}, which is registered when the addon is enabled (and unregistered when disabled).
Then, when a key (context, message) is not found in regular mo catalog, a cache dict for current locale is built from all registered addon translations, and key is searched in it.
Note: currently addons writers have to do all the work by hand, will add something (probably extend "edit translation" addon) to automate messages extraction from addons soon(ish)! To get a look to expected behavior from addons, have a look at render_copy_settings/__init__.py and render_copy_settings/translations.py (rather stupid example currently, but...). Once we have a complete process, I'll also update relevant wiki pages.
2013-01-20 17:29:07 +00:00
|
|
|
{(char *)"translations", (char *)"Application and addons internationalization API"},
|
|
|
|
{NULL},
|
2010-01-31 23:41:46 +00:00
|
|
|
};
|
|
|
|
|
2017-06-15 00:54:41 -04:00
|
|
|
PyDoc_STRVAR(bpy_app_doc,
|
|
|
|
"This module contains application values that remain unchanged during runtime.\n"
|
|
|
|
"\n"
|
|
|
|
"Submodules:\n"
|
|
|
|
"\n"
|
|
|
|
".. toctree::\n"
|
|
|
|
" :maxdepth: 1\n"
|
|
|
|
"\n"
|
|
|
|
" bpy.app.handlers.rst\n"
|
|
|
|
" bpy.app.translations.rst\n"
|
|
|
|
);
|
|
|
|
|
2011-12-26 12:26:11 +00:00
|
|
|
static PyStructSequence_Desc app_info_desc = {
|
2010-12-03 17:05:21 +00:00
|
|
|
(char *)"bpy.app", /* name */
|
2017-06-15 00:54:41 -04:00
|
|
|
bpy_app_doc, /* doc */
|
2010-01-31 23:41:46 +00:00
|
|
|
app_info_fields, /* fields */
|
2014-06-17 02:47:57 +10:00
|
|
|
ARRAY_SIZE(app_info_fields) - 1
|
2010-01-31 23:41:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static PyObject *make_app_info(void)
|
|
|
|
{
|
|
|
|
PyObject *app_info;
|
2011-12-26 12:26:11 +00:00
|
|
|
int pos = 0;
|
2010-01-31 23:41:46 +00:00
|
|
|
|
2011-12-26 12:26:11 +00:00
|
|
|
app_info = PyStructSequence_New(&BlenderAppType);
|
2010-01-31 23:41:46 +00:00
|
|
|
if (app_info == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#define SetIntItem(flag) \
|
|
|
|
PyStructSequence_SET_ITEM(app_info, pos++, PyLong_FromLong(flag))
|
2010-02-12 21:45:47 +00:00
|
|
|
#define SetStrItem(str) \
|
|
|
|
PyStructSequence_SET_ITEM(app_info, pos++, PyUnicode_FromString(str))
|
2012-03-04 03:14:38 +00:00
|
|
|
#define SetBytesItem(str) \
|
|
|
|
PyStructSequence_SET_ITEM(app_info, pos++, PyBytes_FromString(str))
|
2010-01-31 23:41:46 +00:00
|
|
|
#define SetObjItem(obj) \
|
|
|
|
PyStructSequence_SET_ITEM(app_info, pos++, obj)
|
|
|
|
|
2011-12-26 12:26:11 +00:00
|
|
|
SetObjItem(Py_BuildValue("(iii)",
|
|
|
|
BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION));
|
|
|
|
SetObjItem(PyUnicode_FromFormat("%d.%02d (sub %d)",
|
|
|
|
BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION));
|
|
|
|
|
2011-04-01 15:13:58 +00:00
|
|
|
SetStrItem(STRINGIFY(BLENDER_VERSION_CHAR));
|
2011-04-01 14:04:26 +00:00
|
|
|
SetStrItem(STRINGIFY(BLENDER_VERSION_CYCLE));
|
2014-11-23 15:54:29 +01:00
|
|
|
SetStrItem(BKE_appdir_program_path());
|
2010-05-18 15:57:51 +00:00
|
|
|
SetObjItem(PyBool_FromLong(G.background));
|
2017-07-25 20:50:12 +10:00
|
|
|
SetObjItem(PyBool_FromLong(G.factory_startup));
|
2010-01-31 23:41:46 +00:00
|
|
|
|
2012-03-04 03:14:38 +00:00
|
|
|
/* build info, use bytes since we can't assume _any_ encoding:
|
|
|
|
* see patch [#30154] for issue */
|
2010-02-28 22:48:50 +00:00
|
|
|
#ifdef BUILD_DATE
|
2012-03-04 03:14:38 +00:00
|
|
|
SetBytesItem(build_date);
|
|
|
|
SetBytesItem(build_time);
|
2013-11-15 17:11:59 +06:00
|
|
|
SetIntItem(build_commit_timestamp);
|
|
|
|
SetBytesItem(build_commit_date);
|
|
|
|
SetBytesItem(build_commit_time);
|
2013-11-04 13:21:39 +00:00
|
|
|
SetBytesItem(build_hash);
|
|
|
|
SetBytesItem(build_branch);
|
2012-03-04 03:14:38 +00:00
|
|
|
SetBytesItem(build_platform);
|
|
|
|
SetBytesItem(build_type);
|
|
|
|
SetBytesItem(build_cflags);
|
|
|
|
SetBytesItem(build_cxxflags);
|
|
|
|
SetBytesItem(build_linkflags);
|
|
|
|
SetBytesItem(build_system);
|
2010-02-28 22:48:50 +00:00
|
|
|
#else
|
2012-03-04 03:14:38 +00:00
|
|
|
SetBytesItem("Unknown");
|
|
|
|
SetBytesItem("Unknown");
|
2013-11-15 17:11:59 +06:00
|
|
|
SetIntItem(0);
|
|
|
|
SetBytesItem("Unknown");
|
2012-03-04 03:14:38 +00:00
|
|
|
SetBytesItem("Unknown");
|
|
|
|
SetBytesItem("Unknown");
|
|
|
|
SetBytesItem("Unknown");
|
2013-11-04 13:21:39 +00:00
|
|
|
SetBytesItem("Unknown");
|
|
|
|
SetBytesItem("Unknown");
|
2012-03-04 03:14:38 +00:00
|
|
|
SetBytesItem("Unknown");
|
|
|
|
SetBytesItem("Unknown");
|
|
|
|
SetBytesItem("Unknown");
|
|
|
|
SetBytesItem("Unknown");
|
2010-02-28 22:48:50 +00:00
|
|
|
#endif
|
2010-01-31 23:41:46 +00:00
|
|
|
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
SetObjItem(BPY_app_alembic_struct());
|
2011-12-28 12:35:58 +00:00
|
|
|
SetObjItem(BPY_app_ffmpeg_struct());
|
2013-12-08 15:03:17 +06:00
|
|
|
SetObjItem(BPY_app_ocio_struct());
|
|
|
|
SetObjItem(BPY_app_oiio_struct());
|
2017-06-07 12:16:48 +02:00
|
|
|
SetObjItem(BPY_app_opensubdiv_struct());
|
Implementation of OpenVDB as a possible cache format for smoke
simulations.
This commits implements OpenVDB as an extra cache format in the Point
Cache system for smoke simulations. Compilation with the library is
turned off by default for now, and shall be enabled when the library is
present.
A documentation of its doings is available here: http://
wiki.blender.org/index.php/User:Kevindietrich/OpenVDBSmokeExport.
A guide to compile OpenVDB can be found here (Linux): http://
wiki.blender.org/index.php?title=Dev:Doc/Building_Blender/Linux/
Dependencies_From_Source#OpenVDB
Reviewers: sergey, lukastoenne, brecht, campbellbarton
Reviewed By: brecht, campbellbarton
Subscribers: galenb, Blendify, robocyte, Lapineige, bliblubli,
jtheninja, lukasstockner97, dingto, brecht
Differential Revision: https://developer.blender.org/D1721
2016-01-23 08:39:29 +01:00
|
|
|
SetObjItem(BPY_app_openvdb_struct());
|
2015-02-18 12:07:48 +01:00
|
|
|
SetObjItem(BPY_app_sdl_struct());
|
2012-12-18 18:02:20 +00:00
|
|
|
SetObjItem(BPY_app_build_options_struct());
|
2011-06-24 16:54:30 +00:00
|
|
|
SetObjItem(BPY_app_handlers_struct());
|
Python i18n API. Many thanks to Campbell and Brecht for the reviews and suggestions!
This commit adds:
* A new bpy.app.translations module giving some info about locales/translation stuff (current active locale, all locales currently known by blender, all translation contexts currently defined, etc.).
* The ability for addons to feature translations, using the (un)register functions of above module.
* Also cleans up "translate py string when storing into RNA prop" by removing "PROP_TRANSLATE" string's subtype, and adding a PROP_STRING_PY_TRANSLATE flag instead (this way it is no more exposed to python...).
Addon translations work with py dictionaries: each addon features a dict {lang: {(context, message): translation, ...}, ...}, which is registered when the addon is enabled (and unregistered when disabled).
Then, when a key (context, message) is not found in regular mo catalog, a cache dict for current locale is built from all registered addon translations, and key is searched in it.
Note: currently addons writers have to do all the work by hand, will add something (probably extend "edit translation" addon) to automate messages extraction from addons soon(ish)! To get a look to expected behavior from addons, have a look at render_copy_settings/__init__.py and render_copy_settings/translations.py (rather stupid example currently, but...). Once we have a complete process, I'll also update relevant wiki pages.
2013-01-20 17:29:07 +00:00
|
|
|
SetObjItem(BPY_app_translations_struct());
|
2011-06-24 16:54:30 +00:00
|
|
|
|
2010-01-31 23:41:46 +00:00
|
|
|
#undef SetIntItem
|
|
|
|
#undef SetStrItem
|
2012-03-04 03:14:38 +00:00
|
|
|
#undef SetBytesItem
|
2010-01-31 23:41:46 +00:00
|
|
|
#undef SetObjItem
|
|
|
|
|
|
|
|
if (PyErr_Occurred()) {
|
|
|
|
Py_CLEAR(app_info);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return app_info;
|
|
|
|
}
|
|
|
|
|
2010-10-12 23:47:43 +00:00
|
|
|
/* a few getsets because it makes sense for them to be in bpy.app even though
|
|
|
|
* they are not static */
|
2011-11-26 15:18:30 +00:00
|
|
|
|
|
|
|
PyDoc_STRVAR(bpy_app_debug_doc,
|
2012-03-31 00:59:17 +00:00
|
|
|
"Boolean, for debug info (started with --debug / --debug_* matching this attribute name)"
|
2011-11-26 15:18:30 +00:00
|
|
|
);
|
2012-03-31 00:59:17 +00:00
|
|
|
static PyObject *bpy_app_debug_get(PyObject *UNUSED(self), void *closure)
|
2010-10-12 23:47:43 +00:00
|
|
|
{
|
2012-03-31 00:59:17 +00:00
|
|
|
const int flag = GET_INT_FROM_POINTER(closure);
|
|
|
|
return PyBool_FromLong(G.debug & flag);
|
2010-10-12 23:47:43 +00:00
|
|
|
}
|
|
|
|
|
2012-03-31 00:59:17 +00:00
|
|
|
static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *closure)
|
2010-10-12 23:47:43 +00:00
|
|
|
{
|
2012-03-31 00:59:17 +00:00
|
|
|
const int flag = GET_INT_FROM_POINTER(closure);
|
|
|
|
const int param = PyObject_IsTrue(value);
|
2010-10-12 23:47:43 +00:00
|
|
|
|
2013-01-10 15:22:19 +00:00
|
|
|
if (param == -1) {
|
2010-10-12 23:47:43 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "bpy.app.debug can only be True/False");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-03-31 00:59:17 +00:00
|
|
|
if (param) G.debug |= flag;
|
|
|
|
else G.debug &= ~flag;
|
2010-10-12 23:47:43 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-09-14 15:40:35 +02:00
|
|
|
#define BROKEN_BINARY_PATH_PYTHON_HACK
|
2015-05-06 11:07:15 +10:00
|
|
|
|
|
|
|
PyDoc_STRVAR(bpy_app_binary_path_python_doc,
|
|
|
|
"String, the path to the python executable (read-only)"
|
|
|
|
);
|
2016-07-14 18:27:20 +10:00
|
|
|
static PyObject *bpy_app_binary_path_python_get(PyObject *self, void *UNUSED(closure))
|
2015-05-06 11:07:15 +10:00
|
|
|
{
|
|
|
|
/* refcount is held in BlenderAppType.tp_dict */
|
|
|
|
static PyObject *ret = NULL;
|
|
|
|
|
|
|
|
if (ret == NULL) {
|
|
|
|
/* only run once */
|
|
|
|
char fullpath[1024];
|
|
|
|
BKE_appdir_program_python_search(
|
|
|
|
fullpath, sizeof(fullpath),
|
|
|
|
PY_MAJOR_VERSION, PY_MINOR_VERSION);
|
|
|
|
ret = PyC_UnicodeFromByte(fullpath);
|
2016-09-14 15:40:35 +02:00
|
|
|
#ifdef BROKEN_BINARY_PATH_PYTHON_HACK
|
|
|
|
Py_INCREF(ret);
|
|
|
|
UNUSED_VARS(self);
|
|
|
|
#else
|
|
|
|
PyDict_SetItem(BlenderAppType.tp_dict, /* XXX BAAAADDDDDD! self is not a PyDescr at all! it's bpy.app!!! */ PyDescr_NAME(self), ret);
|
|
|
|
#endif
|
2015-05-06 11:07:15 +10:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
Py_INCREF(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-11-26 15:18:30 +00:00
|
|
|
PyDoc_STRVAR(bpy_app_debug_value_doc,
|
|
|
|
"Int, number which can be set to non-zero values for testing purposes"
|
|
|
|
);
|
2010-12-15 06:03:45 +00:00
|
|
|
static PyObject *bpy_app_debug_value_get(PyObject *UNUSED(self), void *UNUSED(closure))
|
|
|
|
{
|
2012-11-21 02:28:36 +00:00
|
|
|
return PyLong_FromLong(G.debug_value);
|
2010-12-15 06:03:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void *UNUSED(closure))
|
|
|
|
{
|
2017-08-20 15:44:54 +10:00
|
|
|
int param = PyC_Long_AsI32(value);
|
2010-12-15 06:03:45 +00:00
|
|
|
|
|
|
|
if (param == -1 && PyErr_Occurred()) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "bpy.app.debug_value can only be set to a whole number");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-08-08 18:21:54 +00:00
|
|
|
G.debug_value = param;
|
2010-12-15 06:03:45 +00:00
|
|
|
|
2016-01-09 22:48:50 +11:00
|
|
|
WM_main_add_notifier(NC_WINDOW, NULL);
|
|
|
|
|
2010-12-15 06:03:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-10 00:42:16 +00:00
|
|
|
static PyObject *bpy_app_global_flag_get(PyObject *UNUSED(self), void *closure)
|
|
|
|
{
|
|
|
|
const int flag = GET_INT_FROM_POINTER(closure);
|
|
|
|
return PyBool_FromLong(G.f & flag);
|
|
|
|
}
|
|
|
|
|
2011-11-26 15:18:30 +00:00
|
|
|
PyDoc_STRVAR(bpy_app_tempdir_doc,
|
|
|
|
"String, the temp directory used by blender (read-only)"
|
|
|
|
);
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *bpy_app_tempdir_get(PyObject *UNUSED(self), void *UNUSED(closure))
|
2010-10-12 23:47:43 +00:00
|
|
|
{
|
2014-11-23 15:54:29 +01:00
|
|
|
return PyC_UnicodeFromByte(BKE_tempdir_session());
|
2010-10-12 23:47:43 +00:00
|
|
|
}
|
|
|
|
|
2011-11-26 15:18:30 +00:00
|
|
|
PyDoc_STRVAR(bpy_app_driver_dict_doc,
|
|
|
|
"Dictionary for drivers namespace, editable in-place, reset on file load (read-only)"
|
|
|
|
);
|
2010-11-27 02:39:51 +00:00
|
|
|
static PyObject *bpy_app_driver_dict_get(PyObject *UNUSED(self), void *UNUSED(closure))
|
|
|
|
{
|
2012-03-26 20:41:54 +00:00
|
|
|
if (bpy_pydriver_Dict == NULL) {
|
2010-11-27 02:39:51 +00:00
|
|
|
if (bpy_pydriver_create_dict() != 0) {
|
|
|
|
PyErr_SetString(PyExc_RuntimeError, "bpy.app.driver_namespace failed to create dictionary");
|
|
|
|
return NULL;
|
2012-03-26 20:41:54 +00:00
|
|
|
}
|
2010-11-27 02:39:51 +00:00
|
|
|
}
|
|
|
|
|
2015-01-06 16:42:22 +11:00
|
|
|
return Py_INCREF_RET(bpy_pydriver_Dict);
|
2010-11-27 02:39:51 +00:00
|
|
|
}
|
|
|
|
|
2015-08-10 17:26:37 +02:00
|
|
|
PyDoc_STRVAR(bpy_app_preview_render_size_doc,
|
|
|
|
"Reference size for icon/preview renders (read-only)"
|
|
|
|
);
|
|
|
|
static PyObject *bpy_app_preview_render_size_get(PyObject *UNUSED(self), void *closure)
|
|
|
|
{
|
|
|
|
return PyLong_FromLong((long)UI_preview_render_size(GET_INT_FROM_POINTER(closure)));
|
|
|
|
}
|
|
|
|
|
2013-06-10 00:42:16 +00:00
|
|
|
static PyObject *bpy_app_autoexec_fail_message_get(PyObject *UNUSED(self), void *UNUSED(closure))
|
|
|
|
{
|
|
|
|
return PyC_UnicodeFromByte(G.autoexec_fail);
|
|
|
|
}
|
|
|
|
|
2010-11-27 02:39:51 +00:00
|
|
|
|
2011-12-26 12:26:11 +00:00
|
|
|
static PyGetSetDef bpy_app_getsets[] = {
|
2013-01-03 23:27:20 +00:00
|
|
|
{(char *)"debug", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG},
|
|
|
|
{(char *)"debug_ffmpeg", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_FFMPEG},
|
|
|
|
{(char *)"debug_freestyle", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_FREESTYLE},
|
|
|
|
{(char *)"debug_python", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_PYTHON},
|
|
|
|
{(char *)"debug_events", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_EVENTS},
|
|
|
|
{(char *)"debug_handlers", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_HANDLERS},
|
|
|
|
{(char *)"debug_wm", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_WM},
|
2014-07-01 10:10:51 +02:00
|
|
|
{(char *)"debug_depsgraph", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_DEPSGRAPH},
|
2015-01-21 14:00:59 +01:00
|
|
|
{(char *)"debug_simdata", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_SIMDATA},
|
2015-05-06 11:07:15 +10:00
|
|
|
{(char *)"debug_gpumem", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_GPU_MEM},
|
|
|
|
|
|
|
|
{(char *)"binary_path_python", bpy_app_binary_path_python_get, NULL, (char *)bpy_app_binary_path_python_doc, NULL},
|
2012-03-31 00:59:17 +00:00
|
|
|
|
2011-11-26 15:18:30 +00:00
|
|
|
{(char *)"debug_value", bpy_app_debug_value_get, bpy_app_debug_value_set, (char *)bpy_app_debug_value_doc, NULL},
|
|
|
|
{(char *)"tempdir", bpy_app_tempdir_get, NULL, (char *)bpy_app_tempdir_doc, NULL},
|
|
|
|
{(char *)"driver_namespace", bpy_app_driver_dict_get, NULL, (char *)bpy_app_driver_dict_doc, NULL},
|
2013-06-10 00:42:16 +00:00
|
|
|
|
2016-01-09 22:56:28 +11:00
|
|
|
{(char *)"render_icon_size", bpy_app_preview_render_size_get, NULL, (char *)bpy_app_preview_render_size_doc, (void *)ICON_SIZE_ICON},
|
|
|
|
{(char *)"render_preview_size", bpy_app_preview_render_size_get, NULL, (char *)bpy_app_preview_render_size_doc, (void *)ICON_SIZE_PREVIEW},
|
2015-08-10 17:26:37 +02:00
|
|
|
|
2013-06-10 00:42:16 +00:00
|
|
|
/* security */
|
|
|
|
{(char *)"autoexec_fail", bpy_app_global_flag_get, NULL, NULL, (void *)G_SCRIPT_AUTOEXEC_FAIL},
|
|
|
|
{(char *)"autoexec_fail_quiet", bpy_app_global_flag_get, NULL, NULL, (void *)G_SCRIPT_AUTOEXEC_FAIL_QUIET},
|
|
|
|
{(char *)"autoexec_fail_message", bpy_app_autoexec_fail_message_get, NULL, NULL, NULL},
|
2010-11-27 02:39:51 +00:00
|
|
|
{NULL, NULL, NULL, NULL, NULL}
|
|
|
|
};
|
2010-10-12 23:47:43 +00:00
|
|
|
|
|
|
|
static void py_struct_seq_getset_init(void)
|
|
|
|
{
|
|
|
|
/* tricky dynamic members, not to py-spec! */
|
2016-07-14 17:28:28 +10:00
|
|
|
for (PyGetSetDef *getset = bpy_app_getsets; getset->name; getset++) {
|
|
|
|
PyObject *item = PyDescr_NewGetSet(&BlenderAppType, getset);
|
2016-07-14 18:27:20 +10:00
|
|
|
PyDict_SetItem(BlenderAppType.tp_dict, PyDescr_NAME(item), item);
|
2016-07-14 17:28:28 +10:00
|
|
|
Py_DECREF(item);
|
2010-11-27 02:39:51 +00:00
|
|
|
}
|
2010-10-12 23:47:43 +00:00
|
|
|
}
|
|
|
|
/* end dynamic bpy.app */
|
|
|
|
|
|
|
|
|
2010-01-31 23:41:46 +00:00
|
|
|
PyObject *BPY_app_struct(void)
|
|
|
|
{
|
|
|
|
PyObject *ret;
|
2010-10-12 23:47:43 +00:00
|
|
|
|
2010-01-31 23:41:46 +00:00
|
|
|
PyStructSequence_InitType(&BlenderAppType, &app_info_desc);
|
|
|
|
|
2011-12-26 12:26:11 +00:00
|
|
|
ret = make_app_info();
|
2010-01-31 23:41:46 +00:00
|
|
|
|
|
|
|
/* prevent user from creating new instances */
|
2011-12-26 12:26:11 +00:00
|
|
|
BlenderAppType.tp_init = NULL;
|
|
|
|
BlenderAppType.tp_new = NULL;
|
|
|
|
BlenderAppType.tp_hash = (hashfunc)_Py_HashPointer; /* without this we can't do set(sys.modules) [#29635] */
|
2010-10-12 23:47:43 +00:00
|
|
|
|
|
|
|
/* kindof a hack ontop of PyStructSequence */
|
|
|
|
py_struct_seq_getset_init();
|
|
|
|
|
2010-01-31 23:49:04 +00:00
|
|
|
return ret;
|
2010-01-31 23:41:46 +00:00
|
|
|
}
|