RNA
[blender.git] / source / blender / windowmanager / intern / wm_operators.c
index 098443d481ad05cbfce9c00036f26cf0c867e534..46e9df10adcf2f790af7db5a458b528be588e773 100644 (file)
 
 #include "DNA_ID.h"
 #include "DNA_screen_types.h"
+#include "DNA_scene_types.h"
 #include "DNA_userdef_types.h"
 #include "DNA_windowmanager_types.h"
 
 #include "MEM_guardedalloc.h"
 
+#include "PIL_time.h"
+
 #include "BLI_blenlib.h"
 #include "BLI_dynstr.h" /*for WM_operator_pystring */
 
 #include "BKE_library.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
+#include "BKE_scene.h"
 #include "BKE_utildefines.h"
 
 #include "BIF_gl.h"
 #include "BIF_glutil.h" /* for paint cursor */
+
 #include "IMB_imbuf_types.h"
 
-#include "ED_fileselect.h"
 #include "ED_screen.h"
+#include "ED_util.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
 #include "WM_types.h"
 
 #include "wm.h"
-#include "wm_window.h"
-#include "wm_subwindow.h"
+#include "wm_draw.h"
 #include "wm_event_system.h"
+#include "wm_subwindow.h"
+#include "wm_window.h"
 
 
 
@@ -101,7 +107,7 @@ void WM_operatortype_append(void (*opfunc)(wmOperatorType*))
        ot= MEM_callocN(sizeof(wmOperatorType), "operatortype");
        ot->srna= RNA_def_struct(&BLENDER_RNA, "", "OperatorProperties");
        opfunc(ot);
-       RNA_def_struct_ui_text(ot->srna, ot->name, "DOC_BROKEN"); /* TODO - add a discription to wmOperatorType? */
+       RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description:""); // XXX All ops should have a description but for now allow them not to.
        RNA_def_struct_identifier(ot->srna, ot->idname);
        BLI_addtail(&global_ops, ot);
 }
@@ -148,12 +154,12 @@ char *WM_operator_pystring(wmOperator *op)
 
        BLI_dynstr_appendf(dynstr, "%s(", op->idname);
 
-       iterprop= RNA_struct_iterator_property(op->ptr);
+       iterprop= RNA_struct_iterator_property(op->ptr->type);
        RNA_property_collection_begin(op->ptr, iterprop, &iter);
 
        for(; iter.valid; RNA_property_collection_next(&iter)) {
                prop= iter.ptr.data;
-               arg_name= RNA_property_identifier(&iter.ptr, prop);
+               arg_name= RNA_property_identifier(prop);
 
                if (strcmp(arg_name, "rna_type")==0) continue;
 
@@ -201,45 +207,37 @@ void WM_operator_properties_free(PointerRNA *ptr)
 int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        PropertyRNA *prop= RNA_struct_find_property(op->ptr, "type");
-       const EnumPropertyItem *item;
-       int totitem, i, len= strlen(op->type->name) + 8;
-       char *menu, *p;
+       uiPopupMenu *pup;
+       uiLayout *layout;
 
        if(prop==NULL) {
                printf("WM_menu_invoke: %s has no \"type\" enum property\n", op->type->idname);
        }
-       else if (RNA_property_type(op->ptr, prop) != PROP_ENUM) {
+       else if (RNA_property_type(prop) != PROP_ENUM) {
                printf("WM_menu_invoke: %s \"type\" is not an enum property\n", op->type->idname);
        }
        else {
-               RNA_property_enum_items(op->ptr, prop, &item, &totitem);
-               
-               for (i=0; i<totitem; i++)
-                       len+= strlen(item[i].name) + 8;
-               
-               menu= MEM_callocN(len, "string");
-               
-               p= menu + sprintf(menu, "%s %%t", op->type->name);
-               for (i=0; i<totitem; i++)
-                       p+= sprintf(p, "|%s %%x%d", item[i].name, item[i].value);
-               
-               uiPupMenuOperator(C, totitem/30, op, "type", menu);
-               MEM_freeN(menu);
-               
-               return OPERATOR_RUNNING_MODAL;
+               pup= uiPupMenuBegin(C, op->type->name, 0);
+               layout= uiPupMenuLayout(pup);
+               uiItemsEnumO(layout, op->type->idname, "type");
+               uiPupMenuEnd(C, pup);
        }
+
        return OPERATOR_CANCELLED;
 }
 
 /* op->invoke */
 int WM_operator_confirm(bContext *C, wmOperator *op, wmEvent *event)
 {
-       char buf[512];
-       
-       sprintf(buf, "OK? %%i%d%%t|%s", ICON_HELP, op->type->name);
-       uiPupMenuOperator(C, 0, op, NULL, buf);
+       uiPopupMenu *pup;
+       uiLayout *layout;
+
+       pup= uiPupMenuBegin(C, "OK?", ICON_QUESTION);
+       layout= uiPupMenuLayout(pup);
+       uiItemO(layout, NULL, 0, op->type->idname);
+       uiPupMenuEnd(C, pup);
        
-       return OPERATOR_RUNNING_MODAL;
+       return OPERATOR_CANCELLED;
 }
 
 /* op->invoke, opens fileselect if filename property not set, otherwise executes */
@@ -247,17 +245,9 @@ int WM_operator_filesel(bContext *C, wmOperator *op, wmEvent *event)
 {
        if (RNA_property_is_set(op->ptr, "filename")) {
                return WM_operator_call(C, op);
-       } else {
-               SpaceFile *sfile;
-
-               ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_FILE);
-               
-               /* settings for filebrowser */
-               sfile= (SpaceFile*)CTX_wm_space_data(C);
-               sfile->op = op;
-               ED_fileselect_set_params(sfile, FILE_BLENDER, op->type->name, "", 0, 0, 0);
-
-               /* screen and area have been reset already in ED_screen_full_newspace */
+       } 
+       else {
+               WM_event_add_fileselect(C, op);
                return OPERATOR_RUNNING_MODAL;
        }
 }
