Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / utilities / Snoopy / gui.c
blob3a50ff790d4e3118501137d5cdc5cdf95dc0d5ab
1 /*
2 Copyright © 2006-2008, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define MUIMASTER_YES_INLINE_STDARG
8 #include <aros/debug.h>
9 #include <proto/muimaster.h>
10 #include <libraries/mui.h>
11 #include <proto/intuition.h>
13 #include "main.h"
14 #include "gui.h"
15 #include "setup.h"
16 #include "patches.h"
17 #include "locale.h"
19 #define VERSION "$VER: Snoopy 0.9 (10.05.2008) © 2006-2008 The AROS Dev Team"
21 static Object *app, *window, *saveBtn, *openBtn, *useBtn, *undoBtn, *resetBtn, *cancelBtn;
22 static Object *failCM, *cliCM, *pathCM, *devCM, *ignoreCM, *breakPointCM, *patternStr;
23 static Object *nameNum, *actionNum, *targetNum, *optionNum;
24 static Object *changeDirCM, *deleteCM, *executeCM, *getVarCM, *loadSegCM, *lockCM, *makeDirCM, *makeLinkCM;
25 static Object *openCM, *renameCM, *runCommandCM, *setVarCM, *systemCM, *findPortCM, *findResidentCM, *findSemaphoreCM;
26 static Object *findTaskCM, *lockScreenCM, *openDeviceCM, *openFontCM, *openLibraryCM, *openResourceCM, *readToolTypesCM;
28 static struct Hook save_hook, open_hook, use_hook, undo_hook, reset_hook, cancel_hook;
30 AROS_UFH3S(void, save_function,
31 AROS_UFHA(struct Hook *, h, A0),
32 AROS_UFHA(Object *, object, A2),
33 AROS_UFHA(APTR, msg, A1))
35 AROS_USERFUNC_INIT
37 oldsetup = setup;
38 gui_get();
39 patches_set();
40 if ( ! setup_save())
42 MUI_Request ( app, window, 0, MSG(MSG_TITLE), MSG(MSG_OK), MSG(MSG_ERROR_SAVE), PREFFILE);
45 AROS_USERFUNC_EXIT
48 AROS_UFH3S(void, open_function,
49 AROS_UFHA(struct Hook *, h, A0),
50 AROS_UFHA(Object *, object, A2),
51 AROS_UFHA(APTR, msg, A1))
53 AROS_USERFUNC_INIT
55 if ( ! setup_open() )
57 MUI_Request ( app, window, 0, MSG(MSG_TITLE), MSG(MSG_OK), MSG(MSG_ERROR_LOAD), PREFFILE);
59 gui_set();
60 patches_set();
62 AROS_USERFUNC_EXIT
65 AROS_UFH3S(void, reset_function,
66 AROS_UFHA(struct Hook *, h, A0),
67 AROS_UFHA(Object *, object, A2),
68 AROS_UFHA(APTR, msg, A1))
70 AROS_USERFUNC_INIT
72 oldsetup = setup;
73 setup_reset();
74 gui_set();
75 patches_set();
77 AROS_USERFUNC_EXIT
80 AROS_UFH3S(void, use_function,
81 AROS_UFHA(struct Hook *, h, A0),
82 AROS_UFHA(Object *, object, A2),
83 AROS_UFHA(APTR, msg, A1))
85 AROS_USERFUNC_INIT
87 oldsetup = setup;
88 gui_get();
89 patches_set();
91 AROS_USERFUNC_EXIT
94 AROS_UFH3S(void, undo_function,
95 AROS_UFHA(struct Hook *, h, A0),
96 AROS_UFHA(Object *, object, A2),
97 AROS_UFHA(APTR, msg, A1))
99 AROS_USERFUNC_INIT
101 setup = oldsetup;
102 gui_set();
103 patches_set();
105 AROS_USERFUNC_EXIT
108 AROS_UFH3S(void, cancel_function,
109 AROS_UFHA(struct Hook *, h, A0),
110 AROS_UFHA(Object *, object, A2),
111 AROS_UFHA(APTR, msg, A1))
113 AROS_USERFUNC_INIT
115 // FIXME: original SnoopDos has a separate task for the patches. When cancelling SnoopDos the GUI
116 // is removed and the patchtask stays in RAM. We can't do that because we have no separate task.
117 // The cancelling function of Snoopy is more for debugging.
118 if (MUI_Request ( app, window, 0, MSG(MSG_TITLE), MSG(MSG_RESET_PATCHES), MSG(MSG_ASK_RESET)))
120 set(saveBtn, MUIA_Disabled, TRUE);
121 set(openBtn, MUIA_Disabled, TRUE);
122 set(useBtn, MUIA_Disabled, TRUE);
123 set(undoBtn, MUIA_Disabled, TRUE);
124 set(resetBtn, MUIA_Disabled, TRUE);
125 set(cancelBtn, MUIA_Disabled, TRUE);
126 patches_reset();
127 if (MUI_Request ( app, window, 0, MSG(MSG_TITLE), MSG(MSG_REMOVE_SNOOP), MSG(MSG_ASK_REMOVE)))
129 DoMethod(app, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
132 AROS_USERFUNC_EXIT
135 void gui_init(void)
137 save_hook.h_Entry = (APTR)save_function;
138 open_hook.h_Entry = (APTR)open_function;
139 use_hook.h_Entry = (APTR)use_function;
140 undo_hook.h_Entry = (APTR)undo_function;
141 reset_hook.h_Entry = (APTR)reset_function;
142 cancel_hook.h_Entry = (APTR)cancel_function;
144 app = (Object *)ApplicationObject,
145 MUIA_Application_Title, (IPTR) MSG(MSG_TITLE),
146 MUIA_Application_Version, (IPTR) VERSION,
147 MUIA_Application_Copyright, (IPTR) MSG(MSG_COPYRIGHT),
148 MUIA_Application_Author, (IPTR) MSG(MSG_AUTHOR),
149 MUIA_Application_Description, (IPTR) MSG(MSG_DESCRIPTION),
150 MUIA_Application_Base, (IPTR) MSG(MSG_PORTNAME),
151 MUIA_Application_SingleTask, TRUE,
153 SubWindow, (IPTR)(window = (Object *)WindowObject,
154 MUIA_Window_Title, (IPTR)MSG(MSG_TITLE),
155 MUIA_Window_CloseGadget, FALSE,
156 WindowContents, (IPTR)(VGroup,
157 Child, (IPTR)(HGroup,
158 Child, (IPTR)(VGroup,
159 Child, (IPTR)(ColGroup(2),
160 GroupFrameT(MSG(MSG_SETTINGS)),
161 Child, (IPTR)Label(MSG(MSG_SHOW_FAILS)),
162 Child, (IPTR)(failCM = MUI_MakeObject(MUIO_Checkmark, "")),
163 Child, (IPTR)Label(MSG(MSG_CLI_NUMBER)),
164 Child, (IPTR)(cliCM = MUI_MakeObject(MUIO_Checkmark, "")),
165 Child, (IPTR)Label(MSG(MSG_FULL_PATH)),
166 Child, (IPTR)(pathCM = MUI_MakeObject(MUIO_Checkmark, "")),
167 Child, (IPTR)Label(MSG(MSG_DEVICE)),
168 Child, (IPTR)(devCM = MUI_MakeObject(MUIO_Checkmark, "")),
169 Child, (IPTR)Label(MSG(MSG_IGNORE_WB)),
170 Child, (IPTR)(ignoreCM = MUI_MakeObject(MUIO_Checkmark, "")),
171 Child, (IPTR)Label(MSG(MSG_BREAKPOINT)),
172 Child, (IPTR)(breakPointCM = MUI_MakeObject(MUIO_Checkmark, "")),
173 Child, (IPTR)HVSpace,
174 Child, (IPTR)HVSpace,
175 End),
176 Child, (IPTR)(ColGroup(2),
177 Child, (IPTR)Label(MSG(MSG_MATCH)),
178 Child, (IPTR)(patternStr = (Object *)StringObject,
179 StringFrame,
180 MUIA_String_MaxLen, PATTERNLEN,
181 End),
182 End),
183 Child, (IPTR)(ColGroup(2),
184 GroupFrameT(MSG(MSG_OUTPUT_FIELD)),
185 Child, (IPTR)Label(MSG(MSG_NAME)),
186 Child, (IPTR)(nameNum = (Object *)SliderObject,
187 MUIA_Numeric_Min, 10,
188 MUIA_Numeric_Max, 50,
189 End),
190 Child, (IPTR)Label(MSG(MSG_ACTION)),
191 Child, (IPTR)(actionNum = (Object *)SliderObject,
192 MUIA_Numeric_Min, 10,
193 MUIA_Numeric_Max, 50,
194 End),
195 Child, (IPTR)Label(MSG(MSG_TARGET)),
196 Child, (IPTR)(targetNum = (Object *)SliderObject,
197 MUIA_Numeric_Min, 10,
198 MUIA_Numeric_Max, 50,
199 End),
200 Child, (IPTR)Label(MSG(MSG_OPTION)),
201 Child, (IPTR)(optionNum = (Object *)SliderObject,
202 MUIA_Numeric_Min, 10,
203 MUIA_Numeric_Max, 50,
204 End),
205 End),
206 End),
207 Child, (IPTR)(VGroup,
208 Child, (IPTR)(ColGroup(2),
209 GroupFrameT(MSG(MSG_SYSTEM_FUNC)),
210 Child, (IPTR)Label("FindPort"),
211 Child, (IPTR)(findPortCM = MUI_MakeObject(MUIO_Checkmark, "")),
212 Child, (IPTR)Label("FindResident"),
213 Child, (IPTR)(findResidentCM = MUI_MakeObject(MUIO_Checkmark, "")),
214 Child, (IPTR)Label("FindSemaphore"),
215 Child, (IPTR)(findSemaphoreCM = MUI_MakeObject(MUIO_Checkmark, "")),
216 Child, (IPTR)Label("FindTask"),
217 Child, (IPTR)(findTaskCM = MUI_MakeObject(MUIO_Checkmark, "")),
218 Child, (IPTR)Label("LockScreen"),
219 Child, (IPTR)(lockScreenCM = MUI_MakeObject(MUIO_Checkmark, "")),
220 Child, (IPTR)Label("OpenDevice"),
221 Child, (IPTR)(openDeviceCM = MUI_MakeObject(MUIO_Checkmark, "")),
222 Child, (IPTR)Label("OpenFont"),
223 Child, (IPTR)(openFontCM = MUI_MakeObject(MUIO_Checkmark, "")),
224 Child, (IPTR)Label("OpenLibrary"),
225 Child, (IPTR)(openLibraryCM = MUI_MakeObject(MUIO_Checkmark, "")),
226 Child, (IPTR)Label("OpenResource"),
227 Child, (IPTR)(openResourceCM = MUI_MakeObject(MUIO_Checkmark, "")),
228 Child, (IPTR)Label("ReadToolTypes"),
229 Child, (IPTR)(readToolTypesCM = MUI_MakeObject(MUIO_Checkmark, "")),
230 Child, (IPTR)HVSpace,
231 Child, (IPTR)HVSpace,
232 End),
233 End),
234 Child, (IPTR)(VGroup,
235 Child, (IPTR)(ColGroup(2),
236 GroupFrameT(MSG(MSG_DOS_FUNC)),
237 Child, (IPTR)Label("ChangeDir"),
238 Child, (IPTR)(changeDirCM = MUI_MakeObject(MUIO_Checkmark, "")),
239 Child, (IPTR)Label("Delete"),
240 Child, (IPTR)(deleteCM = MUI_MakeObject(MUIO_Checkmark, "")),
241 Child, (IPTR)Label("Execute"),
242 Child, (IPTR)(executeCM = MUI_MakeObject(MUIO_Checkmark, "")),
243 Child, (IPTR)Label("GetVar"),
244 Child, (IPTR)(getVarCM = MUI_MakeObject(MUIO_Checkmark, "")),
245 Child, (IPTR)Label("LoadSeg"),
246 Child, (IPTR)(loadSegCM = MUI_MakeObject(MUIO_Checkmark, "")),
247 Child, (IPTR)Label("Lock"),
248 Child, (IPTR)(lockCM = MUI_MakeObject(MUIO_Checkmark, "")),
249 Child, (IPTR)Label("MakeDir"),
250 Child, (IPTR)(makeDirCM = MUI_MakeObject(MUIO_Checkmark, "")),
251 Child, (IPTR)Label("MakeLink"),
252 Child, (IPTR)(makeLinkCM = MUI_MakeObject(MUIO_Checkmark, "")),
253 Child, (IPTR)Label("Open"),
254 Child, (IPTR)(openCM = MUI_MakeObject(MUIO_Checkmark, "")),
255 Child, (IPTR)Label("Rename"),
256 Child, (IPTR)(renameCM = MUI_MakeObject(MUIO_Checkmark, "")),
257 Child, (IPTR)Label("RunCommand"),
258 Child, (IPTR)(runCommandCM = MUI_MakeObject(MUIO_Checkmark, "")),
259 Child, (IPTR)Label("SetVar"),
260 Child, (IPTR)(setVarCM = MUI_MakeObject(MUIO_Checkmark, "")),
261 Child, (IPTR)Label("System"),
262 Child, (IPTR)(systemCM = MUI_MakeObject(MUIO_Checkmark, "")),
263 Child, (IPTR)HVSpace,
264 Child, (IPTR)HVSpace,
265 End),
266 End),
267 End),
268 Child, (IPTR) (RectangleObject,
269 MUIA_Rectangle_HBar, TRUE,
270 MUIA_FixHeight, 2,
271 End),
272 Child, (IPTR)(HGroup,
273 Child, (IPTR)(saveBtn = SimpleButton(MSG(MSG_SAVE))),
274 Child, (IPTR)(openBtn = SimpleButton(MSG(MSG_OPEN))),
275 Child, (IPTR)HVSpace,
276 Child, (IPTR)(useBtn = SimpleButton(MSG(MSG_USE))),
277 Child, (IPTR)(undoBtn = SimpleButton(MSG(MSG_UNDO))),
278 Child, (IPTR)(resetBtn = SimpleButton(MSG(MSG_RESET))),
279 Child, (IPTR)HVSpace,
280 Child, (IPTR)(cancelBtn = SimpleButton(MSG(MSG_CANCEL))),
281 End),
282 End), // WindowContents
283 End), // WindowObject
284 End; // ApplicationObject
286 if ( ! app)
288 clean_exit("Can't create application\n");
291 // disable unavailable functions
292 set(pathCM, MUIA_Disabled, TRUE);
293 set(devCM, MUIA_Disabled, TRUE);
294 // breakpoint option only available on hosted
295 #if !(AROS_FLAVOUR & AROS_FLAVOUR_EMULATION)
296 set(breakPointCM, MUIA_Disabled, TRUE);
297 #endif
299 gui_set();
300 set(window, MUIA_Window_Open, TRUE);
302 DoMethod(saveBtn, MUIM_Notify, MUIA_Pressed, FALSE,
303 (IPTR)app, 2, MUIM_CallHook, (IPTR)&save_hook);
305 DoMethod(openBtn, MUIM_Notify, MUIA_Pressed, FALSE,
306 (IPTR)app, 2, MUIM_CallHook, (IPTR)&open_hook);
308 DoMethod(useBtn, MUIM_Notify, MUIA_Pressed, FALSE,
309 (IPTR)app, 2, MUIM_CallHook, (IPTR)&use_hook);
311 DoMethod(undoBtn, MUIM_Notify, MUIA_Pressed, FALSE,
312 (IPTR)app, 2, MUIM_CallHook, (IPTR)&undo_hook);
314 DoMethod(resetBtn, MUIM_Notify, MUIA_Pressed, FALSE,
315 (IPTR)app, 2, MUIM_CallHook, (IPTR)&reset_hook);
317 DoMethod(cancelBtn, MUIM_Notify, MUIA_Pressed, FALSE,
318 (IPTR)app, 2, MUIM_CallHook, (IPTR)&cancel_hook);
321 void gui_handleevents(void)
323 DoMethod(app, MUIM_Application_Execute);
326 void gui_cleanup(void)
328 MUI_DisposeObject(app);
331 void gui_set(void)
333 set(failCM, MUIA_Selected, setup.onlyShowFails);
334 set(cliCM, MUIA_Selected, setup.showCliNr);
335 set(pathCM, MUIA_Selected, setup.showPaths);
336 set(devCM, MUIA_Selected, setup.useDevNames);
337 set(ignoreCM, MUIA_Selected, setup.ignoreWB);
338 set(breakPointCM, MUIA_Selected, setup.breakPoint);
340 set(patternStr, MUIA_String_Contents, setup.pattern);
341 main_parsepattern();
343 set(changeDirCM, MUIA_Selected, setup.enableChangeDir);
344 set(deleteCM, MUIA_Selected, setup.enableDelete);
345 set(executeCM, MUIA_Selected, setup.enableExecute);
346 set(getVarCM, MUIA_Selected, setup.enableGetVar);
347 set(loadSegCM, MUIA_Selected, setup.enableLoadSeg);
348 set(lockCM, MUIA_Selected, setup.enableLock);
349 set(makeDirCM, MUIA_Selected, setup.enableMakeDir);
350 set(makeLinkCM, MUIA_Selected, setup.enableMakeLink);
351 set(openCM, MUIA_Selected, setup.enableOpen);
352 set(renameCM, MUIA_Selected, setup.enableRename);
353 set(runCommandCM, MUIA_Selected, setup.enableRunCommand);
354 set(setVarCM, MUIA_Selected, setup.enableSetVar);
355 set(systemCM, MUIA_Selected, setup.enableSystem);
357 set(findPortCM, MUIA_Selected, setup.enableFindPort);
358 set(findResidentCM, MUIA_Selected, setup.enableFindResident);
359 set(findSemaphoreCM, MUIA_Selected, setup.enableFindSemaphore);
360 set(findTaskCM, MUIA_Selected, setup.enableFindTask);
361 set(lockScreenCM, MUIA_Selected, setup.enableLockScreen);
362 set(openDeviceCM, MUIA_Selected, setup.enableOpenDevice);
363 set(openFontCM, MUIA_Selected, setup.enableOpenFont);
364 set(openLibraryCM, MUIA_Selected, setup.enableOpenLibrary);
365 set(openResourceCM, MUIA_Selected, setup.enableOpenResource);
366 set(readToolTypesCM, MUIA_Selected, setup.enableReadToolTypes);
368 set(nameNum, MUIA_Numeric_Value, setup.nameLen);
369 set(actionNum, MUIA_Numeric_Value, setup.actionLen);
370 set(targetNum, MUIA_Numeric_Value, setup.targetLen);
371 set(optionNum, MUIA_Numeric_Value, setup.optionLen);
374 void gui_get(void)
376 setup.onlyShowFails = XGET(failCM, MUIA_Selected);
377 setup.showCliNr = XGET(cliCM, MUIA_Selected);
378 setup.showPaths = XGET(pathCM, MUIA_Selected);
379 setup.useDevNames = XGET(devCM, MUIA_Selected);
380 setup.ignoreWB = XGET(ignoreCM, MUIA_Selected);
381 setup.breakPoint = XGET(breakPointCM, MUIA_Selected);
383 setup.pattern = (STRPTR)XGET(patternStr, MUIA_String_Contents);
384 main_parsepattern();
386 setup.enableChangeDir = XGET(changeDirCM, MUIA_Selected);
387 setup.enableDelete = XGET(deleteCM, MUIA_Selected);
388 setup.enableExecute = XGET(executeCM, MUIA_Selected);
389 setup.enableGetVar = XGET(getVarCM, MUIA_Selected);
390 setup.enableLoadSeg = XGET(loadSegCM, MUIA_Selected);
391 setup.enableLock = XGET(lockCM, MUIA_Selected);
392 setup.enableMakeDir = XGET(makeDirCM, MUIA_Selected);
393 setup.enableMakeLink = XGET(makeLinkCM, MUIA_Selected);
394 setup.enableOpen = XGET(openCM, MUIA_Selected);
395 setup.enableRename = XGET(renameCM, MUIA_Selected);
396 setup.enableRunCommand = XGET(runCommandCM, MUIA_Selected);
397 setup.enableSetVar = XGET(setVarCM, MUIA_Selected);
398 setup.enableSystem = XGET(systemCM, MUIA_Selected);
400 setup.enableFindPort = XGET(findPortCM, MUIA_Selected);
401 setup.enableFindResident = XGET(findResidentCM, MUIA_Selected);
402 setup.enableFindSemaphore = XGET(findSemaphoreCM, MUIA_Selected);
403 setup.enableFindTask = XGET(findTaskCM, MUIA_Selected);
404 setup.enableLockScreen = XGET(lockScreenCM, MUIA_Selected);
405 setup.enableOpenDevice = XGET(openDeviceCM, MUIA_Selected);
406 setup.enableOpenFont = XGET(openFontCM, MUIA_Selected);
407 setup.enableOpenLibrary = XGET(openLibraryCM, MUIA_Selected);
408 setup.enableOpenResource = XGET(openResourceCM, MUIA_Selected);
409 setup.enableReadToolTypes = XGET(readToolTypesCM, MUIA_Selected);
411 setup.nameLen = XGET(nameNum, MUIA_Numeric_Value);
412 setup.actionLen = XGET(actionNum, MUIA_Numeric_Value);
413 setup.targetLen = XGET(targetNum, MUIA_Numeric_Value);
414 setup.optionLen = XGET(optionNum, MUIA_Numeric_Value);