diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2004-01-27 06:34:16 +0300 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2004-01-27 06:34:16 +0300 |
commit | 33dd2f5e0d58427d49f9bdbd3a593af5a9cc6302 (patch) | |
tree | 59fc8dcdd2617c78f6a69dbd88ee578dbe44a63d /source/blender/python/BPY_menus.c | |
parent | d482d34ffb7ec92b63a5ffb1fa3237da720cc928 (diff) |
BPython:
- as proposed by Ton, default dir for menu enabled scripts is:
userhome/.blender/scripts if available or (using bprogname -- argv[0]),
blenderInstallationDir/.blender/scripts/ otherwise.
- moved a piece of code from BPY_interface.c to BPY_menus.c to get rid
of a linkage warning reported by J. Walton
-- added the first scripts to release/scripts:
We need time to get more scripts there, but the situation should improve
consistently from now on. Adding three export scripts: cal3d, directX, ac3d.
And one import: ac3d.
Diffstat (limited to 'source/blender/python/BPY_menus.c')
-rw-r--r-- | source/blender/python/BPY_menus.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/source/blender/python/BPY_menus.c b/source/blender/python/BPY_menus.c index a9210f73933..cfe10723329 100644 --- a/source/blender/python/BPY_menus.c +++ b/source/blender/python/BPY_menus.c @@ -74,19 +74,35 @@ static int DEBUG; BPyMenu *BPyMenuTable[PYMENU_TOTAL]; /* we can't be sure if BLI_gethome() returned a path - * with '.blender' appended or not, so: */ -static char *bpymenu_gethome() + * with '.blender' appended or not. Besides, this function now + * either returns userhome/.blender (if it exists) or + * blenderInstallDir/.blender/ otherwise */ +char *bpymenu_gethome() { static char homedir[FILE_MAXDIR]; + char bprogdir[FILE_MAXDIR]; char *s; + int i; - if (homedir[0] != '\0') return homedir; + if (homedir[0] != '\0') return homedir; /* no need to search twice */ s = BLI_gethome(); if (strstr(s, ".blender")) PyOS_snprintf(homedir, FILE_MAXDIR, s); else BLI_make_file_string ("/", homedir, s, ".blender/"); + /* if userhome/.blender/ exists, return it */ + if (BLI_exists(homedir)) return homedir; + + /* otherwise, use argv[0] (bprogname) to get .blender/ in + * Blender's installation dir */ + s = BLI_last_slash(bprogname); + + i = s - bprogname + 1; + + PyOS_snprintf(bprogdir, i, bprogname); + BLI_make_file_string ("/", homedir, bprogdir, ".blender/"); + return homedir; } @@ -195,6 +211,26 @@ static BPyMenu *bpymenu_FindEntry (short group, char *name) return NULL; } +/* BPyMenu_GetEntry: + * given a group and a position, return the entry in that position from + * that group. +*/ +BPyMenu *BPyMenu_GetEntry (short group, short pos) +{ + BPyMenu *pym = NULL; + + if ((group < 0) || (group >= PYMENU_TOTAL)) return NULL; + + pym = BPyMenuTable[group]; + + while (pos--) { + if (pym) pym = pym->next; + else break; + } + + return pym; /* found entry or NULL */ +} + static void bpymenu_set_tooltip (BPyMenu *pymenu, char *tip) { if (!pymenu) return; |