Blender  V3.3
Macros | Functions | Variables
bpy_utils_previews.c File Reference
#include <Python.h>
#include <structmember.h>
#include "BLI_utildefines.h"
#include "RNA_access.h"
#include "RNA_prototypes.h"
#include "RNA_types.h"
#include "BPY_extern.h"
#include "bpy_rna.h"
#include "bpy_utils_previews.h"
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_thumbs.h"
#include "BKE_icons.h"
#include "DNA_ID.h"
#include "../generic/python_utildefines.h"

Go to the source code of this file.

Macros

#define STR_SOURCE_TYPES   "'IMAGE', 'MOVIE', 'BLEND', 'FONT'"
 

Functions

 PyDoc_STRVAR (bpy_utils_previews_new_doc, ".. method:: new(name)\n" "\n" " Generate a new empty preview.\n" "\n" " :arg name: The name (unique id) identifying the preview.\n" " :type name: string\n" " :return: The Preview matching given name, or a new empty one.\n" " :rtype: :class:`bpy.types.ImagePreview`\n" " :raises KeyError: if ``name`` already exists.")
 
static PyObject * bpy_utils_previews_new (PyObject *UNUSED(self), PyObject *args)
 
 PyDoc_STRVAR (bpy_utils_previews_load_doc, ".. method:: load(name, filepath, filetype, force_reload=False)\n" "\n" " Generate a new preview from given file path.\n" "\n" " :arg name: The name (unique id) identifying the preview.\n" " :type name: string\n" " :arg filepath: The file path to generate the preview from.\n" " :type filepath: string\n" " :arg filetype: The type of file, needed to generate the preview in [" STR_SOURCE_TYPES "].\n" " :type filetype: string\n" " :arg force_reload: If True, force running thumbnail manager even if preview already " "exists in cache.\n" " :type force_reload: bool\n" " :return: The Preview matching given name, or a new empty one.\n" " :rtype: :class:`bpy.types.ImagePreview`\n" " :raises KeyError: if ``name`` already exists.")
 
static PyObject * bpy_utils_previews_load (PyObject *UNUSED(self), PyObject *args)
 
 PyDoc_STRVAR (bpy_utils_previews_release_doc, ".. method:: release(name)\n" "\n" " Release (free) a previously created preview.\n" "\n" "\n" " :arg name: The name (unique id) identifying the preview.\n" " :type name: string\n")
 
static PyObject * bpy_utils_previews_release (PyObject *UNUSED(self), PyObject *args)
 
 PyDoc_STRVAR (bpy_utils_previews_doc, "This object contains basic static methods to handle cached (non-ID) previews in Blender\n" "(low-level API, not exposed to final users).")
 
PyObject * BPY_utils_previews_module (void)
 

Variables

static struct PyMethodDef bpy_utils_previews_methods []
 
static struct PyModuleDef bpy_utils_previews_module
 

Detailed Description

This file defines a singleton py object accessed via 'bpy.utils.previews', which exposes low-level API for custom previews/icons. It is replaced in final API by an higher-level python wrapper, that handles previews by addon, and automatically release them on deletion.

Definition in file bpy_utils_previews.c.

Macro Definition Documentation

◆ STR_SOURCE_TYPES

#define STR_SOURCE_TYPES   "'IMAGE', 'MOVIE', 'BLEND', 'FONT'"

Definition at line 37 of file bpy_utils_previews.c.

Function Documentation

◆ bpy_utils_previews_load()

static PyObject* bpy_utils_previews_load ( PyObject *  UNUSEDself,
PyObject *  args 
)
static

◆ BPY_utils_previews_module()

PyObject* BPY_utils_previews_module ( void  )

Definition at line 176 of file bpy_utils_previews.c.

References bpy_utils_previews_module.

Referenced by BPy_init_modules().

◆ bpy_utils_previews_new()

static PyObject* bpy_utils_previews_new ( PyObject *  UNUSEDself,
PyObject *  args 
)
static

◆ bpy_utils_previews_release()

static PyObject* bpy_utils_previews_release ( PyObject *  UNUSEDself,
PyObject *  args 
)
static

Definition at line 136 of file bpy_utils_previews.c.

◆ PyDoc_STRVAR() [1/4]

PyDoc_STRVAR ( bpy_utils_previews_doc  ,
"This object contains basic static methods to handle cached (non-ID) previews in Blender\n" "(low-level API, not exposed to final users)."   
)

◆ PyDoc_STRVAR() [2/4]

PyDoc_STRVAR ( bpy_utils_previews_load_doc  ,
".. method:: load(name, filepath, filetype, force_reload=False)\n" "\n" " Generate a new preview from given file path.\n" "\n" " :arg name: The name (unique id) identifying the preview.\n" " :type name: string\n" " :arg filepath: The file path to generate the preview from.\n" " :type filepath: string\n" " :arg filetype: The type of  file,
needed to generate the preview in .\n" " :type filetype:string\n" " :arg force_reload:If  True[" STR_SOURCE_TYPES "],
force running thumbnail manager even if preview already " "exists in cache.\n" " :type force_reload:bool\n" " :return:The Preview matching given  name,
or a new empty one.\n" " :rtype::class:`bpy.types.ImagePreview`\n" " :raises KeyError:if ``name`` already exists."   
)

◆ PyDoc_STRVAR() [3/4]

PyDoc_STRVAR ( bpy_utils_previews_new_doc  ,
".. method:: new(name)\n" "\n" " Generate a new empty preview.\n" "\n" " :arg name: The name (unique id) identifying the preview.\n" " :type name: string\n" " :return: The Preview matching given  name,
or a new empty one.\n" " :rtype::class:`bpy.types.ImagePreview`\n" " :raises KeyError:if ``name`` already exists."   
)

◆ PyDoc_STRVAR() [4/4]

PyDoc_STRVAR ( bpy_utils_previews_release_doc  ,
".. method:: release(name)\n" "\n" " Release (free) a previously created preview.\n" "\n" "\n" " :arg name: The name (unique id) identifying the preview.\n" " :type name: string\n"   
)

Variable Documentation

◆ bpy_utils_previews_methods

struct PyMethodDef bpy_utils_previews_methods[]
static
Initial value:
= {
{"new", (PyCFunction)bpy_utils_previews_new, METH_VARARGS, bpy_utils_previews_new_doc},
{"load", (PyCFunction)bpy_utils_previews_load, METH_VARARGS, bpy_utils_previews_load_doc},
{"release",
METH_VARARGS,
bpy_utils_previews_release_doc},
{NULL, NULL, 0, NULL},
}
static PyObject * bpy_utils_previews_load(PyObject *UNUSED(self), PyObject *args)
static PyObject * bpy_utils_previews_new(PyObject *UNUSED(self), PyObject *args)
static PyObject * bpy_utils_previews_release(PyObject *UNUSED(self), PyObject *args)

Definition at line 136 of file bpy_utils_previews.c.

◆ bpy_utils_previews_module

struct PyModuleDef bpy_utils_previews_module
static
Initial value:
= {
PyModuleDef_HEAD_INIT,
"bpy._utils_previews",
bpy_utils_previews_doc,
0,
}
static struct PyMethodDef bpy_utils_previews_methods[]

Definition at line 160 of file bpy_utils_previews.c.

Referenced by BPY_utils_previews_module().