Watch listview's MUIA_List_Active attribute rather than
[AROS.git] / workbench / tools / HDToolBox / gui.c
blob9b3e894cd1f48671c809917d92a7a706bba061e4
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /* "TODO: fs support" */
8 #define __CONSOLE_NOLIBBASE__
10 #include <proto/alib.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include <proto/console.h>
14 #include <proto/icon.h>
15 #include <proto/intuition.h>
16 #include <proto/muimaster.h>
18 #include <exec/memory.h>
19 #include <devices/rawkeycodes.h>
20 #include <intuition/gadgetclass.h>
21 #include <intuition/icclass.h>
22 #include <intuition/intuition.h>
23 #include <intuition/sghooks.h>
24 #include <libraries/asl.h>
25 #include <libraries/locale.h>
26 #include <libraries/mui.h>
27 #include <resources/filesysres.h>
28 #include <workbench/workbench.h>
29 #ifdef HAVE_COOLIMAGES
30 #include <libraries/coolimages.h>
31 #endif
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <strings.h>
37 #define DEBUG 0
38 #include "debug.h"
40 #include "gui.h"
41 #include "devices.h"
42 #include "error.h"
43 #include "harddisks.h"
44 #include "hdtoolbox_support.h"
45 #include "locale.h"
46 #include "platform.h"
47 #include "ptclass.h"
48 #include "prefs.h"
50 #undef CATCOMP_STRINGS
51 #undef CATCOMP_NUMBERS
52 #define CATCOMP_NUMBERS
53 #include "strings.h"
55 #define SIMPLEBUTTON(text) SimpleButton(MSG(text))
57 #ifdef HAVE_COOLIMAGES
58 #define IMAGEBUTTON(text,imgid) CoolImageIDButton(MSG(text),imgid)
59 #else
60 #define IMAGEBUTTON(text,imgid) SIMPLEBUTTON(text)
61 #endif
63 struct Library *MUIMasterBase = NULL;
64 struct Library *ConsoleDevice = NULL;
66 Object *app;
67 Object *mainwin;
68 Object *about_item;
69 Object *quit_item;
70 Object *part_item;
71 Object *createml_item;
72 struct GUIGadgets gadgets;
74 struct Hook hook_display;
75 struct Hook hook_buttons;
76 struct Hook hook_createml;
77 struct Hook hook_lv_doubleclick;
78 struct Hook hook_lv_click;
80 struct AddDeviceGadgets {
81 Object *win;
82 Object *disk;
83 Object *file;
84 Object *ok;
85 Object *cancel;
86 } adddevicegadgets;
88 Class *ptclass;
90 struct AddPartitionGadgets {
91 Object *win;
92 Object *pt;
93 Object *ok;
94 Object *cancel;
95 } addpartitiongadgets;
97 struct PartitionTypeGadgets {
98 Object *win;
99 struct TableTypeNode *ttn;
100 Object *lv;
101 Object *base;
102 struct Hook hook_hexidedit;
103 Object *hexid;
104 struct PartitionType type;
105 struct ListNode *iln;
106 Object *ok;
107 Object *cancel;
108 } partitiontypegadgets;
110 struct PartitionTableTypeGadgets {
111 Object *win;
112 Object *lv;
113 struct ListNode *iln;
114 Object *ok;
115 Object *cancel;
116 } partitiontabletypegadgets;
118 struct ResizeMoveGadgets {
119 Object *win;
120 Object *pt;
121 Object *lowcyl;
122 Object *highcyl;
123 Object *totalcyl;
124 Object *size;
125 Object *ok;
126 Object *cancel;
127 } resizemovegadgets;
129 struct RenameGadgets {
130 Object *win;
131 Object *name;
132 struct ListNode *iln;
133 Object *ok;
134 Object *cancel;
135 } renamegadgets;
137 struct DosEnvecGadgets {
138 Object *win;
139 Object *mask;
140 Object *maxtransfer;
141 Object *custboot;
142 Object *numcustboot;
143 Object *reservedblocksstart;
144 Object *reservedblocksend;
145 Object *blocksize;
146 Object *buffers;
147 struct ListNode *iln;
148 Object *ok;
149 Object *cancel;
150 } dosenvecgadgets;
152 struct MountBootGadgets {
153 Object *win;
154 Object *active;
155 Object *automount;
156 Object *bootable;
157 Object *bootpri;
158 struct ListNode *iln;
159 Object *ok;
160 Object *cancel;
161 } mountbootgadgets;
163 char *editcycleentries[] = {"0x", NULL};
164 char *blocksizecycleentries[] = {"512","1024","2048","4096", NULL};
166 void setChanged(struct ListNode *iln)
168 struct ListNode *parent = iln;
170 D(bug("[HDToolBox] setChanged()\n"));
172 while (parent)
174 parent->change_count++;
175 parent = parent->parent;
177 DoMethod(gadgets.leftlv, MUIM_List_Redraw, MUIV_List_Redraw_All);
180 void unsetChanged(struct ListNode *iln)
182 struct ListNode *sub = iln;
183 struct ListNode *parent;
185 D(bug("[HDToolBox] unsetChanged()\n"));
187 /* remove changed from all first generation child partitions */
188 sub = (struct ListNode *)iln->list.lh_Head;
189 while (sub->ln.ln_Succ)
191 if (sub->change_count)
193 parent = sub->parent;
194 while (parent)
196 parent->change_count -= sub->change_count;
197 parent = parent->parent;
199 sub->change_count = 0;
201 sub = (struct ListNode *)sub->ln.ln_Succ;
203 if (iln->flags & LNF_ToSave)
205 iln->flags &= ~LNF_ToSave;
206 /* we saved it so there can't be a change_count */
207 if (iln->change_count)
209 parent = iln->parent;
210 while (parent)
212 parent->change_count -= iln->change_count;
213 parent = parent->parent;
215 iln->change_count = 0;
218 DoMethod(gadgets.leftlv, MUIM_List_Redraw, MUIV_List_Redraw_Active);
221 AROS_UFH3(void, hexidedit_function,
222 AROS_UFHA(struct Hook *, h, A0),
223 AROS_UFHA(struct SGWork *, sgwork, A2),
224 AROS_UFHA(ULONG *, msg, A1))
226 AROS_USERFUNC_INIT
228 D(bug("[HDToolBox] hexidedit_function()\n"));
230 if (*msg == SGH_KEY)
232 D(bug("[HDToolBox] hexidedit_function: KEY PRESS\n"));
235 AROS_USERFUNC_EXIT
238 AROS_UFH3(void, display_function,
239 AROS_UFHA(struct Hook *, h, A0),
240 AROS_UFHA(const char **, strings, A2),
241 AROS_UFHA(struct ListNode *, entry, A1))
243 AROS_USERFUNC_INIT
245 static char buf[16];
246 static char bu2[64];
248 D(bug("[HDToolBox] display_function()\n"));
250 if (entry)
252 int i=0;
253 if (entry->change_count)
254 buf[i++] = '*';
255 if (entry->flags & LNF_ToSave)
256 buf[i++] = 'S';
257 buf[i] = 0;
258 strings[0] = buf;
259 if ((entry->flags & LNF_Listable) || (entry->ln.ln_Type == LNT_Parent))
261 sprintf(bu2,"\0333%s",entry->ln.ln_Name);
262 strings[1] = bu2;
264 else
265 strings[1] = entry->ln.ln_Name;
267 else
269 strings[0] = MSG(WORD_Changed);
270 strings[1] = MSG(WORD_Name);
273 AROS_USERFUNC_EXIT
276 void setTypeString(struct PartitionType *type, Object *strgad)
278 char str[256];
279 char *cur=str;
280 LONG len=0;
282 D(bug("[HDToolBox] setTypeString()\n"));
284 while (len!=type->id_len)
286 sprintf(cur, "%02x ", type->id[len]);
287 cur += 3;
288 len++;
290 cur[-1]=0;
291 set(strgad, MUIA_String_Contents, str);
294 LONG askSave(STRPTR name)
296 struct EasyStruct es =
298 sizeof(struct EasyStruct), 0,
299 "HDToolBox",
300 MSG(MSG_ASK_SAVE),
301 NULL
303 char yesno[32];
305 D(bug("[HDToolBox] askSave('%s')\n", name));
307 sprintf(yesno, "%s|%s|%s", MSG_STD(YESSTR), MSG(WORD_All), MSG_STD(NOSTR));
308 es.es_GadgetFormat = yesno;
309 return EasyRequestArgs(0, &es, 0, &name);
313 LONG saveChanges(struct ListNode *iln, LONG asksave)
315 struct ListNode *sub;
317 D(bug("[HDToolBox] saveChanges()\n"));
319 if (iln->change_count)
321 sub = (struct ListNode *)iln->list.lh_Head;
322 while (sub->ln.ln_Succ)
324 asksave = saveChanges(sub, asksave);
325 sub = (struct ListNode *)sub->ln.ln_Succ;
327 if (iln->flags & LNF_ToSave)
329 struct HDTBPartition *partition;
330 partition = (struct HDTBPartition *)iln;
331 if (partition->table)
333 LONG result=1;
334 if (asksave)
335 result = askSave(iln->ln.ln_Name);
336 if (result == 2)
337 asksave = FALSE;
338 if (result)
340 if (WritePartitionTable(partition->ph) == 0)
341 unsetChanged(iln);
342 else
343 set(gadgets.text, MUIA_Text_Contents, MSG(MSG_WriteTableError));
348 return asksave;
351 AROS_UFH3(void, buttons_function,
352 AROS_UFHA(struct Hook *, h, A0),
353 AROS_UFHA(Object *, object, A2),
354 AROS_UFHA(ULONG *, arg, A1))
356 AROS_USERFUNC_INIT
358 LONG active = MUIV_List_Active_Off;
359 struct ListNode *iln;
360 int i;
362 D(bug("[HDToolBox] buttons_function()\n"));
364 for (i=GB_FIRST;i<=GB_LAST;i++)
365 if (object == gadgets.buttons[i])
366 break;
368 if (i > GB_LAST)
370 if (object == gadgets.leftlv)
373 else if (object == adddevicegadgets.ok)
375 char *str = NULL;
376 struct HDTBDevice *dn;
378 get(adddevicegadgets.file, MUIA_String_Contents, &str);
379 if (str[0])
380 dn = addDeviceName(str);
382 if (!dn) {
383 /* FIXME: Should we fail here? */
386 else if (object == addpartitiongadgets.ok)
388 struct DosEnvec *de = NULL;
390 get(addpartitiongadgets.pt, PTCT_ActivePartition, &de);
391 if (de)
393 struct HDTBPartition *table;
394 struct HDTBPartition *partition;
396 get(addpartitiongadgets.pt, PTCT_PartitionTable, &iln);
397 table = (struct HDTBPartition *)iln;
398 partition = addPartition(table, de);
399 if (partition)
401 setChanged(&partition->listnode);
402 partition->listnode.parent->flags |= LNF_ToSave;
403 InsertList(gadgets.leftlv, &partition->listnode);
405 else
406 set(gadgets.text, MUIA_Text_Contents, MSG(MSG_NO_MEMORY));
409 else if (object == addpartitiongadgets.pt);
410 else if (object == partitiontypegadgets.hexid)
412 char *str = NULL;
414 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
415 get(object, MUIA_String_Contents, &str);
416 partitiontypegadgets.type.id_len=strcpyESC(partitiontypegadgets.type.id, str);
418 else if (object == partitiontypegadgets.lv)
420 get(partitiontypegadgets.lv, MUIA_List_Active, &active);
421 if (active != MUIV_List_Active_Off)
423 struct TypeNode *tn;
424 STRPTR name;
425 DoMethod(partitiontypegadgets.lv, MUIM_List_GetEntry, active, (IPTR)&name);
426 tn = (struct TypeNode *)FindName(partitiontypegadgets.ttn->typelist, name);
427 setTypeString(&tn->type, partitiontypegadgets.hexid);
428 CopyMem(&tn->type, &partitiontypegadgets.type, sizeof(struct PartitionType));
431 else if (object == partitiontypegadgets.ok)
433 struct HDTBPartition *partition;
434 partition = (struct HDTBPartition *)partitiontypegadgets.iln;
435 CopyMem(&partitiontypegadgets.type, &partition->type, sizeof(struct PartitionType));
436 SetPartitionAttrsA(partition->ph, PT_TYPE, &partition->type, TAG_DONE);
437 GetPartitionAttrsA(partition->ph, PT_DOSENVEC, &partition->de, TAG_DONE);
438 partitiontypegadgets.iln->parent->flags |= LNF_ToSave;
439 setChanged(partitiontypegadgets.iln);
441 else if (object == partitiontabletypegadgets.ok)
443 get(partitiontabletypegadgets.lv, MUIA_List_Active, &active);
444 if (active != MUIV_List_Active_Off)
446 struct TableTypeNode *ttn;
447 struct HDTBPartition *table;
448 STRPTR name;
449 DoMethod(partitiontabletypegadgets.lv, MUIM_List_GetEntry, active, (IPTR)&name);
450 ttn = findTableTypeNodeName(name);
451 table = (struct HDTBPartition *)partitiontabletypegadgets.iln;
452 if (
453 (table->table == NULL) ||
454 (ttn->pti->pti_Type != table->table->type)
457 if (makePartitionTable(table, ttn->pti->pti_Type))
459 table->listnode.flags |= LNF_Listable;
460 table->listnode.flags |= LNF_ToSave;
461 setChanged(partitiontabletypegadgets.iln);
463 else
464 set(gadgets.text, MUIA_Text_Contents, MSG(MSG_CreateTableError));
468 else if (object == resizemovegadgets.ok)
470 struct HDTBPartition *table = NULL;
471 struct HDTBPartition *partition;
473 get(resizemovegadgets.pt, PTCT_PartitionTable, &table);
474 partition = (struct HDTBPartition *)table->listnode.list.lh_Head;
475 table->listnode.flags |= LNF_ToSave;
476 while (partition->listnode.ln.ln_Succ)
478 if (partition->listnode.flags & LNF_IntermedChange)
480 partition->listnode.flags &= ~LNF_IntermedChange;
481 setChanged(&partition->listnode);
482 SetPartitionAttrsA(partition->ph, PT_DOSENVEC, &partition->de, TAG_DONE);
484 partition = (struct HDTBPartition *)partition->listnode.ln.ln_Succ;
487 else if (object == resizemovegadgets.cancel)
489 struct HDTBPartition *table = NULL;
490 struct HDTBPartition *partition;
492 get(resizemovegadgets.pt, PTCT_PartitionTable, &table);
493 partition = (struct HDTBPartition *)table->listnode.list.lh_Head;
494 while (partition->listnode.ln.ln_Succ)
496 if (partition->listnode.flags & LNF_IntermedChange)
498 partition->listnode.flags &= ~LNF_IntermedChange;
499 GetPartitionAttrsA(partition->ph, PT_DOSENVEC, &partition->de, TAG_DONE);
501 partition = (struct HDTBPartition *)partition->listnode.ln.ln_Succ;
504 else if (object == resizemovegadgets.pt)
506 LONG type = 0;
507 struct DosEnvec *de = NULL;
508 char str[32];
510 D(bug("[HDToolBox] buttons_function() - Resize/Move Partition Display:\n"));
511 get(resizemovegadgets.pt, PTCT_ActiveType, &type);
512 if (type == PTS_EMPTY_AREA)
514 get(resizemovegadgets.pt, PTCT_ActivePartition, &de);
516 else
518 struct HDTBPartition *partition = NULL;
520 get(resizemovegadgets.pt, PTCT_ActivePartition, &partition);
521 de = &partition->de;
522 if (*arg == PTCT_PartitionMove)
524 partition->listnode.flags |= LNF_IntermedChange;
527 nnset(resizemovegadgets.lowcyl, MUIA_String_Integer, de->de_LowCyl);
528 nnset(resizemovegadgets.highcyl, MUIA_String_Integer, de->de_HighCyl);
529 nnset(resizemovegadgets.totalcyl, MUIA_String_Integer, de->de_HighCyl-de->de_LowCyl+1);
530 getSizeStr(str, (((de->de_HighCyl - de->de_LowCyl + 1) * de->de_Surfaces * de->de_BlocksPerTrack)-1)/2);
531 nnset(resizemovegadgets.size, MUIA_String_Contents, str);
532 D(bug("[HDToolBox] buttons_function() - Resize/Move Partition Display successful\n"));
534 else if (object == resizemovegadgets.lowcyl)
536 LONG type = 0;
537 ULONG value = 0;
539 D(bug("[HDToolBox] buttons_function() - Resize/Move Lowcyl:\n"));
540 get(object, MUIA_String_Integer, &value);
541 get(resizemovegadgets.pt, PTCT_ActiveType, &type);
542 if (type == PTS_PARTITION)
544 struct HDTBPartition *table = NULL;
545 struct HDTBPartition *partition = NULL;
546 ULONG block;
548 get(resizemovegadgets.pt, PTCT_PartitionTable, &table);
549 get(resizemovegadgets.pt, PTCT_ActivePartition, &partition);
550 D(bug("[HDToolBox] - Type : Partition\n"));
551 D(bug("[HDToolBox] - Old value : %ld\n", partition->de.de_LowCyl));
552 D(bug("[HDToolBox] - New value : %ld\n", value));
553 D(bug("[HDToolBox] - Partition table : %p\n", table));
554 D(bug("[HDToolBox] - Active partition : %p\n", partition));
555 if (value != partition->de.de_LowCyl)
557 block =
558 value*partition->de.de_Surfaces*partition->de.de_BlocksPerTrack;
559 if (validValue(table, partition, block))
561 char str[32];
562 partition->listnode.flags |= LNF_IntermedChange;
563 partition->de.de_LowCyl = value;
564 set(resizemovegadgets.totalcyl, MUIA_String_Integer, partition->de.de_HighCyl-partition->de.de_LowCyl+1);
565 set(resizemovegadgets.pt, PTCT_PartitionTable, table);
566 getSizeStr
568 str,
571 (partition->de.de_HighCyl-partition->de.de_LowCyl+1)*
572 partition->de.de_Surfaces*partition->de.de_BlocksPerTrack
576 set(resizemovegadgets.size, MUIA_String_Contents, str);
578 else
579 set(object, MUIA_String_Integer, partition->de.de_LowCyl);
582 else if (type == PTS_EMPTY_AREA)
584 struct DosEnvec *de = NULL;
586 get(resizemovegadgets.pt, PTCT_ActivePartition, &de);
587 if (value != de->de_LowCyl)
588 set(object, MUIA_String_Integer, de->de_LowCyl);
590 else
591 set(object, MUIA_String_Integer, 0);
593 else if (object == resizemovegadgets.highcyl)
595 LONG type = 0;
596 ULONG value = 0;
598 D(bug("[HDToolBox] buttons_function() - Resize/Move Highcyl:\n"));
599 get(object, MUIA_String_Integer, &value);
600 get(resizemovegadgets.pt, PTCT_ActiveType, &type);
601 if (type == PTS_PARTITION)
603 struct HDTBPartition *table = NULL;
604 struct HDTBPartition *partition = NULL;
605 ULONG block;
607 get(resizemovegadgets.pt, PTCT_PartitionTable, &table);
608 get(resizemovegadgets.pt, PTCT_ActivePartition, &partition);
609 D(bug("[HDToolBox] - Type : Partition\n"));
610 D(bug("[HDToolBox] - Old value : %ld\n", partition->de.de_HighCyl));
611 D(bug("[HDToolBox] - New value : %ld\n", value));
612 D(bug("[HDToolBox] - Partition table : %p\n", table));
613 D(bug("[HDToolBox] - Active partition : %p\n", partition));
614 if (value != partition->de.de_HighCyl)
616 block =
618 (value+1)*
619 partition->de.de_Surfaces*partition->de.de_BlocksPerTrack
620 )-1;
621 if (validValue(table, partition, block))
623 char str[32];
624 partition->listnode.flags |= LNF_IntermedChange;
625 partition->de.de_HighCyl = value;
626 nnset(resizemovegadgets.totalcyl, MUIA_String_Integer, partition->de.de_HighCyl-partition->de.de_LowCyl+1);
627 nnset(resizemovegadgets.pt, PTCT_PartitionTable, table);
628 getSizeStr
630 str,
633 (partition->de.de_HighCyl-partition->de.de_LowCyl+1)*
634 partition->de.de_Surfaces*partition->de.de_BlocksPerTrack
638 nnset(resizemovegadgets.size, MUIA_String_Contents, str);
640 else
641 nnset(object, MUIA_String_Integer, partition->de.de_HighCyl);
644 else if (type == PTS_EMPTY_AREA)
646 struct DosEnvec *de = NULL;
648 D(bug("[HDToolBox] - Type : Empty Area\n"));
649 get(resizemovegadgets.pt, PTCT_ActivePartition, &de);
650 if (value != de->de_HighCyl)
651 set(object, MUIA_String_Integer, de->de_HighCyl);
653 else
654 nnset(object, MUIA_String_Integer, 0);
656 else if (object == resizemovegadgets.totalcyl)
658 LONG type = 0;
659 ULONG value = 0;
661 get(object, MUIA_String_Integer, &value);
662 get(resizemovegadgets.pt, PTCT_ActiveType, &type);
663 if (type == PTS_PARTITION)
665 struct HDTBPartition *table = NULL;
666 struct HDTBPartition *partition = NULL;
667 ULONG block;
669 get(resizemovegadgets.pt, PTCT_PartitionTable, &table);
670 get(resizemovegadgets.pt, PTCT_ActivePartition, &partition);
671 if (value != (partition->de.de_HighCyl-partition->de.de_LowCyl+1))
673 block =
675 (partition->de.de_LowCyl+value)*
676 partition->de.de_Surfaces*partition->de.de_BlocksPerTrack
677 )-1;
678 if (validValue(table, partition, block))
680 char str[32];
681 partition->listnode.flags |= LNF_IntermedChange;
682 partition->de.de_HighCyl = partition->de.de_LowCyl+value-1;
683 set(resizemovegadgets.highcyl, MUIA_String_Integer, partition->de.de_HighCyl);
684 set(resizemovegadgets.pt, PTCT_PartitionTable, table);
685 getSizeStr
687 str,
690 (partition->de.de_HighCyl-partition->de.de_LowCyl+1)*
691 partition->de.de_Surfaces*partition->de.de_BlocksPerTrack
695 set(resizemovegadgets.size, MUIA_String_Contents, str);
697 else
698 set(object, MUIA_String_Integer, partition->de.de_HighCyl-partition->de.de_LowCyl+1);
701 else if (type == PTS_EMPTY_AREA)
703 struct DosEnvec *de = NULL;
705 get(resizemovegadgets.pt, PTCT_ActivePartition, &de);
706 if (value != (de->de_HighCyl-de->de_LowCyl+1))
707 set(object, MUIA_String_Integer, de->de_HighCyl-de->de_LowCyl+1);
709 else
710 set(object, MUIA_String_Integer, 0);
712 else if (object == resizemovegadgets.size)
714 char val[32];
715 struct DosEnvec *de = NULL;
716 STRPTR *str = NULL;
717 ULONG size = 0;
718 ULONG type = 0;
720 get(resizemovegadgets.pt, PTCT_ActiveType, &type);
721 if (type == PTS_PARTITION)
723 struct HDTBPartition *partition = NULL;
725 get(resizemovegadgets.pt, PTCT_ActivePartition, &partition);
726 de = &partition->de;
727 get(object, MUIA_String_Contents, &str);
728 size = sizeStrToUL((STRPTR)str);
729 size = (size*2+1)/partition->de.de_BlocksPerTrack/partition->de.de_Surfaces+1;
731 else if (type == PTS_EMPTY_AREA)
733 get(resizemovegadgets.pt, PTCT_ActivePartition, &de);
735 set(resizemovegadgets.totalcyl, MUIA_String_Integer, size);
736 set(resizemovegadgets.totalcyl, MUIA_String_Acknowledge, TRUE);
737 getSizeStr
739 val,
742 (de->de_HighCyl-de->de_LowCyl+1)*
743 de->de_Surfaces*de->de_BlocksPerTrack
747 set(resizemovegadgets.size, MUIA_String_Contents, val);
749 else if (object == renamegadgets.ok)
751 struct HDTBPartition *partition;
752 STRPTR name = NULL;
754 partition = (struct HDTBPartition *)renamegadgets.iln;
755 get(renamegadgets.name, MUIA_String_Contents, &name);
756 if (strcmp(name, partition->listnode.ln.ln_Name) != 0)
758 SetPartitionAttrsA(partition->ph, PT_NAME, name, TAG_DONE);
759 strcpy(partition->listnode.ln.ln_Name, name);
760 renamegadgets.iln->parent->flags |= LNF_ToSave;
761 setChanged(renamegadgets.iln);
764 else if (object == dosenvecgadgets.ok)
766 BOOL changed = FALSE;
767 LONG check = 0;
768 ULONG value = 0;
769 STRPTR str = NULL;
770 char *end;
771 struct HDTBPartition *partition;
773 partition = (struct HDTBPartition *)dosenvecgadgets.iln;
774 get(dosenvecgadgets.mask, MUIA_String_Integer, &value);
775 if (value != partition->de.de_Mask)
777 partition->de.de_Mask = value;
778 changed = TRUE;
780 get(dosenvecgadgets.maxtransfer, MUIA_String_Contents, &str);
781 value = strtoul(str, &end, 0);
782 if (*end == 0)
784 if (value != partition->de.de_MaxTransfer)
786 partition->de.de_MaxTransfer = value;
787 changed = TRUE;
790 get(dosenvecgadgets.custboot, MUIA_Selected, &check);
791 if (check)
793 if (partition->de.de_TableSize<(DE_BOOTBLOCKS+1))
795 partition->de.de_TableSize = DE_BOOTBLOCKS+1;
796 changed = TRUE;
798 get(dosenvecgadgets.numcustboot, MUIA_String_Integer, &value);
799 if (value != partition->de.de_BootBlocks)
801 partition->de.de_BootBlocks = value;
802 changed = TRUE;
805 else
807 if (partition->de.de_TableSize>=(DE_BOOTBLOCKS+1))
809 partition->de.de_TableSize = DE_BOOTBLOCKS;
810 partition->de.de_BootBlocks = 0;
811 changed = TRUE;
814 get(dosenvecgadgets.reservedblocksstart, MUIA_String_Integer, &value);
815 if (value != partition->de.de_Reserved)
817 partition->de.de_Reserved = value;
818 changed = TRUE;
820 get(dosenvecgadgets.reservedblocksend, MUIA_String_Integer, &value);
821 if (value != partition->de.de_PreAlloc)
823 partition->de.de_PreAlloc = value;
824 changed = TRUE;
826 get(dosenvecgadgets.blocksize, MUIA_Cycle_Active, &value);
827 value = 1<<(value+7);
828 if (value != partition->de.de_SizeBlock)
830 partition->de.de_SizeBlock = value;
831 changed = TRUE;
833 get(dosenvecgadgets.buffers, MUIA_String_Integer, &value);
834 if (value != partition->de.de_NumBuffers)
836 partition->de.de_NumBuffers = value;
837 changed = TRUE;
839 if (changed)
841 SetPartitionAttrsA(partition->ph, PT_DOSENVEC, &partition->de, TAG_DONE);
842 dosenvecgadgets.iln->parent->flags |= LNF_ToSave;
843 setChanged(dosenvecgadgets.iln);
846 else if (object == mountbootgadgets.ok)
848 struct HDTBPartition *partition;
849 BOOL changeda = FALSE;
850 BOOL changed = FALSE;
851 LONG check = 0;
852 ULONG value = 0;
854 partition = (struct HDTBPartition *)mountbootgadgets.iln;
855 get(mountbootgadgets.active, MUIA_Selected, &check);
856 if (check)
858 if (!(partition->flags & PNF_ACTIVE))
860 partition->flags |= PNF_ACTIVE;
861 changeda = TRUE;
864 else
866 if (partition->flags & PNF_ACTIVE)
868 partition->flags &= ~PNF_ACTIVE;
869 changeda = TRUE;
872 if (changeda)
874 if (partition->flags & PNF_ACTIVE)
876 struct HDTBPartition *other;
877 other = (struct HDTBPartition *)partition->listnode.ln.ln_Pred;
878 while (other->listnode.ln.ln_Pred)
880 if (other->listnode.ln.ln_Type == LNT_Partition)
882 if (other->flags & PNF_ACTIVE)
884 other->flags &= ~PNF_ACTIVE;
885 SetPartitionAttrsA(other->ph, PT_ACTIVE, FALSE, TAG_DONE);
886 setChanged(&other->listnode);
889 other = (struct HDTBPartition *)other->listnode.ln.ln_Pred;
891 other = (struct HDTBPartition *)partition->listnode.ln.ln_Succ;
892 while (other->listnode.ln.ln_Succ)
894 if (other->listnode.ln.ln_Type == LNT_Partition)
896 if (other->flags & PNF_ACTIVE)
898 other->flags &= ~PNF_ACTIVE;
899 SetPartitionAttrsA(other->ph, PT_ACTIVE, FALSE, TAG_DONE);
900 setChanged(&other->listnode);
903 other = (struct HDTBPartition *)other->listnode.ln.ln_Succ;
906 SetPartitionAttrsA(partition->ph, PT_ACTIVE, check, TAG_DONE);
907 changed = TRUE;
909 changeda = FALSE;
910 get(mountbootgadgets.automount, MUIA_Selected, &check);
911 if (check)
913 if (!(partition->flags & PNF_AUTOMOUNT))
915 partition->flags |= PNF_AUTOMOUNT;
916 changeda = TRUE;
919 else
921 if (partition->flags & PNF_AUTOMOUNT)
923 partition->flags &= ~PNF_AUTOMOUNT;
924 changeda = TRUE;
927 if (changeda)
929 SetPartitionAttrsA(partition->ph, PT_AUTOMOUNT, check, TAG_DONE);
930 changed = TRUE;
932 changeda = FALSE;
933 get(mountbootgadgets.bootable, MUIA_Selected, &check);
934 if (check)
936 if (!(partition->flags & PNF_BOOTABLE))
938 partition->flags |= PNF_BOOTABLE;
939 changeda = TRUE;
941 get(mountbootgadgets.bootpri, MUIA_String_Integer, &value);
942 if (value != partition->de.de_BootPri)
944 partition->de.de_BootPri = value;
945 changeda = TRUE;
948 else
950 if (partition->flags & PNF_BOOTABLE)
952 partition->flags &= ~PNF_BOOTABLE;
953 partition->de.de_BootPri = 0;
954 changeda = TRUE;
957 if (changeda)
959 SetPartitionAttrsA(partition->ph, PT_BOOTABLE, check, PT_DOSENVEC, &partition->de, TAG_DONE);
960 changed = TRUE;
962 if (changed)
964 mountbootgadgets.iln->parent->flags |= LNF_ToSave;
965 setChanged(mountbootgadgets.iln);
969 else
971 switch (i)
973 case GB_ADD_ENTRY:
974 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, 0, (IPTR)&iln);
975 if (
976 (iln == NULL) ||
977 ((iln) && (iln->parent->parent == NULL))
980 set(adddevicegadgets.win, MUIA_Window_Open, TRUE);
982 else if ((iln->parent->ln.ln_Type == LNT_Harddisk) || (iln->parent->ln.ln_Type == LNT_Partition))
984 struct HDTBPartition *table;
985 table = (struct HDTBPartition *)iln->parent;
986 if (
988 (table->table->max_partitions) &&
989 (countNodes(&table->listnode.list, LNT_Partition)<table->table->max_partitions)
990 ) ||
991 (table->table->max_partitions == 0)
994 DoMethod
996 addpartitiongadgets.win,
997 MUIM_Notify, MUIA_Window_Open, TRUE, (IPTR)addpartitiongadgets.pt, 3,
998 MUIM_Set, PTCT_PartitionTable, (IPTR)table
1000 set(addpartitiongadgets.win, MUIA_Window_Open, TRUE);
1002 else
1003 set(gadgets.text, MUIA_Text_Contents, MSG(MSG_PARTITION_TABLE_FULL));
1005 break;
1006 case GB_REMOVE_ENTRY:
1007 get(gadgets.leftlv, MUIA_List_Active, &active);
1008 if (active != MUIV_List_Active_Off)
1010 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
1011 switch (iln->ln.ln_Type)
1013 case LNT_Device:
1014 DoMethod(gadgets.leftlv, MUIM_List_Remove, active);
1015 Remove(&iln->ln);
1016 freeDeviceNode((struct HDTBDevice *)iln);
1017 break;
1018 case LNT_Partition:
1020 struct HDTBPartition *partition;
1021 partition = (struct HDTBPartition *)iln;
1022 iln->parent->flags |= LNF_ToSave;
1023 setChanged(iln);
1024 DoMethod(gadgets.leftlv, MUIM_List_Remove, active);
1025 Remove(&iln->ln);
1026 DeletePartition(partition->ph);
1027 freePartitionNode(partition);
1031 break;
1032 case GB_CREATE_TABLE:
1033 case GB_CHANGE_TYPE:
1034 get(gadgets.leftlv, MUIA_List_Active, &active);
1035 if (active != MUIV_List_Active_Off)
1037 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
1038 if (
1039 (iln->ln.ln_Type == LNT_Harddisk) ||
1040 ((i==2) && (iln->ln.ln_Type == LNT_Partition))
1043 struct HDTBPartition *table;
1044 ULONG type = 0;
1045 partitiontabletypegadgets.iln = iln;
1046 table = (struct HDTBPartition *)iln;
1047 if (table->table)
1048 type = table->table->type;
1049 DoMethod(partitiontabletypegadgets.lv, MUIM_List_Clear);
1050 for (i=0;PartitionBase->tables[i] != NULL;i++)
1052 DoMethod
1054 partitiontabletypegadgets.lv,
1055 MUIM_List_InsertSingle, (IPTR)PartitionBase->tables[i]->pti_Name, MUIV_List_Insert_Bottom
1057 if (type == PartitionBase->tables[i]->pti_Type)
1058 set(partitiontabletypegadgets.lv, MUIA_List_Active, i);
1060 set(partitiontabletypegadgets.win, MUIA_Window_Open, TRUE);
1062 else if ((i==3) && (iln->ln.ln_Type == LNT_Partition))
1064 struct TypeNode *tn;
1065 struct HDTBPartition *partition;
1066 partitiontypegadgets.iln = iln;
1067 i = 0;
1068 DoMethod(partitiontypegadgets.lv, MUIM_List_Clear);
1069 partition = (struct HDTBPartition *)iln;
1070 partitiontypegadgets.ttn = findTableTypeNode(partition->root->table->type);
1071 if (partitiontypegadgets.ttn)
1073 tn = (struct TypeNode *)partitiontypegadgets.ttn->typelist->lh_Head;
1074 while (tn->ln.ln_Succ)
1076 DoMethod
1078 partitiontypegadgets.lv,
1079 MUIM_List_InsertSingle, (IPTR)tn->ln.ln_Name, MUIV_List_Insert_Bottom
1081 if (tn->type.id_len == partition->type.id_len)
1082 if (memcmp(tn->type.id, partition->type.id, tn->type.id_len) == 0)
1083 set(partitiontypegadgets.lv, MUIA_List_Active, i);
1084 tn = (struct TypeNode *)tn->ln.ln_Succ;
1085 i++;
1088 setTypeString(&partition->type, partitiontypegadgets.hexid);
1089 set(partitiontypegadgets.win, MUIA_Window_Open, TRUE);
1092 break;
1093 case GB_RESIZE_MOVE:
1094 break;
1095 case GB_PARENT:
1096 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, 0, (IPTR)&iln);
1097 if (iln->ln.ln_Type == LNT_Parent)
1099 set(gadgets.leftlv, MUIA_List_Active, 0);
1100 set(gadgets.leftlv, MUIA_Listview_DoubleClick, TRUE);
1102 break;
1103 case GB_RENAME:
1104 get(gadgets.leftlv, MUIA_List_Active, &active);
1105 if (active != MUIV_List_Active_Off)
1107 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
1108 if (iln->ln.ln_Type == LNT_Partition)
1110 struct HDTBPartition *partition;
1111 partition = (struct HDTBPartition *)iln;
1112 if (getAttrInfo(partition->root->table->pattrlist, PTA_NAME) & PLAM_READ)
1114 renamegadgets.iln = iln;
1115 set(renamegadgets.name, MUIA_String_Contents, iln->ln.ln_Name);
1116 set(renamegadgets.win, MUIA_Window_Open, TRUE);
1120 break;
1121 case GB_DOSENVEC:
1122 get(gadgets.leftlv, MUIA_List_Active, &active);
1123 if (active != MUIV_List_Active_Off)
1125 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
1126 if (iln->ln.ln_Type == LNT_Partition)
1128 struct HDTBPartition *partition;
1129 partition = (struct HDTBPartition *)iln;
1130 if (getAttrInfo(partition->root->table->pattrlist, PTA_DOSENVEC) & PLAM_READ)
1132 char str[32];
1133 dosenvecgadgets.iln = iln;
1134 set(dosenvecgadgets.mask, MUIA_String_Integer, partition->de.de_Mask);
1135 sprintf(str, "0x%08lx", partition->de.de_MaxTransfer);
1136 set(dosenvecgadgets.maxtransfer, MUIA_String_Contents, str);
1137 if (partition->de.de_TableSize>=(DE_BOOTBLOCKS+1))
1139 set(dosenvecgadgets.custboot, MUIA_Selected, TRUE);
1140 set(dosenvecgadgets.numcustboot, MUIA_String_Integer, partition->de.de_BootBlocks);
1142 else
1143 set(dosenvecgadgets.custboot, MUIA_Selected, FALSE);
1144 set(dosenvecgadgets.reservedblocksstart, MUIA_String_Integer, partition->de.de_Reserved);
1145 set(dosenvecgadgets.reservedblocksend, MUIA_String_Integer, partition->de.de_PreAlloc);
1146 set(dosenvecgadgets.blocksize, MUIA_Cycle_Active, getBitNum(partition->de.de_SizeBlock>>7));
1147 set(dosenvecgadgets.buffers, MUIA_String_Integer, partition->de.de_NumBuffers);
1148 set(dosenvecgadgets.win, MUIA_Window_Open, TRUE);
1152 break;
1153 case GB_SWITCHES:
1154 get(gadgets.leftlv, MUIA_List_Active, &active);
1155 if (active != MUIV_List_Active_Off)
1157 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
1158 if (iln->ln.ln_Type == LNT_Partition)
1160 struct HDTBPartition *partition;
1161 BOOL active;
1162 BOOL automount;
1163 BOOL bootable;
1164 partition = (struct HDTBPartition *)iln;
1165 active = getAttrInfo(partition->root->table->pattrlist, PTA_ACTIVE);
1166 automount = getAttrInfo(partition->root->table->pattrlist, PTA_AUTOMOUNT);
1167 bootable = getAttrInfo(partition->root->table->pattrlist, PTA_BOOTABLE);
1168 if ((active | automount | bootable) & PLAM_READ)
1170 mountbootgadgets.iln = iln;
1171 set(mountbootgadgets.active, MUIA_Disabled, !(active & PLAM_READ));
1172 set(mountbootgadgets.automount, MUIA_Disabled, !(automount & PLAM_READ));
1173 set(mountbootgadgets.bootable, MUIA_Disabled, !(bootable & PLAM_READ));
1174 set(mountbootgadgets.bootpri, MUIA_Disabled, !(bootable & PLAM_READ));
1175 set(mountbootgadgets.active, MUIA_Selected, (partition->flags & PNF_ACTIVE) ? TRUE : FALSE);
1176 set(mountbootgadgets.automount, MUIA_Selected, (partition->flags & PNF_AUTOMOUNT) ? TRUE : FALSE);
1177 if (partition->flags & PNF_BOOTABLE)
1179 set(mountbootgadgets.bootable, MUIA_Selected, TRUE);
1180 set(mountbootgadgets.bootpri, MUIA_String_Integer, partition->de.de_BootPri);
1182 else
1183 set(mountbootgadgets.bootable, MUIA_Selected, FALSE);
1184 set(mountbootgadgets.win, MUIA_Window_Open, TRUE);
1188 break;
1189 case GB_SAVE_CHANGES:
1190 get(gadgets.leftlv, MUIA_List_Active, &active);
1191 if (active != MUIV_List_Active_Off)
1193 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
1194 saveChanges(iln, TRUE);
1196 break;
1200 AROS_USERFUNC_EXIT
1204 * DosEnvec of all partitions holds cylinder numbers relative to partition start.
1205 * This function returns absolute start cylinder number for the partition.
1207 static ULONG GetStartCyl(struct HDTBPartition *part)
1209 ULONG blockspercyl = part->de.de_Surfaces * part->de.de_BlocksPerTrack;
1210 ULONG ret = 0;
1212 while (part->listnode.parent)
1214 part = (struct HDTBPartition *)part->listnode.parent;
1216 if (part->listnode.ln.ln_Type != LNT_Partition)
1217 break;
1220 * Calculate start offset in blocks. This can be done because theoretically
1221 * partitions can have different virtual geometries.
1223 ret += part->de.de_LowCyl * part->de.de_Surfaces * part->de.de_BlocksPerTrack;
1227 * FIXME: What if this can't be divided in interegs?
1228 * This can happen for example if the disk was partitioned on another machine where
1229 * disk driver reported different (virtual) geometry. In this case we should be able
1230 * to adjust mountlist geometry (Surfaces and BlocksPerTrack) so that division works
1231 * correctly and CHS-LBA relationship is still not broken.
1233 return ret / blockspercyl;
1236 static struct FileSysEntry *FindFileSysEntry(ULONG dostype)
1238 struct FileSysEntry *fse;
1239 struct FileSysResource *fsr = OpenResource("FileSystem.resource");
1241 if (!fsr)
1242 return NULL;
1244 ForeachNode(&fsr->fsr_FileSysEntries, fse)
1246 if (fse->fse_DosType == dostype)
1247 return fse;
1250 return NULL;
1253 AROS_UFH3(void, createml_function,
1254 AROS_UFHA(struct Hook *, h, A0),
1255 AROS_UFHA(Object *, object, A2),
1256 AROS_UFHA(ULONG *, arg, A1))
1258 AROS_USERFUNC_INIT
1260 IPTR active = MUIA_List_Active;
1261 struct HDTBPartition *partition = NULL;
1263 get(gadgets.leftlv, MUIA_List_Active, &active);
1264 if (active != MUIV_List_Active_Off)
1266 struct FileRequester *req;
1267 struct TagItem asltags[] =
1269 {ASLFR_InitialDrawer, (IPTR)"SYS:Storage/DOSDrivers"},
1270 {ASLFR_InitialFile , 0},
1271 {ASLFR_DoSaveMode , TRUE},
1272 {TAG_DONE , 0}
1275 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, &partition);
1276 asltags[1].ti_Data = (IPTR)partition->listnode.ln.ln_Name;
1278 req = MUI_AllocAslRequest(ASL_FileRequest, asltags);
1280 if (!req)
1281 return;
1283 if (MUI_AslRequest(req, NULL))
1285 ULONG len = strlen(req->fr_Drawer) + strlen(req->fr_File) + 2;
1286 STRPTR pathname = AllocMem(len, MEMF_ANY);
1288 if (pathname)
1290 BPTR file;
1292 strcpy(pathname, req->fr_Drawer);
1293 AddPart(pathname, req->fr_File, len);
1295 file = Open(pathname, MODE_NEWFILE);
1296 FreeMem(pathname, len);
1298 if (file)
1300 struct DiskObject *icon;
1301 IPTR args[20];
1302 struct FileSysEntry *fse;
1303 ULONG startcyl = GetStartCyl(partition);
1305 args[ 0] = (IPTR)"";
1306 args[ 1] = (IPTR)partition->ph->bd->ioreq->iotd_Req.io_Device->dd_Library.lib_Node.ln_Name;
1307 args[ 2] = ((struct HDNode *)partition->root)->unit;
1308 args[ 3] = partition->de.de_SizeBlock * 4; /* block size in longs */
1309 args[ 4] = partition->de.de_Surfaces;
1310 args[ 5] = partition->de.de_SectorPerBlock;
1311 args[ 6] = partition->de.de_BlocksPerTrack;
1312 args[ 7] = partition->de.de_Reserved;
1313 args[ 8] = partition->de.de_PreAlloc;
1314 args[ 9] = partition->de.de_Interleave;
1315 args[10] = partition->de.de_MaxTransfer;
1316 args[11] = partition->de.de_Mask;
1317 args[12] = partition->de.de_LowCyl + startcyl;
1318 args[13] = partition->de.de_HighCyl + startcyl;
1319 args[14] = partition->de.de_NumBuffers;
1320 args[15] = partition->de.de_BufMemType;
1321 args[16] = 16384;
1322 args[17] = 0;
1323 args[18] = -1;
1324 args[19] = partition->de.de_DosType;
1327 * Some things can be fetched only from FileSystem.resource.
1328 * Let's try to do it.
1330 fse = FindFileSysEntry(partition->de.de_DosType);
1331 if (fse)
1333 if (fse->fse_PatchFlags & FSEF_HANDLER)
1334 args[0] = (IPTR)AROS_BSTR_ADDR(fse->fse_Handler);
1336 if (fse->fse_PatchFlags & FSEF_STACKSIZE)
1337 args[16] = fse->fse_StackSize;
1339 if (fse->fse_PatchFlags & FSEF_PRIORITY)
1340 args[17] = fse->fse_Priority;
1342 if (fse->fse_PatchFlags & FSEF_GLOBALVEC)
1343 args[18] = (IPTR)fse->fse_GlobalVec;
1346 VFPrintf(file, "FileSystem = %s\n"
1347 "Device = %s\n"
1348 "Unit = %ld\n"
1349 "BlockSize = %ld\n"
1350 "Surfaces = %ld\n"
1351 "SectorsPerBlock = %ld\n"
1352 "BlocksPerTrack = %ld\n"
1353 "Reserved = %ld\n"
1354 "PreAlloc = %ld\n"
1355 "Interleave = %ld\n"
1356 "MaxTransfer = 0x%08lx\n"
1357 "Mask = 0x%08lx\n"
1358 "LowCyl = %ld\n"
1359 "HighCyl = %ld\n"
1360 "Buffers = %ld\n"
1361 "BufMemType = %ld\n"
1362 "StackSize = %ld\n"
1363 "Priority = %ld\n"
1364 "GlobVec = %ld\n"
1365 "DosType = 0x%08lx\n"
1366 "Activate = 1\n",
1367 args);
1369 Close(file);
1371 icon = GetDiskObject("ENVARC:Sys/def_Mountlist");
1372 if (icon)
1374 PutDiskObject(pathname, icon);
1375 FreeDiskObject(icon);
1381 MUI_FreeAslRequest(req);
1384 AROS_USERFUNC_EXIT
1387 /************************* general List functions ***************************/
1389 LONG InitListNode(struct ListNode *node, struct ListNode *parent)
1391 struct ListNode *new;
1393 D(bug("[HDToolBox] InitListNode()\n"));
1395 NEWLIST(&node->list);
1396 new = AllocMem(sizeof(struct ListNode), MEMF_PUBLIC | MEMF_CLEAR);
1397 if (new)
1399 node->parent = parent;
1400 new->ln.ln_Name = "..";
1401 new->ln.ln_Type = LNT_Parent;
1402 new->ln.ln_Pri = 127;
1403 new->parent = node;
1404 AddTail(&node->list, &new->ln);
1405 return TRUE;
1407 return FALSE;
1410 void UninitListNode(struct ListNode *node)
1412 struct ListNode *parent, *next;
1414 D(bug("[HDToolBox] UninitListNode()\n"));
1416 /* free parent entry */
1417 parent = (struct ListNode *)node->list.lh_Head;
1418 while (parent->ln.ln_Succ)
1420 next = (struct ListNode *)parent->ln.ln_Succ;
1421 if (parent->ln.ln_Type == LNT_Parent)
1423 Remove(&parent->ln);
1424 FreeMem(parent, sizeof(struct ListNode));
1425 return;
1427 parent = next;
1431 void InsertList(Object *list, struct ListNode *node)
1433 D(bug("[HDToolBox] InsertList()\n"));
1435 DoMethod(list, MUIM_List_InsertSingle, (IPTR)node, MUIV_List_Insert_Bottom);
1438 void ShowList(Object *list, struct List *lh)
1440 struct ListNode *lnode;
1442 D(bug("[HDToolBox] ShowList()\n"));
1444 DoMethod(list, MUIM_List_Clear);
1445 lnode = (struct ListNode *)lh->lh_Head;
1446 while (lnode->ln.ln_Succ)
1448 if (
1450 ((lnode->ln.ln_Type == LNT_Parent) && (lnode->parent->parent != NULL)) ||
1451 (lnode->ln.ln_Type != LNT_Parent)
1452 ) &&
1453 (!(lnode->flags & LNF_Invalid))
1456 DoMethod(list, MUIM_List_InsertSingle, (IPTR)lnode, MUIV_List_Insert_Bottom);
1458 lnode = (struct ListNode *)lnode->ln.ln_Succ;
1462 void disableObject(Object *object)
1464 LONG disabled = FALSE;
1466 D(bug("[HDToolBox] disableObject()\n"));
1468 get(object, MUIA_Disabled, &disabled);
1469 if (disabled == FALSE)
1471 set(object, MUIA_Disabled, TRUE);
1475 void enableObject(Object *object)
1477 LONG disabled = FALSE;
1479 D(bug("[HDToolBox] enableObject()\n"));
1481 get(object, MUIA_Disabled, &disabled);
1482 if (disabled == TRUE)
1484 set(object, MUIA_Disabled, FALSE);
1489 /********************************** Left Listview ***************************/
1491 struct LeftListview__Data
1493 struct IOStdReq ioreq;
1494 struct MUI_EventHandlerNode ehn;
1497 BOOPSI_DISPATCHER(IPTR, LeftListview_Dispatcher, CLASS, self, message)
1499 IPTR retval = 0;
1501 switch (message->MethodID)
1503 case OM_NEW:
1505 struct opSet *msg = (struct opSet *)message;
1507 retval = DoSuperMethod(CLASS, self, OM_NEW, msg->ops_AttrList, NULL);
1508 if (retval)
1510 struct LeftListview__Data *data = INST_DATA(CLASS, retval);
1511 data->ehn.ehn_Events = IDCMP_RAWKEY;
1512 data->ehn.ehn_Priority = 0;
1513 data->ehn.ehn_Flags = 0;
1514 data->ehn.ehn_Object = (Object *)retval;
1515 data->ehn.ehn_Class = CLASS;
1517 break;
1519 case MUIM_Setup:
1521 if ((retval = DoSuperMethodA(CLASS, self, message)))
1523 struct LeftListview__Data *data = INST_DATA(CLASS, self);
1525 if (0 == OpenDevice("console.device", -1, (struct IORequest *)&data->ioreq, 0)) {
1526 ConsoleDevice = (struct Library *)data->ioreq.io_Device;
1527 DoMethod(_win(self), MUIM_Window_AddEventHandler, (IPTR) &data->ehn);
1530 break;
1532 case MUIM_Cleanup:
1534 struct LeftListview__Data *data = INST_DATA(CLASS, self);
1536 if (ConsoleDevice)
1538 DoMethod(_win(self), MUIM_Window_RemEventHandler, (IPTR) &data->ehn);
1539 CloseDevice((struct IORequest *)&data->ioreq);
1542 retval = DoSuperMethodA(CLASS, self, message);
1543 break;
1545 case MUIM_HandleEvent:
1547 struct MUIP_HandleEvent *msg = (struct MUIP_HandleEvent *)message;
1549 if ((ConsoleDevice) && (msg->imsg) && (msg->imsg->Class == IDCMP_RAWKEY))
1551 unsigned char buffer[10];
1552 struct InputEvent keyEvent;
1553 UBYTE numchars;
1555 keyEvent.ie_Class = IECLASS_RAWKEY;
1556 keyEvent.ie_Code = msg->imsg->Code;
1557 keyEvent.ie_Qualifier = msg->imsg->Qualifier;
1558 keyEvent.ie_EventAddress = (APTR) (msg->imsg->IAddress);
1560 numchars = RawKeyConvert(&keyEvent, (char *)buffer, sizeof(buffer), NULL);
1562 if ((numchars == 1) && (buffer[0] == 13))
1564 SET(self, MUIA_Listview_DoubleClick, TRUE);
1565 retval = MUI_EventHandlerRC_Eat;
1567 break;
1571 default:
1572 retval = DoSuperMethodA(CLASS, self, message);
1575 return retval;
1577 BOOPSI_DISPATCHER_END
1579 AROS_UFH3(void, lv_doubleclick,
1580 AROS_UFHA(struct Hook *, h, A0),
1581 AROS_UFHA(Object *, object, A2),
1582 AROS_UFHA(void *, arg, A1))
1584 AROS_USERFUNC_INIT
1586 LONG active = MUIV_List_Active_Off;
1587 LONG type = -1;
1588 struct ListNode *iln;
1590 D(bug("[HDToolBox] lv_doubleclick()\n"));
1592 get(object, MUIA_List_Active, &active);
1593 if (active != MUIV_List_Active_Off)
1595 DoMethod(object,MUIM_List_GetEntry,active, (IPTR)&iln);
1596 if (iln->flags & LNF_Listable)
1598 ShowList(object, &iln->list);
1599 type = iln->ln.ln_Type;
1601 else if (iln->ln.ln_Type == LNT_Parent)
1603 if (iln->parent->parent)
1605 ShowList(object, &iln->parent->parent->list);
1606 type = iln->parent->parent->ln.ln_Type;
1607 iln = iln->parent;
1610 switch (type)
1612 case LNT_Root:
1613 enableObject(gadgets.buttons[GB_ADD_ENTRY]);
1614 disableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
1615 disableObject(gadgets.buttons[GB_CREATE_TABLE]);
1616 disableObject(gadgets.buttons[GB_CHANGE_TYPE]);
1617 disableObject(gadgets.buttons[GB_RESIZE_MOVE]);
1618 disableObject(gadgets.buttons[GB_PARENT]);
1619 disableObject(gadgets.buttons[GB_RENAME]);
1620 disableObject(gadgets.buttons[GB_DOSENVEC]);
1621 disableObject(gadgets.buttons[GB_SWITCHES]);
1622 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1623 break;
1624 case LNT_Device:
1625 disableObject(gadgets.buttons[GB_ADD_ENTRY]);
1626 disableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
1627 disableObject(gadgets.buttons[GB_CREATE_TABLE]);
1628 disableObject(gadgets.buttons[GB_CHANGE_TYPE]);
1629 disableObject(gadgets.buttons[GB_RESIZE_MOVE]);
1630 enableObject(gadgets.buttons[GB_PARENT]);
1631 disableObject(gadgets.buttons[GB_RENAME]);
1632 disableObject(gadgets.buttons[GB_DOSENVEC]);
1633 disableObject(gadgets.buttons[GB_SWITCHES]);
1634 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1635 break;
1636 case LNT_Harddisk:
1637 case LNT_Partition:
1638 enableObject(gadgets.buttons[GB_ADD_ENTRY]);
1639 disableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
1640 disableObject(gadgets.buttons[GB_CREATE_TABLE]);
1641 disableObject(gadgets.buttons[GB_CHANGE_TYPE]);
1642 enableObject(gadgets.buttons[GB_RESIZE_MOVE]);
1643 enableObject(gadgets.buttons[GB_PARENT]);
1644 disableObject(gadgets.buttons[GB_RENAME]);
1645 disableObject(gadgets.buttons[GB_DOSENVEC]);
1646 disableObject(gadgets.buttons[GB_SWITCHES]);
1647 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1648 DoMethod(gadgets.buttons[GB_RESIZE_MOVE], MUIM_KillNotify, MUIA_Pressed);
1649 DoMethod
1651 gadgets.buttons[GB_RESIZE_MOVE],
1652 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)resizemovegadgets.win, 3,
1653 MUIM_Set, MUIA_Window_Open, TRUE
1655 DoMethod
1657 resizemovegadgets.win,
1658 MUIM_Notify, MUIA_Window_Open, TRUE, (IPTR)resizemovegadgets.pt, 3,
1659 MUIM_Set, PTCT_PartitionTable, (IPTR)iln
1661 break;
1665 AROS_USERFUNC_EXIT
1668 AROS_UFH3(void, lv_click,
1669 AROS_UFHA(struct Hook *, h, A0),
1670 AROS_UFHA(Object *, object, A2),
1671 AROS_UFHA(void *, arg, A1))
1673 AROS_USERFUNC_INIT
1675 LONG active = MUIV_List_Active_Off;
1676 struct ListNode *iln;
1677 char str[64];
1678 char sizestr[16];
1680 D(bug("[HDToolBox] lv_click()\n"));
1682 get(object, MUIA_List_Active, &active);
1683 if (active != MUIV_List_Active_Off)
1685 DoMethod(object,MUIM_List_GetEntry,active, (IPTR)&iln);
1686 DoMethod(gadgets.rightlv, MUIM_List_Clear);
1687 switch (iln->ln.ln_Type)
1689 case LNT_Device:
1690 sprintf(str, "%s: %d", MSG(WORD_Units),(int)countNodes(&iln->list, LNT_Harddisk));
1691 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1692 enableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
1693 if (iln->change_count > 0)
1694 enableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1695 else
1696 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1697 break;
1698 case LNT_Harddisk:
1699 case LNT_Partition:
1701 struct HDTBPartition *partition;
1702 partition = (struct HDTBPartition *)iln;
1703 getSizeStr
1705 sizestr,
1708 (partition->de.de_HighCyl-partition->de.de_LowCyl+1)*
1709 partition->de.de_Surfaces*partition->de.de_BlocksPerTrack
1713 sprintf(str, "%s: %s", MSG(WORD_Size), sizestr);
1714 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1715 sprintf(str, "%s: ", MSG(WORD_Partition_Table));
1716 if (partition->table)
1718 struct TableTypeNode *ttn;
1719 ttn = findTableTypeNode(partition->table->type);
1720 strcat(str, ttn->pti->pti_Name);
1721 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1722 sprintf(str, "%s: %d", MSG(WORD_Partitions), (int)countNodes(&iln->list, LNT_Partition));
1723 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1725 else
1727 strcat(str, MSG(WORD_Unknown));
1728 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1730 if (iln->ln.ln_Type == LNT_Partition)
1732 struct TypeNode *type;
1733 type = findPartitionType(&partition->type, partition->root->table->type);
1734 sprintf(str, "%s: ", MSG(WORD_Partition_Type));
1735 if (type)
1736 strcat(str, type->ln.ln_Name);
1737 else
1738 strcat(str, MSG(WORD_Unknown));
1739 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1740 sprintf(str, "%s: ", MSG(WORD_Active));
1741 if (partition->flags & PNF_ACTIVE)
1742 strcat(str, MSG_STD(YESSTR));
1743 else
1744 strcat(str, MSG_STD(NOSTR));
1745 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1746 sprintf(str, "%s: ", MSG(WORD_Bootable));
1747 if (partition->flags & PNF_BOOTABLE)
1748 strcat(str, MSG_STD(YESSTR));
1749 else
1750 strcat(str, MSG_STD(NOSTR));
1751 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1752 sprintf(str, "%s: ", MSG(WORD_Automount));
1753 if (partition->flags & PNF_AUTOMOUNT)
1754 strcat(str, MSG_STD(YESSTR));
1755 else
1756 strcat(str, MSG_STD(NOSTR));
1757 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1758 enableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
1759 enableObject(gadgets.buttons[GB_RENAME]);
1760 enableObject(gadgets.buttons[GB_DOSENVEC]);
1761 enableObject(gadgets.buttons[GB_SWITCHES]);
1762 SetAttrs(part_item, MUIA_Menuitem_Enabled, !partition->table, TAG_DONE);
1764 else if (iln->ln.ln_Type == LNT_Harddisk)
1766 if (iln->change_count > 0)
1767 enableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1768 else
1769 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1771 enableObject(gadgets.buttons[GB_CREATE_TABLE]);
1772 enableObject(gadgets.buttons[GB_CHANGE_TYPE]);
1774 break;
1775 case LNT_Parent:
1776 disableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
1777 disableObject(gadgets.buttons[GB_RENAME]);
1778 disableObject(gadgets.buttons[GB_DOSENVEC]);
1779 disableObject(gadgets.buttons[GB_SWITCHES]);
1780 disableObject(gadgets.buttons[GB_CREATE_TABLE]);
1781 disableObject(gadgets.buttons[GB_CHANGE_TYPE]);
1782 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1783 SetAttrs(part_item, MUIA_Menuitem_Enabled, FALSE, TAG_DONE);
1784 break;
1788 AROS_USERFUNC_EXIT
1791 /**************************************** Main ******************************/
1793 LONG initGUI(void)
1795 struct MUI_CustomClass *listcc;
1796 int i;
1798 D(bug("[HDToolBox] initGUI()\n"));
1800 MUIMasterBase = OpenLibrary("muimaster.library", 0);
1801 if (!MUIMasterBase)
1802 return ERR_MUIMASTER;
1804 ptclass = makePTClass();
1805 if (ptclass == NULL)
1806 return ERR_GADGETS;
1808 listcc = MUI_CreateCustomClass(NULL, MUIC_Listview, NULL,
1809 sizeof(struct LeftListview__Data), LeftListview_Dispatcher);
1810 if (listcc == NULL)
1811 return ERR_GADGETS;
1813 hook_display.h_Entry = (HOOKFUNC)display_function;
1814 hook_buttons.h_Entry = (HOOKFUNC)buttons_function;
1815 hook_createml.h_Entry = (HOOKFUNC)createml_function;
1816 hook_lv_doubleclick.h_Entry = (HOOKFUNC)lv_doubleclick;
1817 hook_lv_click.h_Entry = (HOOKFUNC)lv_click;
1818 partitiontypegadgets.hook_hexidedit.h_Entry = (HOOKFUNC)hexidedit_function;
1820 app = ApplicationObject,
1821 MUIA_Application_Title , "HDToolBox",
1822 MUIA_Application_Version , "$VER: HDToolBox 0.5 (19.5.2015)",
1823 MUIA_Application_Copyright , "(c) 1995-2014 AROS Development Team",
1824 MUIA_Application_Author , "Bearly, Ogun, Fats and others at AROS",
1825 MUIA_Application_Description, "Partition your disks.",
1826 MUIA_Application_Base , "HDTOOLBOX",
1827 MUIA_Application_Menustrip, MenuitemObject,
1828 MUIA_Family_Child, MenuitemObject,
1829 MUIA_Menuitem_Title, MSG(WORD_MENU_Project),
1830 MUIA_Family_Child,
1831 about_item = MenuitemObject, MUIA_Menuitem_Title, MSG(WORD_MENU_About),
1832 End,
1833 MUIA_Family_Child,
1834 quit_item = MenuitemObject, MUIA_Menuitem_Title, MSG(WORD_MENU_Quit),
1835 End,
1836 End,
1837 MUIA_Family_Child,
1838 part_item = MenuitemObject,
1839 MUIA_Menuitem_Title, MSG(WORD_MENU_Partition),
1840 MUIA_Menuitem_Enabled, FALSE,
1841 MUIA_Family_Child,
1842 createml_item = MenuitemObject,
1843 MUIA_Menuitem_Title, MSG(WORD_MENU_CreateMountlist),
1844 End,
1845 End,
1846 End,
1847 SubWindow, mainwin = WindowObject,
1848 MUIA_Window_Title, "HDToolBox",
1849 MUIA_Window_ID, MAKE_ID('H','D','T','B'),
1850 MUIA_Window_Activate, TRUE,
1851 MUIA_Window_Height, MUIV_Window_Height_Visible(50),
1852 MUIA_Window_Width, MUIV_Window_Width_Visible(60),
1853 WindowContents, VGroup,
1854 Child, VGroup,
1855 GroupFrame,
1856 Child, gadgets.text = TextObject,
1857 TextFrame,
1858 MUIA_Text_Contents, MSG(MSG_Welcome),
1859 End,
1860 Child, HGroup,
1861 Child, (gadgets.leftlv = NewObject(listcc->mcc_Class, NULL,
1862 MUIA_Listview_List, ListObject,
1863 InputListFrame,
1864 MUIA_CycleChain, 1,
1865 MUIA_List_DisplayHook, &hook_display,
1866 MUIA_List_Format, ",",
1867 MUIA_List_Title, TRUE,
1868 End,
1869 TAG_DONE)),
1870 Child, ListviewObject,
1871 MUIA_Listview_List, (gadgets.rightlv = ListObject,
1872 ReadListFrame,
1873 MUIA_List_Title, TRUE,
1874 MUIA_List_ConstructHook, MUIV_List_ConstructHook_String,
1875 MUIA_List_DestructHook, MUIV_List_DestructHook_String,
1876 End),
1877 MUIA_Listview_Input, FALSE,
1878 End,
1879 End,
1880 End,
1881 Child, VGroup,
1882 GroupFrame,
1883 Child, HGroup,
1884 Child, VGroup,
1885 Child, gadgets.buttons[GB_ADD_ENTRY] = SIMPLEBUTTON(WORD_AddEntry),
1886 Child, gadgets.buttons[GB_REMOVE_ENTRY] = SIMPLEBUTTON(WORD_RemoveEntry),
1887 End,
1888 Child, VGroup,
1889 Child, gadgets.buttons[GB_CREATE_TABLE] = SIMPLEBUTTON(WORD_Create_Table),
1890 Child, gadgets.buttons[GB_CHANGE_TYPE] = SIMPLEBUTTON(WORD_Change_Type),
1891 End,
1892 Child, VGroup,
1893 Child, gadgets.buttons[GB_RESIZE_MOVE] = SIMPLEBUTTON(WORD_Resize_Move),
1894 Child, gadgets.buttons[GB_PARENT] = SIMPLEBUTTON(WORD_Parent),
1895 End,
1896 Child, VGroup,
1897 Child, gadgets.buttons[GB_RENAME] = SIMPLEBUTTON(WORD_Rename),
1898 Child, gadgets.buttons[GB_DOSENVEC] = SIMPLEBUTTON(WORD_DosEnvec),
1899 End,
1900 Child, VGroup,
1901 Child, gadgets.buttons[GB_SWITCHES] = SIMPLEBUTTON(WORD_Switches),
1902 Child, HVSpace,
1903 End,
1904 End,
1905 Child, HGroup,
1906 MUIA_Group_SameWidth, TRUE,
1907 MUIA_FixHeight, 1,
1908 Child, gadgets.buttons[GB_SAVE_CHANGES] = IMAGEBUTTON(WORD_Save_Changes, COOL_SAVEIMAGE_ID),
1909 Child, gadgets.buttons[GB_EXIT] = IMAGEBUTTON(WORD_Exit, COOL_CANCELIMAGE_ID),
1910 End,
1911 End,
1912 End,
1913 End,
1914 SubWindow, adddevicegadgets.win = WindowObject,
1915 MUIA_Window_Title, MSG(WORD_Devices),
1916 MUIA_Window_Activate, TRUE,
1917 WindowContents, VGroup,
1918 Child, PopaslObject,
1919 MUIA_Popstring_String, adddevicegadgets.file = StringObject,
1920 StringFrame,
1921 End,
1922 MUIA_Popstring_Button, PopButton(MUII_PopFile),
1923 End,
1924 Child, HGroup,
1925 MUIA_Group_SameWidth, TRUE,
1926 MUIA_FixHeight, 1,
1927 Child, adddevicegadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
1928 Child, adddevicegadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
1929 End,
1930 End,
1931 End,
1932 SubWindow, addpartitiongadgets.win = WindowObject,
1933 MUIA_Window_Title, MSG(MSG_Select_Empty_Area),
1934 MUIA_Window_Activate, TRUE,
1935 WindowContents, VGroup,
1936 Child, addpartitiongadgets.pt = BoopsiObject,
1937 GroupFrame,
1938 MUIA_Boopsi_Class, ptclass,
1939 MUIA_Boopsi_MinWidth, 600,
1940 MUIA_Boopsi_MinHeight, 100,
1941 MUIA_Boopsi_TagDrawInfo, GA_DrawInfo,
1942 MUIA_Boopsi_Remember, PTCT_PartitionTable,
1943 MUIA_Boopsi_Remember, PTCT_Flags,
1944 PTCT_Flags, PTCTF_NoPartitionMove | PTCTF_EmptySelectOnly,
1945 GA_Left, 0,
1946 GA_Top, 0,
1947 GA_Width, 0,
1948 GA_Height, 0,
1949 GA_DrawInfo, 0,
1950 MUIA_VertWeight, 10,
1951 ICA_TARGET, ICTARGET_IDCMP,
1952 End,
1953 Child, HGroup,
1954 MUIA_Group_SameWidth, TRUE,
1955 MUIA_FixHeight, 1,
1956 Child, addpartitiongadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
1957 Child, addpartitiongadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
1958 End,
1959 End,
1960 End,
1961 SubWindow, partitiontypegadgets.win = WindowObject,
1962 MUIA_Window_Title, MSG(WORD_Partition_Type),
1963 MUIA_Window_Activate, TRUE,
1964 WindowContents, VGroup,
1965 Child, partitiontypegadgets.lv = ListviewObject,
1966 MUIA_Listview_List, ListObject,
1967 InputListFrame,
1968 MUIA_List_ConstructHook, MUIV_List_ConstructHook_String,
1969 MUIA_List_DestructHook, MUIV_List_DestructHook_String,
1970 MUIA_List_Title, TRUE,
1971 End,
1972 End,
1973 Child, HGroup,
1974 Child, partitiontypegadgets.base = CycleObject,
1975 ButtonFrame,
1976 MUIA_Cycle_Entries, editcycleentries,
1977 MUIA_HorizWeight, 1,
1978 End,
1979 Child, partitiontypegadgets.hexid = StringObject,
1980 StringFrame,
1981 MUIA_String_EditHook, &partitiontypegadgets.hook_hexidedit,
1982 End,
1983 End,
1984 Child, HGroup,
1985 MUIA_Group_SameWidth, TRUE,
1986 MUIA_FixHeight, 1,
1987 Child, partitiontypegadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
1988 Child, partitiontypegadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
1989 End,
1990 End,
1991 End,
1992 SubWindow, partitiontabletypegadgets.win = WindowObject,
1993 MUIA_Window_Title, MSG(WORD_Partition_Table_Type),
1994 MUIA_Window_Activate, TRUE,
1995 WindowContents, VGroup,
1996 Child, partitiontabletypegadgets.lv = ListviewObject,
1997 MUIA_Listview_List, ListObject,
1998 InputListFrame,
1999 MUIA_List_ConstructHook, MUIV_List_ConstructHook_String,
2000 MUIA_List_DestructHook, MUIV_List_DestructHook_String,
2001 MUIA_List_Title, TRUE,
2002 End,
2003 End,
2004 Child, HGroup,
2005 MUIA_Group_SameWidth, TRUE,
2006 MUIA_FixHeight, 1,
2007 Child, partitiontabletypegadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
2008 Child, partitiontabletypegadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
2009 End,
2010 End,
2011 End,
2012 SubWindow, resizemovegadgets.win = WindowObject,
2013 MUIA_Window_Title, MSG(MSG_Select_Partition_Resize_Move),
2014 MUIA_Window_Activate, TRUE,
2015 WindowContents, VGroup,
2016 Child, resizemovegadgets.pt = BoopsiObject,
2017 GroupFrame,
2018 MUIA_Boopsi_Class, ptclass,
2019 MUIA_Boopsi_MinWidth, 600,
2020 MUIA_Boopsi_MinHeight, 100,
2021 MUIA_Boopsi_TagDrawInfo, GA_DrawInfo,
2022 MUIA_Boopsi_Remember, PTCT_PartitionTable,
2023 MUIA_Boopsi_Remember, PTCT_Flags,
2024 PTCT_Flags, 0,
2025 GA_Left, 0,
2026 GA_Top, 0,
2027 GA_Width, 0,
2028 GA_Height, 0,
2029 GA_DrawInfo, 0,
2030 MUIA_VertWeight, 10,
2031 ICA_TARGET, ICTARGET_IDCMP,
2032 End,
2033 Child, VGroup,
2034 GroupFrame,
2035 MUIA_FrameTitle, MSG(WORD_Geometry),
2036 Child, HGroup,
2037 Child, VGroup,
2038 Child, HGroup,
2039 Child, Label2("Low Cyl"),
2040 Child, resizemovegadgets.lowcyl=StringObject,
2041 StringFrame,
2042 MUIA_String_Integer, 0,
2043 MUIA_String_Accept, "0123456789",
2044 End,
2045 End,
2046 Child, HGroup,
2047 Child, Label2("High Cyl"),
2048 Child, resizemovegadgets.highcyl=StringObject,
2049 StringFrame,
2050 MUIA_String_Integer, 0,
2051 MUIA_String_Accept, "0123456789",
2052 End,
2053 End,
2054 Child, HGroup,
2055 Child, Label2("Total Cyl"),
2056 Child, resizemovegadgets.totalcyl=StringObject,
2057 StringFrame,
2058 MUIA_String_Integer, 0,
2059 MUIA_String_Accept, "0123456789",
2060 End,
2061 End,
2062 MUIA_HorizWeight, 10,
2063 End,
2064 Child, Label2("Size"),
2065 Child, resizemovegadgets.size=StringObject,
2066 ButtonFrame,
2067 MUIA_String_Accept, "0123456789GM.",
2068 MUIA_HorizWeight, 3,
2069 End,
2070 End,
2071 End,
2072 Child, HGroup,
2073 MUIA_Group_SameWidth, TRUE,
2074 MUIA_FixHeight, 1,
2075 Child, resizemovegadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
2076 Child, resizemovegadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
2077 End,
2078 End,
2079 End,
2080 SubWindow, renamegadgets.win = WindowObject,
2081 MUIA_Window_Title, MSG(WORD_Rename),
2082 MUIA_Window_Activate, TRUE,
2083 WindowContents, VGroup,
2084 Child, renamegadgets.name = StringObject,
2085 StringFrame,
2086 End,
2087 Child, HGroup,
2088 MUIA_Group_SameWidth, TRUE,
2089 MUIA_FixHeight, 1,
2090 Child, renamegadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
2091 Child, renamegadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
2092 End,
2093 End,
2094 End,
2095 SubWindow, dosenvecgadgets.win = WindowObject,
2096 MUIA_Window_Title, MSG(WORD_DosEnvec),
2097 MUIA_Window_Activate, TRUE,
2098 WindowContents, VGroup,
2099 Child, VGroup,
2100 GroupFrame,
2101 Child, HGroup,
2102 Child, Label2("Mask"),
2103 Child, dosenvecgadgets.mask=StringObject,
2104 StringFrame,
2105 MUIA_String_Integer, -2,
2106 MUIA_String_Accept, "0123456789",
2107 End,
2108 End,
2109 Child, HGroup,
2110 Child, Label2("MaxTransfer"),
2111 Child, dosenvecgadgets.maxtransfer=StringObject,
2112 StringFrame,
2113 MUIA_String_Contents, "0x7FFFFF",
2114 MUIA_String_Accept, "0123456789x",
2115 End,
2116 End,
2117 End,
2118 Child, VGroup,
2119 GroupFrame,
2120 Child, HGroup,
2121 Child, Label("_Custom Bootcode"),
2122 Child, HVSpace,
2123 Child, dosenvecgadgets.custboot=MUI_MakeObject
2125 MUIO_Checkmark,
2126 (IPTR)"_Custom Bootcode"
2128 End,
2129 Child, HGroup,
2130 Child, Label2("Nr. of Custom Bootblocks"),
2131 Child, dosenvecgadgets.numcustboot=StringObject,
2132 StringFrame,
2133 MUIA_String_Integer, 0,
2134 MUIA_String_Accept, "0123456789",
2135 End,
2136 End,
2137 End,
2138 Child, VGroup,
2139 GroupFrame,
2140 MUIA_FrameTitle, "Reserved Blocks at",
2141 Child, HGroup,
2142 Child, Label2("Beginning"),
2143 Child, dosenvecgadgets.reservedblocksstart=StringObject,
2144 StringFrame,
2145 MUIA_String_Integer, 0,
2146 MUIA_String_Accept, "0123456789",
2147 End,
2148 End,
2149 Child, HGroup,
2150 Child, Label2("End"),
2151 Child, dosenvecgadgets.reservedblocksend=StringObject,
2152 StringFrame,
2153 MUIA_String_Integer, 0,
2154 MUIA_String_Accept, "0123456789",
2155 End,
2156 End,
2157 End,
2158 Child, VGroup,
2159 GroupFrame,
2160 Child, HGroup,
2161 Child, Label("BlockSize"),
2162 Child, dosenvecgadgets.blocksize=CycleObject,
2163 ButtonFrame,
2164 MUIA_Cycle_Entries, blocksizecycleentries,
2165 End,
2166 End,
2167 Child, HGroup,
2168 Child, Label2("Buffers"),
2169 Child, dosenvecgadgets.buffers=StringObject,
2170 StringFrame,
2171 MUIA_String_Integer, 20,
2172 MUIA_String_Accept, "0123456789",
2173 End,
2174 End,
2175 End,
2176 Child, HGroup,
2177 MUIA_Group_SameWidth, TRUE,
2178 MUIA_FixHeight, 1,
2179 Child, dosenvecgadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
2180 Child, dosenvecgadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
2181 End,
2182 End,
2183 End,
2184 SubWindow, mountbootgadgets.win = WindowObject,
2185 MUIA_Window_Title, MSG(WORD_Switches),
2186 MUIA_Window_Activate, TRUE,
2187 WindowContents, VGroup,
2188 Child, HGroup,
2189 Child, Label(MSG(WORD_Active)),
2190 Child, HVSpace,
2191 Child, mountbootgadgets.active=MUI_MakeObject
2193 MUIO_Checkmark,
2194 MSG(WORD_Active)
2196 End,
2197 Child, HGroup,
2198 Child, Label(MSG(WORD_Automount)),
2199 Child, HVSpace,
2200 Child, mountbootgadgets.automount=MUI_MakeObject
2202 MUIO_Checkmark,
2203 MSG(WORD_Automount)
2205 End,
2206 Child, HGroup,
2207 Child, Label(MSG(WORD_Bootable)),
2208 Child, HVSpace,
2209 Child, mountbootgadgets.bootable=MUI_MakeObject
2211 MUIO_Checkmark,
2212 MSG(WORD_Bootable)
2214 End,
2215 Child, HGroup,
2216 Child, Label(MSG(WORD_BootPri)),
2217 Child, mountbootgadgets.bootpri=StringObject,
2218 StringFrame,
2219 MUIA_String_Integer, 0,
2220 MUIA_String_Accept, "-0123456789",
2221 End,
2222 End,
2223 Child, HGroup,
2224 MUIA_Group_SameWidth, TRUE,
2225 MUIA_FixHeight, 1,
2226 Child, mountbootgadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
2227 Child, mountbootgadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
2228 End,
2229 End,
2230 End,
2231 End;
2233 if (!app)
2234 return ERR_GADGETS;
2236 /* Main Window */
2237 DoMethod
2239 mainwin, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)app, 2,
2240 MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
2242 DoMethod
2244 gadgets.buttons[GB_EXIT], MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)app, 2,
2245 MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
2247 DoMethod
2249 gadgets.leftlv,
2250 MUIM_Notify, MUIA_Listview_DoubleClick, TRUE, (IPTR)gadgets.leftlv, 2,
2251 MUIM_CallHook, (IPTR)&hook_lv_doubleclick
2253 DoMethod
2255 gadgets.leftlv, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime,
2256 (IPTR)gadgets.leftlv, 2, MUIM_CallHook, (IPTR)&hook_lv_click
2258 for (i=GB_FIRST;i<GB_EXIT;i++)
2260 DoMethod
2262 gadgets.buttons[i],
2263 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)gadgets.buttons[i], 2,
2264 MUIM_CallHook, (IPTR)&hook_buttons
2266 /* MUIM_CallHook, hook */
2268 disableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
2269 disableObject(gadgets.buttons[GB_CREATE_TABLE]);
2270 disableObject(gadgets.buttons[GB_CHANGE_TYPE]);
2271 disableObject(gadgets.buttons[GB_RESIZE_MOVE]);
2272 disableObject(gadgets.buttons[GB_PARENT]);
2273 disableObject(gadgets.buttons[GB_RENAME]);
2274 disableObject(gadgets.buttons[GB_DOSENVEC]);
2275 disableObject(gadgets.buttons[GB_SWITCHES]);
2276 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
2277 DoMethod
2279 quit_item,
2280 MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, (IPTR)app, 2,
2281 MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
2283 DoMethod(createml_item,
2284 MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, app, 2,
2285 MUIM_CallHook, &hook_createml);
2286 /* add device window */
2287 DoMethod
2289 adddevicegadgets.win,
2290 MUIM_Notify, MUIA_Window_Open, TRUE, (IPTR)mainwin, 3,
2291 MUIM_Set, MUIA_Window_Sleep, TRUE
2293 DoMethod
2295 adddevicegadgets.win,
2296 MUIM_Notify, MUIA_Window_Open, FALSE, (IPTR)mainwin, 3,
2297 MUIM_Set, MUIA_Window_Sleep, FALSE
2299 DoMethod
2301 adddevicegadgets.win,
2302 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)adddevicegadgets.win, 3,
2303 MUIM_Set, MUIA_Window_Open, FALSE
2305 DoMethod
2307 adddevicegadgets.ok,
2308 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)adddevicegadgets.ok, 2,
2309 MUIM_CallHook, (IPTR)&hook_buttons
2311 DoMethod
2313 adddevicegadgets.ok,
2314 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)adddevicegadgets.win, 3,
2315 MUIM_Set, MUIA_Window_Open, FALSE
2317 DoMethod
2319 adddevicegadgets.cancel,
2320 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)adddevicegadgets.win, 3,
2321 MUIM_Set, MUIA_Window_Open, FALSE
2323 /* add partition window */
2324 DoMethod
2326 addpartitiongadgets.win,
2327 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)addpartitiongadgets.win, 3,
2328 MUIM_Set, MUIA_Window_Open, FALSE
2330 DoMethod
2332 addpartitiongadgets.ok,
2333 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)addpartitiongadgets.ok, 2,
2334 MUIM_CallHook, (IPTR)&hook_buttons
2336 DoMethod
2338 addpartitiongadgets.ok,
2339 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)addpartitiongadgets.win, 3,
2340 MUIM_Set, MUIA_Window_Open, FALSE
2342 DoMethod
2344 addpartitiongadgets.cancel,
2345 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)addpartitiongadgets.win, 3,
2346 MUIM_Set, MUIA_Window_Open, FALSE
2348 DoMethod
2350 addpartitiongadgets.pt,
2351 MUIM_Notify, PTCT_Selected, TRUE, (IPTR)addpartitiongadgets.pt, 2,
2352 MUIM_CallHook, (IPTR)&hook_buttons
2354 /* partition type window */
2355 DoMethod
2357 partitiontypegadgets.win,
2358 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)partitiontypegadgets.win, 3,
2359 MUIM_Set, MUIA_Window_Open, FALSE
2361 DoMethod
2363 partitiontypegadgets.hexid,
2364 MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
2365 (IPTR)partitiontypegadgets.hexid, 2,
2366 MUIM_CallHook, (IPTR)&hook_buttons
2368 /* "FIXME: notify doesn't work" */
2369 DoMethod
2371 partitiontypegadgets.ok,
2372 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)partitiontypegadgets.ok, 2,
2373 MUIM_CallHook, (IPTR)&hook_buttons
2375 DoMethod
2377 partitiontypegadgets.ok,
2378 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)partitiontypegadgets.win, 3,
2379 MUIM_Set, MUIA_Window_Open, FALSE
2381 DoMethod
2383 partitiontypegadgets.cancel,
2384 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)partitiontypegadgets.win, 3,
2385 MUIM_Set, MUIA_Window_Open, FALSE
2387 DoMethod
2389 partitiontypegadgets.lv,
2390 MUIM_Notify, MUIA_Listview_SelectChange, TRUE, (IPTR)partitiontypegadgets.lv, 2,
2391 MUIM_CallHook, (IPTR)&hook_buttons
2393 /* partition table type window */
2394 DoMethod
2396 partitiontabletypegadgets.win,
2397 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)partitiontabletypegadgets.win, 3,
2398 MUIM_Set, MUIA_Window_Open, FALSE
2400 DoMethod
2402 partitiontabletypegadgets.ok,
2403 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)partitiontabletypegadgets.ok, 2,
2404 MUIM_CallHook, (IPTR)&hook_buttons
2406 DoMethod
2408 partitiontabletypegadgets.ok,
2409 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)partitiontabletypegadgets.win, 3,
2410 MUIM_Set, MUIA_Window_Open, FALSE
2412 DoMethod
2414 partitiontabletypegadgets.cancel,
2415 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)partitiontabletypegadgets.win, 3,
2416 MUIM_Set, MUIA_Window_Open, FALSE
2418 /* resize/move window */
2419 DoMethod
2421 resizemovegadgets.win,
2422 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)resizemovegadgets.win, 3,
2423 MUIM_Set, MUIA_Window_Open, FALSE
2425 DoMethod
2427 resizemovegadgets.ok,
2428 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)resizemovegadgets.ok, 2,
2429 MUIM_CallHook, (IPTR)&hook_buttons
2431 DoMethod
2433 resizemovegadgets.ok,
2434 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)resizemovegadgets.win, 3,
2435 MUIM_Set, MUIA_Window_Open, FALSE
2437 DoMethod
2439 resizemovegadgets.size,
2440 MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
2441 (IPTR)resizemovegadgets.size, 2,
2442 MUIM_CallHook, (IPTR)&hook_buttons
2444 DoMethod
2446 resizemovegadgets.cancel,
2447 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)resizemovegadgets.cancel, 2,
2448 MUIM_CallHook, (IPTR)&hook_buttons
2450 DoMethod
2452 resizemovegadgets.cancel,
2453 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)resizemovegadgets.win, 3,
2454 MUIM_Set, MUIA_Window_Open, FALSE
2456 DoMethod
2458 resizemovegadgets.pt,
2459 MUIM_Notify, PTCT_Selected, TRUE, (IPTR)resizemovegadgets.pt, 3,
2460 MUIM_CallHook, (IPTR)&hook_buttons, PTCT_Selected
2462 DoMethod
2464 resizemovegadgets.pt,
2465 MUIM_Notify, PTCT_PartitionMove, TRUE, (IPTR)resizemovegadgets.pt, 3,
2466 MUIM_CallHook, (IPTR)&hook_buttons, PTCT_PartitionMove
2468 DoMethod
2470 resizemovegadgets.highcyl,
2471 MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, (IPTR)resizemovegadgets.highcyl, 2,
2472 MUIM_CallHook, (IPTR)&hook_buttons
2474 DoMethod
2476 resizemovegadgets.lowcyl,
2477 MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, (IPTR)resizemovegadgets.lowcyl, 2,
2478 MUIM_CallHook, (IPTR)&hook_buttons
2480 DoMethod
2482 resizemovegadgets.totalcyl,
2483 MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, (IPTR)resizemovegadgets.totalcyl, 2,
2484 MUIM_CallHook, (IPTR)&hook_buttons
2486 /* rename window */
2487 DoMethod
2489 renamegadgets.win,
2490 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)renamegadgets.win, 3,
2491 MUIM_Set, MUIA_Window_Open, FALSE
2493 DoMethod
2495 renamegadgets.ok,
2496 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)renamegadgets.ok, 2,
2497 MUIM_CallHook, (IPTR)&hook_buttons
2499 DoMethod
2501 renamegadgets.ok,
2502 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)renamegadgets.win, 3,
2503 MUIM_Set, MUIA_Window_Open, FALSE
2505 DoMethod
2507 renamegadgets.cancel,
2508 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)renamegadgets.win, 3,
2509 MUIM_Set, MUIA_Window_Open, FALSE
2511 /* dosenvec window */
2512 DoMethod
2514 dosenvecgadgets.win,
2515 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)dosenvecgadgets.win, 3,
2516 MUIM_Set, MUIA_Window_Open, FALSE
2518 DoMethod
2520 dosenvecgadgets.ok,
2521 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)dosenvecgadgets.ok, 2,
2522 MUIM_CallHook, (IPTR)&hook_buttons
2524 DoMethod
2526 dosenvecgadgets.ok,
2527 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)dosenvecgadgets.win, 3,
2528 MUIM_Set, MUIA_Window_Open, FALSE
2530 DoMethod
2532 dosenvecgadgets.cancel,
2533 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)dosenvecgadgets.win, 3,
2534 MUIM_Set, MUIA_Window_Open, FALSE
2536 /* automount/boot window */
2537 DoMethod
2539 mountbootgadgets.win,
2540 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)mountbootgadgets.win, 3,
2541 MUIM_Set, MUIA_Window_Open, FALSE
2543 DoMethod
2545 mountbootgadgets.ok,
2546 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)mountbootgadgets.ok, 2,
2547 MUIM_CallHook, (IPTR)&hook_buttons
2549 DoMethod
2551 mountbootgadgets.ok,
2552 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)mountbootgadgets.win, 3,
2553 MUIM_Set, MUIA_Window_Open, FALSE
2555 DoMethod
2557 mountbootgadgets.cancel,
2558 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)mountbootgadgets.win, 3,
2559 MUIM_Set, MUIA_Window_Open, FALSE
2561 set(mainwin, MUIA_Window_Open, TRUE);
2562 return 0;
2565 void deinitGUI()
2567 D(bug("[HDToolBox] deinitGUI()\n"));
2569 if (app)
2570 MUI_DisposeObject(app);
2571 if (ptclass != NULL)
2572 FreeClass(ptclass);
2573 if (MUIMasterBase)
2574 CloseLibrary(MUIMasterBase);
2577 BOOL QuitGUI(ULONG *sigs)
2579 // moved debug from this place because it produces too much garbage
2581 if ((IPTR)DoMethod(app, MUIM_Application_NewInput, (IPTR)sigs) == MUIV_Application_ReturnID_Quit)
2583 D(bug("[HDToolBox] QuitGUI()\n"));
2584 return TRUE;
2586 return FALSE;