This fixes ALT+A playback in 3d windows, with one or more windows having
[blender.git] / source / blender / src / headerbuttons.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL/BL DUAL 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. The Blender
10  * Foundation also sells licenses for use in proprietary software under
11  * the Blender License.  See http://www.blender.org/BL/ for information
12  * about this.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place - Suite 330, Boston, MA        02111-1307, USA.
22  *
23  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24  * All rights reserved.
25  *
26  * The Original Code is: all of this file.
27  *
28  * Contributor(s): none yet.
29  *
30  * ***** END GPL/BL DUAL LICENSE BLOCK *****
31  */
32
33 #include <stdlib.h>
34 #include <string.h>
35 #include <math.h>
36
37 #include <sys/types.h>
38
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
42
43 #include "MEM_guardedalloc.h"
44
45 #include "BMF_Api.h"
46 #include "BIF_language.h"
47 #ifdef INTERNATIONAL
48 #include "FTF_Api.h"
49 #endif
50
51 #include "BLI_blenlib.h"
52 #include "BLI_arithb.h"
53 #include "BLI_storage_types.h"
54
55 #include "IMB_imbuf_types.h"
56 #include "IMB_imbuf.h"
57
58 #include "DNA_ID.h"
59 #include "DNA_action_types.h"
60 #include "DNA_armature_types.h"
61 #include "DNA_camera_types.h"
62 #include "DNA_curve_types.h"
63 #include "DNA_group_types.h"
64 #include "DNA_image_types.h"
65 #include "DNA_ipo_types.h"
66 #include "DNA_key_types.h"
67 #include "DNA_lamp_types.h"
68 #include "DNA_lattice_types.h"
69 #include "DNA_material_types.h"
70 #include "DNA_mesh_types.h"
71 #include "DNA_meta_types.h"
72 #include "DNA_object_types.h"
73 #include "DNA_oops_types.h"
74 #include "DNA_packedFile_types.h"
75 #include "DNA_scene_types.h"
76 #include "DNA_screen_types.h"
77 #include "DNA_sequence_types.h"
78 #include "DNA_sound_types.h"
79 #include "DNA_space_types.h"
80 #include "DNA_texture_types.h"
81 #include "DNA_text_types.h"
82 #include "DNA_userdef_types.h"
83 #include "DNA_view2d_types.h"
84 #include "DNA_view3d_types.h"
85 #include "DNA_world_types.h"
86 #include "DNA_constraint_types.h"
87
88 #include "BKE_utildefines.h"
89
90 #include "BKE_constraint.h"
91 #include "BKE_action.h"
92 #include "BKE_armature.h"
93 #include "BKE_blender.h"
94 #include "BKE_curve.h"
95 #include "BKE_depsgraph.h"
96 #include "BKE_exotic.h"
97 #include "BKE_global.h"
98 #include "BKE_image.h"
99 #include "BKE_ipo.h"
100 #include "BKE_key.h"
101 #include "BKE_lattice.h"
102 #include "BKE_library.h"
103 #include "BKE_main.h"
104 #include "BKE_material.h"
105 #include "BKE_mball.h"
106 #include "BKE_mesh.h"
107 #include "BKE_object.h"
108 #include "BKE_packedFile.h"
109 #include "BKE_sca.h"
110 #include "BKE_scene.h"
111 #include "BKE_texture.h"
112 #include "BKE_text.h"
113 #include "BKE_world.h"
114
115 #include "BLO_readfile.h"
116 #include "BLO_writefile.h"
117
118 #include "BIF_drawimage.h"
119 #include "BIF_drawoops.h"
120 #include "BIF_drawscene.h"
121 #include "BIF_drawtext.h"
122 #include "BIF_editaction.h"
123 #include "BIF_editarmature.h"
124 #include "BIF_editfont.h"
125 #include "BIF_editlattice.h"
126 #include "BIF_editconstraint.h"
127 #include "BIF_editmesh.h"
128 #include "BIF_editmesh.h"
129 #include "BIF_editsima.h"
130 #include "BIF_editsound.h"
131 #include "BIF_gl.h"
132 #include "BIF_imasel.h"
133 #include "BIF_interface.h"
134 #include "BIF_mainqueue.h"
135 #include "BIF_mywindow.h"
136 #include "BIF_poseobject.h"
137 #include "BIF_renderwin.h"
138 #include "BIF_resources.h"
139 #include "BIF_screen.h"
140 #include "BIF_space.h"
141 #include "BIF_toets.h"
142 #include "BIF_toolbox.h"
143 #include "BIF_usiblender.h"
144 #include "BIF_previewrender.h"
145 #include "BIF_writeimage.h"
146 #include "BIF_butspace.h"
147
148 #include "BPI_script.h"
149
150 #include "BSE_edit.h"
151 #include "BSE_filesel.h"
152 #include "BSE_headerbuttons.h"
153 #include "BSE_view.h"
154 #include "BSE_sequence.h"
155 #include "BSE_editipo.h"
156 #include "BSE_drawipo.h"
157
158 #include "BDR_drawmesh.h"
159 #include "BDR_vpaint.h"
160 #include "BDR_editface.h"
161 #include "BDR_editobject.h"
162 #include "BDR_editcurve.h"
163 #include "BDR_editmball.h"
164
165 #include "BPY_extern.h"
166 #include "BPY_menus.h"
167
168 #include "mydevice.h"
169 #include "blendef.h"
170 #include "interface.h"
171 #include "nla.h"        /* __NLA : To be removed later */
172 #include "butspace.h"  // test_idbutton
173
174 #include "BIF_poseobject.h"
175
176 #include "SYS_System.h"
177
178  /* WATCH IT:  always give all headerbuttons for same window the same name
179         *                       event B_REDR is a standard redraw
180         *
181         */
182
183 char *windowtype_pup(void)
184 {
185         static char string[1024];
186
187         strcpy(string, "Window type:%t"); //14
188         strcat(string, "|3D View %x1"); //30
189
190         strcat(string, "|%l"); // 33
191
192         strcat(string, "|Ipo Curve Editor %x2"); //54
193         strcat(string, "|Action Editor %x12"); //73
194         strcat(string, "|NLA Editor %x13"); //94
195
196         strcat(string, "|%l"); //97
197
198         strcat(string, "|UV/Image Editor %x6"); //117
199
200         strcat(string, "|Video Sequence Editor %x8"); //143
201         strcat(string, "|Timeline %x15"); //163
202         strcat(string, "|Audio Window %x11"); //163
203         strcat(string, "|Text Editor %x9"); //179
204
205         strcat(string, "|%l"); //192
206
207
208         strcat(string, "|User Preferences %x7"); //213
209         strcat(string, "|Outliner %x3"); //232
210         strcat(string, "|Buttons Window %x4"); //251
211
212         strcat(string, "|%l"); //254
213
214         strcat(string, "|Image Browser %x10"); //273
215         strcat(string, "|File Browser %x5"); //290
216
217         strcat(string, "|%l"); //293
218
219         strcat(string, "|Scripts Window %x14"); //313
220
221         return (string);
222 }
223
224 int GetButStringLength(char *str) {
225         int rt;
226
227         rt= BIF_GetStringWidth(G.font, str, (U.transopts & USER_TR_BUTTONS));
228
229         return rt + 15;
230 }
231
232 /* ********************** GLOBAL ****************************** */
233
234 int std_libbuttons(uiBlock *block, short xco, short yco,
235                                                         int pin, short *pinpoin, int browse, ID *id,
236                                                         ID *parid, short *menupoin, int users, int lib,
237                                                         int del, int autobut, int keepbut)
238 {
239         ListBase *lb;
240         Object *ob;
241         Ipo *ipo;
242         uiBut *but;
243         int len, idwasnul=0, idtype, oldcol, add_addbutton=0;
244         char *str=NULL, str1[10];
245
246         uiBlockBeginAlign(block);
247         oldcol= uiBlockGetCol(block);
248
249         if(id && pin) {
250                 uiDefIconButS(block, ICONTOG, pin, ICON_PIN_DEHLT, xco,yco,XIC,YIC, pinpoin, 0, 0, 0, 0, "Keeps this view displaying the current data regardless of what object is selected");
251                 xco+= XIC;
252         }
253         if(browse) {
254                 if(id==0) {
255                         idwasnul= 1;
256                         /* only the browse button */
257                         ob= OBACT;
258                         if(curarea->spacetype==SPACE_IMAGE) {
259                                 id= G.main->image.first;
260                         }
261                         else if(curarea->spacetype==SPACE_SOUND) {
262                                 id= G.main->sound.first;
263                         }
264                         else if(curarea->spacetype==SPACE_ACTION) {
265                                 if(ob) id= G.main->action.first;
266                         }
267                         else if(curarea->spacetype==SPACE_NLA) {
268                                 id= NULL;
269                         }
270                         else if(curarea->spacetype==SPACE_IPO) {
271                                 id= G.main->ipo.first;
272                                 
273                                 /* test for ipotype */
274                                 while(id) {
275                                         ipo= (Ipo *)id;
276                                         if(G.sipo->blocktype==ipo->blocktype) break;
277                                         id= id->next;
278                                 }
279                                 if(ob==NULL) {
280                                         if(G.sipo->blocktype!=ID_SEQ && G.sipo->blocktype!=ID_WO) {
281                                                 id= NULL; 
282                                                 idwasnul= 0;
283                                         }
284                                 }
285                         }
286                         else if(curarea->spacetype==SPACE_BUTS) {
287                                 if(browse==B_WORLDBROWSE) {
288                                         id= G.main->world.first;
289                                 }
290                                 else if(ob && ob->type && (ob->type<=OB_LAMP)) {
291                                         if(G.buts->mainb==CONTEXT_SHADING) {
292                                                 int tab= G.buts->tab[CONTEXT_SHADING];
293                                                 
294                                                 if(tab==TAB_SHADING_MAT) id= G.main->mat.first;
295                                                 else if(tab==TAB_SHADING_TEX) id= G.main->tex.first;
296                                                 
297                                                 add_addbutton= 1;
298                                         }
299                                 }
300                         }
301                         else if(curarea->spacetype==SPACE_TEXT) {
302                                 id= G.main->text.first;
303                         }
304                         else if(curarea->spacetype==SPACE_SCRIPT) {
305                                 id= G.main->script.first;
306                         }
307                 }
308                 if(id) {
309                         char *extrastr= NULL;
310                         
311                         idtype= GS(id->name);
312                         lb= wich_libbase(G.main, GS(id->name));
313                         
314                         if(idwasnul) id= NULL;
315                         else if(id->us>1) uiBlockSetCol(block, TH_BUT_SETTING1);
316
317                         if (pin && *pinpoin) {
318                                 uiBlockSetCol(block, TH_BUT_SETTING2);
319                         }
320                         
321                         if ELEM7( idtype, ID_SCE, ID_SCR, ID_MA, ID_TE, ID_WO, ID_IP, ID_AC) extrastr= "ADD NEW %x 32767";
322                         else if (idtype==ID_TXT) extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767";
323                         else if (idtype==ID_SO) extrastr= "OPEN NEW %x 32766";
324                         
325                         uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
326                         if( idtype==ID_SCE || idtype==ID_SCR ) uiClearButLock();
327                         
328                         if(curarea->spacetype==SPACE_BUTS)
329                                 uiSetButLock(idtype!=ID_SCR && G.obedit!=0 && G.buts->mainb==CONTEXT_EDITING, NULL);
330                         
331                         if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
332
333                         if (lb) {
334                                 if( idtype==ID_IP)
335                                         IPOnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin, G.sipo->blocktype);
336                                 else
337                                         IDnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin);
338                         }
339                         
340                         uiDefButS(block, MENU, browse, str, xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses existing choices or adds NEW");
341                         
342                         uiClearButLock();
343                 
344                         MEM_freeN(str);
345                 }
346                 else if(curarea->spacetype==SPACE_BUTS) {
347                         if(G.buts->mainb==CONTEXT_SHADING) {
348                                 uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
349                                 if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
350                                 uiDefButS(block, MENU, browse, "ADD NEW %x 32767",xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
351                                 uiClearButLock();
352                         } else if (G.buts->mainb == CONTEXT_SCENE) {
353                                 if(G.buts->tab[CONTEXT_SCENE]== TAB_SCENE_SOUND) {
354                                         uiDefButS(block, MENU, browse, "OPEN NEW %x 32766",xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
355                                 }
356                         }
357                 }
358                 else if(curarea->spacetype==SPACE_TEXT) {
359                         uiDefButS(block, MENU, browse, "OPEN NEW %x 32766 | ADD NEW %x 32767", xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
360                 }
361                 else if(curarea->spacetype==SPACE_SCRIPT) {
362                         uiDefButS(block, MENU, browse, "No running scripts", xco, yco, XIC, YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
363                 }
364                 else if(curarea->spacetype==SPACE_SOUND) {
365                         uiDefButS(block, MENU, browse, "OPEN NEW %x 32766",xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
366                 }
367                 else if(curarea->spacetype==SPACE_ACTION) {
368                         uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
369                         if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
370
371                         uiDefButS(block, MENU, browse, "ADD NEW %x 32767", xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
372                         uiClearButLock();
373                 }
374                 else if(curarea->spacetype==SPACE_IPO) {
375                         if(idwasnul) {
376                                 uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
377                                 if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
378         
379                                 uiDefButS(block, MENU, browse, "ADD NEW %x 32767", xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
380                                 uiClearButLock();
381                         }
382                 }
383                 
384                 xco+= XIC;
385         }
386
387
388         uiBlockSetCol(block, oldcol);
389
390         if(id) {        /* text button with name */
391         
392                 /* name */
393                 if(id->us>1) uiBlockSetCol(block, TH_BUT_SETTING1);
394                 /* Pinned data ? */
395                 if (pin && *pinpoin) {
396                         uiBlockSetCol(block, TH_BUT_SETTING2);
397                 }
398                 /* Redalert overrides pin color */
399                 if(id->us<=0) uiBlockSetCol(block, TH_REDALERT);
400
401                 uiSetButLock(id->lib!=0, "Can't edit library data");
402                 
403                 str1[0]= id->name[0];
404                 str1[1]= id->name[1];
405                 str1[2]= ':';
406                 str1[3]= 0;
407                 if(strcmp(str1, "SC:")==0) strcpy(str1, "SCE:");
408                 else if(strcmp(str1, "SR:")==0) strcpy(str1, "SCR:");
409                 
410                 if( GS(id->name)==ID_IP) len= 110;
411                 else if(yco) len= 140;  // comes from button panel
412                 else len= 120;
413                 
414                 but= uiDefBut(block, TEX, B_IDNAME, str1,xco, yco, (short)len, YIC, id->name+2, 0.0, 19.0, 0, 0, "Displays current Datablock name. Click to change.");
415                 uiButSetFunc(but, test_idbutton_cb, id->name, NULL);
416
417                 uiClearButLock();
418
419                 xco+= len;
420                 
421                 if(id->lib) {
422                         
423                         if(parid && parid->lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB,xco,yco,XIC,YIC, 0, 0, 0, 0, 0, "Displays name of the current Indirect Library Datablock. Click to change.");
424                         else uiDefIconBut(block, BUT, lib, ICON_PARLIB, xco,yco,XIC,YIC, 0, 0, 0, 0, 0, "Displays current Library Datablock name. Click to make local.");
425                         
426                         xco+= XIC;
427                 }
428                 
429                 
430                 if(users && id->us>1) {
431                         uiSetButLock (pin && *pinpoin, "Can't make pinned data single-user");
432                         
433                         sprintf(str1, "%d", id->us);
434                         if(id->us<10) {
435                                 
436                                 uiDefBut(block, BUT, users, str1, xco,yco,XIC,YIC, 0, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
437                                 xco+= XIC;
438                         }
439                         else {
440                                 uiDefBut(block, BUT, users, str1, xco, yco, XIC+10, YIC, 0, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
441                                 xco+= XIC+10;
442                         }
443                         
444                         uiClearButLock();
445                         
446                 }
447                 
448                 if(del) {
449
450                         uiSetButLock (pin && *pinpoin, "Can't unlink pinned data");
451                         if(parid && parid->lib);
452                         else {
453                                 uiDefIconBut(block, BUT, del, ICON_X, xco,yco,XIC,YIC, 0, 0, 0, 0, 0, "Deletes link to this Datablock");
454                                 xco+= XIC;
455                         }
456
457                         uiClearButLock();
458                 }
459
460                 if(autobut) {
461                         if(parid && parid->lib);
462                         else {
463                                 uiDefIconBut(block, BUT, autobut, ICON_AUTO,xco,yco,XIC,YIC, 0, 0, 0, 0, 0, "Generates an automatic name");
464                                 xco+= XIC;
465                         }
466                         
467                         
468                 }
469                 if(keepbut) {
470                         uiDefBut(block, BUT, keepbut, "F", xco,yco,XIC,YIC, 0, 0, 0, 0, 0, "Saves this datablock even if it has no users");  
471                         xco+= XIC;
472                 }
473         }
474         else if(add_addbutton) {        /* "add new" button */
475                 uiBlockSetCol(block, oldcol);
476                 uiDefButS(block, TOG, browse, "Add New" ,xco, yco, 110, YIC, menupoin, (float)*menupoin, 32767.0, 0, 0, "Add new data block");
477                 xco+= 110;
478         }
479         //xco+=XIC;
480         
481         uiBlockSetCol(block, oldcol);
482         uiBlockEndAlign(block);
483
484         return xco;
485 }
486
487
488 /* results in fully updated anim system */
489 static void do_update_for_newframe(int mute, int events)
490 {
491         extern void audiostream_scrub(unsigned int frame);      /* seqaudio.c */
492         
493         if(events) {
494                 allqueue(REDRAWALL, 0);
495         }
496         
497         /* this function applies the changes too */
498         scene_update_for_newframe(G.scene, screen_view3d_layers()); /* BKE_scene.h */
499
500         if ( (CFRA>1) && (!mute) && (G.scene->audio.flag & AUDIO_SCRUB)) audiostream_scrub( CFRA );
501 }
502
503 void update_for_newframe(void)
504 {
505         do_update_for_newframe(0, 1);
506 }
507
508 void update_for_newframe_muted(void)
509 {
510         do_update_for_newframe(1, 1);
511 }
512
513 /* used by new animated UI playback */
514 void update_for_newframe_nodraw(int nosound)
515 {
516         do_update_for_newframe(nosound, 0);
517 }
518
519
520 static void show_splash(void)
521 {
522         extern char datatoc_splash_jpg[];
523         extern int datatoc_splash_jpg_size;
524         char *string = NULL;
525
526 #ifdef NAN_BUILDINFO
527         char buffer[1024];
528         extern char * build_date;
529         extern char * build_time;
530         extern char * build_platform;
531         extern char * build_type;
532
533         string = &buffer[0];
534         sprintf(string,"Built on %s %s     Version %s %s", build_date, build_time, build_platform, build_type);
535 #endif
536
537         splash((void *)datatoc_splash_jpg, datatoc_splash_jpg_size, string);
538 }
539
540
541 /* Functions for user preferences fileselect windows */
542
543 /* yafray: export dir select */
544 static void filesel_u_yfexportdir(char *name)
545 {
546         char dir[FILE_MAXDIR], file[FILE_MAXFILE];
547         BLI_split_dirfile(name, dir, file);
548
549         strcpy(U.yfexportdir, dir);
550         allqueue(REDRAWALL, 0);
551 }
552
553 static void filesel_u_fontdir(char *name)
554 {
555         char dir[FILE_MAXDIR], file[FILE_MAXFILE];
556         BLI_split_dirfile(name, dir, file);
557
558         strcpy(U.fontdir, dir);
559         allqueue(REDRAWALL, 0);
560 }
561
562 static void filesel_u_textudir(char *name)
563 {
564         char dir[FILE_MAXDIR], file[FILE_MAXFILE];
565         BLI_split_dirfile(name, dir, file);
566
567         strcpy(U.textudir, dir);
568         allqueue(REDRAWALL, 0);
569 }
570
571 static void filesel_u_plugtexdir(char *name)
572 {
573         char dir[FILE_MAXDIR], file[FILE_MAXFILE];
574         BLI_split_dirfile(name, dir, file);
575
576         strcpy(U.plugtexdir, dir);
577         allqueue(REDRAWALL, 0);
578 }
579
580 static void filesel_u_plugseqdir(char *name)
581 {
582         char dir[FILE_MAXDIR], file[FILE_MAXFILE];
583         BLI_split_dirfile(name, dir, file);
584
585         strcpy(U.plugseqdir, dir);
586         allqueue(REDRAWALL, 0);
587 }
588
589 static void filesel_u_renderdir(char *name)
590 {
591         char dir[FILE_MAXDIR], file[FILE_MAXFILE];
592         BLI_split_dirfile(name, dir, file);
593
594         strcpy(U.renderdir, dir);
595         allqueue(REDRAWALL, 0);
596 }
597
598 static void filesel_u_pythondir(char *name)
599 {
600         char dir[FILE_MAXDIR], file[FILE_MAXFILE];
601         BLI_split_dirfile(name, dir, file);
602
603         strcpy(U.pythondir, dir);
604         allqueue(REDRAWALL, 0);
605 }
606
607 static void filesel_u_sounddir(char *name)
608 {
609         char dir[FILE_MAXDIR], file[FILE_MAXFILE];
610         BLI_split_dirfile(name, dir, file);
611
612         strcpy(U.sounddir, dir);
613         allqueue(REDRAWALL, 0);
614 }
615
616 static void filesel_u_tempdir(char *name)
617 {
618         char dir[FILE_MAXDIR], file[FILE_MAXFILE];
619         BLI_split_dirfile(name, dir, file);
620
621         strcpy(U.tempdir, dir);
622         allqueue(REDRAWALL, 0);
623 }
624
625 /* END Functions for user preferences fileselect windows */
626
627
628 void do_global_buttons(unsigned short event)
629 {
630         ListBase *lb;
631         Object *ob;
632         Material *ma;
633         MTex *mtex;
634         Ipo *ipo;
635         Lamp *la;
636         World *wrld;
637         bAction *act;
638         ID *id, *idtest, *from=NULL;
639         ScrArea *sa;
640         int nr= 1;
641         char buf[FILE_MAXDIR+FILE_MAXFILE];
642
643         ob= OBACT;
644
645         id= NULL;       /* id at null for texbrowse */
646
647
648         switch(event) {
649         
650         case B_NEWFRAME:
651                 scrarea_queue_winredraw(curarea);
652                 scrarea_queue_headredraw(curarea);
653
654                 update_for_newframe();
655                 break;          
656         case B_REDR:
657                 scrarea_queue_winredraw(curarea);
658                 scrarea_queue_headredraw(curarea);
659                 break;
660         case B_REDRCURW3D:
661                 allqueue(REDRAWVIEW3D, 0);
662                 scrarea_queue_winredraw(curarea);
663                 scrarea_queue_headredraw(curarea);
664                 break;
665         case B_EDITBROWSE:
666                 if(ob==0) return;
667                 if(ob->id.lib) return;
668                 id= ob->data;
669                 if(id==0) return;
670
671                 if(G.buts->menunr== -2) {
672                         activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_EDITBROWSE, &G.buts->menunr, do_global_buttons);
673                         return;
674                 }
675                 if(G.buts->menunr < 0) return;
676                 
677                 lb= wich_libbase(G.main, GS(id->name));
678                 idtest= lb->first;
679                 while(idtest) {
680                         if(nr==G.buts->menunr) {
681                                 if(idtest!=id) {
682                                         id->us--;
683                                         id_us_plus(idtest);
684                                         
685                                         ob->data= idtest;
686                                         
687                                         test_object_materials(idtest);
688                                         
689                                         if( GS(idtest->name)==ID_CU ) {
690                                                 test_curve_type(ob);
691                                         }
692                                         else if( ob->type==OB_ARMATURE) {
693                                                 armature_rebuild_pose(ob, ob->data);
694                                         }
695                                         DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
696                                         
697                                         allqueue(REDRAWBUTSEDIT, 0);
698                                         allqueue(REDRAWVIEW3D, 0);
699                                         allqueue(REDRAWACTION,0);
700                                         allqueue(REDRAWIPO, 0);
701                                         allqueue(REDRAWNLA,0);
702                                 }
703                                 break;
704                         }
705                         nr++;
706                         idtest= idtest->next;
707                 }
708
709                 break;
710         case B_MESHBROWSE:
711                 if(ob==0) return;
712                 if(ob->id.lib) return;
713                 
714                 id= ob->data;
715                 if(id==0) id= G.main->mesh.first;
716                 if(id==0) return;
717                 
718                 if(G.buts->menunr== -2) {
719                         activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_MESHBROWSE, &G.buts->menunr, do_global_buttons);
720                         return;
721                 }
722                 if(G.buts->menunr < 0) return;
723                 
724
725                 idtest= G.main->mesh.first;
726                 while(idtest) {
727                         if(nr==G.buts->menunr) {
728                                 set_mesh(ob, (Mesh *)idtest);
729                                 
730                                 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
731                                         
732                                 BIF_undo_push("Browse Mesh");
733                                 allqueue(REDRAWBUTSEDIT, 0);
734                                 allqueue(REDRAWVIEW3D, 0);
735                                 allqueue(REDRAWACTION,0);
736                                 allqueue(REDRAWIPO, 0);
737
738                                 break;
739                         }
740                         nr++;
741                         idtest= idtest->next;
742                 }
743
744                 break;
745         case B_MATBROWSE:
746                 if(G.buts->menunr== -2) {
747                         activate_databrowse((ID *)G.buts->lockpoin, ID_MA, 0, B_MATBROWSE, &G.buts->menunr, do_global_buttons);
748                         return;
749                 }
750                 
751                 if(G.buts->menunr < 0) return;
752                 
753                 if(G.buts->pin) {
754                         
755                 }
756                 else {
757                         
758                         ma= give_current_material(ob, ob->actcol);
759                         nr= 1;
760                         
761                         id= (ID *)ma;
762                         
763                         idtest= G.main->mat.first;
764                         while(idtest) {
765                                 if(nr==G.buts->menunr) {
766                                         break;
767                                 }
768                                 nr++;
769                                 idtest= idtest->next;
770                         }
771                         if(idtest==0) { /* new mat */
772                                 if(id)  idtest= (ID *)copy_material((Material *)id);
773                                 else {
774                                         idtest= (ID *)add_material("Material");
775                                 }
776                                 idtest->us--;
777                         }
778                         if(idtest!=id) {
779                                 assign_material(ob, (Material *)idtest, ob->actcol);
780                                 
781                                 BIF_undo_push("Browse Material");
782                                 allqueue(REDRAWBUTSSHADING, 0);
783                                 allqueue(REDRAWIPO, 0);
784                                 BIF_preview_changed(G.buts);
785                         }
786                         
787                 }
788                 break;
789         case B_MATDELETE:
790                 if(G.buts->pin) {
791                         
792                 }
793                 else {
794                         ma= give_current_material(ob, ob->actcol);
795                         if(ma) {
796                                 assign_material(ob, 0, ob->actcol);
797                                 BIF_undo_push("Unlink Material");
798                                 allqueue(REDRAWBUTSSHADING, 0);
799                                 allqueue(REDRAWIPO, 0);
800                                 allqueue(REDRAWOOPS, 0);
801                                 BIF_preview_changed(G.buts);
802                         }
803                 }
804                 break;
805         case B_TEXDELETE:
806                 if(G.buts->pin) {
807                         
808                 }
809                 else {
810                         if(G.buts->texfrom==0) {        /* from mat */
811                                 ma= give_current_material(ob, ob->actcol);
812                                 if(ma) {
813                                         mtex= ma->mtex[ ma->texact ];
814                                         if(mtex) {
815                                                 if(mtex->tex) mtex->tex->id.us--;
816                                                 MEM_freeN(mtex);
817                                                 ma->mtex[ ma->texact ]= NULL;
818                                                 allqueue(REDRAWBUTSSHADING, 0);
819                                                 allqueue(REDRAWIPO, 0);
820                                                 BIF_preview_changed(G.buts);
821                                         }
822                                 }
823                         }
824                         else if(G.buts->texfrom==1) { /* from world */
825                                 wrld= G.scene->world;
826                                 if(wrld) {
827                                         mtex= wrld->mtex[ wrld->texact ];
828                                         if(mtex) {
829                                                 if(mtex->tex) mtex->tex->id.us--;
830                                                 MEM_freeN(mtex);
831                                                 wrld->mtex[ wrld->texact ]= NULL;
832                                                 allqueue(REDRAWBUTSSHADING, 0);
833                                                 allqueue(REDRAWIPO, 0);
834                                                 BIF_preview_changed(G.buts);
835                                         }
836                                 }
837                         }
838                         else {  /* from lamp */
839                                 la= ob->data;
840                                 if(la && ob->type==OB_LAMP) { /* to be sure */
841                                         mtex= la->mtex[ la->texact ];
842                                         if(mtex) {
843                                                 if(mtex->tex) mtex->tex->id.us--;
844                                                 MEM_freeN(mtex);
845                                                 la->mtex[ la->texact ]= NULL;
846                                                 allqueue(REDRAWBUTSSHADING, 0);
847                                                 allqueue(REDRAWIPO, 0);
848                                                 BIF_preview_changed(G.buts);
849                                         }
850                                 }
851                         }
852                         BIF_undo_push("Unlink Texture");
853                 }
854                 break;
855         case B_EXTEXBROWSE: 
856         case B_TEXBROWSE:
857
858                 if(G.buts->texnr== -2) {
859                         
860                         id= G.buts->lockpoin;
861                         if(event==B_EXTEXBROWSE) {
862                                 id= NULL;
863                                 ma= give_current_material(ob, ob->actcol);
864                                 if(ma) {
865                                         mtex= ma->mtex[ ma->texact ];
866                                         if(mtex) id= (ID *)mtex->tex;
867                                 }
868                         }
869                         
870                         activate_databrowse(id, ID_TE, 0, B_TEXBROWSE, &G.buts->texnr, do_global_buttons);
871                         return;
872                 }
873                 if(G.buts->texnr < 0) break;
874                 
875                 if(G.buts->pin) {
876                         
877                 }
878                 else {
879                         id= NULL;
880                         
881                         ma= give_current_material(ob, ob->actcol);
882                         if(ma) {
883                                 mtex= ma->mtex[ ma->texact ];
884                                 if(mtex) id= (ID *)mtex->tex;
885                         }
886
887                         idtest= G.main->tex.first;
888                         while(idtest) {
889                                 if(nr==G.buts->texnr) {
890                                         break;
891                                 }
892                                 nr++;
893                                 idtest= idtest->next;
894                         }
895                         if(idtest==0) { /* new tex */
896                                 if(id)  idtest= (ID *)copy_texture((Tex *)id);
897                                 else idtest= (ID *)add_texture("Tex");
898                                 idtest->us--;
899                         }
900                         if(idtest!=id && ma) {
901                                 
902                                 if( ma->mtex[ma->texact]==0) ma->mtex[ma->texact]= add_mtex();
903                                 
904                                 ma->mtex[ ma->texact ]->tex= (Tex *)idtest;
905                                 id_us_plus(idtest);
906                                 if(id) id->us--;
907                                 
908                                 BIF_undo_push("Browse Texture");
909                                 allqueue(REDRAWBUTSSHADING, 0);
910                                 allqueue(REDRAWIPO, 0);
911                                 allqueue(REDRAWOOPS, 0);
912                                 BIF_preview_changed(G.buts);
913                         }
914                 }
915                 break;
916         case B_ACTIONDELETE:
917                 act=ob->action;
918                 
919                 if (act)
920                         act->id.us--;
921                 ob->action=NULL;
922                 if(ob->pose) {          // clear flag, also used for draw colors
923                         bPoseChannel *pchan;
924                         for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next)
925                                 pchan->flag= 0;
926                 }
927                 BIF_undo_push("Unlink Action");
928                 
929                 allqueue(REDRAWVIEW3D, 0);
930                 allqueue(REDRAWACTION, 0);
931                 allqueue(REDRAWNLA, 0);
932                 allqueue(REDRAWIPO, 0);
933                 break;
934         case B_ACTIONBROWSE:
935                 if (!ob)
936                         break;
937                 act=ob->action;
938                 id= (ID *)act;
939
940                 if (G.saction->actnr== -2){
941                                 activate_databrowse((ID *)G.saction->action, ID_AC,  0, B_ACTIONBROWSE, &G.saction->actnr, do_global_buttons);
942                         return;
943                 }
944
945                 if(G.saction->actnr < 0) break;
946
947                 /*      See if we have selected a valid action */
948                 for (idtest= G.main->action.first; idtest; idtest= idtest->next) {
949                                 if(nr==G.saction->actnr) {
950                                         break;
951                                 }
952                                 nr++;
953                         
954                 }
955
956                 if(G.saction->pin) {
957                         G.saction->action= (bAction *)idtest;
958                         allqueue(REDRAWACTION, 0);
959                 }
960                 else {
961
962                         /* Store current action */
963                         if (!idtest){
964                                 if (act)
965                                         idtest= (ID *)copy_action(act);
966                                 else 
967                                         idtest=(ID *)add_empty_action(ob->type==OB_ARMATURE?ID_PO:ID_OB);
968                                 idtest->us--;
969                         }
970                         
971                         
972                         if(idtest!=id && ob) {
973                                 act= (bAction *)idtest;
974                                 
975                                 ob->action= act;
976                                 id_us_plus(idtest);
977                                 
978                                 if(id) id->us--;
979                                 
980                                 // Update everything
981                                 BIF_undo_push("Browse Action");
982                                 do_global_buttons (B_NEWFRAME);
983                                 allqueue(REDRAWVIEW3D, 0);
984                                 allqueue(REDRAWNLA, 0);
985                                 allqueue(REDRAWACTION, 0);
986                                 allqueue(REDRAWHEADERS, 0); 
987                         }
988                 }
989                 
990                 break;
991         case B_IPOBROWSE:
992
993                 ipo= G.sipo->ipo;
994                 from= G.sipo->from;
995                 id= (ID *)ipo;
996                 if(from==NULL) return;
997
998                 if(G.sipo->menunr== -2) {
999                         activate_databrowse((ID *)G.sipo->ipo, ID_IP, GS(from->name), B_IPOBROWSE, &G.sipo->menunr, do_global_buttons);
1000                         return;
1001                 }
1002
1003                 if(G.sipo->menunr < 0) break;
1004
1005                 idtest= G.main->ipo.first;
1006                 while(idtest) {
1007                         if( ((Ipo *)idtest)->blocktype == G.sipo->blocktype) {
1008                                 if(nr==G.sipo->menunr) {
1009                                         break;
1010                                 }
1011                                 nr++;
1012                         }
1013                         idtest= idtest->next;
1014                 }
1015
1016                 if(G.sipo->pin) {
1017                         if(idtest) {
1018                                 G.sipo->ipo= (Ipo *)idtest;
1019                                 allspace(REMAKEIPO, 0);         // in fact it should only do this one, but there is no function for it
1020                         }
1021                 }
1022                 else {
1023                         // assign the ipo to ...
1024
1025                         if(idtest==0) {
1026                                 if(ipo) idtest= (ID *)copy_ipo(ipo);
1027                                 else {
1028                                         nr= G.sipo->blocktype;
1029                                         if(nr==ID_OB) idtest= (ID *)add_ipo("ObIpo", ID_OB);
1030                                         else if(nr==ID_CO) idtest= (ID *)add_ipo("CoIpo", ID_CO);
1031                                         else if(nr==ID_PO) idtest= (ID *)add_ipo("ActIpo", nr);
1032                                         else if(nr==ID_MA) idtest= (ID *)add_ipo("MatIpo", nr);
1033                                         else if(nr==ID_TE) idtest= (ID *)add_ipo("TexIpo", nr);
1034                                         else if(nr==ID_SEQ) idtest= (ID *)add_ipo("MatSeq", nr);
1035                                         else if(nr==ID_CU) idtest= (ID *)add_ipo("CuIpo", nr);
1036                                         else if(nr==ID_KE) idtest= (ID *)add_ipo("KeyIpo", nr);
1037                                         else if(nr==ID_WO) idtest= (ID *)add_ipo("WoIpo", nr);
1038                                         else if(nr==ID_LA) idtest= (ID *)add_ipo("LaIpo", nr);
1039                                         else if(nr==ID_CA) idtest= (ID *)add_ipo("CaIpo", nr);
1040                                         else if(nr==ID_SO) idtest= (ID *)add_ipo("SndIpo", nr);
1041                                         else error("Warn bugtracker!");
1042                                 }
1043                                 idtest->us--;
1044                         }
1045                         if(idtest!=id && from) {
1046                                 spaceipo_assign_ipo(G.sipo, (Ipo *)idtest);
1047                                                                         
1048                                 BIF_undo_push("Browse Ipo");
1049                         }
1050                 }
1051                 break;
1052         case B_IPODELETE:
1053                 ipo= G.sipo->ipo;
1054                 from= G.sipo->from;
1055                 
1056                 spaceipo_assign_ipo(G.sipo, NULL);
1057                 
1058                 editipo_changed(G.sipo, 1); /* doredraw */
1059                 
1060                 BIF_undo_push("Unlink Ipo");
1061                 
1062                 break;
1063         case B_WORLDBROWSE:
1064
1065                 if(G.buts->menunr==-2) {
1066                         activate_databrowse((ID *)G.scene->world, ID_WO, 0, B_WORLDBROWSE, &G.buts->menunr, do_global_buttons);
1067                         break;
1068                 }
1069
1070                 if(G.buts->menunr < 0) break;
1071                 /* no lock */
1072                         
1073                 wrld= G.scene->world;
1074                 nr= 1;
1075                 
1076                 id= (ID *)wrld;
1077                 
1078                 idtest= G.main->world.first;
1079                 while(idtest) {
1080                         if(nr==G.buts->menunr) {
1081                                 break;
1082                         }
1083                         nr++;
1084                         idtest= idtest->next;
1085                 }
1086                 if(idtest==0) { /* new world */
1087                         if(id) idtest= (ID *)copy_world((World *)id);
1088                         else idtest= (ID *)add_world("World");
1089                         idtest->us--;
1090                 }
1091                 if(idtest!=id) {
1092                         G.scene->world= (World *)idtest;
1093                         id_us_plus(idtest);
1094                         if(id) id->us--;
1095                         
1096                         BIF_undo_push("Browse World");
1097                         allqueue(REDRAWBUTSSHADING, 0);
1098                         allqueue(REDRAWIPO, 0);
1099                         allqueue(REDRAWOOPS, 0);
1100                         BIF_preview_changed(G.buts);
1101                 }
1102                 break;
1103         case B_WORLDDELETE:
1104                 if(G.scene->world) {
1105                         G.scene->world->id.us--;
1106                         G.scene->world= NULL;
1107
1108                         BIF_undo_push("Unlink World");
1109                         allqueue(REDRAWBUTSSHADING, 0);
1110                         allqueue(REDRAWIPO, 0);
1111                 }
1112                 
1113                 break;
1114         case B_WTEXBROWSE:
1115
1116                 if(G.buts->texnr== -2) {
1117                         id= NULL;
1118                         wrld= G.scene->world;
1119                         if(wrld) {
1120                                 mtex= wrld->mtex[ wrld->texact ];
1121                                 if(mtex) id= (ID *)mtex->tex;
1122                         }
1123
1124                         activate_databrowse((ID *)id, ID_TE, 0, B_WTEXBROWSE, &G.buts->texnr, do_global_buttons);
1125                         return;
1126                 }
1127                 if(G.buts->texnr < 0) break;
1128
1129                 if(G.buts->pin) {
1130                         
1131                 }
1132                 else {
1133                         id= NULL;
1134                         
1135                         wrld= G.scene->world;
1136                         if(wrld) {
1137                                 mtex= wrld->mtex[ wrld->texact ];
1138                                 if(mtex) id= (ID *)mtex->tex;
1139                         }
1140
1141                         idtest= G.main->tex.first;
1142                         while(idtest) {
1143                                 if(nr==G.buts->texnr) {
1144                                         break;
1145                                 }
1146                                 nr++;
1147                                 idtest= idtest->next;
1148                         }
1149                         if(idtest==0) { /* new tex */
1150                                 if(id)  idtest= (ID *)copy_texture((Tex *)id);
1151                                 else idtest= (ID *)add_texture("Tex");
1152                                 idtest->us--;
1153                         }
1154                         if(idtest!=id && wrld) {
1155                                 
1156                                 if( wrld->mtex[wrld->texact]==0) {
1157                                         wrld->mtex[wrld->texact]= add_mtex();
1158                                         wrld->mtex[wrld->texact]->texco= TEXCO_VIEW;
1159                                 }
1160                                 wrld->mtex[ wrld->texact ]->tex= (Tex *)idtest;
1161                                 id_us_plus(idtest);
1162                                 if(id) id->us--;
1163                                 
1164                                 BIF_undo_push("Texture browse");
1165                                 allqueue(REDRAWBUTSSHADING, 0);
1166                                 allqueue(REDRAWIPO, 0);
1167                                 allqueue(REDRAWOOPS, 0);
1168                                 BIF_preview_changed(G.buts);
1169                         }
1170                 }
1171                 break;
1172         case B_LAMPBROWSE:
1173                 /* no lock */
1174                 if(ob==0) return;
1175                 if(ob->type!=OB_LAMP) return;
1176
1177                 if(G.buts->menunr== -2) {
1178                         activate_databrowse((ID *)G.buts->lockpoin, ID_LA, 0, B_LAMPBROWSE, &G.buts->menunr, do_global_buttons);
1179                         return;
1180                 }
1181                 if(G.buts->menunr < 0) break;
1182                 
1183                 la= ob->data;
1184                 nr= 1;
1185                 id= (ID *)la;
1186                 
1187                 idtest= G.main->lamp.first;
1188                 while(idtest) {
1189                         if(nr==G.buts->menunr) {
1190                                 break;
1191                         }
1192                         nr++;
1193                         idtest= idtest->next;
1194                 }
1195                 if(idtest==0) { /* no new lamp */
1196                         return;
1197                 }
1198                 if(idtest!=id) {
1199                         ob->data= (Lamp *)idtest;
1200                         id_us_plus(idtest);
1201                         if(id) id->us--;
1202                         
1203                         BIF_undo_push("Lamp browse");
1204                         allqueue(REDRAWBUTSSHADING, 0);
1205                         allqueue(REDRAWVIEW3D, 0);
1206                         allqueue(REDRAWIPO, 0);
1207                         allqueue(REDRAWOOPS, 0);
1208                         BIF_preview_changed(G.buts);
1209                 }
1210                 break;
1211         
1212         case B_LTEXBROWSE:
1213
1214                 if(ob==0) return;
1215                 if(ob->type!=OB_LAMP) return;
1216
1217                 if(G.buts->texnr== -2) {
1218                         id= NULL;
1219                         la= ob->data;
1220                         mtex= la->mtex[ la->texact ];
1221                         if(mtex) id= (ID *)mtex->tex;
1222
1223                         activate_databrowse(id, ID_TE, 0, B_LTEXBROWSE, &G.buts->texnr, do_global_buttons);
1224                         return;
1225                 }
1226                 if(G.buts->texnr < 0) break;
1227
1228                 if(G.buts->pin) {
1229                         
1230                 }
1231                 else {
1232                         id= NULL;
1233                         
1234                         la= ob->data;
1235                         mtex= la->mtex[ la->texact ];
1236                         if(mtex) id= (ID *)mtex->tex;
1237
1238                         idtest= G.main->tex.first;
1239                         while(idtest) {
1240                                 if(nr==G.buts->texnr) {
1241                                         break;
1242                                 }
1243                                 nr++;
1244                                 idtest= idtest->next;
1245                         }
1246                         if(idtest==0) { /* new tex */
1247                                 if(id)  idtest= (ID *)copy_texture((Tex *)id);
1248                                 else idtest= (ID *)add_texture("Tex");
1249                                 idtest->us--;
1250                         }
1251                         if(idtest!=id && la) {
1252                                 
1253                                 if( la->mtex[la->texact]==0) {
1254                                         la->mtex[la->texact]= add_mtex();
1255                                         la->mtex[la->texact]->texco= TEXCO_GLOB;
1256                                 }
1257                                 la->mtex[ la->texact ]->tex= (Tex *)idtest;
1258                                 id_us_plus(idtest);
1259                                 if(id) id->us--;
1260                                 
1261                                 BIF_undo_push("Texture Browse");
1262                                 allqueue(REDRAWBUTSSHADING, 0);
1263                                 allqueue(REDRAWIPO, 0);
1264                                 allqueue(REDRAWOOPS, 0);
1265                                 BIF_preview_changed(G.buts);
1266                         }
1267                 }
1268                 break;
1269         
1270         case B_IMAGEDELETE:
1271                 G.sima->image= NULL;
1272                 image_changed(G.sima, 0);
1273                 BIF_undo_push("Unlink Image");
1274                 allqueue(REDRAWIMAGE, 0);
1275                 break;
1276         
1277         case B_AUTOMATNAME:
1278                 automatname(G.buts->lockpoin);
1279
1280                 BIF_undo_push("Auto name");
1281                 allqueue(REDRAWBUTSSHADING, 0);
1282                 allqueue(REDRAWOOPS, 0);
1283                 break;          
1284         case B_AUTOTEXNAME:
1285                 if(G.buts->mainb==CONTEXT_SHADING) {
1286                         if(G.buts->tab[CONTEXT_SHADING]==TAB_SHADING_TEX) {
1287                                 autotexname(G.buts->lockpoin);
1288                         }
1289                         else if(G.buts->tab[CONTEXT_SHADING]==TAB_SHADING_MAT) {
1290                                 ma= G.buts->lockpoin;
1291                                 if(ma->mtex[ ma->texact]) autotexname(ma->mtex[ma->texact]->tex);
1292                         }
1293                         else if(G.buts->tab[CONTEXT_SHADING]==TAB_SHADING_WORLD) {
1294                                 wrld= G.buts->lockpoin;
1295                                 if(wrld->mtex[ wrld->texact]) autotexname(wrld->mtex[wrld->texact]->tex);
1296                         }
1297                         else if(G.buts->tab[CONTEXT_SHADING]==TAB_SHADING_LAMP) {
1298                                 la= G.buts->lockpoin;
1299                                 if(la->mtex[ la->texact]) autotexname(la->mtex[la->texact]->tex);
1300                         }
1301                         BIF_undo_push("Auto name");
1302                         allqueue(REDRAWBUTSSHADING, 0);
1303                         allqueue(REDRAWOOPS, 0);
1304                 }
1305                 break;
1306
1307         case B_RESETAUTOSAVE:
1308                 reset_autosave();
1309                 allqueue(REDRAWINFO, 0);
1310                 break;
1311         case B_SOUNDTOGGLE:
1312                 SYS_WriteCommandLineInt(SYS_GetSystem(), "noaudio", (U.gameflags & USER_DISABLE_SOUND));
1313                 break;
1314         case B_SHOWSPLASH:
1315                                 show_splash();
1316                 break;
1317         case B_MIPMAPCHANGED:
1318                 set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
1319                 allqueue(REDRAWVIEW3D, 0);
1320                 break;
1321         case B_NEWSPACE:
1322                 newspace(curarea, curarea->butspacetype);
1323                 break;
1324         case B_LOADTEMP:        /* is button from space.c */
1325                 BIF_read_autosavefile();
1326                 break;
1327
1328         case B_USERPREF:
1329                 allqueue(REDRAWINFO, 0);
1330                 break;
1331
1332         case B_DRAWINFO:        /* is button from space.c  *info* */
1333                 allqueue(REDRAWVIEW3D, 0);
1334                 break;
1335
1336         case B_FLIPINFOMENU:    /* is button from space.c  *info* */
1337                 scrarea_queue_headredraw(curarea);
1338                 break;
1339
1340 #if 0
1341 //#ifdef _WIN32 // FULLSCREEN
1342         case B_FLIPFULLSCREEN:
1343                 if(U.uiflag & USER_FLIPFULLSCREEN)
1344                         U.uiflag &= ~USER_FLIPFULLSCREEN;
1345                 else
1346                         U.uiflag |= USER_FLIPFULLSCREEN;
1347                 mainwindow_toggle_fullscreen((U.uiflag & USER_FLIPFULLSCREEN));
1348                 break;
1349 #endif
1350
1351         /* Fileselect windows for user preferences file paths */
1352
1353         /* yafray: xml export dir. select */
1354         case B_YAFRAYDIRFILESEL:        /* space.c */
1355                 if(curarea->spacetype==SPACE_INFO) {
1356                         sa= closest_bigger_area();
1357                         areawinset(sa->win);
1358                 }
1359
1360                 activate_fileselect(FILE_SPECIAL, "SELECT YFEXPORT PATH", U.yfexportdir, filesel_u_yfexportdir);
1361                 break;
1362
1363         case B_FONTDIRFILESEL:  /* is button from space.c  *info* */
1364                 if(curarea->spacetype==SPACE_INFO) {
1365                         sa= closest_bigger_area();
1366                         areawinset(sa->win);
1367                 }
1368
1369                 activate_fileselect(FILE_SPECIAL, "SELECT FONT PATH", U.fontdir, filesel_u_fontdir);
1370                 break;
1371
1372         case B_TEXTUDIRFILESEL:         /* is button from space.c  *info* */
1373                 if(curarea->spacetype==SPACE_INFO) {
1374                         sa= closest_bigger_area();
1375                         areawinset(sa->win);
1376                 }
1377
1378                 activate_fileselect(FILE_SPECIAL, "SELECT TEXTURE PATH", U.textudir, filesel_u_textudir);
1379                 break;
1380         
1381         case B_PLUGTEXDIRFILESEL:               /* is button form space.c  *info* */
1382                 if(curarea->spacetype==SPACE_INFO) {
1383                         sa= closest_bigger_area();
1384                         areawinset(sa->win);
1385                 }
1386
1387                 activate_fileselect(FILE_SPECIAL, "SELECT TEX PLUGIN PATH", U.plugtexdir, filesel_u_plugtexdir);
1388                 break;
1389         
1390         case B_PLUGSEQDIRFILESEL:               /* is button from space.c  *info* */
1391                 if(curarea->spacetype==SPACE_INFO) {
1392                         sa= closest_bigger_area();
1393                         areawinset(sa->win);
1394                 }
1395
1396                 activate_fileselect(FILE_SPECIAL, "SELECT SEQ PLUGIN PATH", U.plugseqdir, filesel_u_plugseqdir);
1397                 break;
1398         
1399         case B_RENDERDIRFILESEL:        /* is button from space.c  *info* */
1400                 if(curarea->spacetype==SPACE_INFO) {
1401                         sa= closest_bigger_area();
1402                         areawinset(sa->win);
1403                 }
1404
1405                 activate_fileselect(FILE_SPECIAL, "SELECT RENDER PATH", U.renderdir, filesel_u_renderdir);
1406                 break;
1407
1408         case B_PYMENUEVAL: /* is button from space.c *info* */
1409                 BPyMenu_RemoveAllEntries(); /* free old data */
1410                 if (BPyMenu_Init(1) == -1) /* re-eval scripts registration in menus */
1411                         error("Invalid scripts dir: check console");
1412                 break;
1413         case B_PYTHONDIRFILESEL:        /* is button from space.c  *info* */
1414                 if(curarea->spacetype==SPACE_INFO) {
1415                         sa= closest_bigger_area();
1416                         areawinset(sa->win);
1417                 }
1418
1419                 activate_fileselect(FILE_SPECIAL, "SELECT SCRIPT PATH", U.pythondir, filesel_u_pythondir);
1420                 break;
1421
1422         case B_SOUNDDIRFILESEL:         /* is button from space.c  *info* */
1423                 if(curarea->spacetype==SPACE_INFO) {
1424                         sa= closest_bigger_area();
1425                         areawinset(sa->win);
1426                 }
1427
1428                 activate_fileselect(FILE_SPECIAL, "SELECT SOUND PATH", U.sounddir, filesel_u_sounddir);
1429                 break;
1430
1431         case B_TEMPDIRFILESEL:  /* is button from space.c  *info* */
1432                 if(curarea->spacetype==SPACE_INFO) {
1433                         sa= closest_bigger_area();
1434                         areawinset(sa->win);
1435                 }
1436
1437                 activate_fileselect(FILE_SPECIAL, "SELECT TEMP FILE PATH", U.tempdir, filesel_u_tempdir);
1438                 break;
1439
1440         /* END Fileselect windows for user preferences file paths */
1441
1442 #ifdef INTERNATIONAL
1443         case B_LOADUIFONT:      /* is button from space.c  *info* */
1444                 if(curarea->spacetype==SPACE_INFO) {
1445                         sa= closest_bigger_area();
1446                         areawinset(sa->win);
1447                 }
1448                 BLI_make_file_string("/", buf, U.fontdir, U.fontname);
1449                 activate_fileselect(FILE_SPECIAL, "LOAD UI FONT", buf, set_interface_font);
1450                 break;
1451
1452         case B_SETLANGUAGE:             /* is button from space.c  *info* */
1453                 lang_setlanguage();
1454                 allqueue(REDRAWALL, 0);
1455                 break;
1456
1457         case B_SETFONTSIZE:             /* is button from space.c  *info* */
1458                 refresh_interface_font();
1459                 FTF_SetSize(U.fontsize); 
1460                 allqueue(REDRAWALL, 0);
1461                 break;
1462                 
1463         case B_SETTRANSBUTS:    /* is button from space.c  *info* */
1464                 allqueue(REDRAWALL, 0);
1465                 break;
1466
1467         case B_RESTOREFONT:             /* is button from space.c  *info* */
1468                 U.fontsize= 0;
1469                 start_interface_font();
1470                 allqueue(REDRAWALL, 0);
1471                 break;
1472                 
1473         case B_USETEXTUREFONT:          /* is button from space.c  *info* */
1474                 refresh_interface_font();
1475                 allqueue(REDRAWALL, 0);
1476                 break;
1477
1478         case B_DOLANGUIFONT:    /* is button from space.c  *info* */
1479                 if(U.transopts & USER_DOTRANSLATE)
1480                         start_interface_font();
1481                 else
1482                         G.ui_international = FALSE;
1483                 allqueue(REDRAWALL, 0);
1484                 break;
1485 #endif
1486                 
1487         case B_FULL:
1488                 if(curarea->spacetype!=SPACE_INFO) {
1489                         area_fullscreen();
1490                 }
1491                 break;  
1492
1493         case B_IDNAME:
1494                         /* changing a metaballs name, sadly enough,
1495                          * can require it to be updated because its
1496                          * basis might have changed... -zr
1497                          */
1498                 if (ob && ob->type==OB_MBALL)
1499                         DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1500                         
1501                 /* redraw because name has changed: new pup */
1502                 scrarea_queue_headredraw(curarea);
1503                 allqueue(REDRAWINFO, 1);
1504                 allqueue(REDRAWOOPS, 1);
1505                 allqueue(REDRAWACTION, 1);
1506                 allqueue(REDRAWNLA, 1);
1507                 /* name scene also in set PUPmenu */
1508                 allqueue(REDRAWBUTSALL, 0);
1509                 allqueue(REDRAWHEADERS, 0);
1510
1511                 break;
1512         
1513         case B_KEEPDATA:
1514                 /* keep datablock. similar to pressing FKEY in a fileselect window
1515                  * maybe we can move that stuff to a seperate function? -- sg
1516                  */
1517                 if (curarea->spacetype==SPACE_BUTS) {
1518                         id= (ID *)G.buts->lockpoin;
1519                 } else if(curarea->spacetype==SPACE_IPO) {
1520                         id = (ID *)G.sipo->ipo;
1521                 } /* similar for other spacetypes ? */
1522                 if (id) {
1523                         if( id->flag & LIB_FAKEUSER) {
1524                                 id->flag -= LIB_FAKEUSER;
1525                                 id->us--;
1526                         } else {
1527                                 id->flag |= LIB_FAKEUSER;
1528                                 id->us++;
1529                         }
1530                 }
1531                 allqueue(REDRAWHEADERS, 0);
1532
1533                 break;
1534
1535         }
1536 }
1537
1538
1539 void do_global_buttons2(short event)
1540 {
1541         Base *base;
1542         Object *ob;
1543         Material *ma;
1544         MTex *mtex;
1545         Mesh *me;
1546         Curve *cu;
1547         MetaBall *mb;
1548         Ipo *ipo;
1549         Lamp *la;
1550         Lattice *lt;
1551         World *wrld;
1552         ID *idfrom; 
1553         bAction *act;
1554
1555         /* general:  Single User is allowed when from==LOCAL 
1556          *                       Make Local is allowed when (from==LOCAL && id==LIB)
1557          */
1558                 
1559         if(event<B_LOCAL_ALONE) return;
1560
1561         ob= OBACT;
1562
1563         switch(event) {
1564                 
1565         case B_LAMPALONE:
1566                 if(ob && ob->id.lib==0) {
1567                         la= ob->data;
1568                         if(la->id.us>1) {
1569                                 if(okee("Single user")) {
1570                                         ob->data= copy_lamp(la);
1571                                         la->id.us--;
1572                                 }
1573                         }
1574                 }
1575                 break;
1576         case B_LAMPLOCAL:
1577                 if(ob && ob->id.lib==0) {
1578                         la= ob->data;
1579                         if(la->id.lib) {
1580                                 if(okee("Make local")) {
1581                                         make_local_lamp(la);
1582                                 }
1583                         }
1584                 }
1585                 break;
1586         
1587         case B_ARMLOCAL:
1588                 if (ob&&ob->id.lib==0){
1589                         bArmature *arm=ob->data;
1590                         if (arm->id.lib){
1591                                 if(okee("Make local")) {
1592                                         make_local_armature(arm);
1593                                 }
1594                         }
1595                 }
1596                 break;
1597         case B_ARMALONE:
1598                 if(ob && ob->id.lib==0) {
1599                         bArmature *arm=ob->data;
1600                         if(arm->id.us>1) {
1601                                 if(okee("Single user")) {
1602                                         ob->data= copy_armature(arm);
1603                                         armature_rebuild_pose(ob, ob->data);
1604                                         arm->id.us--;
1605                                 }
1606                         }
1607                 }
1608                 break;
1609         case B_ACTLOCAL:
1610                 if(ob && ob->id.lib==0) {
1611                         act= ob->action;
1612                         if(act->id.lib) {
1613                                 if(okee("Make local")) {
1614                                         make_local_action(act);
1615                                         allqueue(REDRAWACTION,0);
1616                                 }
1617                         }
1618                 }
1619                 break;
1620         case B_ACTALONE:
1621                 if(ob && ob->id.lib==0) {
1622                         act= ob->action;
1623                 
1624                         if(act->id.us>1) {
1625                                 if(okee("Single user")) {
1626                                         ob->action=copy_action(act);
1627                                         act->id.us--;
1628                                         allqueue(REDRAWACTION, 0);
1629                                 }
1630                         }
1631                 }
1632                 break;
1633
1634         case B_CAMERAALONE:
1635                 if(ob && ob->id.lib==0) {
1636                         Camera *ca= ob->data;
1637                         if(ca->id.us>1) {
1638                                 if(okee("Single user")) {
1639                                         ob->data= copy_camera(ca);
1640                                         ca->id.us--;
1641                                 }
1642                         }
1643                 }
1644                 break;
1645         case B_CAMERALOCAL:
1646                 if(ob && ob->id.lib==0) {
1647                         Camera *ca= ob->data;
1648                         if(ca->id.lib) {
1649                                 if(okee("Make local")) {
1650                                         make_local_camera(ca);
1651                                 }
1652                         }
1653                 }
1654                 break;
1655         case B_WORLDALONE:
1656                 wrld= G.scene->world;
1657                 if(wrld->id.us>1) {
1658                         if(okee("Single user")) {
1659                                 G.scene->world= copy_world(wrld);
1660                                 wrld->id.us--;
1661                         }
1662                 }
1663                 break;
1664         case B_WORLDLOCAL:
1665                 wrld= G.scene->world;
1666                 if(wrld && wrld->id.lib) {
1667                         if(okee("Make local")) {
1668                                 make_local_world(wrld);
1669                         }
1670                 }
1671                 break;
1672
1673         case B_LATTALONE:
1674                 if(ob && ob->id.lib==0) {
1675                         lt= ob->data;
1676                         if(lt->id.us>1) {
1677                                 if(okee("Single user")) {
1678                                         ob->data= copy_lattice(lt);
1679                                         lt->id.us--;
1680                                 }
1681                         }
1682                 }
1683                 break;
1684         case B_LATTLOCAL:
1685                 if(ob && ob->id.lib==0) {
1686                         lt= ob->data;
1687                         if(lt->id.lib) {
1688                                 if(okee("Make local")) {
1689                                         make_local_lattice(lt);
1690                                 }
1691                         }
1692                 }
1693                 break;
1694         
1695         case B_MATALONE:
1696                 if(ob==0) return;
1697                 ma= give_current_material(ob, ob->actcol);
1698                 idfrom= material_from(ob, ob->actcol);
1699                 if(idfrom && idfrom->lib==0) {
1700                         if(ma->id.us>1) {
1701                                 if(okee("Single user")) {
1702                                         ma= copy_material(ma);
1703                                         ma->id.us= 0;
1704                                         assign_material(ob, ma, ob->actcol);
1705                                 }
1706                         }
1707                 }
1708                 break;
1709         case B_MATLOCAL:
1710                 if(ob==0) return;
1711                 idfrom= material_from(ob, ob->actcol);
1712                 if(idfrom->lib==0) {
1713                         ma= give_current_material(ob, ob->actcol);
1714                         if(ma && ma->id.lib) {
1715                                 if(okee("Make local")) {
1716                                         make_local_material(ma);
1717                                 }
1718                         }
1719                 }
1720                 break;
1721
1722         case B_MESHLOCAL:
1723                 if(ob && ob->id.lib==0) {
1724                         me= ob->data;
1725                         if(me && me->id.lib) {
1726                                 if(okee("Make local")) {
1727                                         make_local_mesh(me);
1728                                         make_local_key( me->key );
1729
1730                                         DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);                           
1731                                 }
1732                         }
1733                 }
1734                 break;
1735
1736         case B_MBALLALONE:
1737                 if(ob && ob->id.lib==0) {
1738                         mb= ob->data;
1739                         if(mb->id.us>1) {
1740                                 if(okee("Single user")) {
1741                                         ob->data= copy_mball(mb);
1742                                         mb->id.us--;
1743                                         if(ob==G.obedit) allqueue(REDRAWVIEW3D, 0);
1744                                 }
1745                         }
1746                 }
1747                 break;
1748         case B_MBALLLOCAL:
1749                 if(ob && ob->id.lib==0) {
1750                         mb= ob->data;
1751                         if(mb->id.lib) {
1752                                 if(okee("Make local")) {
1753                                         make_local_mball(mb);
1754                                 }
1755                         }
1756                 }
1757                 break;
1758
1759         case B_CURVEALONE:
1760                 if(ob && ob->id.lib==0) {
1761                         cu= ob->data;
1762                         if(cu->id.us>1) {
1763                                 if(okee("Single user")) {
1764                                         ob->data= copy_curve(cu);
1765                                         cu->id.us--;
1766                                         DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1767                                         if(ob==G.obedit) allqueue(REDRAWVIEW3D, 0);
1768                                 }
1769                         }
1770                 }
1771                 break;
1772         case B_CURVELOCAL:
1773                 if(ob && ob->id.lib==0) {
1774                         cu= ob->data;
1775                         if(cu->id.lib) {
1776                                 if(okee("Make local")) {
1777                                         make_local_curve(cu);
1778                                         make_local_key( cu->key );
1779                                         DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1780                                 }
1781                         }
1782                 }
1783                 break;
1784                 
1785         case B_TEXALONE:
1786                 if(G.buts->texfrom==0) {        /* from mat */
1787                         if(ob==0) return;
1788                         ma= give_current_material(ob, ob->actcol);
1789                         if(ma && ma->id.lib==0) {
1790                                 mtex= ma->mtex[ ma->texact ];
1791                                 if(mtex->tex && mtex->tex->id.us>1) {
1792                                         if(okee("Single user")) {
1793                                                 mtex->tex->id.us--;
1794                                                 mtex->tex= copy_texture(mtex->tex);
1795                                         }
1796                                 }
1797                         }
1798                 }
1799                 else if(G.buts->texfrom==1) { /* from world */
1800                         wrld= G.scene->world;
1801                         if(wrld->id.lib==0) {
1802                                 mtex= wrld->mtex[ wrld->texact ];
1803                                 if(mtex->tex && mtex->tex->id.us>1) {
1804                                         if(okee("Single user")) {
1805                                                 mtex->tex->id.us--;
1806                                                 mtex->tex= copy_texture(mtex->tex);
1807                                         }
1808                                 }
1809                         }
1810                 }
1811                 else if(G.buts->texfrom==2) { /* from lamp */
1812                         if(ob==0 || ob->type!=OB_LAMP) return;
1813                         la= ob->data;
1814                         if(la->id.lib==0) {
1815                                 mtex= la->mtex[ la->texact ];
1816                                 if(mtex->tex && mtex->tex->id.us>1) {
1817                                         if(okee("Single user")) {
1818                                                 mtex->tex->id.us--;
1819                                                 mtex->tex= copy_texture(mtex->tex);
1820                                         }
1821                                 }
1822                         }
1823                 }
1824                 break;
1825         case B_TEXLOCAL:
1826                 if(G.buts->texfrom==0) {        /* from mat */
1827                         if(ob==0) return;
1828                         ma= give_current_material(ob, ob->actcol);
1829                         if(ma && ma->id.lib==0) {
1830                                 mtex= ma->mtex[ ma->texact ];
1831                                 if(mtex->tex && mtex->tex->id.lib) {
1832                                         if(okee("Make local")) {
1833                                                 make_local_texture(mtex->tex);
1834                                         }
1835                                 }
1836                         }
1837                 }
1838                 else if(G.buts->texfrom==1) { /* from world */
1839                         wrld= G.scene->world;
1840                         if(wrld->id.lib==0) {
1841                                 mtex= wrld->mtex[ wrld->texact ];
1842                                 if(mtex->tex && mtex->tex->id.lib) {
1843                                         if(okee("Make local")) {
1844                                                 make_local_texture(mtex->tex);
1845                                         }
1846                                 }
1847                         }
1848                 }
1849                 else if(G.buts->texfrom==2) { /* from lamp */
1850                         if(ob==0 || ob->type!=OB_LAMP) return;
1851                         la= ob->data;
1852                         if(la->id.lib==0) {
1853                                 mtex= la->mtex[ la->texact ];
1854                                 if(mtex->tex && mtex->tex->id.lib) {
1855                                         if(okee("Make local")) {
1856                                                 make_local_texture(mtex->tex);
1857                                         }
1858                                 }
1859                         }
1860                 }
1861                 break;
1862         
1863         case B_IPOALONE:
1864                 ipo= G.sipo->ipo;
1865                 idfrom= G.sipo->from;
1866                 
1867                 if(idfrom && idfrom->lib==NULL) {
1868                         if(ipo->id.us>1) {
1869                                 if(okee("Single user")) {
1870                                         if(ipo->blocktype==ID_OB) ((Object *)idfrom)->ipo= copy_ipo(ipo);
1871                                         else if(ipo->blocktype==ID_MA) ((Material *)idfrom)->ipo= copy_ipo(ipo);
1872                                         else if(ipo->blocktype==ID_TE) ((Tex *)idfrom)->ipo= copy_ipo(ipo);
1873                                         else if(ipo->blocktype==ID_SEQ) ((Sequence *)idfrom)->ipo= copy_ipo(ipo);
1874                                         else if(ipo->blocktype==ID_CU) ((Curve *)idfrom)->ipo= copy_ipo(ipo);
1875                                         else if(ipo->blocktype==ID_KE) ((Key *)idfrom)->ipo= copy_ipo(ipo);
1876                                         else if(ipo->blocktype==ID_LA) ((Lamp *)idfrom)->ipo= copy_ipo(ipo);
1877                                         else if(ipo->blocktype==ID_WO) ((World *)idfrom)->ipo= copy_ipo(ipo);
1878                                         else if(ipo->blocktype==ID_CA) ((Camera *)idfrom)->ipo= copy_ipo(ipo);
1879                                         else if(ipo->blocktype==ID_SO) ((bSound *)idfrom)->ipo= copy_ipo(ipo);
1880                                         else if(ipo->blocktype==ID_AC) 
1881                                                 get_hilighted_action_channel((bAction *)idfrom)->ipo= copy_ipo(ipo);
1882                                         else if(ipo->blocktype==ID_CO) 
1883                                                 get_active_constraint_channel((Object*)idfrom)->ipo= copy_ipo(ipo);
1884                                         else error("Warn bugtracker!");
1885                                         
1886                                         ipo->id.us--;
1887                                         allqueue(REDRAWIPO, 0);
1888                                 }
1889                         }
1890                 }
1891                 break;
1892         case B_IPOLOCAL:
1893                 ipo= G.sipo->ipo;
1894                 idfrom= G.sipo->from;
1895                 
1896                 if(idfrom && idfrom->lib==0) {
1897                         if(ipo->id.lib) {
1898                                 if(okee("Make local")) {
1899                                         make_local_ipo(ipo);
1900                                         allqueue(REDRAWIPO, 0);
1901                                 }
1902                         }
1903                 }
1904                 break;
1905
1906         case B_OBALONE:
1907                 if(G.scene->id.lib==0) {
1908                         if(ob->id.us>1) {
1909                                 if(okee("Single user")) {
1910                                         base= FIRSTBASE;
1911                                         while(base) {
1912                                                 if(base->object==ob) {
1913                                                         base->object= copy_object(ob);
1914                                                         ob->id.us--;
1915                                                         allqueue(REDRAWVIEW3D, 0);
1916                                                         break;
1917                                                 }
1918                                                 base= base->next;
1919                                         }
1920                                 }
1921                         }
1922                 }
1923                 break;
1924         case B_OBLOCAL:
1925                 if(G.scene->id.lib==0) {
1926                         if(ob->id.lib) {
1927                                 if(okee("Make local")) {
1928                                         make_local_object(ob);
1929                                         allqueue(REDRAWVIEW3D, 0);
1930                                 }
1931                         }
1932                 }
1933                 break;
1934         case B_MESHALONE:
1935                 if(ob && ob->id.lib==0) {
1936                         
1937                         me= ob->data;
1938                         
1939                         if(me && me->id.us>1) {
1940                                 if(okee("Single user")) {
1941                                         Mesh *men= copy_mesh(me);
1942                                         men->id.us= 0;
1943                                         
1944                                         set_mesh(ob, men);
1945                                         
1946                                         DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1947                                         
1948                                         if(ob==G.obedit) allqueue(REDRAWVIEW3D, 0);
1949                                 }
1950                         }
1951                 }
1952                 break;
1953         }
1954         
1955         BIF_undo_push("Make single user or local");
1956         allqueue(REDRAWBUTSALL, 0);
1957         allqueue(REDRAWOOPS, 0);
1958 }
1959
1960 /* ******************** GENERAL ********************** */
1961
1962 void do_headerbuttons(short event)
1963 {
1964
1965         if(event<=50) do_global_buttons2(event);
1966         else if(event<=100) do_global_buttons(event);
1967         else if(event<200) do_view3d_buttons(event);
1968         else if(event<250) do_ipo_buttons(event);
1969         else if(event<300) do_oops_buttons(event);
1970         else if(event<350) do_info_buttons(event);
1971         else if(event<400) do_image_buttons(event);
1972         else if(event<450) do_buts_buttons(event);
1973         else if(event<500) do_imasel_buttons(event);
1974         else if(event<525) do_text_buttons(event);
1975         else if(event<550) do_script_buttons(event);
1976         else if(event<600) do_file_buttons(event);
1977         else if(event<650) do_seq_buttons(event);
1978         else if(event<700) do_sound_buttons(event);
1979         else if(event<750) do_action_buttons(event);
1980         else if(event<800) do_time_buttons(curarea, event);
1981         else if(event<900) do_nla_buttons(event);
1982         else if(event>=REDRAWVIEW3D) allqueue(event, 0);
1983 }
1984