Support for the C Macro system in Python.
[blender.git] / source / blender / makesrna / intern / rna_wm.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * Contributor(s): Blender Foundation (2008).
21  *
22  * ***** END GPL LICENSE BLOCK *****
23  */
24
25 #include <stdlib.h>
26
27 #include "RNA_access.h"
28 #include "RNA_define.h"
29 #include "RNA_enum_types.h"
30 #include "RNA_types.h"
31
32 #include "rna_internal.h"
33
34 #include "DNA_screen_types.h"
35 #include "DNA_space_types.h"
36 #include "DNA_userdef_types.h"
37 #include "DNA_windowmanager_types.h"
38
39 #include "WM_types.h"
40
41 EnumPropertyItem event_keymouse_value_items[] = {
42         {KM_ANY, "ANY", 0, "Any", ""},
43         {KM_PRESS, "PRESS", 0, "Press", ""},
44         {KM_RELEASE, "RELEASE", 0, "Release", ""},
45         {KM_CLICK, "CLICK", 0, "Click", ""},
46         {0, NULL, 0, NULL, NULL}};
47
48 EnumPropertyItem event_tweak_value_items[]= {
49         {KM_ANY, "ANY", 0, "Any", ""},
50         {EVT_GESTURE_N, "NORTH", 0, "North", ""},
51         {EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""},
52         {EVT_GESTURE_E, "EAST", 0, "East", ""},
53         {EVT_GESTURE_SE, "SOUTH_EAST", 0, "South-East", ""},
54         {EVT_GESTURE_S, "SOUTH", 0, "South", ""},
55         {EVT_GESTURE_SW, "SOUTH_WEST", 0, "South-West", ""},
56         {EVT_GESTURE_W, "WEST", 0, "West", ""},
57         {EVT_GESTURE_NW, "NORTH_WEST", 0, "North-West", ""},
58         {0, NULL, 0, NULL, NULL}};
59
60 EnumPropertyItem event_value_items[] = {
61         {KM_ANY, "ANY", 0, "Any", ""},
62         {KM_NOTHING, "NOTHING", 0, "Nothing", ""},
63         {KM_PRESS, "PRESS", 0, "Press", ""},
64         {KM_RELEASE, "RELEASE", 0, "Release", ""},
65         {KM_CLICK, "CLICK", 0, "Click", ""},
66         {0, NULL, 0, NULL, NULL}};
67
68 EnumPropertyItem event_tweak_type_items[]= {
69         {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Left", ""},
70         {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Middle", ""},
71         {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Right", ""},
72         {EVT_TWEAK_A, "EVT_TWEAK_A", 0, "Action", ""},
73         {EVT_TWEAK_S, "EVT_TWEAK_S", 0, "Select", ""},
74         {0, NULL, 0, NULL, NULL}};
75
76 EnumPropertyItem event_mouse_type_items[]= {
77         {LEFTMOUSE, "LEFTMOUSE", 0, "Left", ""},
78         {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle", ""},
79         {RIGHTMOUSE, "RIGHTMOUSE", 0, "Right", ""},
80         {BUTTON4MOUSE, "BUTTON4MOUSE", 0, "Button4", ""},
81         {BUTTON5MOUSE, "BUTTON5MOUSE", 0, "Button5", ""},
82         {ACTIONMOUSE, "ACTIONMOUSE", 0, "Action", ""},
83         {SELECTMOUSE, "SELECTMOUSE", 0, "Select", ""},
84         {0, "", 0, NULL, NULL},
85         {MOUSEMOVE, "MOUSEMOVE", 0, "Move", ""},
86         {0, "", 0, NULL, NULL},
87         {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""},
88         {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""},
89         {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", ""},
90         {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", ""},
91         {0, NULL, 0, NULL, NULL}};
92
93 EnumPropertyItem event_timer_type_items[]= {
94         {TIMER, "TIMER", 0, "Timer", ""},
95         {TIMER0, "TIMER0", 0, "Timer 0", ""},
96         {TIMER1, "TIMER1", 0, "Timer 1", ""},
97         {TIMER2, "TIMER2", 0, "Timer 2", ""},
98         {0, NULL, 0, NULL, NULL}};
99
100 /* not returned: CAPSLOCKKEY, UNKNOWNKEY, GRLESSKEY */
101 EnumPropertyItem event_type_items[] = {
102
103         {0, "NONE", 0, "", ""},
104         {LEFTMOUSE, "LEFTMOUSE", 0, "Left Mouse", ""},
105         {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle Mouse", ""},
106         {RIGHTMOUSE, "RIGHTMOUSE", 0, "Right Mouse", ""},
107         {BUTTON4MOUSE, "BUTTON4MOUSE", 0, "Button4 Mouse", ""},
108         {BUTTON5MOUSE, "BUTTON5MOUSE", 0, "Button5 Mouse", ""},
109         {ACTIONMOUSE, "ACTIONMOUSE", 0, "Action Mouse", ""},
110         {SELECTMOUSE, "SELECTMOUSE", 0, "Select Mouse", ""},
111         {0, "", 0, NULL, NULL},
112         {MOUSEMOVE, "MOUSEMOVE", 0, "Mouse Move", ""},
113         {0, "", 0, NULL, NULL},
114         {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""},
115         {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""},
116         {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", ""},
117         {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", ""},
118         {0, "", 0, NULL, NULL},
119         {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Tweak Left", ""},
120         {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Tweak Middle", ""},
121         {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Tweak Right", ""},
122         {EVT_TWEAK_A, "EVT_TWEAK_A", 0, "Tweak Action", ""},
123         {EVT_TWEAK_S, "EVT_TWEAK_S", 0, "Tweak Select", ""},
124         {0, "", 0, NULL, NULL},
125         {AKEY, "A", 0, "A", ""},
126         {BKEY, "B", 0, "B", ""},
127         {CKEY, "C", 0, "C", ""},
128         {DKEY, "D", 0, "D", ""},
129         {EKEY, "E", 0, "E", ""},
130         {FKEY, "F", 0, "F", ""},
131         {GKEY, "G", 0, "G", ""},
132         {HKEY, "H", 0, "H", ""},
133         {IKEY, "I", 0, "I", ""},
134         {JKEY, "J", 0, "J", ""},
135         {KKEY, "K", 0, "K", ""},
136         {LKEY, "L", 0, "L", ""},
137         {MKEY, "M", 0, "M", ""},
138         {NKEY, "N", 0, "N", ""},
139         {OKEY, "O", 0, "O", ""},
140         {PKEY, "P", 0, "P", ""},
141         {QKEY, "Q", 0, "Q", ""},
142         {RKEY, "R", 0, "R", ""},
143         {SKEY, "S", 0, "S", ""},
144         {TKEY, "T", 0, "T", ""},
145         {UKEY, "U", 0, "U", ""},
146         {VKEY, "V", 0, "V", ""},
147         {WKEY, "W", 0, "W", ""},
148         {XKEY, "X", 0, "X", ""},
149         {YKEY, "Y", 0, "Y", ""},
150         {ZKEY, "Z", 0, "Z", ""},
151         {0, "", 0, NULL, NULL},
152         {ZEROKEY, "ZERO",       0, "0", ""},
153         {ONEKEY, "ONE",         0, "1", ""},
154         {TWOKEY, "TWO",         0, "2", ""},
155         {THREEKEY, "THREE",     0, "3", ""},
156         {FOURKEY, "FOUR",       0, "4", ""},
157         {FIVEKEY, "FIVE",       0, "5", ""},
158         {SIXKEY, "SIX",         0, "6", ""},
159         {SEVENKEY, "SEVEN",     0, "7", ""},
160         {EIGHTKEY, "EIGHT",     0, "8", ""},
161         {NINEKEY, "NINE",       0, "9", ""},
162         {0, "", 0, NULL, NULL},
163         {LEFTCTRLKEY,   "LEFT_CTRL",    0, "Left Ctrl", ""},
164         {LEFTALTKEY,    "LEFT_ALT",             0, "Left Alt", ""},
165         {LEFTSHIFTKEY,  "LEFT_SHIFT",   0, "Left Shift", ""},
166         {RIGHTALTKEY,   "RIGHT_ALT",    0, "Right Alt", ""},
167         {RIGHTCTRLKEY,  "RIGHT_CTRL",   0, "Right Ctrl", ""},
168         {RIGHTSHIFTKEY, "RIGHT_SHIFT",  0, "Right Shift", ""},
169         {0, "", 0, NULL, NULL},
170         {COMMANDKEY,    "COMMAND",      0, "Command", ""},
171         {0, "", 0, NULL, NULL},
172         {ESCKEY, "ESC", 0, "Esc", ""},
173         {TABKEY, "TAB", 0, "Tab", ""},
174         {RETKEY, "RET", 0, "Return", ""},
175         {SPACEKEY, "SPACE", 0, "Spacebar", ""},
176         {LINEFEEDKEY, "LINE_FEED", 0, "Line Feed", ""},
177         {BACKSPACEKEY, "BACK_SPACE", 0, "Back Space", ""},
178         {DELKEY, "DEL", 0, "Delete", ""},
179         {SEMICOLONKEY, "SEMI_COLON", 0, ";", ""},
180         {PERIODKEY, "PERIOD", 0, ".", ""},
181         {COMMAKEY, "COMMA", 0, ",", ""},
182         {QUOTEKEY, "QUOTE", 0, "\"", ""},
183         {ACCENTGRAVEKEY, "ACCENT_GRAVE", 0, "`", ""},
184         {MINUSKEY, "MINUS", 0, "-", ""},
185         {SLASHKEY, "SLASH", 0, "/", ""},
186         {BACKSLASHKEY, "BACK_SLASH", 0, "\\", ""},
187         {EQUALKEY, "EQUAL", 0, "=", ""},
188         {LEFTBRACKETKEY, "LEFT_BRACKET", 0, "[", ""},
189         {RIGHTBRACKETKEY, "RIGHT_BRACKET", 0, "]", ""},
190         {LEFTARROWKEY, "LEFT_ARROW", 0, "Left Arrow", ""},
191         {DOWNARROWKEY, "DOWN_ARROW", 0, "Down Arrow", ""},
192         {RIGHTARROWKEY, "RIGHT_ARROW", 0, "Right Arrow", ""},
193         {UPARROWKEY, "UP_ARROW", 0, "Up Arrow", ""},
194         {PAD2, "NUMPAD_2", 0, "Numpad 2", ""},
195         {PAD4, "NUMPAD_4", 0, "Numpad 4", ""},
196         {PAD6, "NUMPAD_6", 0, "Numpad 6", ""},
197         {PAD8, "NUMPAD_8", 0, "Numpad 8", ""},
198         {PAD1, "NUMPAD_1", 0, "Numpad 1", ""},
199         {PAD3, "NUMPAD_3", 0, "Numpad 3", ""},
200         {PAD5, "NUMPAD_5", 0, "Numpad 5", ""},
201         {PAD7, "NUMPAD_7", 0, "Numpad 7", ""},
202         {PAD9, "NUMPAD_9", 0, "Numpad 9", ""},
203         {PADPERIOD, "NUMPAD_PERIOD", 0, "Numpad .", ""},
204         {PADSLASHKEY, "NUMPAD_SLASH", 0, "Numpad /", ""},
205         {PADASTERKEY, "NUMPAD_ASTERIX", 0, "Numpad *", ""},
206         {PAD0, "NUMPAD_0", 0, "Numpad 0", ""},
207         {PADMINUS, "NUMPAD_MINUS", 0, "Numpad -", ""},
208         {PADENTER, "NUMPAD_ENTER", 0, "Numpad Enter", ""},
209         {PADPLUSKEY, "NUMPAD_PLUS", 0, "Numpad +", ""},
210         {F1KEY, "F1", 0, "F1", ""},
211         {F2KEY, "F2", 0, "F2", ""},
212         {F3KEY, "F3", 0, "F3", ""},
213         {F4KEY, "F4", 0, "F4", ""},
214         {F5KEY, "F5", 0, "F5", ""},
215         {F6KEY, "F6", 0, "F6", ""},
216         {F7KEY, "F7", 0, "F7", ""},
217         {F8KEY, "F8", 0, "F8", ""},
218         {F9KEY, "F9", 0, "F9", ""},
219         {F10KEY, "F10", 0, "F10", ""},
220         {F11KEY, "F11", 0, "F11", ""},
221         {F12KEY, "F12", 0, "F12", ""},
222         {PAUSEKEY, "PAUSE", 0, "Pause", ""},
223         {INSERTKEY, "INSERT", 0, "Insert", ""},
224         {HOMEKEY, "HOME", 0, "Home", ""},
225         {PAGEUPKEY, "PAGE_UP", 0, "Page Up", ""},
226         {PAGEDOWNKEY, "PAGE_DOWN", 0, "Page Down", ""},
227         {ENDKEY, "END", 0, "End", ""},
228         {0, "", 0, NULL, NULL},
229         {TIMER, "TIMER", 0, "Timer", ""},
230         {TIMER0, "TIMER0", 0, "Timer 0", ""},
231         {TIMER1, "TIMER1", 0, "Timer 1", ""},
232         {TIMER2, "TIMER2", 0, "Timer 2", ""},
233         {0, NULL, 0, NULL, NULL}};      
234
235 EnumPropertyItem keymap_propvalue_items[] = {
236                 {0, "NONE", 0, "", ""},
237                 {0, NULL, 0, NULL, NULL}};
238
239 EnumPropertyItem keymap_modifiers_items[] = {
240                 {KM_ANY, "ANY", 0, "Any", ""},
241                 {0, "NONE", 0, "None", ""},
242                 {1, "FIRST", 0, "First", ""},
243                 {2, "SECOND", 0, "Second", ""},
244                 {0, NULL, 0, NULL, NULL}};
245
246 #define KMI_TYPE_KEYBOARD       0
247 #define KMI_TYPE_MOUSE          1
248 #define KMI_TYPE_TWEAK          2
249 #define KMI_TYPE_TEXTINPUT      3
250 #define KMI_TYPE_TIMER          4
251
252 #ifdef RNA_RUNTIME
253
254 #include "WM_api.h"
255
256 #include "BKE_idprop.h"
257
258 #include "MEM_guardedalloc.h"
259
260 static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr)
261 {
262         wmWindowManager *wm= ptr->id.data;
263         IDProperty *properties= (IDProperty*)ptr->data;
264         wmOperator *op;
265
266         if(wm)
267                 for(op=wm->operators.first; op; op=op->next)
268                         if(op->properties == properties)
269                                 return op;
270         
271         return NULL;
272 }
273
274 static StructRNA *rna_OperatorProperties_refine(PointerRNA *ptr)
275 {
276         wmOperator *op= rna_OperatorProperties_find_operator(ptr);
277
278         if(op)
279                 return op->type->srna;
280         else
281                 return ptr->type;
282 }
283
284 static IDProperty *rna_OperatorProperties_idproperties(PointerRNA *ptr, int create)
285 {
286         if(create && !ptr->data) {
287                 IDPropertyTemplate val = {0};
288                 ptr->data= IDP_New(IDP_GROUP, val, "RNA_OperatorProperties group");
289         }
290
291         return ptr->data;
292 }
293
294 static void rna_Operator_name_get(PointerRNA *ptr, char *value)
295 {
296         wmOperator *op= (wmOperator*)ptr->data;
297         strcpy(value, op->type->name);
298 }
299
300 static int rna_Operator_name_length(PointerRNA *ptr)
301 {
302         wmOperator *op= (wmOperator*)ptr->data;
303         return strlen(op->type->name);
304 }
305
306 static PointerRNA rna_Operator_properties_get(PointerRNA *ptr)
307 {
308         wmOperator *op= (wmOperator*)ptr->data;
309         return rna_pointer_inherit_refine(ptr, op->type->srna, op->properties);
310 }
311
312 static PointerRNA rna_OperatorTypeMacro_properties_get(PointerRNA *ptr)
313 {
314         wmOperatorTypeMacro *otmacro= (wmOperatorTypeMacro*)ptr->data;
315         wmOperatorType *ot = WM_operatortype_exists(otmacro->idname);
316         return rna_pointer_inherit_refine(ptr, ot->srna, otmacro->properties);
317 }
318
319 static void rna_Event_ascii_get(PointerRNA *ptr, char *value)
320 {
321         wmEvent *event= (wmEvent*)ptr->id.data;
322         value[0]= event->ascii;
323         value[1]= '\0';
324 }
325
326 static int rna_Event_ascii_length(PointerRNA *ptr)
327 {
328         wmEvent *event= (wmEvent*)ptr->id.data;
329         return (event->ascii)? 1 : 0;
330 }
331
332 static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value)
333 {
334         wmWindow *win= (wmWindow*)ptr->data;
335
336         if(value.data == NULL)
337                 return;
338
339         /* exception: can't set screens inside of area/region handers */
340         win->newscreen= value.data;
341 }
342
343 static void rna_Window_screen_update(bContext *C, PointerRNA *ptr)
344 {
345         wmWindow *win= (wmWindow*)ptr->data;
346
347         /* exception: can't set screens inside of area/region handers */
348         if(win->newscreen) {
349                 WM_event_add_notifier(C, NC_SCREEN|ND_SCREENBROWSE, win->newscreen);
350                 win->newscreen= NULL;
351         }
352 }
353
354 static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr)
355 {
356         wmKeyMapItem *kmi= ptr->data;
357
358         if(kmi->ptr)
359                 return *(kmi->ptr);
360         
361         //return rna_pointer_inherit_refine(ptr, &RNA_OperatorProperties, op->properties);
362         return PointerRNA_NULL;
363 }
364
365 static int rna_wmKeyMapItem_map_type_get(PointerRNA *ptr)
366 {
367         wmKeyMapItem *kmi= ptr->data;
368
369         if(ISTIMER(kmi->type)) return KMI_TYPE_TIMER;
370     if(ISKEYBOARD(kmi->type)) return KMI_TYPE_KEYBOARD;
371         if(ISTWEAK(kmi->type)) return KMI_TYPE_TWEAK;
372         if(ISMOUSE(kmi->type)) return KMI_TYPE_MOUSE;
373         if(kmi->type == KM_TEXTINPUT) return KMI_TYPE_TEXTINPUT;
374         return KMI_TYPE_KEYBOARD;
375 }
376
377 static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
378 {
379         wmKeyMapItem *kmi= ptr->data;
380         int map_type= rna_wmKeyMapItem_map_type_get(ptr);
381
382         if(value != map_type) {
383                 switch(value) {
384                 case KMI_TYPE_KEYBOARD:
385                         kmi->type= AKEY;
386                         kmi->val= KM_PRESS;
387                         break;
388                 case KMI_TYPE_TWEAK:
389                         kmi->type= EVT_TWEAK_L;
390                         kmi->val= KM_ANY;
391                         break;
392                 case KMI_TYPE_MOUSE:
393                         kmi->type= LEFTMOUSE;
394                         kmi->val= KM_PRESS;
395                         break;
396                 case KMI_TYPE_TEXTINPUT:
397                         kmi->type= KM_TEXTINPUT;
398                         kmi->val= KM_NOTHING;
399                         break;
400                 case KMI_TYPE_TIMER:
401                         kmi->type= TIMER;
402                         kmi->val= KM_NOTHING;
403                         break;
404                 }
405         }
406 }
407
408 static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *C, PointerRNA *ptr, int *free)
409 {
410         int map_type= rna_wmKeyMapItem_map_type_get(ptr);
411
412         if(map_type == KMI_TYPE_MOUSE) return event_mouse_type_items;
413         if(map_type == KMI_TYPE_TWEAK) return event_tweak_type_items;
414         if(map_type == KMI_TYPE_TIMER) return event_timer_type_items;
415         else return event_type_items;
416 }
417
418 static EnumPropertyItem *rna_KeyMapItem_value_itemf(bContext *C, PointerRNA *ptr, int *free)
419 {
420         int map_type= rna_wmKeyMapItem_map_type_get(ptr);
421
422         if(map_type == KMI_TYPE_MOUSE || map_type == KMI_TYPE_KEYBOARD) return event_keymouse_value_items;
423         if(map_type == KMI_TYPE_TWEAK) return event_tweak_value_items;
424         else return event_value_items;
425 }
426
427 static EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext *C, PointerRNA *ptr, int *free)
428 {
429         wmWindowManager *wm = CTX_wm_manager(C);
430         wmKeyConfig *kc;
431         wmKeyMap *km;
432
433         /* check user keymaps */
434         for(km=U.keymaps.first; km; km=km->next) {
435                 wmKeyMapItem *ki;
436                 for (ki=km->items.first; ki; ki=ki->next) {
437                         if (ki == ptr->data) {
438                                 if (!km->modal_items) {
439                                         if (!WM_keymap_user_init(wm, km)) {
440                                                 return keymap_propvalue_items; /* ERROR */
441                                         }
442                                 }
443
444                                 return km->modal_items;
445                         }
446                 }
447         }
448
449         for(kc=wm->keyconfigs.first; kc; kc=kc->next) {
450                 for(km=kc->keymaps.first; km; km=km->next) {
451                         /* only check if it's a modal keymap */
452                         if (km->modal_items) {
453                                 wmKeyMapItem *ki;
454                                 for (ki=km->items.first; ki; ki=ki->next) {
455                                         if (ki == ptr->data) {
456                                                 return km->modal_items;
457                                         }
458                                 }
459                         }
460                 }
461         }
462
463
464         return keymap_propvalue_items; /* ERROR */
465 }
466
467 static int rna_KeyMapItem_any_getf(PointerRNA *ptr)
468 {
469         wmKeyMapItem *kmi = (wmKeyMapItem*)ptr->data;
470
471         if (kmi->shift == KM_ANY &&
472                 kmi->ctrl == KM_ANY &&
473                 kmi->alt == KM_ANY &&
474                 kmi->oskey == KM_ANY)
475
476                 return 1;
477         else
478                 return 0;
479 }
480
481 static void rna_KeyMapItem_any_setf(PointerRNA *ptr, int value)
482 {
483         wmKeyMapItem *kmi = (wmKeyMapItem*)ptr->data;
484
485         if(value) {
486                 kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= KM_ANY;
487         }
488         else {
489                 kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= 0;
490         }
491 }
492
493
494 static PointerRNA rna_WindowManager_active_keyconfig_get(PointerRNA *ptr)
495 {
496         wmWindowManager *wm= ptr->data;
497         wmKeyConfig *kc;
498
499         for(kc=wm->keyconfigs.first; kc; kc=kc->next)
500                 if(strcmp(kc->idname, U.keyconfigstr) == 0)
501                         break;
502         
503         if(!kc)
504                 kc= wm->defaultconf;
505         
506         return rna_pointer_inherit_refine(ptr, &RNA_KeyConfig, kc);
507 }
508
509 static void rna_WindowManager_active_keyconfig_set(PointerRNA *ptr, PointerRNA value)
510 {
511         wmKeyConfig *kc= value.data;
512
513         if(kc)
514                 BLI_strncpy(U.keyconfigstr, kc->idname, sizeof(U.keyconfigstr));
515 }
516
517 static PointerRNA rna_WindowManager_active_keymap_get(PointerRNA *ptr)
518 {
519         wmWindowManager *wm= ptr->data;
520         wmKeyMap *km= NULL;
521         
522         if(wm->defaultconf) {
523                 km= BLI_findlink(&wm->defaultconf->keymaps, wm->defaultactmap);
524                 
525                 if(!km)
526                         km= wm->defaultconf->keymaps.first;
527         }
528
529         return rna_pointer_inherit_refine(ptr, &RNA_KeyMap, WM_keymap_active(wm, km));
530 }
531
532 static void rna_WindowManager_active_keymap_set(PointerRNA *ptr, PointerRNA value)
533 {
534         wmWindowManager *wm= ptr->data;
535         wmKeyMap *km= value.data;
536         int index;
537         
538         if(wm->defaultconf && km) {
539                 km= WM_keymap_find(wm->defaultconf, km->idname, km->spaceid, km->regionid);
540                 index= BLI_findindex(&wm->defaultconf->keymaps, km);
541
542                 if(index != -1) wm->defaultactmap= index;
543                 else wm->defaultactmap= 0;
544         }
545 }
546
547 static void rna_wmKeyMapItem_idname_get(PointerRNA *ptr, char *value)
548 {
549         wmKeyMapItem *kmi= ptr->data;
550         WM_operator_py_idname(value, kmi->idname);
551 }
552
553 static int rna_wmKeyMapItem_idname_length(PointerRNA *ptr)
554 {
555         wmKeyMapItem *kmi= ptr->data;
556         char pyname[OP_MAX_TYPENAME];
557
558         WM_operator_py_idname(pyname, kmi->idname);
559         return strlen(pyname);
560 }
561
562 static void rna_wmKeyMapItem_idname_set(PointerRNA *ptr, const char *value)
563 {
564         wmKeyMapItem *kmi= ptr->data;
565         char idname[OP_MAX_TYPENAME];
566
567         WM_operator_bl_idname(idname, value);
568         BLI_strncpy(kmi->idname, idname, sizeof(kmi->idname));
569
570         WM_keymap_properties_reset(kmi);
571 }
572
573 #else
574
575 static void rna_def_operator(BlenderRNA *brna)
576 {
577         StructRNA *srna;
578         PropertyRNA *prop;
579
580         srna= RNA_def_struct(brna, "Operator", NULL);
581         RNA_def_struct_ui_text(srna, "Operator", "Storage of an operator being executed, or registered after execution.");
582         RNA_def_struct_sdna(srna, "wmOperator");
583
584         prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
585         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
586         RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL);
587         RNA_def_property_ui_text(prop, "Name", "");
588         RNA_def_struct_name_property(srna, prop);
589
590         prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
591         RNA_def_property_flag(prop, PROP_NEVER_NULL);
592         RNA_def_property_struct_type(prop, "OperatorProperties");
593         RNA_def_property_ui_text(prop, "Properties", "");
594         RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL);
595
596         srna= RNA_def_struct(brna, "OperatorProperties", NULL);
597         RNA_def_struct_ui_text(srna, "Operator Properties", "Input properties of an Operator.");
598         RNA_def_struct_refine_func(srna, "rna_OperatorProperties_refine");
599         RNA_def_struct_idproperties_func(srna, "rna_OperatorProperties_idproperties");
600 }
601
602 static void rna_def_macro_operator(BlenderRNA *brna)
603 {
604         StructRNA *srna;
605         PropertyRNA *prop;
606
607         srna= RNA_def_struct(brna, "Macro", NULL);
608         RNA_def_struct_ui_text(srna, "Macro Operator", "Storage of a macro operator being executed, or registered after execution.");
609         RNA_def_struct_sdna(srna, "wmOperator");
610
611         prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
612         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
613         RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL);
614         RNA_def_property_ui_text(prop, "Name", "");
615         RNA_def_struct_name_property(srna, prop);
616
617         prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
618         RNA_def_property_flag(prop, PROP_NEVER_NULL);
619         RNA_def_property_struct_type(prop, "OperatorProperties");
620         RNA_def_property_ui_text(prop, "Properties", "");
621         RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL);
622 }
623
624 static void rna_def_operator_type_macro(BlenderRNA *brna)
625 {
626         StructRNA *srna;
627         PropertyRNA *prop;
628
629         srna= RNA_def_struct(brna, "OperatorTypeMacro", NULL);
630         RNA_def_struct_ui_text(srna, "OperatorTypeMacro", "Storage of a sub operator in a macro after it has been added.");
631         RNA_def_struct_sdna(srna, "wmOperatorTypeMacro");
632
633 //      prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
634 //      RNA_def_property_clear_flag(prop, PROP_EDITABLE);
635 //      RNA_def_property_string_sdna(prop, NULL, "idname");
636 //      RNA_def_property_ui_text(prop, "Name", "Name of the sub operator.");
637 //      RNA_def_struct_name_property(srna, prop);
638
639         prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
640         RNA_def_property_flag(prop, PROP_NEVER_NULL);
641         RNA_def_property_struct_type(prop, "OperatorProperties");
642         RNA_def_property_ui_text(prop, "Properties", "");
643         RNA_def_property_pointer_funcs(prop, "rna_OperatorTypeMacro_properties_get", NULL, NULL);
644 }
645
646 static void rna_def_operator_utils(BlenderRNA *brna)
647 {
648         StructRNA *srna;
649         PropertyRNA *prop;
650
651         srna= RNA_def_struct(brna, "OperatorMousePath", "IDPropertyGroup");
652         RNA_def_struct_ui_text(srna, "Operator Mouse Path", "Mouse path values for operators that record such paths.");
653
654         prop= RNA_def_property(srna, "loc", PROP_FLOAT, PROP_XYZ);
655         RNA_def_property_flag(prop, PROP_IDPROPERTY);
656         RNA_def_property_array(prop, 2);
657         RNA_def_property_ui_text(prop, "Location", "Mouse location.");
658
659         prop= RNA_def_property(srna, "time", PROP_FLOAT, PROP_NONE);
660         RNA_def_property_flag(prop, PROP_IDPROPERTY);
661         RNA_def_property_ui_text(prop, "Time", "Time of mouse location.");
662 }
663
664 static void rna_def_operator_filelist_element(BlenderRNA *brna)
665 {
666         StructRNA *srna;
667         PropertyRNA *prop;
668
669         srna= RNA_def_struct(brna, "OperatorFileListElement", "IDPropertyGroup");
670         RNA_def_struct_ui_text(srna, "Operator File List Element", "");
671         
672         
673         prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
674         RNA_def_property_flag(prop, PROP_IDPROPERTY);
675         RNA_def_property_ui_text(prop, "Name", "the name of a file or directory within a file list");
676 }
677         
678 static void rna_def_event(BlenderRNA *brna)
679 {
680         StructRNA *srna;
681         PropertyRNA *prop;
682         
683         srna= RNA_def_struct(brna, "Event", NULL);
684         RNA_def_struct_ui_text(srna, "Event", "Window Manager Event");
685         RNA_def_struct_sdna(srna, "wmEvent");
686
687         /* strings */
688         prop= RNA_def_property(srna, "ascii", PROP_STRING, PROP_NONE);
689         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
690         RNA_def_property_string_funcs(prop, "rna_Event_ascii_get", "rna_Event_ascii_length", NULL);
691         RNA_def_property_ui_text(prop, "ASCII", "Single ASCII character for this event.");
692
693
694         /* enums */
695         prop= RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
696         RNA_def_property_enum_sdna(prop, NULL, "val");
697         RNA_def_property_enum_items(prop, event_value_items);
698         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
699         RNA_def_property_ui_text(prop, "Value",  "The type of event, only applies to some.");
700         
701         prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
702         RNA_def_property_enum_sdna(prop, NULL, "type");
703         RNA_def_property_enum_items(prop, event_type_items);
704         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
705         RNA_def_property_ui_text(prop, "Type",  "");
706
707
708         /* mouse */
709         prop= RNA_def_property(srna, "mouse_x", PROP_INT, PROP_NONE);
710         RNA_def_property_int_sdna(prop, NULL, "x");
711         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
712         RNA_def_property_ui_text(prop, "Mouse X Position", "The window relative vertical location of the mouse.");
713         
714         prop= RNA_def_property(srna, "mouse_y", PROP_INT, PROP_NONE);
715         RNA_def_property_int_sdna(prop, NULL, "y");
716         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
717         RNA_def_property_ui_text(prop, "Mouse Y Position", "The window relative horizontal location of the mouse.");
718         
719         prop= RNA_def_property(srna, "mouse_prev_x", PROP_INT, PROP_NONE);
720         RNA_def_property_int_sdna(prop, NULL, "prevx");
721         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
722         RNA_def_property_ui_text(prop, "Mouse Previous X Position", "The window relative vertical location of the mouse.");
723         
724         prop= RNA_def_property(srna, "mouse_prev_y", PROP_INT, PROP_NONE);
725         RNA_def_property_int_sdna(prop, NULL, "prevy");
726         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
727         RNA_def_property_ui_text(prop, "Mouse Previous Y Position", "The window relative horizontal location of the mouse.");   
728
729
730         /* modifiers */
731         prop= RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
732         RNA_def_property_boolean_sdna(prop, NULL, "shift", 1);
733         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
734         RNA_def_property_ui_text(prop, "Shift", "True when the Shift key is held.");
735         
736         prop= RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
737         RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 1);
738         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
739         RNA_def_property_ui_text(prop, "Ctrl", "True when the Ctrl key is held.");
740         
741         prop= RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
742         RNA_def_property_boolean_sdna(prop, NULL, "alt", 1);
743         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
744         RNA_def_property_ui_text(prop, "Alt", "True when the Alt/Option key is held.");
745         
746         prop= RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
747         RNA_def_property_boolean_sdna(prop, NULL, "oskey", 1);
748         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
749         RNA_def_property_ui_text(prop, "OS Key", "True when the Cmd key is held.");
750 }
751
752 static void rna_def_window(BlenderRNA *brna)
753 {
754         StructRNA *srna;
755         PropertyRNA *prop;
756
757         srna= RNA_def_struct(brna, "Window", NULL);
758         RNA_def_struct_ui_text(srna, "Window", "Open window.");
759         RNA_def_struct_sdna(srna, "wmWindow");
760
761         prop= RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE);
762         RNA_def_property_flag(prop, PROP_NEVER_NULL);
763         RNA_def_property_struct_type(prop, "Screen");
764         RNA_def_property_ui_text(prop, "Screen", "Active screen showing in the window.");
765         RNA_def_property_flag(prop, PROP_EDITABLE);
766         RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_screen_set", NULL);
767         RNA_def_property_update(prop, 0, "rna_Window_screen_update");
768 }
769
770 static void rna_def_windowmanager(BlenderRNA *brna)
771 {
772         StructRNA *srna;
773         PropertyRNA *prop;
774
775         srna= RNA_def_struct(brna, "WindowManager", "ID");
776         RNA_def_struct_ui_text(srna, "Window Manager", "Window manager datablock defining open windows and other user interface data.");
777         RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
778         RNA_def_struct_sdna(srna, "wmWindowManager");
779
780         prop= RNA_def_property(srna, "operators", PROP_COLLECTION, PROP_NONE);
781         RNA_def_property_struct_type(prop, "Operator");
782         RNA_def_property_ui_text(prop, "Operators", "Operator registry.");
783
784         prop= RNA_def_property(srna, "windows", PROP_COLLECTION, PROP_NONE);
785         RNA_def_property_struct_type(prop, "Window");
786         RNA_def_property_ui_text(prop, "Windows", "Open windows.");
787
788         prop= RNA_def_property(srna, "keyconfigs", PROP_COLLECTION, PROP_NONE);
789         RNA_def_property_struct_type(prop, "KeyConfig");
790         RNA_def_property_ui_text(prop, "Key Configurations", "Registered key configurations.");
791
792         prop= RNA_def_property(srna, "active_keyconfig", PROP_POINTER, PROP_NEVER_NULL);
793         RNA_def_property_struct_type(prop, "KeyConfig");
794         RNA_def_property_flag(prop, PROP_EDITABLE);
795         RNA_def_property_pointer_funcs(prop, "rna_WindowManager_active_keyconfig_get", "rna_WindowManager_active_keyconfig_set", 0);
796         RNA_def_property_ui_text(prop, "Active Key Configuration", "");
797
798         prop= RNA_def_property(srna, "default_keyconfig", PROP_POINTER, PROP_NEVER_NULL);
799         RNA_def_property_pointer_sdna(prop, NULL, "defaultconf");
800         RNA_def_property_struct_type(prop, "KeyConfig");
801         RNA_def_property_ui_text(prop, "Default Key Configuration", "");
802
803         prop= RNA_def_property(srna, "active_keymap", PROP_POINTER, PROP_NEVER_NULL);
804         RNA_def_property_struct_type(prop, "KeyMap");
805         RNA_def_property_flag(prop, PROP_EDITABLE);
806         RNA_def_property_pointer_funcs(prop, "rna_WindowManager_active_keymap_get", "rna_WindowManager_active_keymap_set", 0);
807         RNA_def_property_ui_text(prop, "Active Key Map", "");
808
809         RNA_api_wm(srna);
810 }
811
812 static void rna_def_keyconfig(BlenderRNA *brna)
813 {
814         StructRNA *srna;
815         // FunctionRNA *func;
816         // PropertyRNA *parm;
817         PropertyRNA *prop;
818
819         static EnumPropertyItem map_type_items[] = {
820                 {KMI_TYPE_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""},
821                 {KMI_TYPE_TWEAK, "TWEAK", 0, "Tweak", ""},
822                 {KMI_TYPE_MOUSE, "MOUSE", 0, "Mouse", ""},
823                 {KMI_TYPE_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""},
824                 {KMI_TYPE_TIMER, "TIMER", 0, "Timer", ""},
825                 {0, NULL, 0, NULL, NULL}};
826
827         /* KeyConfig */
828         srna= RNA_def_struct(brna, "KeyConfig", NULL);
829         RNA_def_struct_sdna(srna, "wmKeyConfig");
830         RNA_def_struct_ui_text(srna, "Key Configuration", "Input configuration, including keymaps.");
831
832         prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
833         RNA_def_property_string_sdna(prop, NULL, "idname");
834         RNA_def_property_ui_text(prop, "Name", "Name of the key configuration.");
835         RNA_def_struct_name_property(srna, prop);
836
837         prop= RNA_def_property(srna, "keymaps", PROP_COLLECTION, PROP_NONE);
838         RNA_def_property_struct_type(prop, "KeyMap");
839         RNA_def_property_ui_text(prop, "Key Maps", "Key maps configured as part of this configuration.");
840
841         RNA_api_keyconfig(srna);
842
843         /* KeyMap */
844         srna= RNA_def_struct(brna, "KeyMap", NULL);
845         RNA_def_struct_sdna(srna, "wmKeyMap");
846         RNA_def_struct_ui_text(srna, "Key Map", "Input configuration, including keymaps.");
847
848         prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
849         RNA_def_property_string_sdna(prop, NULL, "idname");
850         RNA_def_property_ui_text(prop, "Name", "Name of the key map.");
851         RNA_def_struct_name_property(srna, prop);
852
853         prop= RNA_def_property(srna, "space_type", PROP_ENUM, PROP_NONE);
854         RNA_def_property_enum_sdna(prop, NULL, "spaceid");
855         RNA_def_property_enum_items(prop, space_type_items);
856         RNA_def_property_ui_text(prop, "Space Type", "Optional space type keymap is associated with.");
857
858         prop= RNA_def_property(srna, "region_type", PROP_ENUM, PROP_NONE);
859         RNA_def_property_enum_sdna(prop, NULL, "regionid");
860         RNA_def_property_enum_items(prop, region_type_items);
861         RNA_def_property_ui_text(prop, "Region Type", "Optional region type keymap is associated with.");
862
863         prop= RNA_def_property(srna, "items", PROP_COLLECTION, PROP_NONE);
864         RNA_def_property_struct_type(prop, "KeyMapItem");
865         RNA_def_property_ui_text(prop, "Items", "Items in the keymap, linking an operator to an input event.");
866
867         prop= RNA_def_property(srna, "user_defined", PROP_BOOLEAN, PROP_NEVER_NULL);
868         RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_USER);
869         RNA_def_property_ui_text(prop, "User Defined", "Keymap is defined by the user.");
870
871         prop= RNA_def_property(srna, "modal", PROP_BOOLEAN, PROP_NONE);
872         RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_MODAL);
873         RNA_def_property_ui_text(prop, "Modal Keymap", "Indicates that a keymap is used for translate modal events for an operator.");
874
875         RNA_api_keymap(srna);
876
877         /* KeyMapItem */
878         srna= RNA_def_struct(brna, "KeyMapItem", NULL);
879         RNA_def_struct_sdna(srna, "wmKeyMapItem");
880         RNA_def_struct_ui_text(srna, "Key Map Item", "Item in a Key Map.");
881
882         prop= RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE);
883         RNA_def_property_string_sdna(prop, NULL, "idname");
884         RNA_def_property_ui_text(prop, "Identifier", "Identifier of operator to call on input event.");
885         RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_idname_get", "rna_wmKeyMapItem_idname_length", "rna_wmKeyMapItem_idname_set");
886         RNA_def_struct_name_property(srna, prop);
887
888         prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
889         RNA_def_property_struct_type(prop, "OperatorProperties");
890         RNA_def_property_pointer_funcs(prop, "rna_KeyMapItem_properties_get", NULL, NULL);
891         RNA_def_property_ui_text(prop, "Properties", "Properties to set when the operator is called.");
892
893         prop= RNA_def_property(srna, "map_type", PROP_ENUM, PROP_NONE);
894         RNA_def_property_enum_sdna(prop, NULL, "maptype");
895         RNA_def_property_enum_items(prop, map_type_items);
896         RNA_def_property_enum_funcs(prop, "rna_wmKeyMapItem_map_type_get", "rna_wmKeyMapItem_map_type_set", NULL);
897         RNA_def_property_ui_text(prop, "Map Type", "Type of event mapping.");
898
899         prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
900         RNA_def_property_enum_sdna(prop, NULL, "type");
901         RNA_def_property_enum_items(prop, event_type_items);
902         RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_type_itemf");
903         RNA_def_property_ui_text(prop, "Type", "Type of event.");
904
905         prop= RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
906         RNA_def_property_enum_sdna(prop, NULL, "val");
907         RNA_def_property_enum_items(prop, event_value_items);
908         RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_value_itemf");
909         RNA_def_property_ui_text(prop, "Value", "");
910
911         prop= RNA_def_property(srna, "any", PROP_BOOLEAN, PROP_NONE);
912         RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_any_getf", "rna_KeyMapItem_any_setf");
913         RNA_def_property_ui_text(prop, "Any", "Any modifier keys pressed.");
914
915         prop= RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
916         RNA_def_property_boolean_sdna(prop, NULL, "shift", 0);
917 //      RNA_def_property_enum_sdna(prop, NULL, "shift");
918 //      RNA_def_property_enum_items(prop, keymap_modifiers_items);
919         RNA_def_property_ui_text(prop, "Shift", "Shift key pressed.");
920
921         prop= RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
922         RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 0);
923 //      RNA_def_property_enum_sdna(prop, NULL, "ctrl");
924 //      RNA_def_property_enum_items(prop, keymap_modifiers_items);
925         RNA_def_property_ui_text(prop, "Ctrl", "Control key pressed.");
926
927         prop= RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
928         RNA_def_property_boolean_sdna(prop, NULL, "alt", 0);
929 //      RNA_def_property_enum_sdna(prop, NULL, "alt");
930 //      RNA_def_property_enum_items(prop, keymap_modifiers_items);
931         RNA_def_property_ui_text(prop, "Alt", "Alt key pressed.");
932
933         prop= RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
934         RNA_def_property_boolean_sdna(prop, NULL, "oskey", 0);
935 //      RNA_def_property_enum_sdna(prop, NULL, "oskey");
936 //      RNA_def_property_enum_items(prop, keymap_modifiers_items);
937         RNA_def_property_ui_text(prop, "OS Key", "Operating system key pressed.");
938
939         prop= RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE);
940         RNA_def_property_enum_sdna(prop, NULL, "keymodifier");
941         RNA_def_property_enum_items(prop, event_type_items);
942         RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier.");
943
944         prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE);
945         RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_EXPANDED);
946         RNA_def_property_ui_text(prop, "Expanded", "Expanded in the user interface.");
947
948         prop= RNA_def_property(srna, "propvalue", PROP_ENUM, PROP_NONE);
949         RNA_def_property_enum_sdna(prop, NULL, "propvalue");
950         RNA_def_property_enum_items(prop, keymap_propvalue_items);
951         RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_propvalue_itemf");
952         RNA_def_property_ui_text(prop, "Property Value", "The value this event translates to in a modal keymap.");
953
954         prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
955         RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", KMI_INACTIVE);
956         RNA_def_property_ui_text(prop, "Active", "Activate or deactivate item.");
957 }
958
959 void RNA_def_wm(BlenderRNA *brna)
960 {
961         rna_def_operator(brna);
962         rna_def_operator_utils(brna);
963         rna_def_operator_filelist_element(brna);
964         rna_def_macro_operator(brna);
965         rna_def_operator_type_macro(brna);
966         rna_def_event(brna);
967         rna_def_window(brna);
968         rna_def_windowmanager(brna);
969         rna_def_keyconfig(brna);
970 }
971
972 #endif
973