Commit Graph

121 Commits

Author SHA1 Message Date
1a620ac9c3 bpy.props.RemoveProperty() py api docs were still incorrect. 2013-02-19 15:21:12 +00:00
6550fb8452 bpy.props.RemoveProperty() had incorrect docstring. 2013-02-19 02:48:14 +00:00
327b17b26f Fix #31338: python enum properties can now specify icons for items, in the following
order: (identifier, name, description, icon, unique number)

This also works without the icon still, for compatibility.
2013-01-23 21:55:11 +00:00
cef730d969 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
a4d5ef8c7d fix for bpy.props string get-length callback, PyUnicode_GetLength() isn't a measure of the buffer size. 2013-01-11 04:09:54 +00:00
1c99e6aa0b pyapi internal api code: check for == -1 rather then < 0, for known error returns. 2013-01-10 15:22:19 +00:00
Lukas Toenne
127b5423d6 Another fix for bpy.props getters/setters: PyC_AsArray does a refcount decrement internally on errors, need to skip Py_DECREF in that case to avoid negative refcounts. 2013-01-10 14:36:08 +00:00
Lukas Toenne
273cf512dd Fix for bpy.props getter/setter callbacks. These were missing a valid GIL state when being called outside the UI context. 2013-01-10 12:32:09 +00:00
1bf5832dfb code cleanup: warnings and use stdbool for bpy* funcs. 2013-01-07 05:26:12 +00:00
8ee99cc39c add ability to use world gradient rendering when 'Only Render' option is enabled.
supports paper/blend/real.
2013-01-06 15:02:23 +00:00
Lukas Toenne
e8b415bdb4 This patch adds support in bpy.props for getter/setter callback functions. We already have update callbacks, but generic get/set functions can come in handy in some cases where the functionality is too complex to use a single value.
The current C callback functions are too simple allow a straightforward implementation, in particular they don't receive the PropertyRNA pointer itself as an argument, which means the callback cannot directly access the PropertyRNA's py_data pointers which store the python function objects. For this reason a second runtime variant of these callbacks has been added. It is only used for runtime callbacks and not in makesrna, but otherwise works the same way.
2013-01-05 14:56:37 +00:00
b88836a45b Add a warning to enum props' items parameter, to *never* use a generator as value for this param! It works in most cases, but in some it leads to an empty set of values for the enum (see [#33716]), and it's not an easy bug to track down! 2013-01-01 15:55:21 +00:00
f4dea6d829 when an invalid subtype is passed to a property, a list of valid subtypes is now included in the exception message.
from bug report [#33018], this avoids common mistakes.
2012-10-30 12:45:42 +00:00
900fa1bfb9 rename subtype FILENAME --> FILE_NAME to match FILE_PATH, DIR_PATH 2012-10-30 12:36:54 +00:00
2821f822c5 * New string property subtype: PASSWORD
When this new subtypes is used, then string of property is hidden using
asterisks, e.g.: mysecretpassword -> ****************

This code was reviewed and modified by Brecht. Thanks very much:
 - https://codereview.appspot.com/6713044/

This new subtype of string property is intended mostly for Add-on developers
writing Add-on which communicates with some server (http, sql, ftp, verse,
etc.). When this server requires user authentication and user has to type
username and password, then current API didn't allow to type 'hidden' password,
e.g. when you want to demonstrate this script, then everybody can see this
security password. Some examples of Add-on which could use this new subtype:
 - On-line database of textures
 - Integration of render farm
 - Integration of Verse

Security Notes:
 - You can copy paste hiddent string of property from text input using (Ctrl-C, Ctrl-V),
but you can do this in other GUI toolkits too (this behavior it is widely used).
 - Text of string property is stored in plain text, but it is widely used in other
GUI toolkits (Qt, Gtk, etc.).

Simple examples:
 - https://dl.dropbox.com/u/369894/draw_op_passwd.py
 - https://dl.dropbox.com/u/369894/blender-password.png
2012-10-26 12:58:54 +00:00
2223ca1c20 Fix #32973: crash adding python property with update=None parameter passed. 2012-10-25 22:37:05 +00:00
f3ece5a108 style cleanup: trailing tabs & expand some non prefix tabs into spaces. 2012-10-21 05:46:41 +00:00
79d8367974 add warning that RNA update callbacks dont have checks for infinite recursion. 2012-09-28 09:35:32 +00:00
719aedaf60 mask - draw both sides of the curve when filled option is disabled. 2012-08-07 13:37:16 +00:00
b218d90176 fix a crash when python is registering enum properties and the items argument is a generator (some sequence type besides a list/typle), in this case it could free the strings before blender duplicates them.
this fixes [#32192] Import Images as Planes script is broken
2012-08-07 10:03:14 +00:00
32cf7fcdb1 code cleanup: spelling 2012-07-16 23:23:33 +00:00
46f1671c07 missing from previous commit 2012-05-27 21:56:19 +00:00
032d83ecc4 style cleanup: defines with braces 2012-05-27 20:13:59 +00:00
dd7229aee0 Added 'LIBRARY_EDITABLE' flag to bpy.props.*
Rationale: custom props on linked objects are editable through ops and the console but the UI code calls RNA_property_editable() which returns false if (id->lib && !(prop->flag & PROP_LIB_EXCEPTION))

Setting the 'LIBRARY_EDITABLE' flag allows UI templates to change these props (but the changes aren't saved!) for things like indices into CollectionProperties which live on the linked object
2012-05-19 21:22:01 +00:00
133bdac1d0 Patch [#31279] clarifiy a python error-string (when incorrectly specifying enum
items from python)

Thanks Philipp Oeser (lichtwerk)
2012-05-04 14:34:10 +00:00
abf551b1a5 style cleanup: py api 2012-03-26 20:41:54 +00:00
4f19c1a995 spelling cleanup 2012-03-18 07:38:51 +00:00
70d3d1aca6 style cleanup: py/capi 2012-03-16 21:39:56 +00:00
9d49fa0e63 style cleanup - spelling corrections & update some incorrect comments. 2012-03-03 11:45:08 +00:00
c5d7f8e416 formatting edits (<120 line length), remove invalid 'defaults' keyword arg from docs. 2012-01-21 10:27:24 +00:00
309f3f31e7 remove redundant trailing slashes 2012-01-12 06:11:08 +00:00
6d878810c6 for bpy.props, when 'name' argument is not initialized, vallback to the attribute name rather than an empty string. 2011-12-28 04:25:46 +00:00
e17fd46c71 formatting edits only to use more consisted style 2011-12-26 12:26:11 +00:00
9c9099a805 formatting edits in py api, no functional changes 2011-12-18 08:50:06 +00:00
6ec3313e2d Fix: defining properties would fail with argument update=None instead of not
specifying the argument.
2011-11-29 22:57:35 +00:00
d52a811052 minor bpy api edits
- strict check for rna properties
- formatting edits (120 line width)
- use PyDoc_STRVAR macros for getset docstrings
2011-11-26 15:18:30 +00:00
d6c1009195 bytestring support for py/rna - this is so py can access data which
isn't meant to be accessed as unicode text.
2011-11-15 07:09:41 +00:00
0b1066af8e fix [#29251] Properties options={'SKIP_SAVE'} not working, patch attached
patch from Domino Marama (domino)
2011-11-14 15:05:41 +00:00
2b939904ab documentation - brief descriptions for bpy api files. 2011-11-05 08:21:12 +00:00
62f2218554 macro formatting & remve some unused code. 2011-11-05 05:44:52 +00:00
665f602f15 python string conversion
- use _PyUnicode_AsStringAndSize where possible
- use %R for PyErr_Format(...) rather then running repr on the object explicitly 
- use const char
2011-11-03 14:09:18 +00:00
4a04f72069 remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
61389bba41 fix spelling mistakes in comments (and in some python error messages), nothing to effect translations. 2011-10-17 06:39:13 +00:00
276e5f7095 formatting edits & remove debug print. 2011-10-13 01:29:08 +00:00
c27926896f spaces -> tabs (whitespace only changes) 2011-10-06 22:04:01 +00:00
5e3110af05 add support for a 4th item for rna property enums in python so the numeric value can be passed, this is so you can animate the enum and keep the values even if you add items in the middle of the enum. - request from ZanQdo. 2011-09-28 09:18:20 +00:00
aaae90af33 fix [#28751] Item in Enum propertie is grayed out
was infact a very old bug where an empty title took the following word for the title, eg: "%t|First Item|Second Item"
the first item would be evaluated as a title.
2011-09-27 16:23:40 +00:00
943a026c60 py/rna string subtypes for strings which should be automatically translated:
layout.prop("blah", text="Translate Me!")
2011-09-21 13:53:35 +00:00
fa2ba5fbf5 - use static vars and functions where possible.
- use NULL rather than 0 when used as pointers.
2011-08-28 05:06:30 +00:00
de0db6c8da unit arg for FloatVectorProeprty 2011-08-02 10:56:09 +00:00