@@ -269,6 +259,211 @@ int WM_operator_winactive(bContext *C)
        return 1;
 }
 
+/* op->invoke */
+static void redo_cb(bContext *C, void *arg_op, void *arg2)
+{
+       wmOperator *lastop= arg_op;
+       
+       if(lastop) {
+               ED_undo_pop(C);
+               WM_operator_repeat(C, lastop);
+       }
+}
+
+static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
+{
+       wmWindowManager *wm= CTX_wm_manager(C);
+       wmOperator *op= arg_op;
+       PointerRNA ptr;
+       uiBlock *block;
+       uiLayout *layout;
+       uiStyle *style= U.uistyles.first;
+       
+       block= uiBeginBlock(C, ar, "redo_popup", UI_EMBOSS);
+       uiBlockClearFlag(block, UI_BLOCK_LOOP);
+       uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1);
+       uiBlockSetFunc(block, redo_cb, arg_op, NULL);
+
+       if(!op->properties) {
+               IDPropertyTemplate val = {0};
+               op->properties= IDP_New(IDP_GROUP, val, "wmOperatorProperties");
+       }
+
+       RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
+       layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 300, 20, style);
+       uiDefAutoButsRNA(C, layout, &ptr);
+
+       uiPopupBoundsBlock(block, 4.0f, 0, 0);
+       uiEndBlock(C, block);
+
+       return block;
+}
+
+int WM_operator_redo(bContext *C, wmOperator *op, wmEvent *event)
+{
+       int retval= OPERATOR_CANCELLED;
+       
+       if(op->type->exec)
+               retval= op->type->exec(C, op);
+
+       if(retval != OPERATOR_CANCELLED)
+               uiPupBlock(C, wm_block_create_redo, op);
+
+       return retval;
+}
+
+int WM_operator_redo_popup(bContext *C, wmOperator *op)
+{
+       uiPupBlock(C, wm_block_create_redo, op);
+
+       return OPERATOR_CANCELLED;
+}
+
+/* ***************** Debug menu ************************* */
+
+static uiBlock *wm_block_create_menu(bContext *C, ARegion *ar, void *arg_op)
+{
+       wmOperator *op= arg_op;
+       uiBlock *block;
+       uiLayout *layout;
+       uiStyle *style= U.uistyles.first;
+       
+       block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
+       uiBlockClearFlag(block, UI_BLOCK_LOOP);
+       uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1);
+       
+       layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 300, 20, style);
+       uiDefAutoButsRNA(C, layout, op->ptr);
+       
+       uiPopupBoundsBlock(block, 4.0f, 0, 0);
+       uiEndBlock(C, block);
+       
+       return block;
+}
+
+static int wm_debug_menu_exec(bContext *C, wmOperator *op)
+{
+       G.rt= RNA_int_get(op->ptr, "debugval");
+       ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C));
+       WM_event_add_notifier(C, NC_WINDOW, NULL);
+       
+       return OPERATOR_FINISHED;       
+}
+
+static int wm_debug_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       
+       RNA_int_set(op->ptr, "debugval", G.rt);
+       
+       /* pass on operator, so return modal */
+       uiPupBlockOperator(C, wm_block_create_menu, op, WM_OP_EXEC_DEFAULT);
+       
+       return OPERATOR_RUNNING_MODAL;
+}
+
+static void WM_OT_debug_menu(wmOperatorType *ot)
+{
+       ot->name= "Debug Menu";
+       ot->idname= "WM_OT_debug_menu";
+       
+       ot->invoke= wm_debug_menu_invoke;
+       ot->exec= wm_debug_menu_exec;
+       ot->poll= WM_operator_winactive;
+       
+       RNA_def_int(ot->srna, "debugval", 0, -10000, 10000, "Debug Value", "", INT_MIN, INT_MAX);
+}
+
+/* ***************** Search menu ************************* */
+static void operator_call_cb(struct bContext *C, void *arg1, void *arg2)
+{
+       wmOperatorType *ot= arg2;
+       
+       if(ot)
+               WM_operator_name_call(C, ot->idname, WM_OP_INVOKE_DEFAULT, NULL);
+}
+
+static void operator_search_cb(const struct bContext *C, void *arg, char *str, uiSearchItems *items)
+{
+       wmOperatorType *ot = WM_operatortype_first();
+       
+       for(; ot; ot= ot->next) {
+               
+               if(BLI_strcasestr(ot->name, str)) {
+                       if(ot->poll==NULL || ot->poll((bContext *)C)) {
+                               char name[256];
+                               int len= strlen(ot->name);
+                               
+                               /* display name for menu, can hold hotkey */
+                               BLI_strncpy(name, ot->name, 256);
+                               
+                               /* check for hotkey */
+                               if(len < 256-6) {
+                                       if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, &name[len+1], 256-len-1))
+                                               name[len]= '|';
+                               }
+                               
+                               if(0==uiSearchItemAdd(items, name, ot))
+                                       break;
+                       }
+               }
+       }
+}
+
+static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *arg_op)
+{
+       static char search[256]= "";
+       wmEvent event;
+       wmWindow *win= CTX_wm_window(C);
+       uiBlock *block;
+       uiBut *but;
+       
+       block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
+       uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_RET_1);
+       
+       but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 10, 180, 19, "");
+       uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb);
+       
+       /* fake button, it holds space for search items */
+       uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxhHeight(), 180, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
+       
+       uiPopupBoundsBlock(block, 6.0f, 0, -20); /* move it downwards, mouse over button */
+       uiEndBlock(C, block);
+       
+       event= *(win->eventstate);      /* XXX huh huh? make api call */
+       event.type= EVT_BUT_OPEN;
+       event.val= KM_PRESS;
+       event.customdata= but;
+       event.customdatafree= FALSE;
+       wm_event_add(win, &event);
+       
+       return block;
+}
+
+static int wm_search_menu_exec(bContext *C, wmOperator *op)
+{
+       
+       return OPERATOR_FINISHED;       
+}
+
+static int wm_search_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       
+       uiPupBlock(C, wm_block_search_menu, op);
+       
+       return OPERATOR_CANCELLED;
+}
+
+static void WM_OT_search_menu(wmOperatorType *ot)
+{
+       ot->name= "Search Menu";
+       ot->idname= "WM_OT_search_menu";
+       
+       ot->invoke= wm_search_menu_invoke;
+       ot->exec= wm_search_menu_exec;
+       ot->poll= WM_operator_winactive;
+}
+
+
 /* ************ window / screen operator definitions ************** */
 
 static void WM_OT_window_duplicate(wmOperatorType *ot)
