~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/blenkernel/intern/context.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: context.c 28401 2010-04-24 19:26:05Z campbellbarton $
3
 
 *
 
1
/*
4
2
 * ***** BEGIN GPL LICENSE BLOCK *****
5
3
 *
6
4
 * This program is free software; you can redistribute it and/or
25
23
 * ***** END GPL LICENSE BLOCK *****
26
24
 */
27
25
 
 
26
/** \file blender/blenkernel/intern/context.c
 
27
 *  \ingroup bke
 
28
 */
 
29
 
 
30
 
 
31
#include <string.h>
 
32
#include <stddef.h>
 
33
 
28
34
#include "MEM_guardedalloc.h"
29
35
 
30
36
#include "DNA_scene_types.h"
43
49
#include "BKE_main.h"
44
50
#include "BKE_screen.h"
45
51
 
46
 
#ifndef DISABLE_PYTHON
 
52
#ifdef WITH_PYTHON
47
53
#include "BPY_extern.h"
48
54
#endif
49
55
 
50
 
#include <string.h>
51
 
 
52
56
/* struct */
53
57
 
54
58
struct bContext {
63
67
                struct ARegion *region;
64
68
                struct ARegion *menu;
65
69
                struct bContextStore *store;
 
70
                const char *operator_poll_msg; /* reason for poll failing */
66
71
        } wm;
67
72
        
68
73
        /* data context */
83
88
 
84
89
/* context */
85
90
 
86
 
bContext *CTX_create()
 
91
bContext *CTX_create(void)
87
92
{
88
93
        bContext *C;
89
94
        
106
111
 
107
112
/* store */
108
113
 
109
 
bContextStore *CTX_store_add(ListBase *contexts, char *name, PointerRNA *ptr)
 
114
bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *ptr)
110
115
{
111
116
        bContextStoreEntry *entry;
112
117
        bContextStore *ctx, *lastctx;
115
120
         * we have to copy the context to ensure */
116
121
        ctx= contexts->last;
117
122
 
118
 
        if(!ctx || ctx->used) {
119
 
                if(ctx) {
 
123
        if (!ctx || ctx->used) {
 
124
                if (ctx) {
120
125
                        lastctx= ctx;
121
126
                        ctx= MEM_dupallocN(lastctx);
122
127
                        BLI_duplicatelist(&ctx->entries, &lastctx->entries);
136
141
        return ctx;
137
142
}
138
143
 
 
144
bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context)
 
145
{
 
146
        bContextStoreEntry *entry, *tentry;
 
147
        bContextStore *ctx, *lastctx;
 
148
 
 
149
        /* ensure we have a context to put the entries in, if it was already used
 
150
         * we have to copy the context to ensure */
 
151
        ctx= contexts->last;
 
152
 
 
153
        if (!ctx || ctx->used) {
 
154
                if (ctx) {
 
155
                        lastctx= ctx;
 
156
                        ctx= MEM_dupallocN(lastctx);
 
157
                        BLI_duplicatelist(&ctx->entries, &lastctx->entries);
 
158
                }
 
159
                else
 
160
                        ctx= MEM_callocN(sizeof(bContextStore), "bContextStore");
 
161
 
 
162
                BLI_addtail(contexts, ctx);
 
163
        }
 
164
 
 
165
        for (tentry= context->entries.first; tentry; tentry= tentry->next) {
 
166
                entry= MEM_dupallocN(tentry);
 
167
                BLI_addtail(&ctx->entries, entry);
 
168
        }
 
169
 
 
170
        return ctx;
 
171
}
 
172
 
139
173
void CTX_store_set(bContext *C, bContextStore *store)
140
174
{
141
175
        C->wm.store= store;
161
195
{
162
196
        bContextStore *ctx;
163
197
 
164
 
        while((ctx= contexts->first)) {
 
198
        while ((ctx= contexts->first)) {
165
199
                BLI_remlink(contexts, ctx);
166
200
                CTX_store_free(ctx);
167
201
        }
177
211
        C->data.py_init= value;
178
212
}
179
213
 
180
 
void *CTX_py_dict_get(bContext *C)
 
214
void *CTX_py_dict_get(const bContext *C)
181
215
{
182
216
        return C->data.py_context;
183
217
}
238
272
 
239
273
View3D *CTX_wm_view3d(const bContext *C)
240
274
{
241
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_VIEW3D)
 
275
        if (C->wm.area && C->wm.area->spacetype==SPACE_VIEW3D)
242
276
                return C->wm.area->spacedata.first;
243
277
        return NULL;
244
278
}
245
279
 
246
280
RegionView3D *CTX_wm_region_view3d(const bContext *C)
247
281
{
248
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_VIEW3D)
249
 
                if(C->wm.region)
 
282
        if (C->wm.area && C->wm.area->spacetype==SPACE_VIEW3D)
 
283
                if (C->wm.region)
250
284
                        return C->wm.region->regiondata;
251
285
        return NULL;
252
286
}
253
287
 
254
288
struct SpaceText *CTX_wm_space_text(const bContext *C)
255
289
{
256
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_TEXT)
 
290
        if (C->wm.area && C->wm.area->spacetype==SPACE_TEXT)
257
291
                return C->wm.area->spacedata.first;
258
292
        return NULL;
259
293
}
260
294
 
261
295
struct SpaceConsole *CTX_wm_space_console(const bContext *C)
262
296
{
263
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_CONSOLE)
 
297
        if (C->wm.area && C->wm.area->spacetype==SPACE_CONSOLE)
264
298
                return C->wm.area->spacedata.first;
265
299
        return NULL;
266
300
}
267
301
 
268
302
struct SpaceImage *CTX_wm_space_image(const bContext *C)
269
303
{
270
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_IMAGE)
 
304
        if (C->wm.area && C->wm.area->spacetype==SPACE_IMAGE)
271
305
                return C->wm.area->spacedata.first;
272
306
        return NULL;
273
307
}
274
308
 
