3 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. The Blender
9 * Foundation also sells licenses for use in proprietary software under
10 * the Blender License. See http://www.blender.org/BL/ for information
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23 * All rights reserved.
25 * This is a new part of Blender.
27 * Contributor(s): Willian P. Germano
29 * ***** END GPL/BL DUAL LICENSE BLOCK *****
35 /* This header exposes BPyMenu related public declarations. The implementation
36 * adds 'dynamic' menus to Blender, letting scripts register themselves in any
37 * of a few pre-defined (trivial to upgrade) places in menus. These places or
38 * slots are called groups here (Import, Export, etc). This is how it works:
39 * - scripts at some specific folder (only the user pref U.pythondir, right
40 * now) are scanned for registration info.
41 * - this data is also saved to a .Bpymenus file at the user's home dir and
42 * only re-created when the scripts folder gets modified.
43 * - on start-up Blender uses this info to fill a table, which is used to
44 * create the menu entries when they are needed (see header_info.c or
45 * header_script.c, under source/blender/src/, for examples).
48 /* These two structs hold py menu/submenu info.
49 * BPyMenu holds a script's name (as should appear in the menu) and filename,
50 * plus an optional list of submenus. Each submenu is related to a string
51 * (arg) that the script can get from the __script__ pydict, to know which
52 * submenu was chosen. */
54 typedef struct BPySubMenu {
57 struct BPySubMenu *next;
60 typedef struct BPyMenu {
64 short version; /* Blender version */
65 int dir; /* 0: default, 1: U.pythondir */
66 struct BPySubMenu *submenus;
70 /* Scripts can be added to only a few pre-defined places in menus, like
71 * File->Import, File->Export, etc. (for speed and better control).
72 * To make a new menu 'slot' available for scripts:
73 * - add an entry to the enum below, right before PYMENU_TOTAL, of course;
74 * - update the bpymenu_group_atoi() and BPyMenu_group_itoa() functions in
76 * - add the necessary code to the header_***.c file in
77 * source/blender/src/, like done in header_info.c for import/export;
78 * - update the bpython registering function and its documentation to include
88 /* BPyMenuTable holds all registered pymenus, as linked lists for each menu
89 * where they can appear (see PYMENUHOOKS enum above).
91 extern BPyMenu *BPyMenuTable[]; /* defined in BPY_menus.c */
93 /* public functions: */
94 int BPyMenu_Init(int usedir);
95 void BPyMenu_RemoveAllEntries(void);
96 void BPyMenu_PrintAllEntries(void);
97 char *BPyMenu_CreatePupmenuStr(BPyMenu *pym, short group);
98 char *BPyMenu_group_itoa (short group);
99 char *bpymenu_gethome();
100 struct BPyMenu *BPyMenu_GetEntry (short group, short pos);
102 #endif /* BPY_MENUS_H */