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
);
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
;
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
;
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
))
228 D(bug("[HDToolBox] hexidedit_function()\n"));
232 D(bug("[HDToolBox] hexidedit_function: KEY PRESS\n"));
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
))
248 D(bug("[HDToolBox] display_function()\n"));
253 if (entry
->change_count
)
255 if (entry
->flags
& LNF_ToSave
)
259 if ((entry
->flags
& LNF_Listable
) || (entry
->ln
.ln_Type
== LNT_Parent
))
261 sprintf(bu2
,"\0333%s",entry
->ln
.ln_Name
);
265 strings
[1] = entry
->ln
.ln_Name
;
269 strings
[0] = MSG(WORD_Changed
);
270 strings
[1] = MSG(WORD_Name
);
276 void setTypeString(struct PartitionType
*type
, Object
*strgad
)
282 D(bug("[HDToolBox] setTypeString()\n"));
284 while (len
!=type
->id_len
)
286 sprintf(cur
, "%02x ", type
->id
[len
]);
291 set(strgad
, MUIA_String_Contents
, str
);
294 LONG
askSave(STRPTR name
)
296 struct EasyStruct es
=
298 sizeof(struct EasyStruct
), 0,
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
)
335 result
= askSave(iln
->ln
.ln_Name
);
340 if (WritePartitionTable(partition
->ph
) == 0)
343 set(gadgets
.text
, MUIA_Text_Contents
, MSG(MSG_WriteTableError
));
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
))
358 LONG active
= MUIV_List_Active_Off
;
359 struct ListNode
*iln
;
362 D(bug("[HDToolBox] buttons_function()\n"));
364 for (i
=GB_FIRST
;i
<=GB_LAST
;i
++)
365 if (object
== gadgets
.buttons
[i
])
370 if (object
== gadgets
.leftlv
)
373 else if (object
== adddevicegadgets
.ok
)
376 struct HDTBDevice
*dn
;
378 get(adddevicegadgets
.file
, MUIA_String_Contents
, &str
);
380 dn
= addDeviceName(str
);
383 /* FIXME: Should we fail here? */
386 else if (object
== addpartitiongadgets
.ok
)
388 struct DosEnvec
*de
= NULL
;
390 get(addpartitiongadgets
.pt
, PTCT_ActivePartition
, &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
);
401 setChanged(&partition
->listnode
);
402 partition
->listnode
.parent
->flags
|= LNF_ToSave
;
403 InsertList(gadgets
.leftlv
, &partition
->listnode
);
406 set(gadgets
.text
, MUIA_Text_Contents
, MSG(MSG_NO_MEMORY
));
409 else if (object
== addpartitiongadgets
.pt
);
410 else if (object
== partitiontypegadgets
.hexid
)
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
)
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
;
449 DoMethod(partitiontabletypegadgets
.lv
, MUIM_List_GetEntry
, active
, (IPTR
)&name
);
450 ttn
= findTableTypeNodeName(name
);
451 table
= (struct HDTBPartition
*)partitiontabletypegadgets
.iln
;
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
);
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
)
507 struct DosEnvec
*de
= NULL
;
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
);
518 struct HDTBPartition
*partition
= NULL
;
520 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &partition
);
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
)
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
;
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
)
558 value
*partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
;
559 if (validValue(table
, partition
, block
))
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
);
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
);
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
);
591 set(object
, MUIA_String_Integer
, 0);
593 else if (object
== resizemovegadgets
.highcyl
)
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
;
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
)
619 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
621 if (validValue(table
, partition
, block
))
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
);
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
);
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
);
654 nnset(object
, MUIA_String_Integer
, 0);
656 else if (object
== resizemovegadgets
.totalcyl
)
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
;
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))
675 (partition
->de
.de_LowCyl
+value
)*
676 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
678 if (validValue(table
, partition
, block
))
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
);
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
);
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);
710 set(object
, MUIA_String_Integer
, 0);
712 else if (object
== resizemovegadgets
.size
)
715 struct DosEnvec
*de
= NULL
;
720 get(resizemovegadgets
.pt
, PTCT_ActiveType
, &type
);
721 if (type
== PTS_PARTITION
)
723 struct HDTBPartition
*partition
= NULL
;
725 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &partition
);
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
);
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
;
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
;
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
;
780 get(dosenvecgadgets
.maxtransfer
, MUIA_String_Contents
, &str
);
781 value
= strtoul(str
, &end
, 0);
784 if (value
!= partition
->de
.de_MaxTransfer
)
786 partition
->de
.de_MaxTransfer
= value
;
790 get(dosenvecgadgets
.custboot
, MUIA_Selected
, &check
);
793 if (partition
->de
.de_TableSize
<(DE_BOOTBLOCKS
+1))
795 partition
->de
.de_TableSize
= DE_BOOTBLOCKS
+1;
798 get(dosenvecgadgets
.numcustboot
, MUIA_String_Integer
, &value
);
799 if (value
!= partition
->de
.de_BootBlocks
)
801 partition
->de
.de_BootBlocks
= value
;
807 if (partition
->de
.de_TableSize
>=(DE_BOOTBLOCKS
+1))
809 partition
->de
.de_TableSize
= DE_BOOTBLOCKS
;
810 partition
->de
.de_BootBlocks
= 0;
814 get(dosenvecgadgets
.reservedblocksstart
, MUIA_String_Integer
, &value
);
815 if (value
!= partition
->de
.de_Reserved
)
817 partition
->de
.de_Reserved
= value
;
820 get(dosenvecgadgets
.reservedblocksend
, MUIA_String_Integer
, &value
);
821 if (value
!= partition
->de
.de_PreAlloc
)
823 partition
->de
.de_PreAlloc
= value
;
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
;
833 get(dosenvecgadgets
.buffers
, MUIA_String_Integer
, &value
);
834 if (value
!= partition
->de
.de_NumBuffers
)
836 partition
->de
.de_NumBuffers
= value
;
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
;
854 partition
= (struct HDTBPartition
*)mountbootgadgets
.iln
;
855 get(mountbootgadgets
.active
, MUIA_Selected
, &check
);
858 if (!(partition
->flags
& PNF_ACTIVE
))
860 partition
->flags
|= PNF_ACTIVE
;
866 if (partition
->flags
& PNF_ACTIVE
)
868 partition
->flags
&= ~PNF_ACTIVE
;
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
);
910 get(mountbootgadgets
.automount
, MUIA_Selected
, &check
);
913 if (!(partition
->flags
& PNF_AUTOMOUNT
))
915 partition
->flags
|= PNF_AUTOMOUNT
;
921 if (partition
->flags
& PNF_AUTOMOUNT
)
923 partition
->flags
&= ~PNF_AUTOMOUNT
;
929 SetPartitionAttrsA(partition
->ph
, PT_AUTOMOUNT
, check
, TAG_DONE
);
933 get(mountbootgadgets
.bootable
, MUIA_Selected
, &check
);
936 if (!(partition
->flags
& PNF_BOOTABLE
))
938 partition
->flags
|= PNF_BOOTABLE
;
941 get(mountbootgadgets
.bootpri
, MUIA_String_Integer
, &value
);
942 if (value
!= partition
->de
.de_BootPri
)
944 partition
->de
.de_BootPri
= value
;
950 if (partition
->flags
& PNF_BOOTABLE
)
952 partition
->flags
&= ~PNF_BOOTABLE
;
953 partition
->de
.de_BootPri
= 0;
959 SetPartitionAttrsA(partition
->ph
, PT_BOOTABLE
, check
, PT_DOSENVEC
, &partition
->de
, TAG_DONE
);
964 mountbootgadgets
.iln
->parent
->flags
|= LNF_ToSave
;
965 setChanged(mountbootgadgets
.iln
);
974 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, 0, (IPTR
)&iln
);
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
;
988 (table
->table
->max_partitions
) &&
989 (countNodes(&table
->listnode
.list
, LNT_Partition
)<table
->table
->max_partitions
)
991 (table
->table
->max_partitions
== 0)
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
);
1003 set(gadgets
.text
, MUIA_Text_Contents
, MSG(MSG_PARTITION_TABLE_FULL
));
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
)
1014 DoMethod(gadgets
.leftlv
, MUIM_List_Remove
, active
);
1016 freeDeviceNode((struct HDTBDevice
*)iln
);
1020 struct HDTBPartition
*partition
;
1021 partition
= (struct HDTBPartition
*)iln
;
1022 iln
->parent
->flags
|= LNF_ToSave
;
1024 DoMethod(gadgets
.leftlv
, MUIM_List_Remove
, active
);
1026 DeletePartition(partition
->ph
);
1027 freePartitionNode(partition
);
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
);
1039 (iln
->ln
.ln_Type
== LNT_Harddisk
) ||
1040 ((i
==2) && (iln
->ln
.ln_Type
== LNT_Partition
))
1043 struct HDTBPartition
*table
;
1045 partitiontabletypegadgets
.iln
= iln
;
1046 table
= (struct HDTBPartition
*)iln
;
1048 type
= table
->table
->type
;
1049 DoMethod(partitiontabletypegadgets
.lv
, MUIM_List_Clear
);
1050 for (i
=0;PartitionBase
->tables
[i
] != NULL
;i
++)
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
;
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
)
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
;
1088 setTypeString(&partition
->type
, partitiontypegadgets
.hexid
);
1089 set(partitiontypegadgets
.win
, MUIA_Window_Open
, TRUE
);
1093 case GB_RESIZE_MOVE
:
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
);
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
);
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
)
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
);
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
);
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
;
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
);
1183 set(mountbootgadgets
.bootable
, MUIA_Selected
, FALSE
);
1184 set(mountbootgadgets
.win
, MUIA_Window_Open
, TRUE
);
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
);
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
;
1212 while (part
->listnode
.parent
)
1214 part
= (struct HDTBPartition
*)part
->listnode
.parent
;
1216 if (part
->listnode
.ln
.ln_Type
!= LNT_Partition
)
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");
1244 ForeachNode(&fsr
->fsr_FileSysEntries
, fse
)
1246 if (fse
->fse_DosType
== dostype
)
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
))
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
},
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
);
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
);
1292 strcpy(pathname
, req
->fr_Drawer
);
1293 AddPart(pathname
, req
->fr_File
, len
);
1295 file
= Open(pathname
, MODE_NEWFILE
);
1296 FreeMem(pathname
, len
);
1300 struct DiskObject
*icon
;
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
;
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
);
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"
1351 "SectorsPerBlock = %ld\n"
1352 "BlocksPerTrack = %ld\n"
1355 "Interleave = %ld\n"
1356 "MaxTransfer = 0x%08lx\n"
1361 "BufMemType = %ld\n"
1365 "DosType = 0x%08lx\n"
1371 icon
= GetDiskObject("ENVARC:Sys/def_Mountlist");
1374 PutDiskObject(pathname
, icon
);
1375 FreeDiskObject(icon
);
1381 MUI_FreeAslRequest(req
);
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
);
1399 node
->parent
= parent
;
1400 new->ln
.ln_Name
= "..";
1401 new->ln
.ln_Type
= LNT_Parent
;
1402 new->ln
.ln_Pri
= 127;
1404 AddTail(&node
->list
, &new->ln
);
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
));
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
)
1450 ((lnode
->ln
.ln_Type
== LNT_Parent
) && (lnode
->parent
->parent
!= NULL
)) ||
1451 (lnode
->ln
.ln_Type
!= LNT_Parent
)
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
)
1501 switch (message
->MethodID
)
1505 struct opSet
*msg
= (struct opSet
*)message
;
1507 retval
= DoSuperMethod(CLASS
, self
, OM_NEW
, msg
->ops_AttrList
, NULL
);
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
;
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
);
1534 struct LeftListview__Data
*data
= INST_DATA(CLASS
, self
);
1538 DoMethod(_win(self
), MUIM_Window_RemEventHandler
, (IPTR
) &data
->ehn
);
1539 CloseDevice((struct IORequest
*)&data
->ioreq
);
1542 retval
= DoSuperMethodA(CLASS
, self
, message
);
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
;
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
;
1572 retval
= DoSuperMethodA(CLASS
, self
, message
);
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
))
1586 LONG active
= MUIV_List_Active_Off
;
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
;
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
]);
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
]);
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
);
1651 gadgets
.buttons
[GB_RESIZE_MOVE
],
1652 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.win
, 3,
1653 MUIM_Set
, MUIA_Window_Open
, TRUE
1657 resizemovegadgets
.win
,
1658 MUIM_Notify
, MUIA_Window_Open
, TRUE
, (IPTR
)resizemovegadgets
.pt
, 3,
1659 MUIM_Set
, PTCT_PartitionTable
, (IPTR
)iln
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
))
1675 LONG active
= MUIV_List_Active_Off
;
1676 struct ListNode
*iln
;
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
)
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
]);
1696 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1701 struct HDTBPartition
*partition
;
1702 partition
= (struct HDTBPartition
*)iln
;
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
);
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
));
1736 strcat(str
, type
->ln
.ln_Name
);
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
));
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
));
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
));
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
]);
1769 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1771 enableObject(gadgets
.buttons
[GB_CREATE_TABLE
]);
1772 enableObject(gadgets
.buttons
[GB_CHANGE_TYPE
]);
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
);
1791 /**************************************** Main ******************************/
1795 struct MUI_CustomClass
*listcc
;
1798 D(bug("[HDToolBox] initGUI()\n"));
1800 MUIMasterBase
= OpenLibrary("muimaster.library", 0);
1802 return ERR_MUIMASTER
;
1804 ptclass
= makePTClass();
1805 if (ptclass
== NULL
)
1808 listcc
= MUI_CreateCustomClass(NULL
, MUIC_Listview
, NULL
,
1809 sizeof(struct LeftListview__Data
), LeftListview_Dispatcher
);
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
),
1831 about_item
= MenuitemObject
, MUIA_Menuitem_Title
, MSG(WORD_MENU_About
),
1834 quit_item
= MenuitemObject
, MUIA_Menuitem_Title
, MSG(WORD_MENU_Quit
),
1838 part_item
= MenuitemObject
,
1839 MUIA_Menuitem_Title
, MSG(WORD_MENU_Partition
),
1840 MUIA_Menuitem_Enabled
, FALSE
,
1842 createml_item
= MenuitemObject
,
1843 MUIA_Menuitem_Title
, MSG(WORD_MENU_CreateMountlist
),
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
,
1856 Child
, gadgets
.text
= TextObject
,
1858 MUIA_Text_Contents
, MSG(MSG_Welcome
),
1861 Child
, (gadgets
.leftlv
= NewObject(listcc
->mcc_Class
, NULL
,
1862 MUIA_Listview_List
, ListObject
,
1865 MUIA_List_DisplayHook
, &hook_display
,
1866 MUIA_List_Format
, ",",
1867 MUIA_List_Title
, TRUE
,
1870 Child
, ListviewObject
,
1871 MUIA_Listview_List
, (gadgets
.rightlv
= ListObject
,
1873 MUIA_List_Title
, TRUE
,
1874 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
1875 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
1877 MUIA_Listview_Input
, FALSE
,
1885 Child
, gadgets
.buttons
[GB_ADD_ENTRY
] = SIMPLEBUTTON(WORD_AddEntry
),
1886 Child
, gadgets
.buttons
[GB_REMOVE_ENTRY
] = SIMPLEBUTTON(WORD_RemoveEntry
),
1889 Child
, gadgets
.buttons
[GB_CREATE_TABLE
] = SIMPLEBUTTON(WORD_Create_Table
),
1890 Child
, gadgets
.buttons
[GB_CHANGE_TYPE
] = SIMPLEBUTTON(WORD_Change_Type
),
1893 Child
, gadgets
.buttons
[GB_RESIZE_MOVE
] = SIMPLEBUTTON(WORD_Resize_Move
),
1894 Child
, gadgets
.buttons
[GB_PARENT
] = SIMPLEBUTTON(WORD_Parent
),
1897 Child
, gadgets
.buttons
[GB_RENAME
] = SIMPLEBUTTON(WORD_Rename
),
1898 Child
, gadgets
.buttons
[GB_DOSENVEC
] = SIMPLEBUTTON(WORD_DosEnvec
),
1901 Child
, gadgets
.buttons
[GB_SWITCHES
] = SIMPLEBUTTON(WORD_Switches
),
1906 MUIA_Group_SameWidth
, TRUE
,
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
),
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
,
1922 MUIA_Popstring_Button
, PopButton(MUII_PopFile
),
1925 MUIA_Group_SameWidth
, TRUE
,
1927 Child
, adddevicegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
1928 Child
, adddevicegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
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
,
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
,
1950 MUIA_VertWeight
, 10,
1951 ICA_TARGET
, ICTARGET_IDCMP
,
1954 MUIA_Group_SameWidth
, TRUE
,
1956 Child
, addpartitiongadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
1957 Child
, addpartitiongadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
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
,
1968 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
1969 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
1970 MUIA_List_Title
, TRUE
,
1974 Child
, partitiontypegadgets
.base
= CycleObject
,
1976 MUIA_Cycle_Entries
, editcycleentries
,
1977 MUIA_HorizWeight
, 1,
1979 Child
, partitiontypegadgets
.hexid
= StringObject
,
1981 MUIA_String_EditHook
, &partitiontypegadgets
.hook_hexidedit
,
1985 MUIA_Group_SameWidth
, TRUE
,
1987 Child
, partitiontypegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
1988 Child
, partitiontypegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
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
,
1999 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
2000 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
2001 MUIA_List_Title
, TRUE
,
2005 MUIA_Group_SameWidth
, TRUE
,
2007 Child
, partitiontabletypegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
2008 Child
, partitiontabletypegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
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
,
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
,
2030 MUIA_VertWeight
, 10,
2031 ICA_TARGET
, ICTARGET_IDCMP
,
2035 MUIA_FrameTitle
, MSG(WORD_Geometry
),
2039 Child
, Label2("Low Cyl"),
2040 Child
, resizemovegadgets
.lowcyl
=StringObject
,
2042 MUIA_String_Integer
, 0,
2043 MUIA_String_Accept
, "0123456789",
2047 Child
, Label2("High Cyl"),
2048 Child
, resizemovegadgets
.highcyl
=StringObject
,
2050 MUIA_String_Integer
, 0,
2051 MUIA_String_Accept
, "0123456789",
2055 Child
, Label2("Total Cyl"),
2056 Child
, resizemovegadgets
.totalcyl
=StringObject
,
2058 MUIA_String_Integer
, 0,
2059 MUIA_String_Accept
, "0123456789",
2062 MUIA_HorizWeight
, 10,
2064 Child
, Label2("Size"),
2065 Child
, resizemovegadgets
.size
=StringObject
,
2067 MUIA_String_Accept
, "0123456789GM.",
2068 MUIA_HorizWeight
, 3,
2073 MUIA_Group_SameWidth
, TRUE
,
2075 Child
, resizemovegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
2076 Child
, resizemovegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
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
,
2088 MUIA_Group_SameWidth
, TRUE
,
2090 Child
, renamegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
2091 Child
, renamegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
2095 SubWindow
, dosenvecgadgets
.win
= WindowObject
,
2096 MUIA_Window_Title
, MSG(WORD_DosEnvec
),
2097 MUIA_Window_Activate
, TRUE
,
2098 WindowContents
, VGroup
,
2102 Child
, Label2("Mask"),
2103 Child
, dosenvecgadgets
.mask
=StringObject
,
2105 MUIA_String_Integer
, -2,
2106 MUIA_String_Accept
, "0123456789",
2110 Child
, Label2("MaxTransfer"),
2111 Child
, dosenvecgadgets
.maxtransfer
=StringObject
,
2113 MUIA_String_Contents
, "0x7FFFFF",
2114 MUIA_String_Accept
, "0123456789x",
2121 Child
, Label("_Custom Bootcode"),
2123 Child
, dosenvecgadgets
.custboot
=MUI_MakeObject
2126 (IPTR
)"_Custom Bootcode"
2130 Child
, Label2("Nr. of Custom Bootblocks"),
2131 Child
, dosenvecgadgets
.numcustboot
=StringObject
,
2133 MUIA_String_Integer
, 0,
2134 MUIA_String_Accept
, "0123456789",
2140 MUIA_FrameTitle
, "Reserved Blocks at",
2142 Child
, Label2("Beginning"),
2143 Child
, dosenvecgadgets
.reservedblocksstart
=StringObject
,
2145 MUIA_String_Integer
, 0,
2146 MUIA_String_Accept
, "0123456789",
2150 Child
, Label2("End"),
2151 Child
, dosenvecgadgets
.reservedblocksend
=StringObject
,
2153 MUIA_String_Integer
, 0,
2154 MUIA_String_Accept
, "0123456789",
2161 Child
, Label("BlockSize"),
2162 Child
, dosenvecgadgets
.blocksize
=CycleObject
,
2164 MUIA_Cycle_Entries
, blocksizecycleentries
,
2168 Child
, Label2("Buffers"),
2169 Child
, dosenvecgadgets
.buffers
=StringObject
,
2171 MUIA_String_Integer
, 20,
2172 MUIA_String_Accept
, "0123456789",
2177 MUIA_Group_SameWidth
, TRUE
,
2179 Child
, dosenvecgadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
2180 Child
, dosenvecgadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
2184 SubWindow
, mountbootgadgets
.win
= WindowObject
,
2185 MUIA_Window_Title
, MSG(WORD_Switches
),
2186 MUIA_Window_Activate
, TRUE
,
2187 WindowContents
, VGroup
,
2189 Child
, Label(MSG(WORD_Active
)),
2191 Child
, mountbootgadgets
.active
=MUI_MakeObject
2198 Child
, Label(MSG(WORD_Automount
)),
2200 Child
, mountbootgadgets
.automount
=MUI_MakeObject
2207 Child
, Label(MSG(WORD_Bootable
)),
2209 Child
, mountbootgadgets
.bootable
=MUI_MakeObject
2216 Child
, Label(MSG(WORD_BootPri
)),
2217 Child
, mountbootgadgets
.bootpri
=StringObject
,
2219 MUIA_String_Integer
, 0,
2220 MUIA_String_Accept
, "-0123456789",
2224 MUIA_Group_SameWidth
, TRUE
,
2226 Child
, mountbootgadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
2227 Child
, mountbootgadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
2239 mainwin
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)app
, 2,
2240 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
2244 gadgets
.buttons
[GB_EXIT
], MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)app
, 2,
2245 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
2250 MUIM_Notify
, MUIA_Listview_DoubleClick
, TRUE
, (IPTR
)gadgets
.leftlv
, 2,
2251 MUIM_CallHook
, (IPTR
)&hook_lv_doubleclick
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
++)
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
]);
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 */
2289 adddevicegadgets
.win
,
2290 MUIM_Notify
, MUIA_Window_Open
, TRUE
, (IPTR
)mainwin
, 3,
2291 MUIM_Set
, MUIA_Window_Sleep
, TRUE
2295 adddevicegadgets
.win
,
2296 MUIM_Notify
, MUIA_Window_Open
, FALSE
, (IPTR
)mainwin
, 3,
2297 MUIM_Set
, MUIA_Window_Sleep
, FALSE
2301 adddevicegadgets
.win
,
2302 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)adddevicegadgets
.win
, 3,
2303 MUIM_Set
, MUIA_Window_Open
, FALSE
2307 adddevicegadgets
.ok
,
2308 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)adddevicegadgets
.ok
, 2,
2309 MUIM_CallHook
, (IPTR
)&hook_buttons
2313 adddevicegadgets
.ok
,
2314 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)adddevicegadgets
.win
, 3,
2315 MUIM_Set
, MUIA_Window_Open
, FALSE
2319 adddevicegadgets
.cancel
,
2320 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)adddevicegadgets
.win
, 3,
2321 MUIM_Set
, MUIA_Window_Open
, FALSE
2323 /* add partition window */
2326 addpartitiongadgets
.win
,
2327 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)addpartitiongadgets
.win
, 3,
2328 MUIM_Set
, MUIA_Window_Open
, FALSE
2332 addpartitiongadgets
.ok
,
2333 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)addpartitiongadgets
.ok
, 2,
2334 MUIM_CallHook
, (IPTR
)&hook_buttons
2338 addpartitiongadgets
.ok
,
2339 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)addpartitiongadgets
.win
, 3,
2340 MUIM_Set
, MUIA_Window_Open
, FALSE
2344 addpartitiongadgets
.cancel
,
2345 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)addpartitiongadgets
.win
, 3,
2346 MUIM_Set
, MUIA_Window_Open
, FALSE
2350 addpartitiongadgets
.pt
,
2351 MUIM_Notify
, PTCT_Selected
, TRUE
, (IPTR
)addpartitiongadgets
.pt
, 2,
2352 MUIM_CallHook
, (IPTR
)&hook_buttons
2354 /* partition type window */
2357 partitiontypegadgets
.win
,
2358 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)partitiontypegadgets
.win
, 3,
2359 MUIM_Set
, MUIA_Window_Open
, FALSE
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" */
2371 partitiontypegadgets
.ok
,
2372 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontypegadgets
.ok
, 2,
2373 MUIM_CallHook
, (IPTR
)&hook_buttons
2377 partitiontypegadgets
.ok
,
2378 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontypegadgets
.win
, 3,
2379 MUIM_Set
, MUIA_Window_Open
, FALSE
2383 partitiontypegadgets
.cancel
,
2384 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontypegadgets
.win
, 3,
2385 MUIM_Set
, MUIA_Window_Open
, FALSE
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 */
2396 partitiontabletypegadgets
.win
,
2397 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)partitiontabletypegadgets
.win
, 3,
2398 MUIM_Set
, MUIA_Window_Open
, FALSE
2402 partitiontabletypegadgets
.ok
,
2403 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontabletypegadgets
.ok
, 2,
2404 MUIM_CallHook
, (IPTR
)&hook_buttons
2408 partitiontabletypegadgets
.ok
,
2409 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontabletypegadgets
.win
, 3,
2410 MUIM_Set
, MUIA_Window_Open
, FALSE
2414 partitiontabletypegadgets
.cancel
,
2415 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontabletypegadgets
.win
, 3,
2416 MUIM_Set
, MUIA_Window_Open
, FALSE
2418 /* resize/move window */
2421 resizemovegadgets
.win
,
2422 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)resizemovegadgets
.win
, 3,
2423 MUIM_Set
, MUIA_Window_Open
, FALSE
2427 resizemovegadgets
.ok
,
2428 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.ok
, 2,
2429 MUIM_CallHook
, (IPTR
)&hook_buttons
2433 resizemovegadgets
.ok
,
2434 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.win
, 3,
2435 MUIM_Set
, MUIA_Window_Open
, FALSE
2439 resizemovegadgets
.size
,
2440 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
2441 (IPTR
)resizemovegadgets
.size
, 2,
2442 MUIM_CallHook
, (IPTR
)&hook_buttons
2446 resizemovegadgets
.cancel
,
2447 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.cancel
, 2,
2448 MUIM_CallHook
, (IPTR
)&hook_buttons
2452 resizemovegadgets
.cancel
,
2453 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.win
, 3,
2454 MUIM_Set
, MUIA_Window_Open
, FALSE
2458 resizemovegadgets
.pt
,
2459 MUIM_Notify
, PTCT_Selected
, TRUE
, (IPTR
)resizemovegadgets
.pt
, 3,
2460 MUIM_CallHook
, (IPTR
)&hook_buttons
, PTCT_Selected
2464 resizemovegadgets
.pt
,
2465 MUIM_Notify
, PTCT_PartitionMove
, TRUE
, (IPTR
)resizemovegadgets
.pt
, 3,
2466 MUIM_CallHook
, (IPTR
)&hook_buttons
, PTCT_PartitionMove
2470 resizemovegadgets
.highcyl
,
2471 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
, (IPTR
)resizemovegadgets
.highcyl
, 2,
2472 MUIM_CallHook
, (IPTR
)&hook_buttons
2476 resizemovegadgets
.lowcyl
,
2477 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
, (IPTR
)resizemovegadgets
.lowcyl
, 2,
2478 MUIM_CallHook
, (IPTR
)&hook_buttons
2482 resizemovegadgets
.totalcyl
,
2483 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
, (IPTR
)resizemovegadgets
.totalcyl
, 2,
2484 MUIM_CallHook
, (IPTR
)&hook_buttons
2490 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)renamegadgets
.win
, 3,
2491 MUIM_Set
, MUIA_Window_Open
, FALSE
2496 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)renamegadgets
.ok
, 2,
2497 MUIM_CallHook
, (IPTR
)&hook_buttons
2502 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)renamegadgets
.win
, 3,
2503 MUIM_Set
, MUIA_Window_Open
, FALSE
2507 renamegadgets
.cancel
,
2508 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)renamegadgets
.win
, 3,
2509 MUIM_Set
, MUIA_Window_Open
, FALSE
2511 /* dosenvec window */
2514 dosenvecgadgets
.win
,
2515 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)dosenvecgadgets
.win
, 3,
2516 MUIM_Set
, MUIA_Window_Open
, FALSE
2521 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)dosenvecgadgets
.ok
, 2,
2522 MUIM_CallHook
, (IPTR
)&hook_buttons
2527 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)dosenvecgadgets
.win
, 3,
2528 MUIM_Set
, MUIA_Window_Open
, FALSE
2532 dosenvecgadgets
.cancel
,
2533 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)dosenvecgadgets
.win
, 3,
2534 MUIM_Set
, MUIA_Window_Open
, FALSE
2536 /* automount/boot window */
2539 mountbootgadgets
.win
,
2540 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)mountbootgadgets
.win
, 3,
2541 MUIM_Set
, MUIA_Window_Open
, FALSE
2545 mountbootgadgets
.ok
,
2546 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)mountbootgadgets
.ok
, 2,
2547 MUIM_CallHook
, (IPTR
)&hook_buttons
2551 mountbootgadgets
.ok
,
2552 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)mountbootgadgets
.win
, 3,
2553 MUIM_Set
, MUIA_Window_Open
, FALSE
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
);
2567 D(bug("[HDToolBox] deinitGUI()\n"));
2570 MUI_DisposeObject(app
);
2571 if (ptclass
!= NULL
)
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"));