275
309
struct SpaceButs *CTX_wm_space_buts(const bContext *C)
276
310
{
277
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_BUTS)
 
311
        if (C->wm.area && C->wm.area->spacetype==SPACE_BUTS)
278
312
                return C->wm.area->spacedata.first;
279
313
        return NULL;
280
314
}
281
315
 
282
316
struct SpaceFile *CTX_wm_space_file(const bContext *C)
283
317
{
284
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_FILE)
 
318
        if (C->wm.area && C->wm.area->spacetype==SPACE_FILE)
285
319
                return C->wm.area->spacedata.first;
286
320
        return NULL;
287
321
}
288
322
 
289
323
struct SpaceSeq *CTX_wm_space_seq(const bContext *C)
290
324
{
291
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_SEQ)
 
325
        if (C->wm.area && C->wm.area->spacetype==SPACE_SEQ)
292
326
                return C->wm.area->spacedata.first;
293
327
        return NULL;
294
328
}
295
329
 
296
330
struct SpaceOops *CTX_wm_space_outliner(const bContext *C)
297
331
{
298
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_OUTLINER)
 
332
        if (C->wm.area && C->wm.area->spacetype==SPACE_OUTLINER)
299
333
                return C->wm.area->spacedata.first;
300
334
        return NULL;
301
335
}
302
336
 
303
337
struct SpaceNla *CTX_wm_space_nla(const bContext *C)
304
338
{
305
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_NLA)
 
339
        if (C->wm.area && C->wm.area->spacetype==SPACE_NLA)
306
340
                return C->wm.area->spacedata.first;
307
341
        return NULL;
308
342
}
309
343
 
310
344
struct SpaceTime *CTX_wm_space_time(const bContext *C)
311
345
{
312
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_TIME)
 
346
        if (C->wm.area && C->wm.area->spacetype==SPACE_TIME)
313
347
                return C->wm.area->spacedata.first;
314
348
        return NULL;
315
349
}
316
350
 
317
351
struct SpaceNode *CTX_wm_space_node(const bContext *C)
318
352
{
319
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_NODE)
 
353
        if (C->wm.area && C->wm.area->spacetype==SPACE_NODE)
320
354
                return C->wm.area->spacedata.first;
321
355
        return NULL;
322
356
}
323
357
 
324
358
struct SpaceLogic *CTX_wm_space_logic(const bContext *C)
325
359
{
326
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_LOGIC)
 
