1 /* Copyright 2007-2012 Fredrik Wikstrom. All rights reserved.
3 ** Redistribution and use in source and binary forms, with or without
4 ** modification, are permitted provided that the following conditions
7 ** 1. Redistributions of source code must retain the above copyright
8 ** notice, this list of conditions and the following disclaimer.
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 <intuition/icclass.h>
29 #include <proto/exec.h>
30 #include <proto/dos.h>
31 #include <proto/intuition.h>
32 #include <proto/gadtools.h>
33 #include <proto/diskimage.h>
34 #include <clib/alib_protos.h>
36 #define dbug(x) //Printf x
38 extern struct ClassLibrary
*TBIBase
;
40 static CONST CONST_STRPTR image_names
[IID_MAX
] = {
53 #ifdef FALLBACK_IMAGES
54 #include "images/insert.c"
55 #include "images/eject.c"
56 #include "images/writeprotect.c"
57 #include "images/prefs.c"
58 #include "images/refresh.c"
59 #include "images/list_writeprotected.c"
60 #include "images/list_checkmark.c"
61 #include "images/list_plugin.c"
62 #include "images/list_disk.c"
63 #include "images/list_cd.c"
65 static CONST APTR fallback_images
[IID_MAX
] = {
79 struct GUIElements Gui
;
81 static BOOL translate_gui
= TRUE
;
83 static struct NewMenu main_newmenu
[] = {
84 { NM_TITLE
, STR_ID(-1), NULL
, 0, 0, MENU_ID(0) },
85 { NM_ITEM
, STR_ID(MSG_PROJECT_ABOUT
), "?", 0, 0, MENU_ID(MID_ABOUT
) },
86 { NM_ITEM
, NM_BARLABEL
, NULL
, 0, 0, MENU_ID(0) },
87 { NM_ITEM
, STR_ID(MSG_PROJECT_HIDE
), "H", 0, 0, MENU_ID(MID_HIDE
) },
88 { NM_ITEM
, STR_ID(MSG_PROJECT_ICONIFY
), "I", 0, 0, MENU_ID(MID_ICONIFY
) },
89 { NM_ITEM
, NM_BARLABEL
, NULL
, 0, 0, MENU_ID(0) },
90 { NM_ITEM
, STR_ID(MSG_PROJECT_QUIT
), "Q", 0, 0, MENU_ID(MID_QUIT
) },
91 { NM_TITLE
, STR_ID(MSG_SETTINGS_MENU
), NULL
, 0, 0, MENU_ID(0) },
92 { NM_ITEM
, STR_ID(MSG_SETTINGS_CHANGETEMPDIR
), NULL
, 0, 0, MENU_ID(MID_CHANGETEMPDIR
) },
93 { NM_ITEM
, STR_ID(MSG_SETTINGS_PLUGINS
), "P", 0, 0, MENU_ID(MID_PLUGINS
) },
94 { NM_ITEM
, NM_BARLABEL
, NULL
, 0, 0, MENU_ID(0) },
95 { NM_ITEM
, STR_ID(MSG_SETTINGS_SAVE
), NULL
, 0, 0, MENU_ID(MID_SAVESETTINGS
) },
96 { NM_END
, STR_ID(-1), NULL
, 0, 0, MENU_ID(0) }
99 static struct NewMenu main_newmenu_notbiclass
[] = {
100 { NM_TITLE
, STR_ID(-1), NULL
, 0, 0, MENU_ID(0) },
101 { NM_ITEM
, STR_ID(MSG_PROJECT_ABOUT
), "?", 0, 0, MENU_ID(MID_ABOUT
) },
102 { NM_ITEM
, NM_BARLABEL
, NULL
, 0, 0, MENU_ID(0) },
103 { NM_ITEM
, STR_ID(MSG_PROJECT_HIDE
), "H", 0, 0, MENU_ID(MID_HIDE
) },
104 { NM_ITEM
, STR_ID(MSG_PROJECT_ICONIFY
), "I", 0, 0, MENU_ID(MID_ICONIFY
) },
105 { NM_ITEM
, STR_ID(MSG_PROJECT_SNAPSHOT
), NULL
, 0, 0, MENU_ID(MID_SNAPSHOT
) },
106 { NM_ITEM
, NM_BARLABEL
, NULL
, 0, 0, MENU_ID(0) },
107 { NM_ITEM
, STR_ID(MSG_PROJECT_QUIT
), "Q", 0, 0, MENU_ID(MID_QUIT
) },
108 { NM_TITLE
, STR_ID(MSG_SETTINGS_MENU
), NULL
, 0, 0, MENU_ID(0) },
109 { NM_ITEM
, STR_ID(MSG_SETTINGS_CHANGETEMPDIR
), NULL
, 0, 0, MENU_ID(MID_CHANGETEMPDIR
) },
110 { NM_ITEM
, STR_ID(MSG_SETTINGS_PLUGINS
), "P", 0, 0, MENU_ID(MID_PLUGINS
) },
111 { NM_ITEM
, NM_BARLABEL
, NULL
, 0, 0, MENU_ID(0) },
112 { NM_ITEM
, STR_ID(MSG_SETTINGS_SAVE
), NULL
, 0, 0, MENU_ID(MID_SAVESETTINGS
) },
113 { NM_END
, STR_ID(-1), NULL
, 0, 0, MENU_ID(0) }
116 static struct HintInfo main_hintinfo
[] = {
117 { GID_SPEEDBAR
, SBID_INSERT
, STR_ID(MSG_INSERT_GAD
), 0 },
118 { GID_SPEEDBAR
, SBID_EJECT
, STR_ID(MSG_EJECT_GAD
), 0 },
119 { GID_SPEEDBAR
, SBID_WRITEPROTECT
, STR_ID(MSG_WRITEPROTECT_GAD
), 0 },
120 { GID_SPEEDBAR
, SBID_SETDEVICETYPE
, STR_ID(MSG_SETDEVICETYPE_GAD
), 0 },
121 { GID_SPEEDBAR
, SBID_REFRESH
, STR_ID(MSG_REFRESH_GAD
), 0 },
125 CONST_STRPTR device_types_array
[] = {
126 STR_ID(MSG_DEVICETYPE_DIRECT_ACCESS
),
127 STR_ID(MSG_DEVICETYPE_CDROM
),
131 struct ColumnInfo drivelist_columns
[DRIVE_COL_MAX
+1];
132 struct ColumnInfo pluginlist_columns
[PLUG_COL_MAX
+1];
134 BOOL
SetupGUI (void) {
138 CONST_STRPTR main_window_title
;
139 CONST_STRPTR
*devtype
;
140 static Tag vertproptag
= EXTWINDOW_VertProp
;
141 static Tag vertobjecttag
= EXTWINDOW_VertObject
;
143 if (Gui
.initialised
) {
147 Gui
.initialised
= TRUE
;
149 if (WindowBase
->lib_Version
>= 50) {
150 vertproptag
= WINDOW_VertProp
;
151 vertobjecttag
= WINDOW_VertObject
;
154 Gui
.pool
= CreatePool(MEMF_ANY
, 4096, 1024);
160 translate_gui
= FALSE
;
161 TranslateMenus(&LocaleInfo
, main_newmenu
);
162 main_newmenu
[0].nm_Label
= PROGNAME
;
163 TranslateMenus(&LocaleInfo
, main_newmenu_notbiclass
);
164 main_newmenu_notbiclass
[0].nm_Label
= PROGNAME
;
165 TranslateHints(&LocaleInfo
, main_hintinfo
);
166 TranslateArray(&LocaleInfo
, device_types_array
);
169 Gui
.userport
= CreateMsgPort();
170 Gui
.appport
= CreateMsgPort();
171 if (!Gui
.userport
|| !Gui
.appport
) {
175 Gui
.screen
= LockPubScreen(WORKBENCHNAME
);
180 ClearMem(&drivelist_columns
, sizeof(drivelist_columns
));
181 drivelist_columns
[DRIVE_COL_ICON
].ci_Title
= "";
182 drivelist_columns
[DRIVE_COL_UNIT
].ci_Title
= (STRPTR
)GetString(&LocaleInfo
, MSG_UNIT_LBL
);
183 drivelist_columns
[DRIVE_COL_DEVICE
].ci_Title
= (STRPTR
)GetString(&LocaleInfo
, MSG_DEVICE_LBL
);
184 drivelist_columns
[DRIVE_COL_WP
].ci_Title
= (STRPTR
)GetString(&LocaleInfo
, MSG_WRITEPROTECT_LBL
);
185 drivelist_columns
[DRIVE_COL_DISKIMAGE
].ci_Title
= (STRPTR
)GetString(&LocaleInfo
, MSG_FILENAME_LBL
);
186 drivelist_columns
[DRIVE_COL_MAX
].ci_Width
= -1;
187 ClearMem(&pluginlist_columns
, sizeof(pluginlist_columns
));
188 pluginlist_columns
[PLUG_COL_ICON
].ci_Title
= "";
189 pluginlist_columns
[PLUG_COL_PRI
].ci_Title
= (STRPTR
)GetString(&LocaleInfo
, MSG_PRIORITY_LBL
);
190 pluginlist_columns
[PLUG_COL_WRITE
].ci_Title
= (STRPTR
)GetString(&LocaleInfo
, MSG_WRITESUPPORT_LBL
);
191 pluginlist_columns
[PLUG_COL_NAME
].ci_Title
= (STRPTR
)GetString(&LocaleInfo
, MSG_PLUGIN_LBL
);
192 pluginlist_columns
[PLUG_COL_MAX
].ci_Width
= -1;
194 for (i
= 0; i
< LID_MAX
; i
++) {
195 Gui
.lists
[i
] = CreateList(FALSE
);
201 Gui
.images
[IID_INSERT
] = LoadImage(Gui
.screen
, image_names
[IID_INSERT
], TRUE
, TRUE
);
202 Gui
.images
[IID_EJECT
] = LoadImage(Gui
.screen
, image_names
[IID_EJECT
], TRUE
, TRUE
);
203 Gui
.images
[IID_WRITEPROTECT
] = LoadImage(Gui
.screen
, image_names
[IID_WRITEPROTECT
], TRUE
, TRUE
);
204 Gui
.images
[IID_PREFS
] = LoadImage(Gui
.screen
, image_names
[IID_PREFS
], TRUE
, TRUE
);
205 Gui
.images
[IID_REFRESH
] = LoadImage(Gui
.screen
, image_names
[IID_REFRESH
], TRUE
, TRUE
);
206 Gui
.images
[IID_LIST_WRITEPROTECTED
] = LoadImage(Gui
.screen
, image_names
[IID_LIST_WRITEPROTECTED
], FALSE
, FALSE
);
207 Gui
.images
[IID_LIST_CHECKMARK
] = LoadImage(Gui
.screen
, image_names
[IID_LIST_CHECKMARK
], FALSE
, FALSE
);
208 Gui
.images
[IID_LIST_PLUGIN
] = LoadImage(Gui
.screen
, image_names
[IID_LIST_PLUGIN
], FALSE
, FALSE
);
209 Gui
.images
[IID_LIST_DISK
] = LoadImage(Gui
.screen
, image_names
[IID_LIST_DISK
], FALSE
, FALSE
);
210 Gui
.images
[IID_LIST_CDROM
] = LoadImage(Gui
.screen
, image_names
[IID_LIST_CDROM
], FALSE
, FALSE
);
211 for (i
= 0; i
< IID_MAX
; i
++) {
212 if (!Gui
.images
[i
]) {
213 #ifdef FALLBACK_IMAGES
214 Gui
.images
[i
] = fallback_images
[i
];
215 Gui
.fallback_image
[i
] = TRUE
;
217 ImageNotFoundRequester(image_names
[i
]);
223 node
= AllocSpeedButtonNode(SBID_INSERT
,
225 SBNA_Image
, Gui
.images
[IID_INSERT
],
226 SBNA_Highlight
, SBH_IMAGE
,
231 AddTail(Gui
.lists
[LID_SPEEDBAR
], node
);
232 node
= AllocSpeedButtonNode(SBID_EJECT
,
234 SBNA_Image
, Gui
.images
[IID_EJECT
],
235 SBNA_Highlight
, SBH_IMAGE
,
240 AddTail(Gui
.lists
[LID_SPEEDBAR
], node
);
241 node
= AllocSpeedButtonNode(SBID_WRITEPROTECT
,
243 SBNA_Image
, Gui
.images
[IID_WRITEPROTECT
],
244 SBNA_Highlight
, SBH_IMAGE
,
249 AddTail(Gui
.lists
[LID_SPEEDBAR
], node
);
250 if (CheckLib(DiskImageBase
, 52, 23)) {
251 node
= AllocSpeedButtonNode(SBID_SETDEVICETYPE
,
253 SBNA_Image
, Gui
.images
[IID_PREFS
],
254 SBNA_Highlight
, SBH_IMAGE
,
259 AddTail(Gui
.lists
[LID_SPEEDBAR
], node
);
261 node
= AllocSpeedButtonNode(SBID_REFRESH
,
262 SBNA_Disabled
, FALSE
,
263 SBNA_Image
, Gui
.images
[IID_REFRESH
],
264 SBNA_Highlight
, SBH_IMAGE
,
269 AddTail(Gui
.lists
[LID_SPEEDBAR
], node
);
271 node
= AllocChooserNode(
272 CNA_Text
, GetString(&LocaleInfo
, MSG_AUTO_LBL
),
277 AddHead(Gui
.lists
[LID_PLUGINCHOOSER
], node
);
279 devtype
= device_types_array
;
281 node
= AllocChooserNode(
282 CNA_Text
, *devtype
++,
287 AddTail(Gui
.lists
[LID_DEVICETYPECHOOSER
], node
);
290 popkey
= TTString(Icon
, "CX_POPKEY", NULL
);
291 if (!popkey
|| !TrimStr(popkey
)[0]) {
295 main_window_title
= ASPrintfPooled(Gui
.pool
, GetString(&LocaleInfo
, MSG_MAIN_WND
), PROGNAME
, popkey
);
296 if (!main_window_title
) {
300 Gui
.visualinfo
= GetVisualInfoA(Gui
.screen
, NULL
);
301 if (!Gui
.visualinfo
) {
305 Gui
.menustrip
= CreateMenus(main_newmenu
, GTMN_FullMenu
, TRUE
, TAG_END
);
307 Gui
.menustrip
= CreateMenus(main_newmenu_notbiclass
, GTMN_FullMenu
, TRUE
, TAG_END
);
309 if (!Gui
.menustrip
|| !LayoutMenus(Gui
.menustrip
, Gui
.visualinfo
, GTMN_NewLookMenus
, TRUE
, TAG_END
)) {
313 Gui
.windows
[WID_MAIN
] = ExtWindowObject
,
314 WA_Title
, main_window_title
,
315 WA_Flags
, WFLG_CLOSEGADGET
|WFLG_DRAGBAR
|WFLG_DEPTHGADGET
|WFLG_SIZEGADGET
316 |WFLG_NEWLOOKMENUS
|WFLG_NOCAREREFRESH
|WFLG_ACTIVATE
|WFLG_SIZEBRIGHT
,
317 WA_IDCMP
, IDCMP_CLOSEWINDOW
|IDCMP_GADGETUP
|IDCMP_MENUPICK
|IDCMP_NEWSIZE
,
318 WA_PubScreen
, Gui
.screen
,
319 WINDOW_Position
, WPOS_CENTERMOUSE
,
320 WINDOW_SharedPort
, Gui
.userport
,
321 WINDOW_AppPort
, Gui
.appport
,
322 WINDOW_IconifyGadget
, TRUE
,
323 WINDOW_Icon
, GetProgramIcon(),
324 WINDOW_IconTitle
, PROGNAME
,
325 WINDOW_HintInfo
, main_hintinfo
,
326 WINDOW_GadgetHelp
, TRUE
,
327 WINDOW_MenuStrip
, Gui
.menustrip
,
329 WINDOW_Layout
, VLayoutObject
,
330 LAYOUT_SpaceOuter
, TRUE
,
331 LAYOUT_AddChild
, Gui
.gadgets
[GID_SPEEDBAR
] = SpeedBarObject
,
334 SPEEDBAR_Buttons
, Gui
.lists
[LID_SPEEDBAR
],
336 LAYOUT_AddChild
, Gui
.gadgets
[GID_DRIVELIST
] = ListBrowserObject
,
337 GA_ID
, GID_DRIVELIST
,
339 LISTBROWSER_ColumnTitles
, TRUE
,
340 LISTBROWSER_TitleClickable
, TRUE
,
341 LISTBROWSER_ColumnInfo
, drivelist_columns
,
342 LISTBROWSER_Labels
, Gui
.lists
[LID_DRIVELIST
],
343 LISTBROWSER_ShowSelected
, TRUE
,
344 LISTBROWSER_AutoFit
, TRUE
,
345 LISTBROWSER_VerticalProp
, FALSE
,
347 LAYOUT_AddChild
, Gui
.gadgets
[GID_PLUGINCHOOSER
] = ChooserObject
,
348 GA_ID
, GID_PLUGINCHOOSER
,
349 CHOOSER_Labels
, Gui
.lists
[LID_PLUGINCHOOSER
],
351 CHILD_Label
, LabelObject
,
352 LABEL_Text
, GetString(&LocaleInfo
, MSG_PLUGIN_GAD
),
355 EXTWINDOW_SnapshotGadget
, TRUE
,
357 Gui
.windows
[WID_PLUGINS
] = ExtWindowObject
,
358 WA_Title
, GetString(&LocaleInfo
, MSG_PLUGINS_WND
),
359 WA_Flags
, WFLG_CLOSEGADGET
|WFLG_DRAGBAR
|WFLG_DEPTHGADGET
|WFLG_SIZEGADGET
360 |WFLG_NOCAREREFRESH
|WFLG_ACTIVATE
|WFLG_SIZEBRIGHT
,
361 WA_IDCMP
, IDCMP_CLOSEWINDOW
|IDCMP_GADGETUP
|IDCMP_NEWSIZE
,
362 WA_PubScreen
, Gui
.screen
,
363 WINDOW_Position
, WPOS_CENTERMOUSE
,
364 WINDOW_SharedPort
, Gui
.userport
,
365 WINDOW_AppPort
, Gui
.appport
,
366 WINDOW_IconifyGadget
, TRUE
,
367 WINDOW_Icon
, GetProgramIcon(),
369 WINDOW_Layout
, LayoutObject
,
370 LAYOUT_SpaceOuter
, TRUE
,
371 LAYOUT_AddChild
, Gui
.gadgets
[GID_PLUGINLIST
] = ListBrowserObject
,
372 GA_ID
, GID_PLUGINLIST
,
374 LISTBROWSER_ColumnTitles
, TRUE
,
375 LISTBROWSER_TitleClickable
, TRUE
,
376 LISTBROWSER_ColumnInfo
, pluginlist_columns
,
377 LISTBROWSER_Labels
, Gui
.lists
[LID_PLUGINLIST
],
378 LISTBROWSER_ShowSelected
, TRUE
,
379 LISTBROWSER_AutoFit
, TRUE
,
380 LISTBROWSER_VerticalProp
, FALSE
,
383 EXTWINDOW_SnapshotGadget
, TRUE
,
385 Gui
.windows
[WID_SETDEVICETYPE
] = WindowObject
,
386 WA_Flags
, WFLG_CLOSEGADGET
|WFLG_DRAGBAR
|WFLG_DEPTHGADGET
|WFLG_NOCAREREFRESH
388 WA_IDCMP
, IDCMP_CLOSEWINDOW
|IDCMP_GADGETUP
,
389 WA_PubScreen
, Gui
.screen
,
390 WINDOW_Position
, WPOS_CENTERMOUSE
,
391 WINDOW_SharedPort
, Gui
.userport
,
392 WINDOW_Layout
, VLayoutObject
,
393 LAYOUT_SpaceOuter
, TRUE
,
394 LAYOUT_AddChild
, Gui
.gadgets
[GID_DEVICETYPECHOOSER
] = ChooserObject
,
395 GA_ID
, GID_DEVICETYPECHOOSER
,
396 CHOOSER_Labels
, Gui
.lists
[LID_DEVICETYPECHOOSER
],
399 CHILD_Label
, LabelObject
,
400 LABEL_Text
, GetString(&LocaleInfo
, MSG_DEVICETYPE_GAD
),
402 LAYOUT_AddChild
, HLayoutObject
,
403 LAYOUT_BevelStyle
, BVS_SBAR_VERT
,
404 LAYOUT_AddChild
, Gui
.gadgets
[GID_SETDEVICETYPE_SAVE
] = ButtonObject
,
405 GA_ID
, GID_SETDEVICETYPE_SAVE
,
407 GA_Text
, GetString(&LocaleInfo
, MSG_SAVE_GAD
),
409 LAYOUT_AddChild
, Gui
.gadgets
[GID_SETDEVICETYPE_CANCEL
] = ButtonObject
,
410 GA_ID
, GID_SETDEVICETYPE_CANCEL
,
412 GA_Text
, GetString(&LocaleInfo
, MSG_CANCEL_GAD
),
417 for (i
= 0; i
< WID_MAX
; i
++) {
418 if (!Gui
.windows
[i
]) {
424 static const struct TagItem vprop2lb_map
[] = {
425 { PGA_Top
, LISTBROWSER_VPropTop
},
426 { SCROLLER_Top
, LISTBROWSER_VPropTop
},
429 static const struct TagItem lb2vprop_map
[] = {
430 { LISTBROWSER_VPropTotal
, SCROLLER_Total
},
431 { LISTBROWSER_VPropVisible
, SCROLLER_Visible
},
432 { LISTBROWSER_VPropTop
, SCROLLER_Top
},
435 GetAttr(vertobjecttag
, Gui
.windows
[WID_MAIN
], (Tag
*)&Gui
.gadgets
[GID_DRIVELISTVPROP
]);
436 GetAttr(vertobjecttag
, Gui
.windows
[WID_PLUGINS
], (Tag
*)&Gui
.gadgets
[GID_PLUGINLISTVPROP
]);
437 SetAttrs(Gui
.gadgets
[GID_DRIVELISTVPROP
],
438 ICA_MAP
, vprop2lb_map
,
439 ICA_TARGET
, Gui
.gadgets
[GID_DRIVELIST
],
441 SetAttrs(Gui
.gadgets
[GID_PLUGINLISTVPROP
],
442 ICA_MAP
, vprop2lb_map
,
443 ICA_TARGET
, Gui
.gadgets
[GID_PLUGINLIST
],
445 SetAttrs(Gui
.gadgets
[GID_DRIVELIST
],
446 ICA_MAP
, lb2vprop_map
,
447 ICA_TARGET
, Gui
.gadgets
[GID_DRIVELISTVPROP
],
449 SetAttrs(Gui
.gadgets
[GID_PLUGINLIST
],
450 ICA_MAP
, lb2vprop_map
,
451 ICA_TARGET
, Gui
.gadgets
[GID_PLUGINLISTVPROP
],
455 RestoreWindowSize(Gui
.windows
[WID_MAIN
], "main_window");
456 RestoreWindowSize(Gui
.windows
[WID_PLUGINS
], "plugins_window");
469 void CleanupGUI (void) {
470 if (Gui
.initialised
) {
472 struct Node
*node
, *succ
;
474 Gui
.initialised
= FALSE
;
476 for (i
= 0; i
< GID_MAX
; i
++) {
477 Gui
.gadgets
[i
] = NULL
;
480 HideWindow(WID_MAIN
);
481 HideWindow(WID_PLUGINS
);
483 for (i
= 0; i
< WID_MAX
; i
++) {
484 DisposeObject(Gui
.windows
[i
]);
485 Gui
.windows
[i
] = NULL
;
488 FreeMenus(Gui
.menustrip
);
489 FreeVisualInfo(Gui
.visualinfo
);
491 while (node
= RemHead(Gui
.lists
[LID_DEVICETYPECHOOSER
])) {
492 FreeChooserNode(node
);
494 while (node
= RemHead(Gui
.lists
[LID_PLUGINCHOOSER
])) {
495 FreeChooserNode(node
);
497 FreeListBrowserList(Gui
.lists
[LID_PLUGINLIST
]);
498 FreeListBrowserList(Gui
.lists
[LID_DRIVELIST
]);
500 node
= GetHead(Gui
.lists
[LID_SPEEDBAR
]);
502 succ
= GetSucc(node
);
503 FreeSpeedButtonNode(node
);
507 for (i
= 0; i
< IID_MAX
; i
++) {
508 #ifdef FALLBACK_IMAGES
509 if (Gui
.fallback_image
[i
]) {
510 Gui
.fallback_image
[i
] = FALSE
;
511 Gui
.images
[i
] = NULL
;
515 DisposeObject(Gui
.images
[i
]);
516 Gui
.images
[i
] = NULL
;
519 for (i
= 0; i
< LID_MAX
; i
++) {
520 DeleteList(Gui
.lists
[i
]);
524 UnlockPubScreen(NULL
, Gui
.screen
);
527 DeleteMsgPort(Gui
.appport
);
528 DeleteMsgPort(Gui
.userport
);
532 DeletePool(Gui
.pool
);
537 APTR
ShowWindow (ULONG window_id
) {
538 struct Window
*window
;
539 if (!Gui
.initialised
&& !SetupGUI()) {
542 dbug(("RA_OpenWindow\n"));
543 window
= RA_OpenWindow(Gui
.windows
[window_id
]);
547 UpdateLBVertScroller(WID_MAIN
, GID_DRIVELIST
, GID_DRIVELISTVPROP
);
550 UpdateLBVertScroller(WID_PLUGINS
, GID_PLUGINLIST
, GID_PLUGINLISTVPROP
);
557 void HideWindow (ULONG window_id
) {
558 if (Gui
.initialised
) {
561 SaveWindowSize(Gui
.windows
[WID_MAIN
], "main_window", FALSE
);
564 SaveWindowSize(Gui
.windows
[WID_PLUGINS
], "plugins_window", FALSE
);
567 RA_CloseWindow(Gui
.windows
[window_id
]);
571 void IconifyWindow (ULONG window_id
) {
572 if (Gui
.initialised
) {
575 SaveWindowSize(Gui
.windows
[WID_MAIN
], "main_window", FALSE
);
578 SaveWindowSize(Gui
.windows
[WID_PLUGINS
], "plugins_window", FALSE
);
581 RA_Iconify(Gui
.windows
[window_id
]);
585 void SetWindowBusy (ULONG window_id
, ULONG busy
) {
586 if (Gui
.initialised
) {
587 if (window_id
== (ULONG
)-1) {
588 SetWindowBusy(WID_MAIN
, busy
);
589 SetWindowBusy(WID_PLUGINS
, busy
);
591 if (Gui
.windows
[window_id
]) {
592 SetAttrs(Gui
.windows
[window_id
],
593 WA_BusyPointer
, busy
,
601 ULONG
GetGUISignals (void) {
603 if (Gui
.initialised
) {
606 for (i
= 0; i
< WID_MAX
; i
++) {
608 GetAttr(WINDOW_SigMask
, Gui
.windows
[i
], &sigmask
);
615 void UpdateLBVertScroller (ULONG wnd_id
, ULONG lb_id
, ULONG sc_id
) {
616 if (Gui
.initialised
) {
617 struct Window
*window
;
618 ULONG top
, visible
, total
;
620 GetAttr(WINDOW_Window
, Gui
.windows
[wnd_id
], (Tag
*)&window
);
621 total
= top
= visible
= 0;
622 GetAttrs(Gui
.gadgets
[lb_id
],
623 LISTBROWSER_VPropTotal
, &total
,
624 LISTBROWSER_VPropVisible
, &visible
,
625 LISTBROWSER_VPropTop
, &top
,
627 dbug(("total: %ld\nvisible: %ld\ntop: %ld\n", total
, visible
, top
));
628 SetGadgetAttrs(GA(Gui
.gadgets
[sc_id
]), window
, NULL
,
629 SCROLLER_Total
, total
,
630 SCROLLER_Visible
, visible
,