grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / utilities / More / misc.c
bloba176c87a0fb96041688477425737eb59cbc7bcc8
1 /*
2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /*********************************************************************************************/
8 #include <intuition/intuition.h>
9 #include <libraries/asl.h>
10 #include <libraries/gadtools.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include <proto/intuition.h>
14 #include <proto/gadtools.h>
15 #include <proto/asl.h>
17 #define CATCOMP_NUMBERS
18 #include "strings.h"
20 #include "global.h"
21 #include "version.h"
23 #include <string.h>
25 const char *versionstring = VERSIONSTR;
27 /*********************************************************************************************/
29 struct Library *AslBase;
31 /*********************************************************************************************/
33 static struct NewMenu nm[] =
35 {NM_TITLE, (STRPTR)MSG_MEN_PROJECT },
36 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_OPEN },
37 {NM_ITEM, NM_BARLABEL },
38 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_SAVEAS },
39 {NM_ITEM, NM_BARLABEL },
40 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_PRINT },
41 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_ABOUT },
42 {NM_ITEM, NM_BARLABEL },
43 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_QUIT },
44 {NM_TITLE, (STRPTR)MSG_MEN_NAVIGATION },
45 {NM_ITEM, (STRPTR)MSG_MEN_NAVIGATION_FIND },
46 {NM_ITEM, (STRPTR)MSG_MEN_NAVIGATION_FIND_NEXT },
47 {NM_ITEM, (STRPTR)MSG_MEN_NAVIGATION_FIND_PREV },
48 {NM_ITEM, NM_BARLABEL },
49 {NM_ITEM, (STRPTR)MSG_MEN_NAVIGATION_JUMP },
50 {NM_END}
53 /*********************************************************************************************/
55 void InitMenus(void)
57 struct NewMenu *actnm = nm;
59 for(actnm = nm; actnm->nm_Type != NM_END; actnm++)
61 if (actnm->nm_Label != NM_BARLABEL)
63 ULONG id = (IPTR)actnm->nm_Label;
64 CONST_STRPTR str = MSG(id);
66 if (actnm->nm_Type == NM_TITLE)
68 actnm->nm_Label = str;
69 } else {
70 actnm->nm_Label = str + 2;
71 if (str[0] != ' ') actnm->nm_CommKey = str;
73 actnm->nm_UserData = (APTR)(IPTR)id;
75 } /* if (actnm->nm_Label != NM_BARLABEL) */
77 } /* for(actnm = nm; nm->nm_Type != NM_END; nm++) */
81 /*********************************************************************************************/
83 void MakeMenus(void)
85 menus = CreateMenusA(nm, NULL);
86 if (!menus) Cleanup(MSG(MSG_CANT_CREATE_MENUS));
88 if (!LayoutMenusA(menus, vi, NULL)) Cleanup(MSG(MSG_CANT_CREATE_MENUS));
92 /*********************************************************************************************/
94 void KillMenus(void)
96 if (win) ClearMenuStrip(win);
97 if (menus) FreeMenus(menus);
99 menus = NULL;
102 /*********************************************************************************************/
104 STRPTR GetFile(BOOL open)
106 static UBYTE pathbuffer[300];
107 static UBYTE filebuffer[108];
108 struct FileRequester *req;
109 STRPTR retval = NULL;
111 AslBase = OpenLibrary("asl.library", 39);
112 if (AslBase)
114 filebuffer[sizeof filebuffer - 1] = 0;
115 pathbuffer[sizeof pathbuffer - 1] = 0;
117 strncpy(filebuffer, FilePart(filenamebuffer), sizeof filebuffer - 1);
118 strncpy(pathbuffer, filenamebuffer, sizeof pathbuffer - 1);
119 *(FilePart(pathbuffer)) = 0;
121 req = AllocAslRequestTags(ASL_FileRequest, ASLFR_TitleText , open ?
122 (IPTR)MSG(MSG_ASL_OPEN_TITLE) :
123 (IPTR)MSG(MSG_ASL_SAVE_TITLE) ,
124 ASLFR_DoSaveMode , open ?
125 (IPTR)FALSE :
126 (IPTR)TRUE ,
127 ASLFR_RejectIcons , (IPTR)TRUE ,
128 ASLFR_DoPatterns , (IPTR)TRUE ,
129 ASLFR_InitialDrawer , (IPTR)pathbuffer ,
130 ASLFR_InitialFile , (IPTR)filebuffer ,
131 TAG_DONE);
132 if (req)
134 if (AslRequest(req, NULL))
136 strncpy(filebuffer, req->fr_Drawer, sizeof filebuffer - 1);
137 AddPart(filebuffer, req->fr_File, sizeof filebuffer - 1);
139 retval = filebuffer;
141 } /* if (AslRequest(req, NULL) */
143 FreeAslRequest(req);
145 } /* if (req) */
147 CloseLibrary(AslBase);
149 } /* if (AslBase) */
151 return retval;
154 /*********************************************************************************************/
156 void About(void)
158 struct EasyStruct es;
160 es.es_StructSize = sizeof(es);
161 es.es_Flags = 0;
162 es.es_Title = MSG(MSG_ABOUT_TITLE);
163 es.es_TextFormat = MSG(MSG_ABOUT);
164 es.es_GadgetFormat = MSG(MSG_CONTINUE);
166 EasyRequest(win, &es, NULL, (IPTR)VERSION,
167 (IPTR)REVISION,
168 (IPTR)DATESTR,
169 (IPTR)"2005-2009",
170 (IPTR)"AROS Development Team");
174 /*********************************************************************************************/