Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / diskimage / ra_gui / requesters.c
blob9568141385f47beccdaff9c75730cb4b84fc7754
1 /* Copyright 2007-2012 Fredrik Wikstrom. All rights reserved.
2 **
3 ** Redistribution and use in source and binary forms, with or without
4 ** modification, are permitted provided that the following conditions
5 ** are met:
6 **
7 ** 1. Redistributions of source code must retain the above copyright
8 ** notice, this list of conditions and the following disclaimer.
9 **
10 ** 2. Redistributions in binary form must reproduce the above copyright
11 ** notice, this list of conditions and the following disclaimer in the
12 ** documentation and/or other materials provided with the distribution.
14 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
15 ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18 ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 ** POSSIBILITY OF SUCH DAMAGE.
27 #include "diskimagegui.h"
28 #include <proto/exec.h>
29 #include <proto/dos.h>
30 #include <proto/utility.h>
31 #include <proto/intuition.h>
32 #include <proto/diskimage.h>
33 #include <clib/alib_protos.h>
34 #include "rev/DiskImageGUI_rev.h"
36 LONG DoReq (Object *req) {
37 LONG res = 0;
38 if (req) {
39 struct Window *window;
41 StopScreenNotify();
42 SetWindowBusy(~0, TRUE);
43 window = NULL;
44 if (Gui.windows[WID_MAIN]) {
45 GetAttr(WINDOW_Window, Gui.windows[WID_MAIN], (Tag *)&window);
48 if (Gui.screen) {
49 res = DoMethod(req, RM_OPENREQ, NULL, window, Gui.screen);
50 } else {
51 struct Screen *screen;
52 screen = LockPubScreen(NULL);
53 if (screen) {
54 res = DoMethod(req, RM_OPENREQ, NULL, NULL, screen);
55 UnlockPubScreen(NULL, screen);
59 SetWindowBusy(~0, FALSE);
60 BeginScreenNotify();
62 DisposeObject(req);
64 return res;
67 #ifndef FALLBACK_IMAGES
68 void ImageNotFoundRequester (CONST_STRPTR image) {
69 TEXT titletext[40];
70 TEXT bodytext[80];
71 CONST_STRPTR gadgettext;
72 Object *req;
74 SNPrintf(titletext, sizeof(titletext), GetString(&LocaleInfo, MSG_ERROR_WND), PROGNAME);
75 SNPrintf(bodytext, sizeof(bodytext), GetString(&LocaleInfo, MSG_IMAGENOTFOUND_REQ), image);
76 gadgettext = GetString(&LocaleInfo, MSG_OK_GAD);
78 req = RequesterObject,
79 REQ_TitleText, titletext,
80 REQ_BodyText, bodytext,
81 REQ_GadgetText, gadgettext,
82 End;
84 DoReq(req);
86 #endif
88 void AboutRequester (void) {
89 TEXT titletext[40];
90 STRPTR bodytext;
91 CONST_STRPTR gadgettext;
92 Object *req;
94 SNPrintf(titletext, sizeof(titletext), GetString(&LocaleInfo, MSG_ABOUT_WND), PROGNAME);
95 bodytext = ASPrintf(GetString(&LocaleInfo, MSG_ABOUT_REQ),
96 DiskImageBase->lib_Node.ln_Name, DiskImageBase->lib_Version, DiskImageBase->lib_Revision,
97 PROGNAME, VERSION, REVISION);
98 gadgettext = GetString(&LocaleInfo, MSG_OK_GAD);
99 if (!bodytext) {
100 IoErrRequester(ERROR_NO_FREE_STORE);
101 return;
104 req = RequesterObject,
105 REQ_TitleText, titletext,
106 REQ_BodyText, bodytext,
107 REQ_GadgetText, gadgettext,
108 End;
110 DoReq(req);
112 FreeVec(bodytext);
115 void IoErrRequester (LONG error) {
116 TEXT titletext[40];
117 TEXT bodytext[80];
118 CONST_STRPTR gadgettext;
119 Object *req;
121 if (error == NO_ERROR) {
122 return;
125 SNPrintf(titletext, sizeof(titletext), GetString(&LocaleInfo, MSG_ERROR_WND), PROGNAME);
126 Fault(error, NULL, bodytext, sizeof(bodytext));
127 gadgettext = GetString(&LocaleInfo, MSG_OK_GAD);
129 req = RequesterObject,
130 REQ_TitleText, titletext,
131 REQ_BodyText, bodytext,
132 REQ_GadgetText, gadgettext,
133 End;
135 DoReq(req);
138 void ErrorStringRequester (CONST_STRPTR error_string) {
139 TEXT titletext[40];
140 CONST_STRPTR bodytext;
141 CONST_STRPTR gadgettext;
142 Object *req;
144 SNPrintf(titletext, sizeof(titletext), GetString(&LocaleInfo, MSG_ERROR_WND), PROGNAME);
145 bodytext = error_string;
146 gadgettext = GetString(&LocaleInfo, MSG_OK_GAD);
148 req = RequesterObject,
149 REQ_TitleText, titletext,
150 REQ_BodyText, bodytext,
151 REQ_GadgetText, gadgettext,
152 End;
154 DoReq(req);
157 void RequiredVersionRequester (CONST_STRPTR res_name, LONG version, LONG revision) {
158 TEXT titletext[40];
159 TEXT bodytext[80];
160 CONST_STRPTR gadgettext;
161 Object *req;
163 SNPrintf(titletext, sizeof(titletext), GetString(&LocaleInfo, MSG_ERROR_WND), PROGNAME);
164 SNPrintf(bodytext, sizeof(bodytext), GetString(&LocaleInfo, MSG_REQUIREDVERSION_REQ),
165 res_name, version, revision);
166 gadgettext = GetString(&LocaleInfo, MSG_OK_GAD);
168 req = RequesterObject,
169 REQ_TitleText, titletext,
170 REQ_BodyText, bodytext,
171 REQ_GadgetText, gadgettext,
172 End;
174 DoReq(req);