360
        if (C->wm.area && C->wm.area->spacetype==SPACE_LOGIC)
327
361
                return C->wm.area->spacedata.first;
328
362
        return NULL;
329
363
}
330
364
 
331
365
struct SpaceIpo *CTX_wm_space_graph(const bContext *C)
332
366
{
333
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_IPO)
 
367
        if (C->wm.area && C->wm.area->spacetype==SPACE_IPO)
334
368
                return C->wm.area->spacedata.first;
335
369
        return NULL;
336
370
}
337
371
 
338
372
struct SpaceAction *CTX_wm_space_action(const bContext *C)
339
373
{
340
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_ACTION)
 
374
        if (C->wm.area && C->wm.area->spacetype==SPACE_ACTION)
341
375
                return C->wm.area->spacedata.first;
342
376
        return NULL;
343
377
}
344
378
 
345
379
struct SpaceInfo *CTX_wm_space_info(const bContext *C)
346
380
{
347
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_INFO)
 
381
        if (C->wm.area && C->wm.area->spacetype==SPACE_INFO)
348
382
                return C->wm.area->spacedata.first;
349
383
        return NULL;
350
384
}
351
385
 
352
386
struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
353
387
{
354
 
        if(C->wm.area && C->wm.area->spacetype==SPACE_USERPREF)
 
388
        if (C->wm.area && C->wm.area->spacetype==SPACE_USERPREF)
 
389
                return C->wm.area->spacedata.first;
 
390
        return NULL;
 
391
}
 
392
 
 
393
struct SpaceClip *CTX_wm_space_clip(const bContext *C)
 
394
{
 
395
        if (C->wm.area && C->wm.area->spacetype==SPACE_CLIP)
355
396
                return C->wm.area->spacedata.first;
356
397
        return NULL;
357
398
}
369
410
{
370
411
        C->wm.window= win;
371
412
        C->wm.screen= (win)? win->screen: NULL;
372
 
        C->data.scene= (C->wm.screen)? C->wm.screen->scene: NULL;
 
413
        if (C->wm.screen)
 
414
                C->data.scene= C->wm.screen->scene;
373
415
        C->wm.area= NULL;
374
416
        C->wm.region= NULL;
375
417
}
377
419
void CTX_wm_screen_set(bContext *C, bScreen *screen)
378
420
{
379
421
        C->wm.screen= screen;
380
 
        C->data.scene= (C->wm.screen)? C->wm.screen->scene: NULL;
 
422
        if (C->wm.screen)
 
423
                C->data.scene= C->wm.screen->scene;
381
424
        C->wm.area= NULL;
382
425
        C->wm.region= NULL;
383
426
}
398
441
        C->wm.menu= menu;
399
442
}
400
443
 
 
444
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
 
445
{
 
446
        C->wm.operator_poll_msg= msg;
 
447
}
 
448
 
 
449
const char *CTX_wm_operator_poll_msg_get(bContext *C)
 
450
{
 
451
        return C->wm.operator_poll_msg;
 
452
}
 
453
 
401
454
/* data context utility functions */
402
455
 
403
456
struct bContextDataResult {
413
466
        int ret= 0;
414
467
 
415
468
        memset(result, 0, sizeof(bContextDataResult));
416
 
#ifndef DISABLE_PYTHON
417
 