@@ -291,28 +486,21 @@ static void WM_OT_save_homefile(wmOperatorType *ot)
        ot->poll= WM_operator_winactive;
 }
 
-/* ********* recent file *********** */
-
-static void recent_filelist(char *pup)
+static void WM_OT_read_homefile(wmOperatorType *ot)
 {
-       struct RecentFile *recent;
-       int i, ofs= 0;
-       char *p;
-       
-       p= pup + sprintf(pup, "Open Recent%%t");
+       ot->name= "Reload Start-Up File";
+       ot->idname= "WM_OT_read_homefile";
        
-       if (G.sce[0]) {
-               p+= sprintf(p, "|%s %%x%d", G.sce, 1);
-               ofs = 1;
-       }
+       ot->invoke= WM_operator_confirm;
+       ot->exec= WM_read_homefile;
+       ot->poll= WM_operator_winactive;
        
-       for (recent = G.recent_files.first, i=0; (i<U.recent_files) && (recent); recent = recent->next, i++) {
-               if (strcmp(recent->filename, G.sce)) {
-                       p+= sprintf(p, "|%s %%x%d", recent->filename, i+ofs+1);
-               }
-       }
+       RNA_def_boolean(ot->srna, "factory", 0, "Factory Settings", "");
 }
 
+
+/* ********* recent file *********** */
+
 static int recentfile_exec(bContext *C, wmOperator *op)
 {
        int event= RNA_enum_get(op->ptr, "nr");
@@ -338,12 +526,26 @@ static int recentfile_exec(bContext *C, wmOperator *op)
 
 static int wm_recentfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       char pup[2048];
+       struct RecentFile *recent;
+       uiPopupMenu *pup;
+       uiLayout *layout;
+       int i, ofs= 0;
+
+       pup= uiPupMenuBegin(C, "Open Recent", 0);
+       layout= uiPupMenuLayout(pup);
+
+       if(G.sce[0]) {
+               uiItemIntO(layout, G.sce, 0, op->type->idname, "nr", 1);
+               ofs = 1;
+       }
        
-       recent_filelist(pup);
-       uiPupMenuOperator(C, 0, op, "nr", pup);
+       for(recent = G.recent_files.first, i=0; (i<U.recent_files) && (recent); recent = recent->next, i++)
+               if(strcmp(recent->filename, G.sce))
+                       uiItemIntO(layout, recent->filename, 0, op->type->idname, "nr", i+ofs+1);
+
+       uiPupMenuEnd(C, pup);
        
-       return OPERATOR_RUNNING_MODAL;
+       return OPERATOR_CANCELLED;
 }
 
 static void WM_OT_open_recentfile(wmOperatorType *ot)
