1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/**
* $Id:
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2007 Blender Foundation.
* All rights reserved.
*
*
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <string.h>
#include "DNA_windowmanager_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BKE_blender.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BIF_toolbox.h"
#include "WM_api.h"
#include "WM_types.h"
#include "wm_window.h"
#include "wm_event_system.h"
static ListBase global_ops= {NULL, NULL};
/* ************ operator API, exported ********** */
wmOperatorType *WM_operatortype_find(const char *idname)
{
wmOperatorType *ot;
for(ot= global_ops.first; ot; ot= ot->next) {
if(strncmp(ot->idname, idname, OP_MAX_TYPENAME)==0)
return ot;
}
return NULL;
}
/* ************ default ops, exported *********** */
int WM_operator_confirm(bContext *C, wmOperator *op, wmEvent *event)
{
// if(okee(op->type->name)) {
// return op->type->exec(C, op);
// }
return 0;
}
int WM_operator_winactive(bContext *C)
{
if(C->window==NULL) return 0;
return 1;
}
/* ************ window / screen operator definitions ************** */
static void WM_OT_window_duplicate(wmOperatorType *ot)
{
ot->name= "Duplicate Window";
ot->idname= "WM_OT_window_duplicate";
ot->interactive= NULL; //WM_operator_confirm;
ot->exec= wm_window_duplicate_op;
ot->poll= WM_operator_winactive;
}
static void WM_OT_save_homefile(wmOperatorType *ot)
{
ot->name= "Save User Settings";
ot->idname= "WM_OT_save_homefile";
ot->interactive= NULL; //WM_operator_confirm;
ot->exec= WM_write_homefile;
ot->poll= WM_operator_winactive;
ot->flag= OPTYPE_REGISTER;
}
#define ADD_OPTYPE(opfunc) ot= MEM_callocN(sizeof(wmOperatorType), "operatortype"); \
opfunc(ot); \
BLI_addtail(&global_ops, ot)
/* called on initialize WM_exit() */
void wm_operatortype_free(void)
{
BLI_freelistN(&global_ops);
}
/* called on initialize WM_init() */
void wm_operatortype_init(void)
{
wmOperatorType *ot;
ADD_OPTYPE(WM_OT_window_duplicate);
ADD_OPTYPE(WM_OT_save_homefile);
}
|