revert between 56095 -> 55830 in arch
[AROS.git] / workbench / system / AboutAROS / aboutaros.c
blob2556d25e6a8af01e6d3c99ec402fbe457bf64123
1 /*
2 Copyright © 2003-2019, 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.2 ("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 = NULL;
190 STRPTR str_variant = NULL;
191 STRPTR str_arosarch = NULL;
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 Child, (IPTR) HVSpace,
302 End,
303 #ifdef REPOTYPE
304 Child, (IPTR) HGroup,
305 InnerSpacing(0,0),
306 GroupSpacing(0),
308 Child, (IPTR) TextObject,
309 MUIA_Text_PreParse, (IPTR) "\0333\033b",
310 MUIA_Text_Contents, (IPTR) "" REPOTYPE " ID: " REPOREVISION,
311 MUIA_Weight, 0,
312 End,
313 #ifdef REPOID
314 Child, (IPTR) TextObject,
315 MUIA_Text_PreParse, (IPTR) "\0333\033b",
316 MUIA_Text_Contents, (IPTR) " (" REPOID ")",
317 MUIA_Weight, 0,
318 End,
319 #endif
320 End,
321 #endif
322 Child, (IPTR) VSpace(4),
323 Child, (IPTR) TextObject,
324 MUIA_Text_PreParse, (IPTR) "\0333\033c",
325 MUIA_Text_Contents, __(MSG_COPYRIGHT),
326 End,
327 Child, (IPTR) HGroup,
328 InnerSpacing(0,0),
329 GroupSpacing(0),
331 Child, (IPTR) HVSpace,
332 Child, (IPTR) TextObject,
333 MUIA_Text_PreParse, (IPTR) "\0333",
334 MUIA_Text_Contents, __(MSG_LICENSE_1),
335 MUIA_Weight, 0,
336 End,
337 Child, (IPTR) TextObject,
338 MUIA_Text_Contents, (IPTR) " ",
339 MUIA_Weight, 0,
340 End,
341 Child, (IPTR) (licenseButton = (Object *)TextObject,
342 MUIA_InputMode, MUIV_InputMode_RelVerify,
343 MUIA_Text_PreParse, (IPTR) "\0333\033u",
344 MUIA_Text_Contents, __(MSG_LICENSE_2),
345 MUIA_Weight, 0,
346 End),
347 Child, (IPTR) TextObject,
348 MUIA_Text_PreParse, (IPTR) "\0333",
349 MUIA_Text_Contents, __(MSG_LICENSE_3),
350 MUIA_Weight, 0,
351 End,
352 Child, (IPTR) HVSpace,
353 End,
354 Child, (IPTR) TextObject,
355 MUIA_Text_PreParse, (IPTR) "\0333\033c",
356 MUIA_Text_Contents, __(MSG_MORE_INFORMATION),
357 End,
358 Child, (IPTR) VSpace(4),
359 Child, (IPTR) VGroup,
360 InnerSpacing(4,4),
362 Child, (IPTR) RegisterGroup(pages),
363 MUIA_Background, REGISTER_BG,
365 Child, (IPTR) ListviewObject,
366 MUIA_Listview_List, (IPTR) (authorsList = (Object *)ListObject,
367 TextFrame,
368 MUIA_Background, LIST_BG,
369 End),
370 End,
371 Child, (IPTR) ListviewObject,
372 MUIA_Listview_List, (IPTR) (sponsorsList = (Object *)ListObject,
373 TextFrame,
374 MUIA_Background, LIST_BG,
375 End),
376 End,
377 Child, (IPTR) ListviewObject,
378 MUIA_Listview_List, (IPTR) (acknowledgementsList = (Object *)ListObject,
379 TextFrame,
380 MUIA_Background, LIST_BG,
381 End),
382 End,
383 End,
384 End,
385 End,
386 End),
388 TAG_DONE
391 if (self != NULL)
393 SETUP_INST_DATA;
395 data->aad_Window = window;
396 data->aad_Pool = pool;
398 /*-- Initialize lists --------------------------------------------------*/
399 NamesToList(authorsList, AUTHORS, data);
400 NamesToList(sponsorsList, SPONSORS, data);
402 DoMethod
404 acknowledgementsList, MUIM_List_Insert,
405 (IPTR) ACKNOWLEDGEMENTS, ACKNOWLEDGEMENTS_SIZE, MUIV_List_Insert_Top
408 /*-- Setup notifications -----------------------------------------------*/
409 DoMethod
411 window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
412 (IPTR) self, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
415 DoMethod
417 licenseButton, MUIM_Notify, MUIA_Pressed, FALSE,
418 (IPTR) self, 1, MUIM_AboutAROS_ShowLicense
422 return self;
425 IPTR AboutAROS__OM_DISPOSE(Class *CLASS, Object *self, Msg message)
427 SETUP_INST_DATA;
429 if (data->aad_Pool != NULL) DeletePool(data->aad_Pool);
431 return DoSuperMethodA(CLASS, self, message);
434 IPTR AboutAROS__MUIM_Application_Execute(Class *CLASS, Object *self, Msg message)
436 SETUP_INST_DATA;
438 SET(data->aad_Window, MUIA_Window_Open, TRUE);
439 DoSuperMethodA(CLASS, self, message);
440 SET(data->aad_Window, MUIA_Window_Open, FALSE);
442 return 0;
445 IPTR AboutAROS__MUIM_AboutAROS_ShowLicense(Class *CLASS, Object *self, Msg message)
447 OpenWorkbenchObject("HELP:LICENSE", TAG_DONE);
449 return 0;
452 /*** Setup ******************************************************************/
453 ZUNE_CUSTOMCLASS_4
455 AboutAROS, NULL, MUIC_Application, NULL,
456 OM_NEW, struct opSet *,
457 OM_DISPOSE, Msg,
458 MUIM_Application_Execute, Msg,
459 MUIM_AboutAROS_ShowLicense, Msg