@@ -360,24 +562,29 @@ static void WM_OT_open_recentfile(wmOperatorType *ot)
 
 /* ********* main file *********** */
 
-static int wm_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static void untitled(char *name)
 {
-       SpaceFile *sfile;
-       
-       ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_FILE);
+       if (G.save_over == 0 && strlen(name) < FILE_MAX-16) {
+               char *c= BLI_last_slash(name);
+               
+               if (c)
+                       strcpy(&c[1], "untitled.blend");
+               else
+                       strcpy(name, "untitled.blend");
+       }
+}
+
 
-       /* settings for filebrowser */
-       sfile= (SpaceFile*)CTX_wm_space_data(C);
-       sfile->op = op;
-       // XXX replace G.sce
-       ED_fileselect_set_params(sfile, FILE_BLENDER, "Load", G.sce, 0, 0, 0);
+static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
 
-       /* screen and area have been reset already in ED_screen_full_newspace */
+       RNA_string_set(op->ptr, "filename", G.sce);
+       WM_event_add_fileselect(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
 
-static int wm_mainfile_exec(bContext *C, wmOperator *op)
+static int wm_open_mainfile_exec(bContext *C, wmOperator *op)
 {
        char filename[FILE_MAX];
        RNA_string_get(op->ptr, "filename", filename);
@@ -396,8 +603,8 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
        ot->name= "Open Blender File";
        ot->idname= "WM_OT_open_mainfile";
        
-       ot->invoke= wm_mainfile_invoke;
-       ot->exec= wm_mainfile_exec;
+       ot->invoke= wm_open_mainfile_invoke;
+       ot->exec= wm_open_mainfile_exec;
        ot->poll= WM_operator_winactive;
        
        ot->flag= 0;
@@ -408,36 +615,38 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
 
 static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       SpaceFile *sfile;
+       char name[FILE_MAX];
        
-       ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_FILE);
-
-       /* settings for filebrowser */
-       sfile= (SpaceFile*)CTX_wm_space_data(C);
-       sfile->op = op;
-       // XXX replace G.sce
-       ED_fileselect_set_params(sfile, FILE_BLENDER, "Save As", G.sce, 0, 0, 0);
-
-       /* screen and area have been reset already in ED_screen_full_newspace */
+       BLI_strncpy(name, G.sce, FILE_MAX);
+       untitled(name);
+       RNA_string_set(op->ptr, "filename", name);
+       
+       WM_event_add_fileselect(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
 
+/* function used for WM_OT_save_mainfile too */
 static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
 {
        char filename[FILE_MAX];
-       RNA_string_get(op->ptr, "filename", filename);
        
+       if(RNA_property_is_set(op->ptr, "filename"))
+               RNA_string_get(op->ptr, "filename", filename);
+       else {
+               BLI_strncpy(filename, G.sce, FILE_MAX);
+               untitled(filename);
+       }
        WM_write_file(C, filename, op->reports);
        
-       WM_event_add_notifier(C, NC_WINDOW, NULL);
+       WM_event_add_notifier(C, NC_WM|ND_FILESAVE, NULL);
 
        return 0;
 }
 
 static void WM_OT_save_as_mainfile(wmOperatorType *ot)
 {
-       ot->name= "Open Blender File";
+       ot->name= "Save As Blender File";
        ot->idname= "WM_OT_save_as_mainfile";
        
        ot->invoke= wm_save_as_mainfile_invoke;
@@ -450,6 +659,36 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
 
 }
 
+/* *************** Save file directly ******** */
+
+static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       char name[FILE_MAX];
+       
+       BLI_strncpy(name, G.sce, FILE_MAX);
+       untitled(name);
+       RNA_string_set(op->ptr, "filename", name);
+       uiPupMenuSaveOver(C, op, name);
+
+       return OPERATOR_RUNNING_MODAL;
+}
+
+static void WM_OT_save_mainfile(wmOperatorType *ot)
+{
+       ot->name= "Save Blender File";
+       ot->idname= "WM_OT_save_mainfile";
+       
+       ot->invoke= wm_save_mainfile_invoke;
+       ot->exec= wm_save_as_mainfile_exec;
+       ot->poll= WM_operator_winactive;
+       
+       ot->flag= 0;
+       
+       RNA_def_property(ot->srna, "filename", PROP_STRING, PROP_FILEPATH);
+       
+}
+
+
 /* *********************** */
 
 static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot)
