~diresu/blender/blender-command-port

« back to all changes in this revision

Viewing changes to source/blender/src/imasel.c

  • Committer: theeth
  • Date: 2008-10-14 16:52:04 UTC
  • Revision ID: vcs-imports@canonical.com-20081014165204-r32w2gm6s0osvdhn
copy back trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * $Id: imasel.c 14711 2008-05-06 19:29:37Z elubie $
 
3
 *
 
4
 * ***** BEGIN GPL LICENSE BLOCK *****
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software Foundation,
 
18
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
19
 *
 
20
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 
21
 * All rights reserved.
 
22
 *
 
23
 * The Original Code is: all of this file.
 
24
 *
 
25
 * Contributor(s): none yet.
 
26
 *
 
27
 * ***** END GPL LICENSE BLOCK *****
 
28
 */
 
29
 
 
30
#include <stdio.h>
 
31
#include <stdlib.h>
 
32
#include <string.h>
 
33
 
 
34
#ifndef WIN32
 
35
#include <unistd.h>
 
36
#else
 
37
#include "BLI_winstuff.h"
 
38
#include <io.h>
 
39
#include <direct.h>
 
40
#endif   
 
41
#include <fcntl.h>
 
42
#include "MEM_guardedalloc.h"
 
43
 
 
44
#include "BLI_blenlib.h"
 
45
#include "BLI_arithb.h"
 
46
 
 
47
#include "IMB_imbuf_types.h"
 
48
#include "IMB_imbuf.h"
 
49
 
 
50
#include "DNA_screen_types.h"
 
51
#include "DNA_space_types.h"
 
52
 
 
53
#include "BKE_utildefines.h"
 
54
#include "BKE_global.h"
 
55
 
 
56
#include "BIF_imasel.h"
 
57
#include "BIF_filelist.h"
 
58
#include "BIF_space.h"
 
59
#include "BIF_screen.h"
 
60
 
 
61
#include "blendef.h"
 
62
#include "mydevice.h"
 
63
 
 
64
 
 
65
void free_imasel(SpaceImaSel *simasel)
 
66
{
 
67
        /* do not free imasel itself */
 
68
        if(simasel->files) {
 
69
                BIF_filelist_freelib(simasel->files);
 
70
                BIF_filelist_free(simasel->files);
 
71
                MEM_freeN(simasel->files);
 
72
                simasel->files = NULL;
 
73
        }
 
74
        if (simasel->img) {
 
75
                IMB_freeImBuf(simasel->img);
 
76
        }
 
77
        if(simasel->pupmenu) {
 
78
                MEM_freeN(simasel->pupmenu);
 
79
                simasel->pupmenu = NULL;                
 
80
        }
 
81
}
 
82
 
 
83
/* resets a previous imagebrowser space type */
 
84
/* is used when opening an imagebrowser directly from windowtype_pupmenu,
 
85
   since in that case we don't want any load/save/append/link action
 
86
*/
 
87
void reset_imaselspace(ScrArea *sa) 
 
88
{
 
89
        if(sa->spacetype==SPACE_IMASEL) {
 
90
                SpaceImaSel *simasel= sa->spacedata.first;
 
91
                if(simasel->type==FILE_MAIN) {
 
92
                        if (simasel->files) {
 
93
                                BIF_filelist_free(simasel->files);
 
94
                                BIF_filelist_settype(simasel->files, FILE_MAIN);
 
95
                        }
 
96
                } else {
 
97
                        if (simasel->files) {
 
98
                                simasel->type= FILE_UNIX;
 
99
                                BIF_filelist_settype(simasel->files, simasel->type);
 
100
                        }
 
101
                }
 
102
                simasel->returnfunc= NULL;
 
103
                simasel->title[0]= 0;
 
104
        }
 
105
}