2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
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>
43 #include "harddisks.h"
44 #include "hdtoolbox_support.h"
50 #undef CATCOMP_STRINGS
51 #undef CATCOMP_NUMBERS
52 #define CATCOMP_NUMBERS
55 #define SIMPLEBUTTON(text) SimpleButton(MSG(text))
57 #ifdef HAVE_COOLIMAGES
58 #define IMAGEBUTTON(text,imgid) CoolImageIDButton(MSG(text),imgid)
60 #define IMAGEBUTTON(text,imgid) SIMPLEBUTTON(text)
63 struct Library
*MUIMasterBase
= NULL
;
64 struct Library
*ConsoleDevice
= NULL
;
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
{
90 struct AddPartitionGadgets
{
95 } addpartitiongadgets
;
97 struct PartitionTypeGadgets
{
99 struct TableTypeNode
*ttn
;
102 struct Hook hook_hexidedit
;
104 struct PartitionType type
;
105 struct ListNode
*iln
;
108 } partitiontypegadgets
;
110 struct PartitionTableTypeGadgets
{
113 struct ListNode
*iln
;
116 } partitiontabletypegadgets
;
118 struct ResizeMoveGadgets
{
129 struct RenameGadgets
{
132 struct ListNode
*iln
;
137 struct DosEnvecGadgets
{
143 Object
*reservedblocksstart
;
144 Object
*reservedblocksend
;
147 struct ListNode
*iln
;
152 struct MountBootGadgets
{
158 struct ListNode
*iln
;
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"));
174 parent
->change_count
++;
175 parent
= parent
->parent
;
177 DoMethod(gadgets
.leftlv
, MUIM_List_Redraw
, MUIV_List_Redraw_All
);
178 DoMethod(gadgets
.leftlv
, MUIM_CallHook
, (IPTR
)&hook_lv_click
);
181 void unsetChanged(struct ListNode
*iln
)
183 struct ListNode
*sub
= iln
;
184 struct ListNode
*parent
;
186 D(bug("[HDToolBox] unsetChanged()\n"));
188 /* remove changed from all first generation child partitions */
189 sub
= (struct ListNode
*)iln
->list
.lh_Head
;
190 while (sub
->ln
.ln_Succ
)
192 if (sub
->change_count
)
194 parent
= sub
->parent
;
197 parent
->change_count
-= sub
->change_count
;
198 parent
= parent
->parent
;
200 sub
->change_count
= 0;
202 sub
= (struct ListNode
*)sub
->ln
.ln_Succ
;
204 if (iln
->flags
& LNF_ToSave
)
206 iln
->flags
&= ~LNF_ToSave
;
207 /* we saved it so there can't be a change_count */
208 if (iln
->change_count
)
210 parent
= iln
->parent
;
213 parent
->change_count
-= iln
->change_count
;
214 parent
= parent
->parent
;
216 iln
->change_count
= 0;
219 DoMethod(gadgets
.leftlv
, MUIM_List_Redraw
, MUIV_List_Redraw_Active
);
222 AROS_UFH3(void, hexidedit_function
,
223 AROS_UFHA(struct Hook
*, h
, A0
),
224 AROS_UFHA(struct SGWork
*, sgwork
, A2
),
225 AROS_UFHA(ULONG
*, msg
, A1
))
229 D(bug("[HDToolBox] hexidedit_function()\n"));
233 D(bug("[HDToolBox] hexidedit_function: KEY PRESS\n"));
239 AROS_UFH3(void, display_function
,
240 AROS_UFHA(struct Hook
*, h
, A0
),
241 AROS_UFHA(const char **, strings
, A2
),
242 AROS_UFHA(struct ListNode
*, entry
, A1
))
249 D(bug("[HDToolBox] display_function()\n"));
254 if (entry
->change_count
)
256 if (entry
->flags
& LNF_ToSave
)
260 if ((entry
->flags
& LNF_Listable
) || (entry
->ln
.ln_Type
== LNT_Parent
))
262 sprintf(bu2
,"\0333%s",entry
->ln
.ln_Name
);
266 strings
[1] = entry
->ln
.ln_Name
;
270 strings
[0] = MSG(WORD_Changed
);
271 strings
[1] = MSG(WORD_Name
);
277 void setTypeString(struct PartitionType
*type
, Object
*strgad
)
283 D(bug("[HDToolBox] setTypeString()\n"));
285 while (len
!=type
->id_len
)
287 sprintf(cur
, "%02x ", type
->id
[len
]);
292 set(strgad
, MUIA_String_Contents
, str
);
295 LONG
askSave(STRPTR name
)
297 struct EasyStruct es
=
299 sizeof(struct EasyStruct
), 0,
306 D(bug("[HDToolBox] askSave('%s')\n", name
));
308 sprintf(yesno
, "%s|%s|%s", MSG_STD(YESSTR
), MSG(WORD_All
), MSG_STD(NOSTR
));
309 es
.es_GadgetFormat
= yesno
;
310 return EasyRequestArgs(0, &es
, 0, (RAWARG
)&name
);
314 LONG
saveChanges(struct ListNode
*iln
, LONG asksave
)
316 struct ListNode
*sub
;
318 D(bug("[HDToolBox] saveChanges()\n"));
320 if (iln
->change_count
)
322 sub
= (struct ListNode
*)iln
->list
.lh_Head
;
323 while (sub
->ln
.ln_Succ
)
325 asksave
= saveChanges(sub
, asksave
);
326 sub
= (struct ListNode
*)sub
->ln
.ln_Succ
;
328 if (iln
->flags
& LNF_ToSave
)
330 struct HDTBPartition
*partition
;
331 partition
= (struct HDTBPartition
*)iln
;
332 if (partition
->table
)
336 result
= askSave(iln
->ln
.ln_Name
);
341 if (WritePartitionTable(partition
->ph
) == 0)
344 set(gadgets
.text
, MUIA_Text_Contents
, MSG(MSG_WriteTableError
));
352 AROS_UFH3(void, buttons_function
,
353 AROS_UFHA(struct Hook
*, h
, A0
),
354 AROS_UFHA(Object
*, object
, A2
),
355 AROS_UFHA(ULONG
*, arg
, A1
))
359 LONG active
= MUIV_List_Active_Off
;
360 struct ListNode
*iln
;
363 D(bug("[HDToolBox] buttons_function()\n"));
365 for (i
=GB_FIRST
;i
<=GB_LAST
;i
++)
366 if (object
== gadgets
.buttons
[i
])
371 if (object
== gadgets
.leftlv
)
374 else if (object
== adddevicegadgets
.ok
)
377 struct HDTBDevice
*dn
;
379 get(adddevicegadgets
.file
, MUIA_String_Contents
, &str
);
381 dn
= addDeviceName(str
);
384 /* FIXME: Should we fail here? */
387 else if (object
== addpartitiongadgets
.ok
)
389 struct DosEnvec
*de
= NULL
;
391 get(addpartitiongadgets
.pt
, PTCT_ActivePartition
, &de
);
394 struct HDTBPartition
*table
;
395 struct HDTBPartition
*partition
;
397 get(addpartitiongadgets
.pt
, PTCT_PartitionTable
, &iln
);
398 table
= (struct HDTBPartition
*)iln
;
399 partition
= addPartition(table
, de
);
402 setChanged(&partition
->listnode
);
403 partition
->listnode
.parent
->flags
|= LNF_ToSave
;
404 InsertList(gadgets
.leftlv
, &partition
->listnode
);
407 set(gadgets
.text
, MUIA_Text_Contents
, MSG(MSG_NO_MEMORY
));
410 else if (object
== addpartitiongadgets
.pt
);
411 else if (object
== partitiontypegadgets
.hexid
)
415 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
416 get(object
, MUIA_String_Contents
, &str
);
417 partitiontypegadgets
.type
.id_len
=strcpyESC(partitiontypegadgets
.type
.id
, str
);
419 else if (object
== partitiontypegadgets
.lv
)
421 get(partitiontypegadgets
.lv
, MUIA_List_Active
, &active
);
422 if (active
!= MUIV_List_Active_Off
)
426 DoMethod(partitiontypegadgets
.lv
, MUIM_List_GetEntry
, active
, (IPTR
)&name
);
427 tn
= (struct TypeNode
*)FindName(partitiontypegadgets
.ttn
->typelist
, name
);
428 setTypeString(&tn
->type
, partitiontypegadgets
.hexid
);
429 CopyMem(&tn
->type
, &partitiontypegadgets
.type
, sizeof(struct PartitionType
));
432 else if (object
== partitiontypegadgets
.ok
)
434 struct HDTBPartition
*partition
;
435 partition
= (struct HDTBPartition
*)partitiontypegadgets
.iln
;
436 CopyMem(&partitiontypegadgets
.type
, &partition
->type
, sizeof(struct PartitionType
));
437 SetPartitionAttrsA(partition
->ph
, PT_TYPE
, &partition
->type
, TAG_DONE
);
438 GetPartitionAttrsA(partition
->ph
, PT_DOSENVEC
, &partition
->de
, TAG_DONE
);
439 partitiontypegadgets
.iln
->parent
->flags
|= LNF_ToSave
;
440 setChanged(partitiontypegadgets
.iln
);
442 else if (object
== partitiontabletypegadgets
.ok
)
444 get(partitiontabletypegadgets
.lv
, MUIA_List_Active
, &active
);
445 if (active
!= MUIV_List_Active_Off
)
447 struct TableTypeNode
*ttn
;
448 struct HDTBPartition
*table
;
450 DoMethod(partitiontabletypegadgets
.lv
, MUIM_List_GetEntry
, active
, (IPTR
)&name
);
451 ttn
= findTableTypeNodeName(name
);
452 table
= (struct HDTBPartition
*)partitiontabletypegadgets
.iln
;
454 (table
->table
== NULL
) ||
455 (ttn
->pti
->pti_Type
!= table
->table
->type
)
458 if (makePartitionTable(table
, ttn
->pti
->pti_Type
))
460 table
->listnode
.flags
|= LNF_Listable
;
461 table
->listnode
.flags
|= LNF_ToSave
;
462 setChanged(partitiontabletypegadgets
.iln
);
465 set(gadgets
.text
, MUIA_Text_Contents
, MSG(MSG_CreateTableError
));
469 else if (object
== resizemovegadgets
.ok
)
471 struct HDTBPartition
*table
= NULL
;
472 struct HDTBPartition
*partition
;
474 get(resizemovegadgets
.pt
, PTCT_PartitionTable
, &table
);
475 partition
= (struct HDTBPartition
*)table
->listnode
.list
.lh_Head
;
476 table
->listnode
.flags
|= LNF_ToSave
;
477 while (partition
->listnode
.ln
.ln_Succ
)
479 if (partition
->listnode
.flags
& LNF_IntermedChange
)
481 partition
->listnode
.flags
&= ~LNF_IntermedChange
;
482 setChanged(&partition
->listnode
);
483 SetPartitionAttrsA(partition
->ph
, PT_DOSENVEC
, &partition
->de
, TAG_DONE
);
485 partition
= (struct HDTBPartition
*)partition
->listnode
.ln
.ln_Succ
;
488 else if (object
== resizemovegadgets
.cancel
)
490 struct HDTBPartition
*table
= NULL
;
491 struct HDTBPartition
*partition
;
493 get(resizemovegadgets
.pt
, PTCT_PartitionTable
, &table
);
494 partition
= (struct HDTBPartition
*)table
->listnode
.list
.lh_Head
;
495 while (partition
->listnode
.ln
.ln_Succ
)
497 if (partition
->listnode
.flags
& LNF_IntermedChange
)
499 partition
->listnode
.flags
&= ~LNF_IntermedChange
;
500 GetPartitionAttrsA(partition
->ph
, PT_DOSENVEC
, &partition
->de
, TAG_DONE
);
502 partition
= (struct HDTBPartition
*)partition
->listnode
.ln
.ln_Succ
;
505 else if (object
== resizemovegadgets
.pt
)
508 struct DosEnvec
*de
= NULL
;
511 D(bug("[HDToolBox] buttons_function() - Resize/Move Partition Display:\n"));
512 get(resizemovegadgets
.pt
, PTCT_ActiveType
, &type
);
513 if (type
== PTS_EMPTY_AREA
)
515 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &de
);
519 struct HDTBPartition
*partition
= NULL
;
521 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &partition
);
523 if (*arg
== PTCT_PartitionMove
)
525 partition
->listnode
.flags
|= LNF_IntermedChange
;
528 nnset(resizemovegadgets
.lowcyl
, MUIA_String_Integer
, de
->de_LowCyl
);
529 nnset(resizemovegadgets
.highcyl
, MUIA_String_Integer
, de
->de_HighCyl
);
530 nnset(resizemovegadgets
.totalcyl
, MUIA_String_Integer
, de
->de_HighCyl
-de
->de_LowCyl
+1);
531 getSizeStr(str
, (((de
->de_HighCyl
- de
->de_LowCyl
+ 1) * de
->de_Surfaces
* de
->de_BlocksPerTrack
)-1)/2);
532 nnset(resizemovegadgets
.size
, MUIA_String_Contents
, str
);
533 D(bug("[HDToolBox] buttons_function() - Resize/Move Partition Display successful\n"));
535 else if (object
== resizemovegadgets
.lowcyl
)
540 D(bug("[HDToolBox] buttons_function() - Resize/Move Lowcyl:\n"));
541 get(object
, MUIA_String_Integer
, &value
);
542 get(resizemovegadgets
.pt
, PTCT_ActiveType
, &type
);
543 if (type
== PTS_PARTITION
)
545 struct HDTBPartition
*table
= NULL
;
546 struct HDTBPartition
*partition
= NULL
;
549 get(resizemovegadgets
.pt
, PTCT_PartitionTable
, &table
);
550 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &partition
);
551 D(bug("[HDToolBox] - Type : Partition\n"));
552 D(bug("[HDToolBox] - Old value : %ld\n", partition
->de
.de_LowCyl
));
553 D(bug("[HDToolBox] - New value : %ld\n", value
));
554 D(bug("[HDToolBox] - Partition table : %p\n", table
));
555 D(bug("[HDToolBox] - Active partition : %p\n", partition
));
556 if (value
!= partition
->de
.de_LowCyl
)
559 value
*partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
;
560 if (validValue(table
, partition
, block
))
563 partition
->listnode
.flags
|= LNF_IntermedChange
;
564 partition
->de
.de_LowCyl
= value
;
565 set(resizemovegadgets
.totalcyl
, MUIA_String_Integer
, partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1);
566 set(resizemovegadgets
.pt
, PTCT_PartitionTable
, table
);
572 (partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1)*
573 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
577 set(resizemovegadgets
.size
, MUIA_String_Contents
, str
);
580 set(object
, MUIA_String_Integer
, partition
->de
.de_LowCyl
);
583 else if (type
== PTS_EMPTY_AREA
)
585 struct DosEnvec
*de
= NULL
;
587 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &de
);
588 if (value
!= de
->de_LowCyl
)
589 set(object
, MUIA_String_Integer
, de
->de_LowCyl
);
592 set(object
, MUIA_String_Integer
, 0);
594 else if (object
== resizemovegadgets
.highcyl
)
599 D(bug("[HDToolBox] buttons_function() - Resize/Move Highcyl:\n"));
600 get(object
, MUIA_String_Integer
, &value
);
601 get(resizemovegadgets
.pt
, PTCT_ActiveType
, &type
);
602 if (type
== PTS_PARTITION
)
604 struct HDTBPartition
*table
= NULL
;
605 struct HDTBPartition
*partition
= NULL
;
608 get(resizemovegadgets
.pt
, PTCT_PartitionTable
, &table
);
609 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &partition
);
610 D(bug("[HDToolBox] - Type : Partition\n"));
611 D(bug("[HDToolBox] - Old value : %ld\n", partition
->de
.de_HighCyl
));
612 D(bug("[HDToolBox] - New value : %ld\n", value
));
613 D(bug("[HDToolBox] - Partition table : %p\n", table
));
614 D(bug("[HDToolBox] - Active partition : %p\n", partition
));
615 if (value
!= partition
->de
.de_HighCyl
)
620 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
622 if (validValue(table
, partition
, block
))
625 partition
->listnode
.flags
|= LNF_IntermedChange
;
626 partition
->de
.de_HighCyl
= value
;
627 nnset(resizemovegadgets
.totalcyl
, MUIA_String_Integer
, partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1);
628 nnset(resizemovegadgets
.pt
, PTCT_PartitionTable
, table
);
634 (partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1)*
635 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
639 nnset(resizemovegadgets
.size
, MUIA_String_Contents
, str
);
642 nnset(object
, MUIA_String_Integer
, partition
->de
.de_HighCyl
);
645 else if (type
== PTS_EMPTY_AREA
)
647 struct DosEnvec
*de
= NULL
;
649 D(bug("[HDToolBox] - Type : Empty Area\n"));
650 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &de
);
651 if (value
!= de
->de_HighCyl
)
652 set(object
, MUIA_String_Integer
, de
->de_HighCyl
);
655 nnset(object
, MUIA_String_Integer
, 0);
657 else if (object
== resizemovegadgets
.totalcyl
)
662 get(object
, MUIA_String_Integer
, &value
);
663 get(resizemovegadgets
.pt
, PTCT_ActiveType
, &type
);
664 if (type
== PTS_PARTITION
)
666 struct HDTBPartition
*table
= NULL
;
667 struct HDTBPartition
*partition
= NULL
;
670 get(resizemovegadgets
.pt
, PTCT_PartitionTable
, &table
);
671 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &partition
);
672 if (value
!= (partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1))
676 (partition
->de
.de_LowCyl
+value
)*
677 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
679 if (validValue(table
, partition
, block
))
682 partition
->listnode
.flags
|= LNF_IntermedChange
;
683 partition
->de
.de_HighCyl
= partition
->de
.de_LowCyl
+value
-1;
684 set(resizemovegadgets
.highcyl
, MUIA_String_Integer
, partition
->de
.de_HighCyl
);
685 set(resizemovegadgets
.pt
, PTCT_PartitionTable
, table
);
691 (partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1)*
692 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
696 set(resizemovegadgets
.size
, MUIA_String_Contents
, str
);
699 set(object
, MUIA_String_Integer
, partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1);
702 else if (type
== PTS_EMPTY_AREA
)
704 struct DosEnvec
*de
= NULL
;
706 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &de
);
707 if (value
!= (de
->de_HighCyl
-de
->de_LowCyl
+1))
708 set(object
, MUIA_String_Integer
, de
->de_HighCyl
-de
->de_LowCyl
+1);
711 set(object
, MUIA_String_Integer
, 0);
713 else if (object
== resizemovegadgets
.size
)
716 struct DosEnvec
*de
= NULL
;
721 get(resizemovegadgets
.pt
, PTCT_ActiveType
, &type
);
722 if (type
== PTS_PARTITION
)
724 struct HDTBPartition
*partition
= NULL
;
726 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &partition
);
728 get(object
, MUIA_String_Contents
, &str
);
729 size
= sizeStrToUL((STRPTR
)str
);
730 size
= (size
*2+1)/partition
->de
.de_BlocksPerTrack
/partition
->de
.de_Surfaces
+1;
732 else if (type
== PTS_EMPTY_AREA
)
734 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &de
);
736 set(resizemovegadgets
.totalcyl
, MUIA_String_Integer
, size
);
737 set(resizemovegadgets
.totalcyl
, MUIA_String_Acknowledge
, TRUE
);
743 (de
->de_HighCyl
-de
->de_LowCyl
+1)*
744 de
->de_Surfaces
*de
->de_BlocksPerTrack
748 set(resizemovegadgets
.size
, MUIA_String_Contents
, val
);
750 else if (object
== renamegadgets
.ok
)
752 struct HDTBPartition
*partition
;
755 partition
= (struct HDTBPartition
*)renamegadgets
.iln
;
756 get(renamegadgets
.name
, MUIA_String_Contents
, &name
);
757 if (strcmp(name
, partition
->listnode
.ln
.ln_Name
) != 0)
759 SetPartitionAttrsA(partition
->ph
, PT_NAME
, name
, TAG_DONE
);
760 strcpy(partition
->listnode
.ln
.ln_Name
, name
);
761 renamegadgets
.iln
->parent
->flags
|= LNF_ToSave
;
762 setChanged(renamegadgets
.iln
);
765 else if (object
== dosenvecgadgets
.ok
)
767 BOOL changed
= FALSE
;
772 struct HDTBPartition
*partition
;
774 partition
= (struct HDTBPartition
*)dosenvecgadgets
.iln
;
775 get(dosenvecgadgets
.mask
, MUIA_String_Integer
, &value
);
776 if (value
!= partition
->de
.de_Mask
)
778 partition
->de
.de_Mask
= value
;
781 get(dosenvecgadgets
.maxtransfer
, MUIA_String_Contents
, &str
);
782 value
= strtoul(str
, &end
, 0);
785 if (value
!= partition
->de
.de_MaxTransfer
)
787 partition
->de
.de_MaxTransfer
= value
;
791 get(dosenvecgadgets
.custboot
, MUIA_Selected
, &check
);
794 if (partition
->de
.de_TableSize
<(DE_BOOTBLOCKS
+1))
796 partition
->de
.de_TableSize
= DE_BOOTBLOCKS
+1;
799 get(dosenvecgadgets
.numcustboot
, MUIA_String_Integer
, &value
);
800 if (value
!= partition
->de
.de_BootBlocks
)
802 partition
->de
.de_BootBlocks
= value
;
808 if (partition
->de
.de_TableSize
>=(DE_BOOTBLOCKS
+1))
810 partition
->de
.de_TableSize
= DE_BOOTBLOCKS
;
811 partition
->de
.de_BootBlocks
= 0;
815 get(dosenvecgadgets
.reservedblocksstart
, MUIA_String_Integer
, &value
);
816 if (value
!= partition
->de
.de_Reserved
)
818 partition
->de
.de_Reserved
= value
;
821 get(dosenvecgadgets
.reservedblocksend
, MUIA_String_Integer
, &value
);
822 if (value
!= partition
->de
.de_PreAlloc
)
824 partition
->de
.de_PreAlloc
= value
;
827 get(dosenvecgadgets
.blocksize
, MUIA_Cycle_Active
, &value
);
828 value
= 1<<(value
+7);
829 if (value
!= partition
->de
.de_SizeBlock
)
831 partition
->de
.de_SizeBlock
= value
;
834 get(dosenvecgadgets
.buffers
, MUIA_String_Integer
, &value
);
835 if (value
!= partition
->de
.de_NumBuffers
)
837 partition
->de
.de_NumBuffers
= value
;
842 SetPartitionAttrsA(partition
->ph
, PT_DOSENVEC
, &partition
->de
, TAG_DONE
);
843 dosenvecgadgets
.iln
->parent
->flags
|= LNF_ToSave
;
844 setChanged(dosenvecgadgets
.iln
);
847 else if (object
== mountbootgadgets
.ok
)
849 struct HDTBPartition
*partition
;
850 BOOL changeda
= FALSE
;
851 BOOL changed
= FALSE
;
855 partition
= (struct HDTBPartition
*)mountbootgadgets
.iln
;
856 get(mountbootgadgets
.active
, MUIA_Selected
, &check
);
859 if (!(partition
->flags
& PNF_ACTIVE
))
861 partition
->flags
|= PNF_ACTIVE
;
867 if (partition
->flags
& PNF_ACTIVE
)
869 partition
->flags
&= ~PNF_ACTIVE
;
875 if (partition
->flags
& PNF_ACTIVE
)
877 struct HDTBPartition
*other
;
878 other
= (struct HDTBPartition
*)partition
->listnode
.ln
.ln_Pred
;
879 while (other
->listnode
.ln
.ln_Pred
)
881 if (other
->listnode
.ln
.ln_Type
== LNT_Partition
)
883 if (other
->flags
& PNF_ACTIVE
)
885 other
->flags
&= ~PNF_ACTIVE
;
886 SetPartitionAttrsA(other
->ph
, PT_ACTIVE
, FALSE
, TAG_DONE
);
887 setChanged(&other
->listnode
);
890 other
= (struct HDTBPartition
*)other
->listnode
.ln
.ln_Pred
;
892 other
= (struct HDTBPartition
*)partition
->listnode
.ln
.ln_Succ
;
893 while (other
->listnode
.ln
.ln_Succ
)
895 if (other
->listnode
.ln
.ln_Type
== LNT_Partition
)
897 if (other
->flags
& PNF_ACTIVE
)
899 other
->flags
&= ~PNF_ACTIVE
;
900 SetPartitionAttrsA(other
->ph
, PT_ACTIVE
, FALSE
, TAG_DONE
);
901 setChanged(&other
->listnode
);
904 other
= (struct HDTBPartition
*)other
->listnode
.ln
.ln_Succ
;
907 SetPartitionAttrsA(partition
->ph
, PT_ACTIVE
, check
, TAG_DONE
);
911 get(mountbootgadgets
.automount
, MUIA_Selected
, &check
);
914 if (!(partition
->flags
& PNF_AUTOMOUNT
))
916 partition
->flags
|= PNF_AUTOMOUNT
;
922 if (partition
->flags
& PNF_AUTOMOUNT
)
924 partition
->flags
&= ~PNF_AUTOMOUNT
;
930 SetPartitionAttrsA(partition
->ph
, PT_AUTOMOUNT
, check
, TAG_DONE
);
934 get(mountbootgadgets
.bootable
, MUIA_Selected
, &check
);
937 if (!(partition
->flags
& PNF_BOOTABLE
))
939 partition
->flags
|= PNF_BOOTABLE
;
942 get(mountbootgadgets
.bootpri
, MUIA_String_Integer
, &value
);
943 if (value
!= partition
->de
.de_BootPri
)
945 partition
->de
.de_BootPri
= value
;
951 if (partition
->flags
& PNF_BOOTABLE
)
953 partition
->flags
&= ~PNF_BOOTABLE
;
954 partition
->de
.de_BootPri
= 0;
960 SetPartitionAttrsA(partition
->ph
, PT_BOOTABLE
, check
, PT_DOSENVEC
, &partition
->de
, TAG_DONE
);
965 mountbootgadgets
.iln
->parent
->flags
|= LNF_ToSave
;
966 setChanged(mountbootgadgets
.iln
);
975 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, 0, (IPTR
)&iln
);
978 ((iln
) && (iln
->parent
->parent
== NULL
))
981 set(adddevicegadgets
.win
, MUIA_Window_Open
, TRUE
);
983 else if ((iln
->parent
->ln
.ln_Type
== LNT_Harddisk
) || (iln
->parent
->ln
.ln_Type
== LNT_Partition
))
985 struct HDTBPartition
*table
;
986 table
= (struct HDTBPartition
*)iln
->parent
;
989 (table
->table
->max_partitions
) &&
990 (countNodes(&table
->listnode
.list
, LNT_Partition
)<table
->table
->max_partitions
)
992 (table
->table
->max_partitions
== 0)
997 addpartitiongadgets
.win
,
998 MUIM_Notify
, MUIA_Window_Open
, TRUE
, (IPTR
)addpartitiongadgets
.pt
, 3,
999 MUIM_Set
, PTCT_PartitionTable
, (IPTR
)table
1001 set(addpartitiongadgets
.win
, MUIA_Window_Open
, TRUE
);
1004 set(gadgets
.text
, MUIA_Text_Contents
, MSG(MSG_PARTITION_TABLE_FULL
));
1007 case GB_REMOVE_ENTRY
:
1008 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1009 if (active
!= MUIV_List_Active_Off
)
1011 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
1012 switch (iln
->ln
.ln_Type
)
1015 DoMethod(gadgets
.leftlv
, MUIM_List_Remove
, active
);
1017 freeDeviceNode((struct HDTBDevice
*)iln
);
1021 struct HDTBPartition
*partition
;
1022 partition
= (struct HDTBPartition
*)iln
;
1023 iln
->parent
->flags
|= LNF_ToSave
;
1025 DoMethod(gadgets
.leftlv
, MUIM_List_Remove
, active
);
1027 DeletePartition(partition
->ph
);
1028 freePartitionNode(partition
);
1033 case GB_CREATE_TABLE
:
1034 case GB_CHANGE_TYPE
:
1035 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1036 if (active
!= MUIV_List_Active_Off
)
1038 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
1040 (iln
->ln
.ln_Type
== LNT_Harddisk
) ||
1041 ((i
==2) && (iln
->ln
.ln_Type
== LNT_Partition
))
1044 struct HDTBPartition
*table
;
1046 partitiontabletypegadgets
.iln
= iln
;
1047 table
= (struct HDTBPartition
*)iln
;
1049 type
= table
->table
->type
;
1050 DoMethod(partitiontabletypegadgets
.lv
, MUIM_List_Clear
);
1051 for (i
=0;PartitionBase
->tables
[i
] != NULL
;i
++)
1055 partitiontabletypegadgets
.lv
,
1056 MUIM_List_InsertSingle
, (IPTR
)PartitionBase
->tables
[i
]->pti_Name
, MUIV_List_Insert_Bottom
1058 if (type
== PartitionBase
->tables
[i
]->pti_Type
)
1059 set(partitiontabletypegadgets
.lv
, MUIA_List_Active
, i
);
1061 set(partitiontabletypegadgets
.win
, MUIA_Window_Open
, TRUE
);
1063 else if ((i
==3) && (iln
->ln
.ln_Type
== LNT_Partition
))
1065 struct TypeNode
*tn
;
1066 struct HDTBPartition
*partition
;
1067 partitiontypegadgets
.iln
= iln
;
1069 DoMethod(partitiontypegadgets
.lv
, MUIM_List_Clear
);
1070 partition
= (struct HDTBPartition
*)iln
;
1071 partitiontypegadgets
.ttn
= findTableTypeNode(partition
->root
->table
->type
);
1072 if (partitiontypegadgets
.ttn
)
1074 tn
= (struct TypeNode
*)partitiontypegadgets
.ttn
->typelist
->lh_Head
;
1075 while (tn
->ln
.ln_Succ
)
1079 partitiontypegadgets
.lv
,
1080 MUIM_List_InsertSingle
, (IPTR
)tn
->ln
.ln_Name
, MUIV_List_Insert_Bottom
1082 if (tn
->type
.id_len
== partition
->type
.id_len
)
1083 if (memcmp(tn
->type
.id
, partition
->type
.id
, tn
->type
.id_len
) == 0)
1084 set(partitiontypegadgets
.lv
, MUIA_List_Active
, i
);
1085 tn
= (struct TypeNode
*)tn
->ln
.ln_Succ
;
1089 setTypeString(&partition
->type
, partitiontypegadgets
.hexid
);
1090 set(partitiontypegadgets
.win
, MUIA_Window_Open
, TRUE
);
1094 case GB_RESIZE_MOVE
:
1097 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, 0, (IPTR
)&iln
);
1098 if (iln
->ln
.ln_Type
== LNT_Parent
)
1100 set(gadgets
.leftlv
, MUIA_List_Active
, 0);
1101 set(gadgets
.leftlv
, MUIA_Listview_DoubleClick
, TRUE
);
1105 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1106 if (active
!= MUIV_List_Active_Off
)
1108 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
1109 if (iln
->ln
.ln_Type
== LNT_Partition
)
1111 struct HDTBPartition
*partition
;
1112 partition
= (struct HDTBPartition
*)iln
;
1113 if (getAttrInfo(partition
->root
->table
->pattrlist
, PTA_NAME
) & PLAM_READ
)
1115 renamegadgets
.iln
= iln
;
1116 set(renamegadgets
.name
, MUIA_String_Contents
, iln
->ln
.ln_Name
);
1117 set(renamegadgets
.win
, MUIA_Window_Open
, TRUE
);
1123 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1124 if (active
!= MUIV_List_Active_Off
)
1126 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
1127 if (iln
->ln
.ln_Type
== LNT_Partition
)
1129 struct HDTBPartition
*partition
;
1130 partition
= (struct HDTBPartition
*)iln
;
1131 if (getAttrInfo(partition
->root
->table
->pattrlist
, PTA_DOSENVEC
) & PLAM_READ
)
1134 dosenvecgadgets
.iln
= iln
;
1135 set(dosenvecgadgets
.mask
, MUIA_String_Integer
, partition
->de
.de_Mask
);
1136 sprintf(str
, "0x%08lx", partition
->de
.de_MaxTransfer
);
1137 set(dosenvecgadgets
.maxtransfer
, MUIA_String_Contents
, str
);
1138 if (partition
->de
.de_TableSize
>=(DE_BOOTBLOCKS
+1))
1140 set(dosenvecgadgets
.custboot
, MUIA_Selected
, TRUE
);
1141 set(dosenvecgadgets
.numcustboot
, MUIA_String_Integer
, partition
->de
.de_BootBlocks
);
1144 set(dosenvecgadgets
.custboot
, MUIA_Selected
, FALSE
);
1145 set(dosenvecgadgets
.reservedblocksstart
, MUIA_String_Integer
, partition
->de
.de_Reserved
);
1146 set(dosenvecgadgets
.reservedblocksend
, MUIA_String_Integer
, partition
->de
.de_PreAlloc
);
1147 set(dosenvecgadgets
.blocksize
, MUIA_Cycle_Active
, getBitNum(partition
->de
.de_SizeBlock
>>7));
1148 set(dosenvecgadgets
.buffers
, MUIA_String_Integer
, partition
->de
.de_NumBuffers
);
1149 set(dosenvecgadgets
.win
, MUIA_Window_Open
, TRUE
);
1155 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1156 if (active
!= MUIV_List_Active_Off
)
1158 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
1159 if (iln
->ln
.ln_Type
== LNT_Partition
)
1161 struct HDTBPartition
*partition
;
1165 partition
= (struct HDTBPartition
*)iln
;
1166 active
= getAttrInfo(partition
->root
->table
->pattrlist
, PTA_ACTIVE
);
1167 automount
= getAttrInfo(partition
->root
->table
->pattrlist
, PTA_AUTOMOUNT
);
1168 bootable
= getAttrInfo(partition
->root
->table
->pattrlist
, PTA_BOOTABLE
);
1169 if ((active
| automount
| bootable
) & PLAM_READ
)
1171 mountbootgadgets
.iln
= iln
;
1172 set(mountbootgadgets
.active
, MUIA_Disabled
, !(active
& PLAM_READ
));
1173 set(mountbootgadgets
.automount
, MUIA_Disabled
, !(automount
& PLAM_READ
));
1174 set(mountbootgadgets
.bootable
, MUIA_Disabled
, !(bootable
& PLAM_READ
));
1175 set(mountbootgadgets
.bootpri
, MUIA_Disabled
, !(bootable
& PLAM_READ
));
1176 set(mountbootgadgets
.active
, MUIA_Selected
, (partition
->flags
& PNF_ACTIVE
) ? TRUE
: FALSE
);
1177 set(mountbootgadgets
.automount
, MUIA_Selected
, (partition
->flags
& PNF_AUTOMOUNT
) ? TRUE
: FALSE
);
1178 if (partition
->flags
& PNF_BOOTABLE
)
1180 set(mountbootgadgets
.bootable
, MUIA_Selected
, TRUE
);
1181 set(mountbootgadgets
.bootpri
, MUIA_String_Integer
, partition
->de
.de_BootPri
);
1184 set(mountbootgadgets
.bootable
, MUIA_Selected
, FALSE
);
1185 set(mountbootgadgets
.win
, MUIA_Window_Open
, TRUE
);
1190 case GB_SAVE_CHANGES
:
1191 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1192 if (active
!= MUIV_List_Active_Off
)
1194 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
1195 saveChanges(iln
, TRUE
);
1205 * DosEnvec of all partitions holds cylinder numbers relative to partition start.
1206 * This function returns absolute start cylinder number for the partition.
1208 static ULONG
GetStartCyl(struct HDTBPartition
*part
)
1210 ULONG blockspercyl
= part
->de
.de_Surfaces
* part
->de
.de_BlocksPerTrack
;
1213 while (part
->listnode
.parent
)
1215 part
= (struct HDTBPartition
*)part
->listnode
.parent
;
1217 if (part
->listnode
.ln
.ln_Type
!= LNT_Partition
)
1221 * Calculate start offset in blocks. This can be done because theoretically
1222 * partitions can have different virtual geometries.
1224 ret
+= part
->de
.de_LowCyl
* part
->de
.de_Surfaces
* part
->de
.de_BlocksPerTrack
;
1228 * FIXME: What if this can't be divided in interegs?
1229 * This can happen for example if the disk was partitioned on another machine where
1230 * disk driver reported different (virtual) geometry. In this case we should be able
1231 * to adjust mountlist geometry (Surfaces and BlocksPerTrack) so that division works
1232 * correctly and CHS-LBA relationship is still not broken.
1234 return ret
/ blockspercyl
;
1237 static struct FileSysEntry
*FindFileSysEntry(ULONG dostype
)
1239 struct FileSysEntry
*fse
;
1240 struct FileSysResource
*fsr
= OpenResource("FileSystem.resource");
1245 ForeachNode(&fsr
->fsr_FileSysEntries
, fse
)
1247 if (fse
->fse_DosType
== dostype
)
1254 AROS_UFH3(void, createml_function
,
1255 AROS_UFHA(struct Hook
*, h
, A0
),
1256 AROS_UFHA(Object
*, object
, A2
),
1257 AROS_UFHA(ULONG
*, arg
, A1
))
1261 IPTR active
= MUIA_List_Active
;
1262 struct HDTBPartition
*partition
= NULL
;
1264 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1265 if (active
!= MUIV_List_Active_Off
)
1267 struct FileRequester
*req
;
1268 struct TagItem asltags
[] =
1270 {ASLFR_InitialDrawer
, (IPTR
)"SYS:Storage/DOSDrivers"},
1271 {ASLFR_InitialFile
, 0},
1272 {ASLFR_DoSaveMode
, TRUE
},
1276 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, &partition
);
1277 asltags
[1].ti_Data
= (IPTR
)partition
->listnode
.ln
.ln_Name
;
1279 req
= MUI_AllocAslRequest(ASL_FileRequest
, asltags
);
1284 if (MUI_AslRequest(req
, NULL
))
1286 ULONG len
= strlen(req
->fr_Drawer
) + strlen(req
->fr_File
) + 2;
1287 STRPTR pathname
= AllocMem(len
, MEMF_ANY
);
1293 strcpy(pathname
, req
->fr_Drawer
);
1294 AddPart(pathname
, req
->fr_File
, len
);
1296 file
= Open(pathname
, MODE_NEWFILE
);
1297 FreeMem(pathname
, len
);
1301 struct DiskObject
*icon
;
1302 CONST_STRPTR args
[2];
1304 struct FileSysEntry
*fse
;
1305 ULONG startcyl
= GetStartCyl(partition
);
1308 args
[ 1] = partition
->ph
->bd
->ioreq
->iotd_Req
.io_Device
->dd_Library
.lib_Node
.ln_Name
;
1310 argu
[ 0] = ((struct HDNode
*)partition
->root
)->unit
;
1311 argu
[ 1] = partition
->de
.de_SizeBlock
* 4; /* block size in longs */
1312 argu
[ 2] = partition
->de
.de_Surfaces
;
1313 argu
[ 3] = partition
->de
.de_SectorPerBlock
;
1314 argu
[ 4] = partition
->de
.de_BlocksPerTrack
;
1315 argu
[ 5] = partition
->de
.de_Reserved
;
1316 argu
[ 6] = partition
->de
.de_PreAlloc
;
1317 argu
[ 7] = partition
->de
.de_Interleave
;
1318 argu
[ 8] = partition
->de
.de_MaxTransfer
;
1319 argu
[ 9] = partition
->de
.de_Mask
;
1320 argu
[10] = partition
->de
.de_LowCyl
+ startcyl
;
1321 argu
[11] = partition
->de
.de_HighCyl
+ startcyl
;
1322 argu
[12] = partition
->de
.de_NumBuffers
;
1323 argu
[13] = partition
->de
.de_BufMemType
;
1327 argu
[17] = partition
->de
.de_DosType
;
1330 * Some things can be fetched only from FileSystem.resource.
1331 * Let's try to do it.
1333 fse
= FindFileSysEntry(partition
->de
.de_DosType
);
1336 if (fse
->fse_PatchFlags
& FSEF_HANDLER
)
1337 args
[0] = AROS_BSTR_ADDR(fse
->fse_Handler
);
1339 if (fse
->fse_PatchFlags
& FSEF_STACKSIZE
)
1340 argu
[14] = fse
->fse_StackSize
;
1342 if (fse
->fse_PatchFlags
& FSEF_PRIORITY
)
1343 argu
[15] = fse
->fse_Priority
;
1345 if (fse
->fse_PatchFlags
& FSEF_GLOBALVEC
)
1346 argu
[16] = (ULONG
)(IPTR
)fse
->fse_GlobalVec
;
1349 VFPrintf(file
, "FileSystem = %s\n"
1352 VFPrintf(file
,"Unit = %ld\n"
1355 "SectorsPerBlock = %ld\n"
1356 "BlocksPerTrack = %ld\n"
1359 "Interleave = %ld\n"
1360 "MaxTransfer = 0x%08lx\n"
1365 "BufMemType = %ld\n"
1369 "DosType = 0x%08lx\n"
1375 icon
= GetDiskObject("ENVARC:Sys/def_Mountlist");
1378 PutDiskObject(pathname
, icon
);
1379 FreeDiskObject(icon
);
1385 MUI_FreeAslRequest(req
);
1391 /************************* general List functions ***************************/
1393 LONG
InitListNode(struct ListNode
*node
, struct ListNode
*parent
)
1395 struct ListNode
*new;
1397 D(bug("[HDToolBox] InitListNode()\n"));
1399 NEWLIST(&node
->list
);
1400 new = AllocMem(sizeof(struct ListNode
), MEMF_PUBLIC
| MEMF_CLEAR
);
1403 node
->parent
= parent
;
1404 new->ln
.ln_Name
= "..";
1405 new->ln
.ln_Type
= LNT_Parent
;
1406 new->ln
.ln_Pri
= 127;
1408 AddTail(&node
->list
, &new->ln
);
1414 void UninitListNode(struct ListNode
*node
)
1416 struct ListNode
*parent
, *next
;
1418 D(bug("[HDToolBox] UninitListNode()\n"));
1420 /* free parent entry */
1421 parent
= (struct ListNode
*)node
->list
.lh_Head
;
1422 while (parent
->ln
.ln_Succ
)
1424 next
= (struct ListNode
*)parent
->ln
.ln_Succ
;
1425 if (parent
->ln
.ln_Type
== LNT_Parent
)
1427 Remove(&parent
->ln
);
1428 FreeMem(parent
, sizeof(struct ListNode
));
1435 void InsertList(Object
*list
, struct ListNode
*node
)
1437 D(bug("[HDToolBox] InsertList()\n"));
1439 DoMethod(list
, MUIM_List_InsertSingle
, (IPTR
)node
, MUIV_List_Insert_Bottom
);
1442 void ShowList(Object
*list
, struct List
*lh
)
1444 struct ListNode
*lnode
;
1446 D(bug("[HDToolBox] ShowList()\n"));
1448 DoMethod(list
, MUIM_List_Clear
);
1449 lnode
= (struct ListNode
*)lh
->lh_Head
;
1450 while (lnode
->ln
.ln_Succ
)
1454 ((lnode
->ln
.ln_Type
== LNT_Parent
) && (lnode
->parent
->parent
!= NULL
)) ||
1455 (lnode
->ln
.ln_Type
!= LNT_Parent
)
1457 (!(lnode
->flags
& LNF_Invalid
))
1460 DoMethod(list
, MUIM_List_InsertSingle
, (IPTR
)lnode
, MUIV_List_Insert_Bottom
);
1462 lnode
= (struct ListNode
*)lnode
->ln
.ln_Succ
;
1466 void disableObject(Object
*object
)
1468 LONG disabled
= FALSE
;
1470 D(bug("[HDToolBox] disableObject()\n"));
1472 get(object
, MUIA_Disabled
, &disabled
);
1473 if (disabled
== FALSE
)
1475 set(object
, MUIA_Disabled
, TRUE
);
1479 void enableObject(Object
*object
)
1481 LONG disabled
= FALSE
;
1483 D(bug("[HDToolBox] enableObject()\n"));
1485 get(object
, MUIA_Disabled
, &disabled
);
1486 if (disabled
== TRUE
)
1488 set(object
, MUIA_Disabled
, FALSE
);
1493 /********************************** Left Listview ***************************/
1495 struct LeftListview__Data
1497 struct IOStdReq ioreq
;
1498 struct MUI_EventHandlerNode ehn
;
1501 BOOPSI_DISPATCHER(IPTR
, LeftListview_Dispatcher
, CLASS
, self
, message
)
1505 switch (message
->MethodID
)
1509 struct opSet
*msg
= (struct opSet
*)message
;
1511 retval
= DoSuperMethod(CLASS
, self
, OM_NEW
, msg
->ops_AttrList
, NULL
);
1514 struct LeftListview__Data
*data
= INST_DATA(CLASS
, retval
);
1515 data
->ehn
.ehn_Events
= IDCMP_RAWKEY
;
1516 data
->ehn
.ehn_Priority
= 0;
1517 data
->ehn
.ehn_Flags
= 0;
1518 data
->ehn
.ehn_Object
= (Object
*)retval
;
1519 data
->ehn
.ehn_Class
= CLASS
;
1525 if ((retval
= DoSuperMethodA(CLASS
, self
, message
)))
1527 struct LeftListview__Data
*data
= INST_DATA(CLASS
, self
);
1529 if (0 == OpenDevice("console.device", -1, (struct IORequest
*)&data
->ioreq
, 0)) {
1530 ConsoleDevice
= (struct Library
*)data
->ioreq
.io_Device
;
1531 DoMethod(_win(self
), MUIM_Window_AddEventHandler
, (IPTR
) &data
->ehn
);
1538 struct LeftListview__Data
*data
= INST_DATA(CLASS
, self
);
1542 DoMethod(_win(self
), MUIM_Window_RemEventHandler
, (IPTR
) &data
->ehn
);
1543 CloseDevice((struct IORequest
*)&data
->ioreq
);
1546 retval
= DoSuperMethodA(CLASS
, self
, message
);
1549 case MUIM_HandleEvent
:
1551 struct MUIP_HandleEvent
*msg
= (struct MUIP_HandleEvent
*)message
;
1553 if ((ConsoleDevice
) && (msg
->imsg
) && (msg
->imsg
->Class
== IDCMP_RAWKEY
))
1555 unsigned char buffer
[10];
1556 struct InputEvent keyEvent
;
1559 keyEvent
.ie_Class
= IECLASS_RAWKEY
;
1560 keyEvent
.ie_Code
= msg
->imsg
->Code
;
1561 keyEvent
.ie_Qualifier
= msg
->imsg
->Qualifier
;
1562 keyEvent
.ie_EventAddress
= (APTR
) (msg
->imsg
->IAddress
);
1564 numchars
= RawKeyConvert(&keyEvent
, (char *)buffer
, sizeof(buffer
), NULL
);
1566 if ((numchars
== 1) && (buffer
[0] == 13))
1568 SET(self
, MUIA_Listview_DoubleClick
, TRUE
);
1569 retval
= MUI_EventHandlerRC_Eat
;
1576 retval
= DoSuperMethodA(CLASS
, self
, message
);
1581 BOOPSI_DISPATCHER_END
1583 AROS_UFH3(void, lv_doubleclick
,
1584 AROS_UFHA(struct Hook
*, h
, A0
),
1585 AROS_UFHA(Object
*, object
, A2
),
1586 AROS_UFHA(void *, arg
, A1
))
1590 LONG active
= MUIV_List_Active_Off
;
1592 struct ListNode
*iln
;
1594 D(bug("[HDToolBox] lv_doubleclick()\n"));
1596 get(object
, MUIA_List_Active
, &active
);
1597 if (active
!= MUIV_List_Active_Off
)
1599 DoMethod(object
,MUIM_List_GetEntry
,active
, (IPTR
)&iln
);
1600 if (iln
->flags
& LNF_Listable
)
1602 ShowList(object
, &iln
->list
);
1603 type
= iln
->ln
.ln_Type
;
1605 else if (iln
->ln
.ln_Type
== LNT_Parent
)
1607 if (iln
->parent
->parent
)
1609 ShowList(object
, &iln
->parent
->parent
->list
);
1610 type
= iln
->parent
->parent
->ln
.ln_Type
;
1617 enableObject(gadgets
.buttons
[GB_ADD_ENTRY
]);
1618 disableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
1619 disableObject(gadgets
.buttons
[GB_CREATE_TABLE
]);
1620 disableObject(gadgets
.buttons
[GB_CHANGE_TYPE
]);
1621 disableObject(gadgets
.buttons
[GB_RESIZE_MOVE
]);
1622 disableObject(gadgets
.buttons
[GB_PARENT
]);
1623 disableObject(gadgets
.buttons
[GB_RENAME
]);
1624 disableObject(gadgets
.buttons
[GB_DOSENVEC
]);
1625 disableObject(gadgets
.buttons
[GB_SWITCHES
]);
1626 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1629 disableObject(gadgets
.buttons
[GB_ADD_ENTRY
]);
1630 disableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
1631 disableObject(gadgets
.buttons
[GB_CREATE_TABLE
]);
1632 disableObject(gadgets
.buttons
[GB_CHANGE_TYPE
]);
1633 disableObject(gadgets
.buttons
[GB_RESIZE_MOVE
]);
1634 enableObject(gadgets
.buttons
[GB_PARENT
]);
1635 disableObject(gadgets
.buttons
[GB_RENAME
]);
1636 disableObject(gadgets
.buttons
[GB_DOSENVEC
]);
1637 disableObject(gadgets
.buttons
[GB_SWITCHES
]);
1638 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1642 enableObject(gadgets
.buttons
[GB_ADD_ENTRY
]);
1643 disableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
1644 disableObject(gadgets
.buttons
[GB_CREATE_TABLE
]);
1645 disableObject(gadgets
.buttons
[GB_CHANGE_TYPE
]);
1646 enableObject(gadgets
.buttons
[GB_RESIZE_MOVE
]);
1647 enableObject(gadgets
.buttons
[GB_PARENT
]);
1648 disableObject(gadgets
.buttons
[GB_RENAME
]);
1649 disableObject(gadgets
.buttons
[GB_DOSENVEC
]);
1650 disableObject(gadgets
.buttons
[GB_SWITCHES
]);
1651 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1652 DoMethod(gadgets
.buttons
[GB_RESIZE_MOVE
], MUIM_KillNotify
, MUIA_Pressed
);
1655 gadgets
.buttons
[GB_RESIZE_MOVE
],
1656 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.win
, 3,
1657 MUIM_Set
, MUIA_Window_Open
, TRUE
1661 resizemovegadgets
.win
,
1662 MUIM_Notify
, MUIA_Window_Open
, TRUE
, (IPTR
)resizemovegadgets
.pt
, 3,
1663 MUIM_Set
, PTCT_PartitionTable
, (IPTR
)iln
1672 AROS_UFH3(void, lv_click
,
1673 AROS_UFHA(struct Hook
*, h
, A0
),
1674 AROS_UFHA(Object
*, object
, A2
),
1675 AROS_UFHA(void *, arg
, A1
))
1679 LONG active
= MUIV_List_Active_Off
;
1680 struct ListNode
*iln
;
1684 D(bug("[HDToolBox] lv_click()\n"));
1686 get(object
, MUIA_List_Active
, &active
);
1687 if (active
!= MUIV_List_Active_Off
)
1689 DoMethod(object
,MUIM_List_GetEntry
,active
, (IPTR
)&iln
);
1690 DoMethod(gadgets
.rightlv
, MUIM_List_Clear
);
1691 switch (iln
->ln
.ln_Type
)
1694 sprintf(str
, "%s: %d", MSG(WORD_Units
),(int)countNodes(&iln
->list
, LNT_Harddisk
));
1695 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1696 enableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
1697 if (iln
->change_count
> 0)
1698 enableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1700 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1705 struct HDTBPartition
*partition
;
1706 partition
= (struct HDTBPartition
*)iln
;
1712 (partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1)*
1713 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
1717 sprintf(str
, "%s: %s", MSG(WORD_Size
), sizestr
);
1718 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1719 sprintf(str
, "%s: ", MSG(WORD_Partition_Table
));
1720 if (partition
->table
)
1722 struct TableTypeNode
*ttn
;
1723 ttn
= findTableTypeNode(partition
->table
->type
);
1724 strcat(str
, ttn
->pti
->pti_Name
);
1725 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1726 sprintf(str
, "%s: %d", MSG(WORD_Partitions
), (int)countNodes(&iln
->list
, LNT_Partition
));
1727 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1731 strcat(str
, MSG(WORD_Unknown
));
1732 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1734 if (iln
->ln
.ln_Type
== LNT_Partition
)
1736 struct TypeNode
*type
;
1737 type
= findPartitionType(&partition
->type
, partition
->root
->table
->type
);
1738 sprintf(str
, "%s: ", MSG(WORD_Partition_Type
));
1740 strcat(str
, type
->ln
.ln_Name
);
1742 strcat(str
, MSG(WORD_Unknown
));
1743 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1744 sprintf(str
, "%s: ", MSG(WORD_Active
));
1745 if (partition
->flags
& PNF_ACTIVE
)
1746 strcat(str
, MSG_STD(YESSTR
));
1748 strcat(str
, MSG_STD(NOSTR
));
1749 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1750 sprintf(str
, "%s: ", MSG(WORD_Bootable
));
1751 if (partition
->flags
& PNF_BOOTABLE
)
1752 strcat(str
, MSG_STD(YESSTR
));
1754 strcat(str
, MSG_STD(NOSTR
));
1755 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1756 sprintf(str
, "%s: ", MSG(WORD_Automount
));
1757 if (partition
->flags
& PNF_AUTOMOUNT
)
1758 strcat(str
, MSG_STD(YESSTR
));
1760 strcat(str
, MSG_STD(NOSTR
));
1761 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1762 enableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
1763 enableObject(gadgets
.buttons
[GB_RENAME
]);
1764 enableObject(gadgets
.buttons
[GB_DOSENVEC
]);
1765 enableObject(gadgets
.buttons
[GB_SWITCHES
]);
1766 SetAttrs(part_item
, MUIA_Menu_Enabled
, !partition
->table
, TAG_DONE
);
1768 else if (iln
->ln
.ln_Type
== LNT_Harddisk
)
1770 if (iln
->change_count
> 0)
1771 enableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1773 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1775 enableObject(gadgets
.buttons
[GB_CREATE_TABLE
]);
1776 enableObject(gadgets
.buttons
[GB_CHANGE_TYPE
]);
1780 disableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
1781 disableObject(gadgets
.buttons
[GB_RENAME
]);
1782 disableObject(gadgets
.buttons
[GB_DOSENVEC
]);
1783 disableObject(gadgets
.buttons
[GB_SWITCHES
]);
1784 disableObject(gadgets
.buttons
[GB_CREATE_TABLE
]);
1785 disableObject(gadgets
.buttons
[GB_CHANGE_TYPE
]);
1786 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1787 SetAttrs(part_item
, MUIA_Menu_Enabled
, FALSE
, TAG_DONE
);
1795 /**************************************** Main ******************************/
1799 struct MUI_CustomClass
*listcc
;
1802 D(bug("[HDToolBox] initGUI()\n"));
1804 MUIMasterBase
= OpenLibrary("muimaster.library", 0);
1806 return ERR_MUIMASTER
;
1808 ptclass
= makePTClass();
1809 if (ptclass
== NULL
)
1812 listcc
= MUI_CreateCustomClass(NULL
, MUIC_Listview
, NULL
,
1813 sizeof(struct LeftListview__Data
), LeftListview_Dispatcher
);
1817 hook_display
.h_Entry
= (HOOKFUNC
)display_function
;
1818 hook_buttons
.h_Entry
= (HOOKFUNC
)buttons_function
;
1819 hook_createml
.h_Entry
= (HOOKFUNC
)createml_function
;
1820 hook_lv_doubleclick
.h_Entry
= (HOOKFUNC
)lv_doubleclick
;
1821 hook_lv_click
.h_Entry
= (HOOKFUNC
)lv_click
;
1822 partitiontypegadgets
.hook_hexidedit
.h_Entry
= (HOOKFUNC
)hexidedit_function
;
1824 app
= ApplicationObject
,
1825 MUIA_Application_Title
, "HDToolBox",
1826 MUIA_Application_Version
, "$VER: HDToolBox 0.5 (19.5.2015)",
1827 MUIA_Application_Copyright
, "(c) 1995-2014 AROS Development Team",
1828 MUIA_Application_Author
, "Bearly, Ogun, Fats and others at AROS",
1829 MUIA_Application_Description
, "Partition your disks.",
1830 MUIA_Application_Base
, "HDTOOLBOX",
1831 MUIA_Application_Menustrip
, MenustripObject
,
1832 MUIA_Family_Child
, MenuObject
,
1833 MUIA_Menu_Title
, MSG(WORD_MENU_Project
),
1835 about_item
= MenuitemObject
, MUIA_Menuitem_Title
, MSG(WORD_MENU_About
),
1838 quit_item
= MenuitemObject
, MUIA_Menuitem_Title
, MSG(WORD_MENU_Quit
),
1842 part_item
= MenuObject
,
1843 MUIA_Menu_Title
, MSG(WORD_MENU_Partition
),
1844 MUIA_Menu_Enabled
, FALSE
,
1846 createml_item
= MenuitemObject
,
1847 MUIA_Menuitem_Title
, MSG(WORD_MENU_CreateMountlist
),
1851 SubWindow
, mainwin
= WindowObject
,
1852 MUIA_Window_Title
, "HDToolBox",
1853 MUIA_Window_ID
, MAKE_ID('H','D','T','B'),
1854 MUIA_Window_Activate
, TRUE
,
1855 MUIA_Window_Height
, MUIV_Window_Height_Visible(50),
1856 MUIA_Window_Width
, MUIV_Window_Width_Visible(60),
1857 WindowContents
, VGroup
,
1860 Child
, gadgets
.text
= TextObject
,
1862 MUIA_Text_Contents
, MSG(MSG_Welcome
),
1865 Child
, (gadgets
.leftlv
= NewObject(listcc
->mcc_Class
, NULL
,
1866 MUIA_Listview_List
, ListObject
,
1869 MUIA_List_DisplayHook
, &hook_display
,
1870 MUIA_List_Format
, ",",
1871 MUIA_List_Title
, TRUE
,
1874 Child
, ListviewObject
,
1875 MUIA_Listview_List
, (gadgets
.rightlv
= ListObject
,
1877 MUIA_List_Title
, TRUE
,
1878 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
1879 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
1881 MUIA_Listview_Input
, FALSE
,
1889 Child
, gadgets
.buttons
[GB_ADD_ENTRY
] = SIMPLEBUTTON(WORD_AddEntry
),
1890 Child
, gadgets
.buttons
[GB_REMOVE_ENTRY
] = SIMPLEBUTTON(WORD_RemoveEntry
),
1893 Child
, gadgets
.buttons
[GB_CREATE_TABLE
] = SIMPLEBUTTON(WORD_Create_Table
),
1894 Child
, gadgets
.buttons
[GB_CHANGE_TYPE
] = SIMPLEBUTTON(WORD_Change_Type
),
1897 Child
, gadgets
.buttons
[GB_RESIZE_MOVE
] = SIMPLEBUTTON(WORD_Resize_Move
),
1898 Child
, gadgets
.buttons
[GB_PARENT
] = SIMPLEBUTTON(WORD_Parent
),
1901 Child
, gadgets
.buttons
[GB_RENAME
] = SIMPLEBUTTON(WORD_Rename
),
1902 Child
, gadgets
.buttons
[GB_DOSENVEC
] = SIMPLEBUTTON(WORD_DosEnvec
),
1905 Child
, gadgets
.buttons
[GB_SWITCHES
] = SIMPLEBUTTON(WORD_Switches
),
1910 MUIA_Group_SameWidth
, TRUE
,
1912 Child
, gadgets
.buttons
[GB_SAVE_CHANGES
] = IMAGEBUTTON(WORD_Save_Changes
, COOL_SAVEIMAGE_ID
),
1913 Child
, gadgets
.buttons
[GB_EXIT
] = IMAGEBUTTON(WORD_Exit
, COOL_CANCELIMAGE_ID
),
1918 SubWindow
, adddevicegadgets
.win
= WindowObject
,
1919 MUIA_Window_Title
, MSG(WORD_Devices
),
1920 MUIA_Window_Activate
, TRUE
,
1921 WindowContents
, VGroup
,
1922 Child
, PopaslObject
,
1923 MUIA_Popstring_String
, adddevicegadgets
.file
= StringObject
,
1926 MUIA_Popstring_Button
, PopButton(MUII_PopFile
),
1929 MUIA_Group_SameWidth
, TRUE
,
1931 Child
, adddevicegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
1932 Child
, adddevicegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
1936 SubWindow
, addpartitiongadgets
.win
= WindowObject
,
1937 MUIA_Window_Title
, MSG(MSG_Select_Empty_Area
),
1938 MUIA_Window_Activate
, TRUE
,
1939 WindowContents
, VGroup
,
1940 Child
, addpartitiongadgets
.pt
= BoopsiObject
,
1942 MUIA_Boopsi_Class
, ptclass
,
1943 MUIA_Boopsi_MinWidth
, 600,
1944 MUIA_Boopsi_MinHeight
, 100,
1945 MUIA_Boopsi_TagDrawInfo
, GA_DrawInfo
,
1946 MUIA_Boopsi_Remember
, PTCT_PartitionTable
,
1947 MUIA_Boopsi_Remember
, PTCT_Flags
,
1948 PTCT_Flags
, PTCTF_NoPartitionMove
| PTCTF_EmptySelectOnly
,
1954 MUIA_VertWeight
, 10,
1955 ICA_TARGET
, ICTARGET_IDCMP
,
1958 MUIA_Group_SameWidth
, TRUE
,
1960 Child
, addpartitiongadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
1961 Child
, addpartitiongadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
1965 SubWindow
, partitiontypegadgets
.win
= WindowObject
,
1966 MUIA_Window_Title
, MSG(WORD_Partition_Type
),
1967 MUIA_Window_Activate
, TRUE
,
1968 WindowContents
, VGroup
,
1969 Child
, partitiontypegadgets
.lv
= ListviewObject
,
1970 MUIA_Listview_List
, ListObject
,
1972 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
1973 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
1974 MUIA_List_Title
, TRUE
,
1978 Child
, partitiontypegadgets
.base
= CycleObject
,
1980 MUIA_Cycle_Entries
, editcycleentries
,
1981 MUIA_HorizWeight
, 1,
1983 Child
, partitiontypegadgets
.hexid
= StringObject
,
1985 MUIA_String_EditHook
, &partitiontypegadgets
.hook_hexidedit
,
1989 MUIA_Group_SameWidth
, TRUE
,
1991 Child
, partitiontypegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
1992 Child
, partitiontypegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
1996 SubWindow
, partitiontabletypegadgets
.win
= WindowObject
,
1997 MUIA_Window_Title
, MSG(WORD_Partition_Table_Type
),
1998 MUIA_Window_Activate
, TRUE
,
1999 WindowContents
, VGroup
,
2000 Child
, partitiontabletypegadgets
.lv
= ListviewObject
,
2001 MUIA_Listview_List
, ListObject
,
2003 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
2004 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
2005 MUIA_List_Title
, TRUE
,
2009 MUIA_Group_SameWidth
, TRUE
,
2011 Child
, partitiontabletypegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
2012 Child
, partitiontabletypegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
2016 SubWindow
, resizemovegadgets
.win
= WindowObject
,
2017 MUIA_Window_Title
, MSG(MSG_Select_Partition_Resize_Move
),
2018 MUIA_Window_Activate
, TRUE
,
2019 WindowContents
, VGroup
,
2020 Child
, resizemovegadgets
.pt
= BoopsiObject
,
2022 MUIA_Boopsi_Class
, ptclass
,
2023 MUIA_Boopsi_MinWidth
, 600,
2024 MUIA_Boopsi_MinHeight
, 100,
2025 MUIA_Boopsi_TagDrawInfo
, GA_DrawInfo
,
2026 MUIA_Boopsi_Remember
, PTCT_PartitionTable
,
2027 MUIA_Boopsi_Remember
, PTCT_Flags
,
2034 MUIA_VertWeight
, 10,
2035 ICA_TARGET
, ICTARGET_IDCMP
,
2039 MUIA_FrameTitle
, MSG(WORD_Geometry
),
2043 Child
, Label2("Low Cyl"),
2044 Child
, resizemovegadgets
.lowcyl
=StringObject
,
2046 MUIA_String_Integer
, 0,
2047 MUIA_String_Accept
, "0123456789",
2051 Child
, Label2("High Cyl"),
2052 Child
, resizemovegadgets
.highcyl
=StringObject
,
2054 MUIA_String_Integer
, 0,
2055 MUIA_String_Accept
, "0123456789",
2059 Child
, Label2("Total Cyl"),
2060 Child
, resizemovegadgets
.totalcyl
=StringObject
,
2062 MUIA_String_Integer
, 0,
2063 MUIA_String_Accept
, "0123456789",
2066 MUIA_HorizWeight
, 10,
2068 Child
, Label2("Size"),
2069 Child
, resizemovegadgets
.size
=StringObject
,
2071 MUIA_String_Accept
, "0123456789GM.",
2072 MUIA_HorizWeight
, 3,
2077 MUIA_Group_SameWidth
, TRUE
,
2079 Child
, resizemovegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
2080 Child
, resizemovegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
2084 SubWindow
, renamegadgets
.win
= WindowObject
,
2085 MUIA_Window_Title
, MSG(WORD_Rename
),
2086 MUIA_Window_Activate
, TRUE
,
2087 WindowContents
, VGroup
,
2088 Child
, renamegadgets
.name
= StringObject
,
2092 MUIA_Group_SameWidth
, TRUE
,
2094 Child
, renamegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
2095 Child
, renamegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
2099 SubWindow
, dosenvecgadgets
.win
= WindowObject
,
2100 MUIA_Window_Title
, MSG(WORD_DosEnvec
),
2101 MUIA_Window_Activate
, TRUE
,
2102 WindowContents
, VGroup
,
2106 Child
, Label2("Mask"),
2107 Child
, dosenvecgadgets
.mask
=StringObject
,
2109 MUIA_String_Integer
, -2,
2110 MUIA_String_Accept
, "0123456789",
2114 Child
, Label2("MaxTransfer"),
2115 Child
, dosenvecgadgets
.maxtransfer
=StringObject
,
2117 MUIA_String_Contents
, "0x7FFFFF",
2118 MUIA_String_Accept
, "0123456789x",
2125 Child
, Label("_Custom Bootcode"),
2127 Child
, dosenvecgadgets
.custboot
=MUI_MakeObject
2130 (IPTR
)"_Custom Bootcode"
2134 Child
, Label2("Nr. of Custom Bootblocks"),
2135 Child
, dosenvecgadgets
.numcustboot
=StringObject
,
2137 MUIA_String_Integer
, 0,
2138 MUIA_String_Accept
, "0123456789",
2144 MUIA_FrameTitle
, "Reserved Blocks at",
2146 Child
, Label2("Beginning"),
2147 Child
, dosenvecgadgets
.reservedblocksstart
=StringObject
,
2149 MUIA_String_Integer
, 0,
2150 MUIA_String_Accept
, "0123456789",
2154 Child
, Label2("End"),
2155 Child
, dosenvecgadgets
.reservedblocksend
=StringObject
,
2157 MUIA_String_Integer
, 0,
2158 MUIA_String_Accept
, "0123456789",
2165 Child
, Label("BlockSize"),
2166 Child
, dosenvecgadgets
.blocksize
=CycleObject
,
2168 MUIA_Cycle_Entries
, blocksizecycleentries
,
2172 Child
, Label2("Buffers"),
2173 Child
, dosenvecgadgets
.buffers
=StringObject
,
2175 MUIA_String_Integer
, 20,
2176 MUIA_String_Accept
, "0123456789",
2181 MUIA_Group_SameWidth
, TRUE
,
2183 Child
, dosenvecgadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
2184 Child
, dosenvecgadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
2188 SubWindow
, mountbootgadgets
.win
= WindowObject
,
2189 MUIA_Window_Title
, MSG(WORD_Switches
),
2190 MUIA_Window_Activate
, TRUE
,
2191 WindowContents
, VGroup
,
2193 Child
, Label(MSG(WORD_Active
)),
2195 Child
, mountbootgadgets
.active
=MUI_MakeObject
2202 Child
, Label(MSG(WORD_Automount
)),
2204 Child
, mountbootgadgets
.automount
=MUI_MakeObject
2211 Child
, Label(MSG(WORD_Bootable
)),
2213 Child
, mountbootgadgets
.bootable
=MUI_MakeObject
2220 Child
, Label(MSG(WORD_BootPri
)),
2221 Child
, mountbootgadgets
.bootpri
=StringObject
,
2223 MUIA_String_Integer
, 0,
2224 MUIA_String_Accept
, "-0123456789",
2228 MUIA_Group_SameWidth
, TRUE
,
2230 Child
, mountbootgadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
2231 Child
, mountbootgadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
2243 mainwin
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)app
, 2,
2244 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
2248 gadgets
.buttons
[GB_EXIT
], MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)app
, 2,
2249 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
2254 MUIM_Notify
, MUIA_Listview_DoubleClick
, TRUE
, (IPTR
)gadgets
.leftlv
, 2,
2255 MUIM_CallHook
, (IPTR
)&hook_lv_doubleclick
2259 gadgets
.leftlv
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
,
2260 (IPTR
)gadgets
.leftlv
, 2, MUIM_CallHook
, (IPTR
)&hook_lv_click
2262 for (i
=GB_FIRST
;i
<GB_EXIT
;i
++)
2267 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)gadgets
.buttons
[i
], 2,
2268 MUIM_CallHook
, (IPTR
)&hook_buttons
2270 /* MUIM_CallHook, hook */
2272 disableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
2273 disableObject(gadgets
.buttons
[GB_CREATE_TABLE
]);
2274 disableObject(gadgets
.buttons
[GB_CHANGE_TYPE
]);
2275 disableObject(gadgets
.buttons
[GB_RESIZE_MOVE
]);
2276 disableObject(gadgets
.buttons
[GB_PARENT
]);
2277 disableObject(gadgets
.buttons
[GB_RENAME
]);
2278 disableObject(gadgets
.buttons
[GB_DOSENVEC
]);
2279 disableObject(gadgets
.buttons
[GB_SWITCHES
]);
2280 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
2284 MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
, (IPTR
)app
, 2,
2285 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
2287 DoMethod(createml_item
,
2288 MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
, app
, 2,
2289 MUIM_CallHook
, &hook_createml
);
2290 /* add device window */
2293 adddevicegadgets
.win
,
2294 MUIM_Notify
, MUIA_Window_Open
, TRUE
, (IPTR
)mainwin
, 3,
2295 MUIM_Set
, MUIA_Window_Sleep
, TRUE
2299 adddevicegadgets
.win
,
2300 MUIM_Notify
, MUIA_Window_Open
, FALSE
, (IPTR
)mainwin
, 3,
2301 MUIM_Set
, MUIA_Window_Sleep
, FALSE
2305 adddevicegadgets
.win
,
2306 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)adddevicegadgets
.win
, 3,
2307 MUIM_Set
, MUIA_Window_Open
, FALSE
2311 adddevicegadgets
.ok
,
2312 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)adddevicegadgets
.ok
, 2,
2313 MUIM_CallHook
, (IPTR
)&hook_buttons
2317 adddevicegadgets
.ok
,
2318 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)adddevicegadgets
.win
, 3,
2319 MUIM_Set
, MUIA_Window_Open
, FALSE
2323 adddevicegadgets
.cancel
,
2324 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)adddevicegadgets
.win
, 3,
2325 MUIM_Set
, MUIA_Window_Open
, FALSE
2327 /* add partition window */
2330 addpartitiongadgets
.win
,
2331 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)addpartitiongadgets
.win
, 3,
2332 MUIM_Set
, MUIA_Window_Open
, FALSE
2336 addpartitiongadgets
.ok
,
2337 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)addpartitiongadgets
.ok
, 2,
2338 MUIM_CallHook
, (IPTR
)&hook_buttons
2342 addpartitiongadgets
.ok
,
2343 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)addpartitiongadgets
.win
, 3,
2344 MUIM_Set
, MUIA_Window_Open
, FALSE
2348 addpartitiongadgets
.cancel
,
2349 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)addpartitiongadgets
.win
, 3,
2350 MUIM_Set
, MUIA_Window_Open
, FALSE
2354 addpartitiongadgets
.pt
,
2355 MUIM_Notify
, PTCT_Selected
, TRUE
, (IPTR
)addpartitiongadgets
.pt
, 2,
2356 MUIM_CallHook
, (IPTR
)&hook_buttons
2358 /* partition type window */
2361 partitiontypegadgets
.win
,
2362 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)partitiontypegadgets
.win
, 3,
2363 MUIM_Set
, MUIA_Window_Open
, FALSE
2367 partitiontypegadgets
.hexid
,
2368 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
2369 (IPTR
)partitiontypegadgets
.hexid
, 2,
2370 MUIM_CallHook
, (IPTR
)&hook_buttons
2372 /* "FIXME: notify doesn't work" */
2375 partitiontypegadgets
.ok
,
2376 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontypegadgets
.ok
, 2,
2377 MUIM_CallHook
, (IPTR
)&hook_buttons
2381 partitiontypegadgets
.ok
,
2382 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontypegadgets
.win
, 3,
2383 MUIM_Set
, MUIA_Window_Open
, FALSE
2387 partitiontypegadgets
.cancel
,
2388 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontypegadgets
.win
, 3,
2389 MUIM_Set
, MUIA_Window_Open
, FALSE
2393 partitiontypegadgets
.lv
, MUIM_Notify
, MUIA_List_Active
,
2394 MUIV_EveryTime
, (IPTR
)partitiontypegadgets
.lv
, 2, MUIM_CallHook
,
2397 /* partition table type window */
2400 partitiontabletypegadgets
.win
,
2401 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)partitiontabletypegadgets
.win
, 3,
2402 MUIM_Set
, MUIA_Window_Open
, FALSE
2406 partitiontabletypegadgets
.ok
,
2407 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontabletypegadgets
.ok
, 2,
2408 MUIM_CallHook
, (IPTR
)&hook_buttons
2412 partitiontabletypegadgets
.ok
,
2413 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontabletypegadgets
.win
, 3,
2414 MUIM_Set
, MUIA_Window_Open
, FALSE
2418 partitiontabletypegadgets
.cancel
,
2419 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontabletypegadgets
.win
, 3,
2420 MUIM_Set
, MUIA_Window_Open
, FALSE
2422 /* resize/move window */
2425 resizemovegadgets
.win
,
2426 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)resizemovegadgets
.win
, 3,
2427 MUIM_Set
, MUIA_Window_Open
, FALSE
2431 resizemovegadgets
.ok
,
2432 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.ok
, 2,
2433 MUIM_CallHook
, (IPTR
)&hook_buttons
2437 resizemovegadgets
.ok
,
2438 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.win
, 3,
2439 MUIM_Set
, MUIA_Window_Open
, FALSE
2443 resizemovegadgets
.size
,
2444 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
2445 (IPTR
)resizemovegadgets
.size
, 2,
2446 MUIM_CallHook
, (IPTR
)&hook_buttons
2450 resizemovegadgets
.cancel
,
2451 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.cancel
, 2,
2452 MUIM_CallHook
, (IPTR
)&hook_buttons
2456 resizemovegadgets
.cancel
,
2457 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.win
, 3,
2458 MUIM_Set
, MUIA_Window_Open
, FALSE
2462 resizemovegadgets
.pt
,
2463 MUIM_Notify
, PTCT_Selected
, TRUE
, (IPTR
)resizemovegadgets
.pt
, 3,
2464 MUIM_CallHook
, (IPTR
)&hook_buttons
, PTCT_Selected
2468 resizemovegadgets
.pt
,
2469 MUIM_Notify
, PTCT_PartitionMove
, TRUE
, (IPTR
)resizemovegadgets
.pt
, 3,
2470 MUIM_CallHook
, (IPTR
)&hook_buttons
, PTCT_PartitionMove
2474 resizemovegadgets
.highcyl
,
2475 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
, (IPTR
)resizemovegadgets
.highcyl
, 2,
2476 MUIM_CallHook
, (IPTR
)&hook_buttons
2480 resizemovegadgets
.lowcyl
,
2481 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
, (IPTR
)resizemovegadgets
.lowcyl
, 2,
2482 MUIM_CallHook
, (IPTR
)&hook_buttons
2486 resizemovegadgets
.totalcyl
,
2487 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
, (IPTR
)resizemovegadgets
.totalcyl
, 2,
2488 MUIM_CallHook
, (IPTR
)&hook_buttons
2494 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)renamegadgets
.win
, 3,
2495 MUIM_Set
, MUIA_Window_Open
, FALSE
2500 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)renamegadgets
.ok
, 2,
2501 MUIM_CallHook
, (IPTR
)&hook_buttons
2506 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)renamegadgets
.win
, 3,
2507 MUIM_Set
, MUIA_Window_Open
, FALSE
2511 renamegadgets
.cancel
,
2512 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)renamegadgets
.win
, 3,
2513 MUIM_Set
, MUIA_Window_Open
, FALSE
2515 /* dosenvec window */
2518 dosenvecgadgets
.win
,
2519 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)dosenvecgadgets
.win
, 3,
2520 MUIM_Set
, MUIA_Window_Open
, FALSE
2525 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)dosenvecgadgets
.ok
, 2,
2526 MUIM_CallHook
, (IPTR
)&hook_buttons
2531 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)dosenvecgadgets
.win
, 3,
2532 MUIM_Set
, MUIA_Window_Open
, FALSE
2536 dosenvecgadgets
.cancel
,
2537 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)dosenvecgadgets
.win
, 3,
2538 MUIM_Set
, MUIA_Window_Open
, FALSE
2540 /* automount/boot window */
2543 mountbootgadgets
.win
,
2544 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)mountbootgadgets
.win
, 3,
2545 MUIM_Set
, MUIA_Window_Open
, FALSE
2549 mountbootgadgets
.ok
,
2550 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)mountbootgadgets
.ok
, 2,
2551 MUIM_CallHook
, (IPTR
)&hook_buttons
2555 mountbootgadgets
.ok
,
2556 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)mountbootgadgets
.win
, 3,
2557 MUIM_Set
, MUIA_Window_Open
, FALSE
2561 mountbootgadgets
.cancel
,
2562 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)mountbootgadgets
.win
, 3,
2563 MUIM_Set
, MUIA_Window_Open
, FALSE
2565 set(mainwin
, MUIA_Window_Open
, TRUE
);
2571 D(bug("[HDToolBox] deinitGUI()\n"));
2574 MUI_DisposeObject(app
);
2575 if (ptclass
!= NULL
)
2578 CloseLibrary(MUIMasterBase
);
2581 BOOL
QuitGUI(ULONG
*sigs
)
2583 // moved debug from this place because it produces too much garbage
2585 if ((IPTR
)DoMethod(app
, MUIM_Application_NewInput
, (IPTR
)sigs
) == MUIV_Application_ReturnID_Quit
)
2587 D(bug("[HDToolBox] QuitGUI()\n"));