@@ -564,6 +803,8 @@ static void wm_gesture_end(bContext *C, wmOperator *op)
 
        ED_area_tag_redraw(CTX_wm_area(C));
        
+       if( RNA_struct_find_property(op->ptr, "cursor") )
+               WM_cursor_restore(CTX_wm_window(C));
 }
 
 int WM_border_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
@@ -771,11 +1012,8 @@ static void tweak_gesture_modal(bContext *C, wmEvent *event)
                                WM_gesture_end(C, gesture);
                                window->tweak= NULL;
                                
-                               /* when tweak fails we should give the other keymap entries a chance
-                                * those then won't react to km_press, but km_release
-                                * it sets hidden event value where tweak maps fail on, to prevent loops */
-                               //event->val= 1;
-                               //event->no_tweak= 1;
+                               /* when tweak fails we should give the other keymap entries a chance */
+                               event->val= KM_RELEASE;
                        }
                        break;
                default:
@@ -818,6 +1056,24 @@ int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, wmEvent *event)
        
        wm_gesture_tag_redraw(C);
        
+       if( RNA_struct_find_property(op->ptr, "cursor") )
+               WM_cursor_modal(CTX_wm_window(C), RNA_int_get(op->ptr, "cursor"));
+       
+       return OPERATOR_RUNNING_MODAL;
+}
+
+int WM_gesture_lines_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       op->customdata= WM_gesture_new(C, event, WM_GESTURE_LINES);
+       
+       /* add modal handler */
+       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       
+       wm_gesture_tag_redraw(C);
+       
+       if( RNA_struct_find_property(op->ptr, "cursor") )
+               WM_cursor_modal(CTX_wm_window(C), RNA_int_get(op->ptr, "cursor"));
+       
        return OPERATOR_RUNNING_MODAL;
 }
 
