editors/space_* build without unused args warnings
[blender.git] / source / blender / editors / space_info / space_info.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. 
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * The Original Code is Copyright (C) 2008 Blender Foundation.
21  * All rights reserved.
22  *
23  * 
24  * Contributor(s): Blender Foundation
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #include <string.h>
30 #include <stdio.h>
31
32
33 #include "MEM_guardedalloc.h"
34
35 #include "BLI_blenlib.h"
36 #include "BLI_math.h"
37 #include "BLI_rand.h"
38
39 #include "BKE_context.h"
40 #include "BKE_global.h"
41 #include "BKE_screen.h"
42
43 #include "ED_screen.h"
44
45 #include "BIF_gl.h"
46
47 #include "WM_api.h"
48 #include "WM_types.h"
49
50 #include "UI_resources.h"
51 #include "UI_interface.h"
52
53
54 #include "info_intern.h"        // own include
55
56 /* ******************** default callbacks for info space ***************** */
57
58 static SpaceLink *info_new(const bContext *UNUSED(C))
59 {
60         ARegion *ar;
61         SpaceInfo *sinfo;
62         
63         sinfo= MEM_callocN(sizeof(SpaceInfo), "initinfo");
64         sinfo->spacetype= SPACE_INFO;
65         
66         /* header */
67         ar= MEM_callocN(sizeof(ARegion), "header for info");
68         
69         BLI_addtail(&sinfo->regionbase, ar);
70         ar->regiontype= RGN_TYPE_HEADER;
71         ar->alignment= RGN_ALIGN_BOTTOM;
72         
73         /* main area */
74         ar= MEM_callocN(sizeof(ARegion), "main area for info");
75         
76         BLI_addtail(&sinfo->regionbase, ar);
77         ar->regiontype= RGN_TYPE_WINDOW;
78         
79         return (SpaceLink *)sinfo;
80 }
81
82 /* not spacelink itself */
83 static void info_free(SpaceLink *UNUSED(sl))
84 {       
85 //      SpaceInfo *sinfo= (SpaceInfo*) sl;
86         
87 }
88
89
90 /* spacetype; init callback */
91 static void info_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
92 {
93
94 }
95
96 static SpaceLink *info_duplicate(SpaceLink *sl)
97 {
98         SpaceInfo *sinfon= MEM_dupallocN(sl);
99         
100         /* clear or remove stuff from old */
101         
102         return (SpaceLink *)sinfon;
103 }
104
105
106
107 /* add handlers, stuff you only do once or on area/region changes */
108 static void info_main_area_init(wmWindowManager *UNUSED(wm), ARegion *UNUSED(ar))
109 {
110 }
111
112 static void info_main_area_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar))
113 {
114         
115         /* clear and setup matrix */
116         UI_ThemeClearColor(TH_BACK);
117         glClear(GL_COLOR_BUFFER_BIT);
118 }
119
120 void info_operatortypes(void)
121 {
122         WM_operatortype_append(FILE_OT_pack_all);
123         WM_operatortype_append(FILE_OT_unpack_all);
124         WM_operatortype_append(FILE_OT_make_paths_relative);
125         WM_operatortype_append(FILE_OT_make_paths_absolute);
126         WM_operatortype_append(FILE_OT_report_missing_files);
127         WM_operatortype_append(FILE_OT_find_missing_files);
128         
129         WM_operatortype_append(INFO_OT_reports_display_update);
130 }
131
132 void info_keymap(struct wmKeyConfig *keyconf)
133 {
134         wmKeyMap *keymap= WM_keymap_find(keyconf, "Window", 0, 0);
135         
136         WM_keymap_verify_item(keymap, "INFO_OT_reports_display_update", TIMER, KM_ANY, KM_ANY, 0);
137 }
138
139 /* add handlers, stuff you only do once or on area/region changes */
140 static void info_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar)
141 {
142         ED_region_header_init(ar);
143 }
144
145 static void info_header_area_draw(const bContext *C, ARegion *ar)
146 {
147         ED_region_header(C, ar);
148 }
149
150 static void info_main_area_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn))
151 {
152         /* context changes */
153 }
154
155 static void info_header_listener(ARegion *ar, wmNotifier *wmn)
156 {
157         /* context changes */
158         switch(wmn->category) {
159                 case NC_SCREEN:
160                         if(ELEM(wmn->data, ND_SCREENCAST, ND_ANIMPLAY))
161                                 ED_region_tag_redraw(ar);
162                         break;
163                 case NC_WM:     
164                         if(wmn->data == ND_JOB)
165                                 ED_region_tag_redraw(ar);
166                         break;
167                 case NC_SCENE:
168                         if(wmn->data==ND_RENDER_RESULT)
169                                 ED_region_tag_redraw(ar);
170                         break;
171                 case NC_SPACE:  
172                         if(wmn->data == ND_SPACE_INFO)
173                                 ED_region_tag_redraw(ar);
174                         break;
175                 case NC_ID:
176                         if(wmn->action == NA_RENAME)
177                                 ED_region_tag_redraw(ar);
178         }
179         
180 }
181
182 static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu)
183 {
184         struct RecentFile *recent;
185         uiLayout *layout= menu->layout;
186         uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
187         if (G.recent_files.first) {
188                 for(recent = G.recent_files.first; (recent); recent = recent->next) {
189                         uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
190                 }
191         } else {
192                 uiItemL(layout, "No Recent Files", 0);
193         }
194 }
195
196 void recent_files_menu_register()
197 {
198         MenuType *mt;
199
200         mt= MEM_callocN(sizeof(MenuType), "spacetype info menu recent files");
201         strcpy(mt->idname, "INFO_MT_file_open_recent");
202         strcpy(mt->label, "Open Recent...");
203         mt->draw= recent_files_menu_draw;
204         WM_menutype_add(mt);
205 }
206
207 /* only called once, from space/spacetypes.c */
208 void ED_spacetype_info(void)
209 {
210         SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype info");
211         ARegionType *art;
212         
213         st->spaceid= SPACE_INFO;
214         strncpy(st->name, "Info", BKE_ST_MAXNAME);
215         
216         st->new= info_new;
217         st->free= info_free;
218         st->init= info_init;
219         st->duplicate= info_duplicate;
220         st->operatortypes= info_operatortypes;
221         st->keymap= info_keymap;
222         
223         /* regions: main window */
224         art= MEM_callocN(sizeof(ARegionType), "spacetype info region");
225         art->regionid = RGN_TYPE_WINDOW;
226         art->init= info_main_area_init;
227         art->draw= info_main_area_draw;
228         art->listener= info_main_area_listener;
229         art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
230
231         BLI_addhead(&st->regiontypes, art);
232         
233         /* regions: header */
234         art= MEM_callocN(sizeof(ARegionType), "spacetype info region");
235         art->regionid = RGN_TYPE_HEADER;
236         art->prefsizey= HEADERY;
237         
238         art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER;
239         art->listener= info_header_listener;
240         art->init= info_header_area_init;
241         art->draw= info_header_area_draw;
242         
243         BLI_addhead(&st->regiontypes, art);
244         
245         recent_files_menu_register();
246
247         BKE_spacetype_register(st);
248 }
249