Fixed warnings and removed unnecessary include files.
[AROS.git] / workbench / system / AboutAROS / aboutaros.c
blob19a4f25f043d469647b3d27166b11172bc6a74ed
1 /*
2 Copyright © 2003-2011, The AROS Development Team. All rights reserved.
3 This file is part of the About program, which is distributed under
4 the terms of version 2 of the GNU General Public License.
6 $Id$
7 */
9 #define MUIMASTER_YES_INLINE_STDARG
11 #include <aros/debug.h>
12 #include <aros/build.h>
13 #include <aros/inquire.h>
14 #include <exec/types.h>
15 #include <utility/tagitem.h>
16 #include <libraries/mui.h>
18 #include <proto/alib.h>
19 #include <proto/aros.h>
20 #include <proto/exec.h>
21 #include <proto/dos.h>
22 #include <proto/intuition.h>
23 #include <proto/utility.h>
24 #include <proto/muimaster.h>
25 #include <proto/workbench.h>
27 #include <zune/aboutwindow.h>
28 #include <zune/customclasses.h>
30 #include <stdio.h>
31 #include <string.h>
33 #include "aboutaros.h"
34 #include "locale.h"
35 #include "logotype.h"
37 #include "authors.h"
38 #include "sponsors.h"
39 #include "acknowledgements.h"
41 #define VERSION "$VER: AboutAROS 0.1 ("ADATE") ©AROS Dev Team"
43 #define WINDOW_BG ((IPTR) "2:00000000,00000000,00000000")
44 #define REGISTER_BG ((IPTR) "7:V,00000000,92000000,91000000-00000000,82000000,81000000")
45 #define LIST_BG ((IPTR) "2:00000000,82000000,81000000")
47 #define SETUP_INST_DATA struct AboutAROS_DATA *data = INST_DATA(CLASS, self)
49 /*** Private methods ********************************************************/
50 #define MUIM_AboutAROS_ShowLicense (TAG_USER | 0x20000000)
52 /*** Instance Data **********************************************************/
53 struct AboutAROS_DATA
55 Object *aad_Window;
56 APTR aad_Pool;
59 /*** Utility Functions ******************************************************/
60 STRPTR Section2Name(ULONG section)
62 switch (section)
64 case SID_COORDINATION: return _(MSG_SECTION_COORDINATION);
65 case SID_EVANGELISM: return _(MSG_SECTION_EVANGELISM);
66 case SID_HIDD: return _(MSG_SECTION_HIDD);
67 case SID_INTUITION: return _(MSG_SECTION_INTUITION);
68 case SID_GRAPHICS: return _(MSG_SECTION_GRAPHICS);
69 case SID_SHELL_COMMANDS: return _(MSG_SECTION_SHELL_COMMANDS);
70 case SID_WORKBENCH: return _(MSG_SECTION_WORKBENCH);
71 case SID_TOOLS: return _(MSG_SECTION_TOOLS);
72 case SID_PREFERENCES: return _(MSG_SECTION_PREFERENCES);
73 case SID_BGUI: return _(MSG_SECTION_BGUI);
74 case SID_ZUNE: return _(MSG_SECTION_ZUNE);
75 case SID_KERNEL: return _(MSG_SECTION_KERNEL);
76 case SID_DOS: return _(MSG_SECTION_DOS);
77 case SID_NETWORKING: return _(MSG_SECTION_NETWORK);
78 case SID_LIBC_POSIX: return _(MSG_SECTION_LIBC_POSIX);
79 case SID_DOCUMENTATION: return _(MSG_SECTION_DOCUMENTATION);
80 case SID_TRANSLATION: return _(MSG_SECTION_TRANSLATION);
81 case SID_ARTISTRY: return _(MSG_SECTION_ARTISTRY);
82 case SID_WEBSITE: return _(MSG_SECTION_WEBSITE);
83 case SID_DATATYPES: return _(MSG_SECTION_DATATYPES);
84 case SID_TESTING: return _(MSG_SECTION_TESTING);
85 default: return NULL;
89 BOOL NamesToList
91 Object *list, struct TagItem *tags, struct AboutAROS_DATA *data
94 struct TagItem *tstate = tags;
95 struct TagItem *tag = NULL;
96 BOOL success = TRUE;
97 IPTR section = SID_NONE;
98 STRPTR sectionName = NULL;
99 BOOL sectionFirst = TRUE;
100 STRPTR name;
101 STRPTR buffer;
102 ULONG length = 0;
104 if (tags == NULL) return FALSE;
106 while ((tag = NextTagItem(&tstate)) != NULL && success == TRUE)
108 switch (tag->ti_Tag)
110 case SECTION_ID:
111 section = tag->ti_Data;
112 sectionName = Section2Name(section);
114 if (sectionName != NULL)
116 sectionFirst
117 ? sectionFirst = FALSE
118 : DoMethod
120 list, MUIM_List_InsertSingle, (IPTR) "",
121 MUIV_List_Insert_Bottom
124 length = strlen(MUIX_B) + strlen(sectionName) + 1;
125 buffer = AllocPooled(data->aad_Pool, length);
126 if (buffer != NULL)
128 buffer[0] = '\0';
129 strcat(buffer, MUIX_B);
130 strcat(buffer, sectionName);
132 DoMethod
134 list, MUIM_List_InsertSingle,
135 (IPTR) buffer, MUIV_List_Insert_Bottom
138 else
140 success = FALSE;
141 break;
145 break;
147 case NAME_STRING:
148 name = (STRPTR) tag->ti_Data;
150 length = strlen(name) + 1;
151 if (sectionName != NULL) length += 4;
153 buffer = AllocPooled(data->aad_Pool, length);
154 if (buffer != NULL)
156 buffer[0] = '\0';
157 if (sectionName != NULL) strcat(buffer, " ");
158 strcat(buffer, name);
160 DoMethod
162 list, MUIM_List_InsertSingle,
163 (IPTR) buffer, MUIV_List_Insert_Bottom
166 else
168 success = FALSE;
169 break;
172 break;
176 return success;
179 /*** Methods ****************************************************************/
180 Object *AboutAROS__OM_NEW(Class *CLASS, Object *self, struct opSet *message)
182 Object *window,
183 *licenseButton,
184 *authorsList,
185 *sponsorsList,
186 *acknowledgementsList;
188 STRPTR pages[4] = { NULL };
189 STRPTR str_builddate;
190 STRPTR str_variant;
191 STRPTR str_arosarch;
192 STRPTR str_buildtype;
193 IPTR abiversion;
194 STRPTR str_abi;
195 BOOL showLogotype;
196 BPTR lock;
197 APTR pool;
199 /* Allocate memory pool ------------------------------------------------*/
200 pool = CreatePool(MEMF_ANY, 4096, 4096);
201 if (pool == NULL) return NULL;
203 /* Check if the logotype is available ----------------------------------*/
204 if ((lock = Lock(LOGOTYPE_IMAGE, ACCESS_READ)) != BNULL)
206 showLogotype = TRUE;
207 UnLock(lock);
209 else
211 showLogotype = FALSE;
214 /* Retrieve the build date and the variant name ------------------------*/
215 ArosInquire(AI_ArosBuildDate, (IPTR) &str_builddate,
216 AI_ArosVariant, (IPTR) &str_variant,
217 AI_ArosArchitecture, (IPTR) &str_arosarch,
218 AI_ArosABIMajor, (IPTR) &abiversion,
219 TAG_DONE);
221 str_buildtype = AllocPooled(pool, strlen(_(MSG_BUILD_TYPE)) + strlen(str_arosarch) + 1);
222 sprintf(str_buildtype, _(MSG_BUILD_TYPE), str_arosarch);
223 if (abiversion != -1)
225 str_abi = AllocPooled(pool, 7 + 1);
226 sprintf(str_abi, "ABI_V%d", (int)abiversion);
228 else
229 str_abi = "ABI_WIP";
232 /* Initialize page labels ----------------------------------------------*/
233 pages[0] = _(MSG_PAGE_AUTHORS);
234 pages[1] = _(MSG_PAGE_SPONSORS);
235 pages[2] = _(MSG_PAGE_ACKNOWLEDGEMENTS);
237 /* Create application and window objects -------------------------------*/
238 self = (Object *) DoSuperNewTags
240 CLASS, self, NULL,
242 MUIA_Application_Title, __(MSG_TITLE),
243 MUIA_Application_Version, (IPTR)VERSION,
244 MUIA_Application_Copyright, (IPTR)"© 2010, The AROS Development Team",
245 MUIA_Application_Description, __(MSG_TITLE),
246 MUIA_Application_Base, (IPTR) "ABOUTAROS",
247 SubWindow, (IPTR) (window = (Object *)WindowObject,
248 MUIA_Window_Title, __(MSG_TITLE),
249 MUIA_Window_Width, MUIV_Window_Width_MinMax(0),
250 MUIA_Window_NoMenus, TRUE,
251 MUIA_Window_Activate, TRUE,
252 MUIA_Window_ID, MAKE_ID('A','B','W','N'),
253 WindowContents, (IPTR) VGroup,
254 InnerSpacing(0, 0),
255 GroupSpacing(2),
256 MUIA_Background, WINDOW_BG,
258 Child, showLogotype
259 ? (IPTR) ImageObject,
260 MUIA_Image_Spec, (IPTR) "3:"LOGOTYPE_IMAGE,
262 : (IPTR) TextObject,
263 MUIA_Font, MUIV_Font_Fixed,
264 MUIA_Text_PreParse, (IPTR) "\0333\033b\033c",
265 MUIA_Text_Contents, (IPTR) LOGOTYPE_ASCII,
266 MUIA_Weight, 0,
269 Child, (IPTR) VSpace(4),
270 Child, (IPTR) HGroup,
271 InnerSpacing(0,0),
273 GroupSpacing(6),
274 Child, (IPTR) HVSpace,
275 Child, (IPTR) TextObject,
276 MUIA_Font, MUIV_Font_Big,
277 MUIA_Text_PreParse, (IPTR) "\0333\033b",
278 MUIA_Text_Contents, (IPTR) str_buildtype,
279 MUIA_Weight, 0,
280 End,
282 Child, (IPTR) TextObject,
283 MUIA_Font, MUIV_Font_Big,
284 MUIA_Text_PreParse, (IPTR) "\0333\033b",
285 MUIA_Text_Contents, (IPTR) str_abi,
286 MUIA_Weight, 0,
287 End,
289 Child, (IPTR) TextObject,
290 MUIA_Font, MUIV_Font_Big,
291 MUIA_Text_PreParse, (IPTR) "\0333\033b",
292 MUIA_Text_Contents, (IPTR) str_variant,
293 MUIA_Weight, 0,
294 End,
295 Child, (IPTR) TextObject,
296 MUIA_Font, MUIV_Font_Big,
297 MUIA_Text_PreParse, (IPTR) "\0333\033b",
298 MUIA_Text_Contents, (IPTR) str_builddate,
299 MUIA_Weight, 0,
300 End,
301 #ifdef SVNREV
302 Child, (IPTR) TextObject,
303 MUIA_Font, MUIV_Font_Big,
304 MUIA_Text_PreParse, (IPTR) "\0333\033b",
305 MUIA_Text_Contents, (IPTR) "SVN: " SVNREV,
306 MUIA_Weight, 0,
307 End,
308 #endif
309 Child, (IPTR) HVSpace,
310 End,
311 Child, (IPTR) VSpace(4),
312 Child, (IPTR) TextObject,
313 MUIA_Text_PreParse, (IPTR) "\0333\033c",
314 MUIA_Text_Contents, __(MSG_COPYRIGHT),
315 End,
316 Child, (IPTR) HGroup,
317 InnerSpacing(0,0),
318 GroupSpacing(0),
320 Child, (IPTR) HVSpace,
321 Child, (IPTR) TextObject,
322 MUIA_Text_PreParse, (IPTR) "\0333",
323 MUIA_Text_Contents, __(MSG_LICENSE_1),
324 MUIA_Weight, 0,
325 End,
326 Child, (IPTR) TextObject,
327 MUIA_Text_Contents, (IPTR) " ",
328 MUIA_Weight, 0,
329 End,
330 Child, (IPTR) (licenseButton = (Object *)TextObject,
331 MUIA_InputMode, MUIV_InputMode_RelVerify,
332 MUIA_Text_PreParse, (IPTR) "\0333\033u",
333 MUIA_Text_Contents, __(MSG_LICENSE_2),
334 MUIA_Weight, 0,
335 End),
336 Child, (IPTR) TextObject,
337 MUIA_Text_PreParse, (IPTR) "\0333",
338 MUIA_Text_Contents, __(MSG_LICENSE_3),
339 MUIA_Weight, 0,
340 End,
341 Child, (IPTR) HVSpace,
342 End,
343 Child, (IPTR) TextObject,
344 MUIA_Text_PreParse, (IPTR) "\0333\033c",
345 MUIA_Text_Contents, __(MSG_MORE_INFORMATION),
346 End,
347 Child, (IPTR) VSpace(4),
348 Child, (IPTR) VGroup,
349 InnerSpacing(4,4),
351 Child, (IPTR) RegisterGroup(pages),
352 MUIA_Background, REGISTER_BG,
354 Child, (IPTR) ListviewObject,
355 MUIA_Listview_List, (IPTR) (authorsList = (Object *)ListObject,
356 TextFrame,
357 MUIA_Background, LIST_BG,
358 End),
359 End,
360 Child, (IPTR) ListviewObject,
361 MUIA_Listview_List, (IPTR) (sponsorsList = (Object *)ListObject,
362 TextFrame,
363 MUIA_Background, LIST_BG,
364 End),
365 End,
366 Child, (IPTR) ListviewObject,
367 MUIA_Listview_List, (IPTR) (acknowledgementsList = (Object *)ListObject,
368 TextFrame,
369 MUIA_Background, LIST_BG,
370 End),
371 End,
372 End,
373 End,
374 End,
375 End),
377 TAG_DONE
380 if (self != NULL)
382 SETUP_INST_DATA;
384 data->aad_Window = window;
385 data->aad_Pool = pool;
387 /*-- Initialize lists --------------------------------------------------*/
388 NamesToList(authorsList, AUTHORS, data);
389 NamesToList(sponsorsList, SPONSORS, data);
391 DoMethod
393 acknowledgementsList, MUIM_List_Insert,
394 (IPTR) ACKNOWLEDGEMENTS, ACKNOWLEDGEMENTS_SIZE, MUIV_List_Insert_Top
397 /*-- Setup notifications -----------------------------------------------*/
398 DoMethod
400 window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
401 (IPTR) self, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
404 DoMethod
406 licenseButton, MUIM_Notify, MUIA_Pressed, FALSE,
407 (IPTR) self, 1, MUIM_AboutAROS_ShowLicense
411 return self;
414 IPTR AboutAROS__OM_DISPOSE(Class *CLASS, Object *self, Msg message)
416 SETUP_INST_DATA;
418 if (data->aad_Pool != NULL) DeletePool(data->aad_Pool);
420 return DoSuperMethodA(CLASS, self, message);
423 IPTR AboutAROS__MUIM_Application_Execute(Class *CLASS, Object *self, Msg message)
425 SETUP_INST_DATA;
427 SET(data->aad_Window, MUIA_Window_Open, TRUE);
428 DoSuperMethodA(CLASS, self, message);
429 SET(data->aad_Window, MUIA_Window_Open, FALSE);
431 return 0;
434 IPTR AboutAROS__MUIM_AboutAROS_ShowLicense(Class *CLASS, Object *self, Msg message)
436 OpenWorkbenchObject("HELP:LICENSE", TAG_DONE);
438 return 0;
441 /*** Setup ******************************************************************/
442 ZUNE_CUSTOMCLASS_4
444 AboutAROS, NULL, MUIC_Application, NULL,
445 OM_NEW, struct opSet *,
446 OM_DISPOSE, Msg,
447 MUIM_Application_Execute, Msg,
448 MUIM_AboutAROS_ShowLicense, Msg