@@ -885,6 +1141,11 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event)
        return OPERATOR_RUNNING_MODAL;
 }
 
+int WM_gesture_lines_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+       return WM_gesture_lasso_modal(C, op, event);
+}
+
 #if 0
 /* template to copy from */
 
@@ -935,7 +1196,7 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata)
 {
        wmRadialControl *rc = (wmRadialControl*)customdata;
        ARegion *ar = CTX_wm_region(C);
-       float r1, r2, r3, angle;
+       float r1=0.0f, r2=0.0f, r3=0.0f, angle=0.0f;
 
        /* Keep cursor in the original place */
        x = rc->initial_mouse[0] - ar->winrct.xmin;
@@ -1138,10 +1399,10 @@ void WM_radial_control_string(wmOperator *op, char str[], int maxlen)
 void WM_OT_radial_control_partial(wmOperatorType *ot)
 {
        static EnumPropertyItem prop_mode_items[] = {
-               {WM_RADIALCONTROL_SIZE, "SIZE", "Size", ""},
-               {WM_RADIALCONTROL_STRENGTH, "STRENGTH", "Strength", ""},
-               {WM_RADIALCONTROL_ANGLE, "ANGLE", "Angle", ""},
-               {0, NULL, NULL, NULL}};
+               {WM_RADIALCONTROL_SIZE, "SIZE", 0, "Size", ""},
+               {WM_RADIALCONTROL_STRENGTH, "STRENGTH", 0, "Strength", ""},
+               {WM_RADIALCONTROL_ANGLE, "ANGLE", 0, "Angle", ""},
+               {0, NULL, 0, NULL, NULL}};
 
        /* Should be set in custom invoke() */
        RNA_def_float(ot->srna, "initial_value", 0, 0, FLT_MAX, "Initial Value", "", 0, FLT_MAX);
@@ -1156,6 +1417,93 @@ void WM_OT_radial_control_partial(wmOperatorType *ot)
        RNA_def_int_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX);
 }
 
+/* ************************** timer for testing ***************** */
+
+/* uses no type defines, fully local testing function anyway... ;) */
+
+static int ten_timer_exec(bContext *C, wmOperator *op)
+{
+       ARegion *ar= CTX_wm_region(C);
+       double stime= PIL_check_seconds_timer();
+       int type = RNA_int_get(op->ptr, "type");
+       int a, time;
+       char tmpstr[128];
+       
+       WM_cursor_wait(1);
+       
+       for(a=0; a<10; a++) {
+               if (type==0) {
+                       ED_region_do_draw(C, ar);
+               } 
+               else if (type==1) {
+                       wmWindow *win= CTX_wm_window(C);
+                       
+                       ED_region_tag_redraw(ar);
+                       wm_draw_update(C);
+                       
+                       CTX_wm_window_set(C, win);      /* XXX context manipulation warning! */
+               }
+               else if (type==2) {
+                       wmWindow *win= CTX_wm_window(C);
+                       ScrArea *sa;
+                       
+                       for(sa= CTX_wm_screen(C)->areabase.first; sa; sa= sa->next)
+                               ED_area_tag_redraw(sa);
+                       wm_draw_update(C);
+                       
+                       CTX_wm_window_set(C, win);      /* XXX context manipulation warning! */
+               }
+               else if (type==3) {
+                       Scene *scene= CTX_data_scene(C);
+                       
+                       if(a & 1) scene->r.cfra--;
+                       else scene->r.cfra++;
+                       scene_update_for_newframe(scene, scene->lay);
+               }
+               else {
+                       ED_undo_pop(C);
+                       ED_undo_redo(C);
+               }
+       }
+       
+       time= (int) ((PIL_check_seconds_timer()-stime)*1000);
+       
+       if(type==0) sprintf(tmpstr, "10 x Draw Region: %d ms", time);
+       if(type==1) sprintf(tmpstr, "10 x Draw Region and Swap: %d ms", time);
+       if(type==2) sprintf(tmpstr, "10 x Draw Window and Swap: %d ms", time);
+       if(type==3) sprintf(tmpstr, "Anim Step: %d ms", time);
+       if(type==4) sprintf(tmpstr, "10 x Undo/Redo: %d ms", time);
+       
+       WM_cursor_wait(0);
+       
+       uiPupMenuNotice(C, tmpstr);
+       
+       return OPERATOR_FINISHED;
+}
+
+static void WM_OT_ten_timer(wmOperatorType *ot)
+{
+       static EnumPropertyItem prop_type_items[] = {
+       {0, "DRAW", 0, "Draw Region", ""},
+       {1, "DRAWSWAP", 0, "Draw Region + Swap", ""},
+       {2, "DRAWWINSWAP", 0, "Draw Window + Swap", ""},
+       {3, "ANIMSTEP", 0, "Anim Step", ""},
+       {4, "UNDO", 0, "Undo/Redo", ""},
+       {0, NULL, 0, NULL, NULL}};
+       
+       ot->name= "Ten Timer";
+       ot->idname= "WM_OT_ten_timer";
+       
+       ot->invoke= WM_menu_invoke;
+       ot->exec= ten_timer_exec;
+       ot->poll= WM_operator_winactive;
+       
+       RNA_def_enum(ot->srna, "type", prop_type_items, 0, "Type", "");
+
+}
+
+
+
 /* ******************************************************* */
  
 /* called on initialize WM_exit() */