        if(CTX_py_dict_get(C)) {
418
 
                return BPY_context_get(C, member, result);
419
 
//              if (BPY_context_get(C, member, result))
 
469
#ifdef WITH_PYTHON
 
470
        if (CTX_py_dict_get(C)) {
 
471
                return BPY_context_member_get(C, member, result);
 
472
//              if (BPY_context_member_get(C, member, result))
420
473
//                      return 1;
421
474
        }
422
475
#endif
424
477
         * loops requesting data from ourselfs in a context callback */
425
478
 
426
479
        /* Ok, this looks evil...
427
 
         * if(ret) done= -(-ret | -done);
 
480
         * if (ret) done= -(-ret | -done);
428
481
         *
429
482
         * Values in order of importance
430
483
         * (0, -1, 1) - Where 1 is highest priority
431
484
         * */
432
 
        if(done!=1 && recursion < 1 && C->wm.store) {
 
485
        if (done!=1 && recursion < 1 && C->wm.store) {
433
486
                bContextStoreEntry *entry;
434
487
 
435
488
                C->data.recursion= 1;
436
489
 
437
 
                for(entry=C->wm.store->entries.first; entry; entry=entry->next) {
438
 
                        if(strcmp(entry->name, member) == 0) {
439
 
                                result->ptr= entry->ptr;
440
 
                                done= 1;
441
 
                        }
 
490
                entry= BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name));
 
491
                if (entry) {
 
492
                        result->ptr= entry->ptr;
 
493
                        done= 1;
442
494
                }
443
495
        }
444
 
        if(done!=1 && recursion < 2 && C->wm.region) {
 
496
        if (done!=1 && recursion < 2 && C->wm.region) {
445
497
                C->data.recursion= 2;
446
 
                if(C->wm.region->type && C->wm.region->type->context) {
 
498
                if (C->wm.region->type && C->wm.region->type->context) {
447
499
                        ret = C->wm.region->type->context(C, member, result);
448
 
                        if(ret) done= -(-ret | -done);
 
500
                        if (ret) done= -(-ret | -done);
449
501
 
450
502
                }
451
503
        }
452
 
        if(done!=1 && recursion < 3 && C->wm.area) {
 
504
        if (done!=1 && recursion < 3 && C->wm.area) {
453
505
                C->data.recursion= 3;
454
 
                if(C->wm.area->type && C->wm.area->type->context) {
 
506
                if (C->wm.area->type && C->wm.area->type->context) {
455
507
                        ret = C->wm.area->type->context(C, member, result);
456
 
                        if(ret) done= -(-ret | -done);
 
508
                        if (ret) done= -(-ret | -done);
457
509
                }
458
510
        }
459
 
        if(done!=1 && recursion < 4 && C->wm.screen) {
 
511
        if (done!=1 && recursion < 4 && C->wm.screen) {
460
512
                bContextDataCallback cb= C->wm.screen->context;
461
513
                C->data.recursion= 4;
462
 
                if(cb) {
 
514
                if (cb) {
463
515
                        ret = cb(C, member, result);
464
 
                        if(ret) done= -(-ret | -done);
 
516
                        if (ret) done= -(-ret | -done);
465
517
                }
466
518
        }
467
519
 
474
526
{
475
527
        bContextDataResult result;
476
528
 
477
 
        if(C && ctx_data_get((bContext*)C, member, &result)==1)
 
529
        if (C && ctx_data_get((bContext*)C, member, &result)==1)
478
530
                return result.ptr.data;
479
531
 
480
532
        return NULL;
489
541
                *pointer= NULL;
490
542
                return 1;
491
543
        }
492
 
        else if(ctx_data_get((bContext*)C, member, &result)==1) {
 
544
        else if (ctx_data_get((bContext*)C, member, &result)==1) {
493
545
                *pointer= result.ptr.data;
494
546
                return 1;
495
547
        }
503
555
{
504
556
        bContextDataResult result;
505
557
 
506
 
        if(ctx_data_get((bContext*)C, member, &result)==1) {
 
558
        if (ctx_data_get((bContext*)C, member, &result)==1) {
507
559
                *list= result.list;
508
560
                return 1;
509
561
        }
518
570
{
519
571
        bContextDataResult result;
520
572
 
521
 
        if(ctx_data_get((bContext*)C, member, &result)==1)
 
573
        if (ctx_data_get((bContext*)C, member, &result)==1)
522
574
                return result.ptr;
523
575
        else
524
576
                return PointerRNA_NULL;
528
580
{
529
581
        PointerRNA ptr = CTX_data_pointer_get(C, member);
530
582
 
531
 
        if(ptr.data && RNA_struct_is_a(ptr.type, type))
 
583
        if (ptr.data && RNA_struct_is_a(ptr.type, type))
532
584
                return ptr;
533
585
        
534
586
        return PointerRNA_NULL;
538
590
{
539
591
        bContextDataResult result;
540
592
 
541
 
        if(ctx_data_get((bContext*)C, member, &result)==1) {
 
593
        if (ctx_data_get((bContext*)C, member, &result)==1) {
542
594
                return result.list;
543
595
        }
544
596
        else {
545
 
                ListBase list;
546
 
                memset(&list, 0, sizeof(list));
 
597
                ListBase list= {NULL, NULL};
547
598
                return list;
548
599
        }
549
600
}
554
605
        bContextDataResult result;
555
606
        int ret= ctx_data_get((bContext*)C, member, &result);
556
607
 
557
 
        if(ret==1) {
 
608
        if (ret==1) {
558
609
                *r_ptr= result.ptr;
559
610
                *r_lb= result.list;
560
611
                *r_type= result.type;
571
622
static void data_dir_add(ListBase *lb, const char *member)
572
623
{
573
624
        LinkData *link;
574
 
 
575
 
        if(strcmp(member, "scene") == 0) /* exception */
576
 
                return;
577
 
 
578
 
        for(link=lb->first; link; link=link->next)
579
 
                if(strcmp(link->data, member) == 0)
580
 
                        return;
 
625
        
 
626
        if (strcmp(member, "scene") == 0) /* exception */
 
627
                return;
 
628
 
 
629
        if (BLI_findstring(lb, member, offsetof(LinkData, data)))
 
630
                return;
581
631
        
582
632
        link= MEM_callocN(sizeof(LinkData), "LinkData");
583
633
        link->data= (void*)member;
592
642
 
593
643
        memset(&lb, 0, sizeof(lb));
594
644
 
595
 
        if(C->wm.store) {
 
645
        if (C->wm.store) {
596
646
                bContextStoreEntry *entry;
597
647
 
598
 
                for(entry=C->wm.store->entries.first; entry; entry=entry->next)
 
648
                for (entry=C->wm.store->entries.first; entry; entry=entry->next)
599
649
                        data_dir_add(&lb, entry->name);
600
650
        }
601
 
        if(C->wm.region && C->wm.region->type && C->wm.region->type->context) {
 
651
        if (C->wm.region && C->wm.region->type && C->wm.region->type->context) {
602
652
                memset(&result, 0, sizeof(result));
603
653
                C->wm.region->type->context(C, "", &result);
604
654
 
605
 
                if(result.dir)
606
 
                        for(a=0; result.dir[a]; a++)
 
655
                if (result.dir)
 
656
                        for (a=0; result.dir[a]; a++)
607
657
                                data_dir_add(&lb, result.dir[a]);
608
658
        }
609
 
        if(C->wm.area && C->wm.area->type && C->wm.area->type->context) {
 
659
        if (C->wm.area && C->wm.area->type && C->wm.area->type->context) {
610
660
                memset(&result, 0, sizeof(result));
611
661
                C->wm.area->type->context(C, "", &result);
612
662
 
613
 
                if(result.dir)
614
 
                        for(a=0; result.dir[a]; a++)
 
663
                if (result.dir)
 
664
                        for (a=0; result.dir[a]; a++)
615
665
                                data_dir_add(&lb, result.dir[a]);
616
666
        }
617
 
        if(C->wm.screen && C->wm.screen->context) {
 
667
        if (C->wm.screen && C->wm.screen->context) {
618
668
                bContextDataCallback cb= C->wm.screen->context;
619
669
                memset(&result, 0, sizeof(result));
620
670
                cb(C, "", &result);
621
671
 
622
 
                if(result.dir)
623
 
                        for(a=0; result.dir[a]; a++)
 
672
                if (result.dir)
 
673
                        for (a=0; result.dir[a]; a++)
624
674
                                data_dir_add(&lb, result.dir[a]);
625
675
        }
626
676
 
634
684
 
635
685
int CTX_data_dir(const char *member)
636
686
{
637
 
        return (strcmp(member, "") == 0);
 
687
        return member[0] == '\0';
638
688
}
639
689
 
640
690
void CTX_data_id_pointer_set(bContextDataResult *result, ID *id)
671
721
{
672
722
        ListBase list;
673
723
 
674
 
        if(func(C, &list)) {
 
724
        if (func(C, &list)) {
675
725
                int tot= BLI_countlist(&list);
676
726
                BLI_freelistN(&list);
677
727
                return tot;
701
751
{
702
752
        Main *bmain;
703
753
 
704
 
        if(ctx_data_pointer_verify(C, "main", (void*)&bmain))
 
754
        if (ctx_data_pointer_verify(C, "blend_data", (void*)&bmain))
705
755
                return bmain;
706
756
        else
707
757
                return C->data.main;
716
766
{
717
767
        Scene *scene;
718
768
 
719
 
        if(ctx_data_pointer_verify(C, "scene", (void*)&scene))
 
769
        if (ctx_data_pointer_verify(C, "scene", (void*)&scene))
720
770
                return scene;
721
771
        else
722
772
                return C->data.scene;
726
776
{
727
777
        Object *obedit= CTX_data_edit_object(C);
728
778
 
729
 
        if(obedit) {
 
779
        if (obedit) {
730
780
                switch(obedit->type) {
731
781
                        case OB_MESH:
732
782
                                return CTX_MODE_EDIT_MESH;
747
797
        else {
748
798
                Object *ob = CTX_data_active_object(C);
749
799
 
750
 
                if(ob) {
751
 
                        if(ob->mode & OB_MODE_POSE) return CTX_MODE_POSE;
752
 
                        else if(ob->mode & OB_MODE_SCULPT)  return CTX_MODE_SCULPT;
753
 
                        else if(ob->mode & OB_MODE_WEIGHT_PAINT) return CTX_MODE_PAINT_WEIGHT;
754
 
                        else if(ob->mode & OB_MODE_VERTEX_PAINT) return CTX_MODE_PAINT_VERTEX;
755
 
                        else if(ob->mode & OB_MODE_TEXTURE_PAINT) return CTX_MODE_PAINT_TEXTURE;
756
 
                        else if(ob->mode & OB_MODE_PARTICLE_EDIT) return CTX_MODE_PARTICLE;
 
800
                if (ob) {
 
801
                        if (ob->mode & OB_MODE_POSE) return CTX_MODE_POSE;
 
802
                        else if (ob->mode & OB_MODE_SCULPT)  return CTX_MODE_SCULPT;
 
803
                        else if (ob->mode & OB_MODE_WEIGHT_PAINT) return CTX_MODE_PAINT_WEIGHT;
 
804
                        else if (ob->mode & OB_MODE_VERTEX_PAINT) return CTX_MODE_PAINT_VERTEX;
 
805
                        else if (ob->mode & OB_MODE_TEXTURE_PAINT) return CTX_MODE_PAINT_TEXTURE;
 
806
                        else if (ob->mode & OB_MODE_PARTICLE_EDIT) return CTX_MODE_PARTICLE;
757
807
                }
758
808
        }
759
809
 
763
813
 
764
814
/* would prefer if we can use the enum version below over this one - Campbell */
765
815
/* must be aligned with above enum  */
766
 
static char *data_mode_strings[] = {
 
816
static const char *data_mode_strings[] = {
767
817
        "mesh_edit",
768
818
        "curve_edit",
769
819
        "surface_edit",
775
825
        "sculpt_mode",
776
826
        "weightpaint",
777
827
        "vertexpaint",
778
 
        "texturepaint",
 
828
        "imagepaint",
779
829
        "particlemode",
780
830
        "objectmode",
781
 
        0
 
831
        NULL
782
832
};
783
 
char *CTX_data_mode_string(const bContext *C)
 
833
const char *CTX_data_mode_string(const bContext *C)
784
834
{
785
835
        return data_mode_strings[CTX_data_mode_enum(C)];
786
836
}
794
844
{
795
845
        Scene *scene = CTX_data_scene(C);
796
846
 
797
 
        if(scene)
 
847
        if (scene)
798
848
                return scene->toolsettings;
799
849
        else
800
850
                return NULL;
870
920
        return ctx_data_pointer_get(C, "edit_text");
871
921
}
872
922
 
 
923
struct MovieClip *CTX_data_edit_movieclip(const bContext *C)
 
924
{
 
925
        return ctx_data_pointer_get(C, "edit_movieclip");
 
926
}
 
927
 
873
928
struct EditBone *CTX_data_active_bone(const bContext *C)
874
929
{
875
930
        return ctx_data_pointer_get(C, "active_bone");