Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorWillian Padovani Germano <wpgermano@gmail.com>2004-06-10 07:27:46 +0400
committerWillian Padovani Germano <wpgermano@gmail.com>2004-06-10 07:27:46 +0400
commita6d077bae243eef5f8826b2c7b27bd297428d7d4 (patch)
treee170a7cc6c848969d5316c5abb3f68fa89de5d9d /source
parent7ff5c16a025adc56651b293ca993da82a2432a75 (diff)
Scripts:
- tiny updates for better behavior, unix line endings, cvs Id tags; - Updated DX7 exporter (thanks to author Ben Omari who's also working on a DX8 one); - added sysinfo script; Interface (scripts): - changed behavior for which win is chosen for script guis: Now there's a smarter order, guis will use either: - Scripts win - Buttons win (if not a script from groups Wizards or Utils) - Text win - Closest bigger area - Added a button to the scripts header so that it's faster to return to the buttons win (this can be made general), if that was the previous win used.
Diffstat (limited to 'source')
-rw-r--r--source/blender/include/blendef.h1
-rw-r--r--source/blender/python/BPY_interface.c47
-rw-r--r--source/blender/src/header_info.c14
-rw-r--r--source/blender/src/header_script.c9
4 files changed, 56 insertions, 15 deletions
diff --git a/source/blender/include/blendef.h b/source/blender/include/blendef.h
index 0cc2c0aefc1..a4a50114841 100644
--- a/source/blender/include/blendef.h
+++ b/source/blender/include/blendef.h
@@ -342,6 +342,7 @@
/* SCRIPT: 525 */
#define B_SCRIPTBROWSE 526
+#define B_SCRIPT2BUTS 527
/* FILE: 550 */
#define B_SORTFILELIST 551
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index 0a2e0dd7cc5..4a7f347de5b 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -42,7 +42,8 @@
#include <MEM_guardedalloc.h>
#include <BLI_blenlib.h> /* for BLI_last_slash() */
-#include <BIF_interface.h> /* for pupmenu */
+#include <BDR_editobject.h> /* for exit_editmode() */
+#include <BIF_interface.h> /* for pupmenu() */
#include <BIF_space.h>
#include <BIF_screen.h>
#include <BIF_toolbox.h>
@@ -273,10 +274,26 @@ void init_syspath(void)
/*****************************************************************************/
void BPY_post_start_python(void)
{
+ PyObject *result, *dict;
+
if (U.pythondir && U.pythondir[0] != '\0')
syspath_append(U.pythondir); /* append to module search path */
BPyMenu_Init(0); /* get dynamic menus (registered scripts) data */
+
+ dict = PyDict_New();
+
+ /* here we check if the user has (some of) the expected modules */
+ if (dict) {
+ char *s = "import chunk, gzip, math, os, struct, string";
+ result = PyRun_String(s, Py_eval_input, dict, dict);
+ if (!result) {
+ PyErr_Clear();
+ /*XXX print msg about this, point to readme.html */
+ }
+ else Py_DECREF(result);
+ Py_DECREF(dict);
+ }
}
/*****************************************************************************/
@@ -425,6 +442,10 @@ int BPY_txt_do_python_Text(struct Text* text)
return 0;
}
+ /* if in it, leave editmode, since changes a script makes to meshdata
+ * can be lost otherwise. */
+ if (G.obedit) exit_editmode(1);
+
script->id.us = 1;
script->flags = SCRIPT_RUNNING;
script->py_draw = NULL;
@@ -586,6 +607,30 @@ int BPY_menu_do_python(short menutype, int event)
return 0;
}
+ /* if in editmode, leave it, since changes a script makes to meshdata
+ * can be lost otherwise. */
+ if (G.obedit) exit_editmode(1);
+
+ /* let's find a proper area for an eventual script gui:
+ * preference in order: Script, Buttons (if not a Wizards or Utils script),
+ * Text, any closest bigger area */
+ if (curarea->spacetype != SPACE_SCRIPT) {
+ ScrArea *sa;
+
+ sa = find_biggest_area_of_type(SPACE_SCRIPT);
+
+ if (!sa) {
+ if ((menutype != PYMENU_WIZARDS) && (menutype != PYMENU_UTILS))
+ sa = find_biggest_area_of_type(SPACE_BUTS);
+ }
+
+ if (!sa) sa = find_biggest_area_of_type(SPACE_TEXT);
+
+ if (!sa) sa = closest_bigger_area();
+
+ areawinset(sa->win);
+ }
+
script->id.us = 1;
script->flags = SCRIPT_RUNNING;
script->py_draw = NULL;
diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c
index e8127931fed..6566c191291 100644
--- a/source/blender/src/header_info.c
+++ b/source/blender/src/header_info.c
@@ -673,13 +673,6 @@ static uiBlock *info_runtime_optionsmenu(void *arg_unused)
static void do_info_file_importmenu(void *arg, int event)
{
extern int BPY_menu_do_python(short menutype, int event); // BPY_interface.c
- ScrArea *sa;
-
- if(curarea->spacetype==SPACE_INFO) {
- sa= find_biggest_area_of_type(SPACE_SCRIPT);
- if (!sa) sa= closest_bigger_area();
- areawinset(sa->win);
- }
BPY_menu_do_python(PYMENU_IMPORT, event);
@@ -710,13 +703,6 @@ static uiBlock *info_file_importmenu(void *arg_unused)
static void do_info_file_exportmenu(void *arg, int event)
{
extern int BPY_menu_do_python(short menutype, int event); // BPY_interface.c
- ScrArea *sa;
-
- if(curarea->spacetype==SPACE_INFO) {
- sa= find_biggest_area_of_type(SPACE_SCRIPT);
- if (!sa) sa= closest_bigger_area();
- areawinset(sa->win);
- }
/* events >=3 are registered bpython scripts */
if (event >= 3) BPY_menu_do_python(PYMENU_EXPORT, event - 3);
diff --git a/source/blender/src/header_script.c b/source/blender/src/header_script.c
index 9b1d618ab7e..0ce38ec9846 100644
--- a/source/blender/src/header_script.c
+++ b/source/blender/src/header_script.c
@@ -202,6 +202,9 @@ void do_script_buttons(unsigned short event)
allqueue(REDRAWHEADERS, 0);
}
break;
+ case B_SCRIPT2BUTS:
+ newspace(curarea, SPACE_BUTS);
+ break;
}
return;
@@ -267,6 +270,12 @@ void script_buttons(void)
xco += 2*XIC;
xco= std_libbuttons(block, xco, 0, 0, NULL, B_SCRIPTBROWSE, (ID*)sc->script, 0, &(sc->menunr), 0, 0, 0, 0, 0);
+ if (sc->script && sc->script->lastspace == SPACE_BUTS) {
+ xco += 10;
+ uiDefIconBut(block, BUT, B_SCRIPT2BUTS, ICON_BUTS, xco+=XIC, 0, XIC, YIC,
+ 0, 0, 0, 0, 0, "Returns to Buttons Window");
+ }
+
/* always as last */
curarea->headbutlen= xco+2*XIC;