@@ -1168,6 +1516,7 @@ void wm_operatortype_free(void)
 void wm_operatortype_init(void)
 {
        WM_operatortype_append(WM_OT_window_duplicate);
+       WM_operatortype_append(WM_OT_read_homefile);
        WM_operatortype_append(WM_OT_save_homefile);
        WM_operatortype_append(WM_OT_window_fullscreen_toggle);
        WM_operatortype_append(WM_OT_exit_blender);
@@ -1175,6 +1524,10 @@ void wm_operatortype_init(void)
        WM_operatortype_append(WM_OT_open_mainfile);
        WM_operatortype_append(WM_OT_jobs_timer);
        WM_operatortype_append(WM_OT_save_as_mainfile);
+       WM_operatortype_append(WM_OT_save_mainfile);
+       WM_operatortype_append(WM_OT_ten_timer);
+       WM_operatortype_append(WM_OT_debug_menu);
+       WM_operatortype_append(WM_OT_search_menu);
 }
 
 /* default keymap for windows and screens, only call once per WM */
@@ -1186,13 +1539,20 @@ void wm_window_keymap(wmWindowManager *wm)
        WM_keymap_verify_item(keymap, "WM_OT_jobs_timer", TIMERJOBS, KM_ANY, KM_ANY, 0);
        
        /* note, this doesn't replace existing keymap items */
-       WM_keymap_verify_item(keymap, "WM_OT_window_duplicate", AKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
+       WM_keymap_verify_item(keymap, "WM_OT_window_duplicate", WKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
+       WM_keymap_verify_item(keymap, "WM_OT_read_homefile", XKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_verify_item(keymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_verify_item(keymap, "WM_OT_open_recentfile", OKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_verify_item(keymap, "WM_OT_open_mainfile", F1KEY, KM_PRESS, 0, 0);
+       WM_keymap_verify_item(keymap, "WM_OT_save_mainfile", WKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_verify_item(keymap, "WM_OT_save_as_mainfile", F2KEY, KM_PRESS, 0, 0);
        WM_keymap_verify_item(keymap, "WM_OT_window_fullscreen_toggle", F11KEY, KM_PRESS, 0, 0);
        WM_keymap_verify_item(keymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_CTRL, 0);
 
+       /* debug/testing */
+       WM_keymap_verify_item(keymap, "WM_OT_ten_timer", TKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
+       WM_keymap_verify_item(keymap, "WM_OT_debug_menu", DKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
+       WM_keymap_verify_item(keymap, "WM_OT_search_menu", FKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
+       
 }