2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
6 /* "TODO: fs support" */
8 #include <proto/alib.h>
10 #include <proto/exec.h>
11 #include <proto/icon.h>
12 #include <proto/intuition.h>
13 #include <proto/muimaster.h>
15 #include <exec/memory.h>
16 #include <intuition/gadgetclass.h>
17 #include <intuition/icclass.h>
18 #include <intuition/intuition.h>
19 #include <intuition/sghooks.h>
20 #include <libraries/asl.h>
21 #include <libraries/locale.h>
22 #include <libraries/mui.h>
23 #include <resources/filesysres.h>
24 #include <workbench/workbench.h>
25 #ifdef HAVE_COOLIMAGES
26 #include <libraries/coolimages.h>
39 #include "harddisks.h"
40 #include "hdtoolbox_support.h"
46 #undef CATCOMP_STRINGS
47 #undef CATCOMP_NUMBERS
48 #define CATCOMP_NUMBERS
51 #define SIMPLEBUTTON(text) SimpleButton(MSG(text))
53 #ifdef HAVE_COOLIMAGES
54 #define IMAGEBUTTON(text,imgid) CoolImageIDButton(MSG(text),imgid)
56 #define IMAGEBUTTON(text,imgid) SIMPLEBUTTON(text)
59 struct Library
*MUIMasterBase
= NULL
;
66 Object
*createml_item
;
67 struct GUIGadgets gadgets
;
69 struct Hook hook_display
;
70 struct Hook hook_buttons
;
71 struct Hook hook_createml
;
72 struct Hook hook_lv_doubleclick
;
73 struct Hook hook_lv_click
;
75 struct AddDeviceGadgets
{
85 struct AddPartitionGadgets
{
90 } addpartitiongadgets
;
92 struct PartitionTypeGadgets
{
94 struct TableTypeNode
*ttn
;
97 struct Hook hook_hexidedit
;
99 struct PartitionType type
;
100 struct ListNode
*iln
;
103 } partitiontypegadgets
;
105 struct PartitionTableTypeGadgets
{
108 struct ListNode
*iln
;
111 } partitiontabletypegadgets
;
113 struct ResizeMoveGadgets
{
124 struct RenameGadgets
{
127 struct ListNode
*iln
;
132 struct DosEnvecGadgets
{
138 Object
*reservedblocksstart
;
139 Object
*reservedblocksend
;
142 struct ListNode
*iln
;
147 struct MountBootGadgets
{
153 struct ListNode
*iln
;
158 char *editcycleentries
[] = {"0x", NULL
};
159 char *blocksizecycleentries
[] = {"512","1024","2048","4096", NULL
};
161 void setChanged(struct ListNode
*iln
)
163 struct ListNode
*parent
= iln
;
165 D(bug("[HDToolBox] setChanged()\n"));
169 parent
->change_count
++;
170 parent
= parent
->parent
;
172 DoMethod(gadgets
.leftlv
, MUIM_List_Redraw
, MUIV_List_Redraw_All
);
173 set(gadgets
.leftlv
, MUIA_Listview_SelectChange
, TRUE
);
176 void unsetChanged(struct ListNode
*iln
)
178 struct ListNode
*sub
= iln
;
179 struct ListNode
*parent
;
181 D(bug("[HDToolBox] unsetChanged()\n"));
183 /* remove changed from all first generation child partitions */
184 sub
= (struct ListNode
*)iln
->list
.lh_Head
;
185 while (sub
->ln
.ln_Succ
)
187 if (sub
->change_count
)
189 parent
= sub
->parent
;
192 parent
->change_count
-= sub
->change_count
;
193 parent
= parent
->parent
;
195 sub
->change_count
= 0;
197 sub
= (struct ListNode
*)sub
->ln
.ln_Succ
;
199 if (iln
->flags
& LNF_ToSave
)
201 iln
->flags
&= ~LNF_ToSave
;
202 /* we saved it so there can't be a change_count */
203 if (iln
->change_count
)
205 parent
= iln
->parent
;
208 parent
->change_count
-= iln
->change_count
;
209 parent
= parent
->parent
;
211 iln
->change_count
= 0;
214 DoMethod(gadgets
.leftlv
, MUIM_List_Redraw
, MUIV_List_Redraw_Active
);
217 AROS_UFH3(void, hexidedit_function
,
218 AROS_UFHA(struct Hook
*, h
, A0
),
219 AROS_UFHA(struct SGWork
*, sgwork
, A2
),
220 AROS_UFHA(ULONG
*, msg
, A1
))
224 D(bug("[HDToolBox] hexidedit_function()\n"));
228 D(bug("[HDToolBox] hexidedit_function: KEY PRESS\n"));
234 AROS_UFH3(void, display_function
,
235 AROS_UFHA(struct Hook
*, h
, A0
),
236 AROS_UFHA(const char **, strings
, A2
),
237 AROS_UFHA(struct ListNode
*, entry
, A1
))
244 D(bug("[HDToolBox] display_function()\n"));
249 if (entry
->change_count
)
251 if (entry
->flags
& LNF_ToSave
)
255 if ((entry
->flags
& LNF_Listable
) || (entry
->ln
.ln_Type
== LNT_Parent
))
257 sprintf(bu2
,"\0333%s",entry
->ln
.ln_Name
);
261 strings
[1] = entry
->ln
.ln_Name
;
265 strings
[0] = MSG(WORD_Changed
);
266 strings
[1] = MSG(WORD_Name
);
272 void setTypeString(struct PartitionType
*type
, Object
*strgad
)
278 D(bug("[HDToolBox] setTypeString()\n"));
280 while (len
!=type
->id_len
)
282 sprintf(cur
, "%02x ", type
->id
[len
]);
287 set(strgad
, MUIA_String_Contents
, str
);
290 LONG
askSave(STRPTR name
)
292 struct EasyStruct es
=
294 sizeof(struct EasyStruct
), 0,
301 D(bug("[HDToolBox] askSave('%s')\n", name
));
303 sprintf(yesno
, "%s|%s|%s", MSG_STD(YESSTR
), MSG(WORD_All
), MSG_STD(NOSTR
));
304 es
.es_GadgetFormat
= yesno
;
305 return EasyRequestArgs(0, &es
, 0, &name
);
309 LONG
saveChanges(struct ListNode
*iln
, LONG asksave
)
311 struct ListNode
*sub
;
313 D(bug("[HDToolBox] saveChanges()\n"));
315 if (iln
->change_count
)
317 sub
= (struct ListNode
*)iln
->list
.lh_Head
;
318 while (sub
->ln
.ln_Succ
)
320 asksave
= saveChanges(sub
, asksave
);
321 sub
= (struct ListNode
*)sub
->ln
.ln_Succ
;
323 if (iln
->flags
& LNF_ToSave
)
325 struct HDTBPartition
*partition
;
326 partition
= (struct HDTBPartition
*)iln
;
327 if (partition
->table
)
331 result
= askSave(iln
->ln
.ln_Name
);
336 if (WritePartitionTable(partition
->ph
) == 0)
339 set(gadgets
.text
, MUIA_Text_Contents
, MSG(MSG_WriteTableError
));
347 AROS_UFH3(void, buttons_function
,
348 AROS_UFHA(struct Hook
*, h
, A0
),
349 AROS_UFHA(Object
*, object
, A2
),
350 AROS_UFHA(ULONG
*, arg
, A1
))
354 LONG active
= MUIV_List_Active_Off
;
355 struct ListNode
*iln
;
358 D(bug("[HDToolBox] buttons_function()\n"));
360 for (i
=GB_FIRST
;i
<=GB_LAST
;i
++)
361 if (object
== gadgets
.buttons
[i
])
366 if (object
== gadgets
.leftlv
)
369 else if (object
== adddevicegadgets
.ok
)
372 struct HDTBDevice
*dn
;
374 get(adddevicegadgets
.file
, MUIA_String_Contents
, &str
);
376 dn
= addDeviceName(str
);
379 /* FIXME: Should we fail here? */
382 else if (object
== addpartitiongadgets
.ok
)
384 struct DosEnvec
*de
= NULL
;
386 get(addpartitiongadgets
.pt
, PTCT_ActivePartition
, &de
);
389 struct HDTBPartition
*table
;
390 struct HDTBPartition
*partition
;
392 get(addpartitiongadgets
.pt
, PTCT_PartitionTable
, &iln
);
393 table
= (struct HDTBPartition
*)iln
;
394 partition
= addPartition(table
, de
);
397 setChanged(&partition
->listnode
);
398 partition
->listnode
.parent
->flags
|= LNF_ToSave
;
399 InsertList(gadgets
.leftlv
, &partition
->listnode
);
402 set(gadgets
.text
, MUIA_Text_Contents
, MSG(MSG_NO_MEMORY
));
405 else if (object
== addpartitiongadgets
.pt
);
406 else if (object
== partitiontypegadgets
.hexid
)
410 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
411 get(object
, MUIA_String_Contents
, &str
);
412 partitiontypegadgets
.type
.id_len
=strcpyESC(partitiontypegadgets
.type
.id
, str
);
414 else if (object
== partitiontypegadgets
.lv
)
416 get(partitiontypegadgets
.lv
, MUIA_List_Active
, &active
);
417 if (active
!= MUIV_List_Active_Off
)
421 DoMethod(partitiontypegadgets
.lv
, MUIM_List_GetEntry
, active
, (IPTR
)&name
);
422 tn
= (struct TypeNode
*)FindName(partitiontypegadgets
.ttn
->typelist
, name
);
423 setTypeString(&tn
->type
, partitiontypegadgets
.hexid
);
424 CopyMem(&tn
->type
, &partitiontypegadgets
.type
, sizeof(struct PartitionType
));
427 else if (object
== partitiontypegadgets
.ok
)
429 struct HDTBPartition
*partition
;
430 partition
= (struct HDTBPartition
*)partitiontypegadgets
.iln
;
431 CopyMem(&partitiontypegadgets
.type
, &partition
->type
, sizeof(struct PartitionType
));
432 SetPartitionAttrsA(partition
->ph
, PT_TYPE
, &partition
->type
, TAG_DONE
);
433 GetPartitionAttrsA(partition
->ph
, PT_DOSENVEC
, &partition
->de
, TAG_DONE
);
434 partitiontypegadgets
.iln
->parent
->flags
|= LNF_ToSave
;
435 setChanged(partitiontypegadgets
.iln
);
437 else if (object
== partitiontabletypegadgets
.ok
)
439 get(partitiontabletypegadgets
.lv
, MUIA_List_Active
, &active
);
440 if (active
!= MUIV_List_Active_Off
)
442 struct TableTypeNode
*ttn
;
443 struct HDTBPartition
*table
;
445 DoMethod(partitiontabletypegadgets
.lv
, MUIM_List_GetEntry
, active
, (IPTR
)&name
);
446 ttn
= findTableTypeNodeName(name
);
447 table
= (struct HDTBPartition
*)partitiontabletypegadgets
.iln
;
449 (table
->table
== NULL
) ||
450 (ttn
->pti
->pti_Type
!= table
->table
->type
)
453 if (makePartitionTable(table
, ttn
->pti
->pti_Type
))
455 table
->listnode
.flags
|= LNF_Listable
;
456 table
->listnode
.flags
|= LNF_ToSave
;
457 setChanged(partitiontabletypegadgets
.iln
);
460 set(gadgets
.text
, MUIA_Text_Contents
, MSG(MSG_CreateTableError
));
464 else if (object
== resizemovegadgets
.ok
)
466 struct HDTBPartition
*table
= NULL
;
467 struct HDTBPartition
*partition
;
469 get(resizemovegadgets
.pt
, PTCT_PartitionTable
, &table
);
470 partition
= (struct HDTBPartition
*)table
->listnode
.list
.lh_Head
;
471 table
->listnode
.flags
|= LNF_ToSave
;
472 while (partition
->listnode
.ln
.ln_Succ
)
474 if (partition
->listnode
.flags
& LNF_IntermedChange
)
476 partition
->listnode
.flags
&= ~LNF_IntermedChange
;
477 setChanged(&partition
->listnode
);
478 SetPartitionAttrsA(partition
->ph
, PT_DOSENVEC
, &partition
->de
, TAG_DONE
);
480 partition
= (struct HDTBPartition
*)partition
->listnode
.ln
.ln_Succ
;
483 else if (object
== resizemovegadgets
.cancel
)
485 struct HDTBPartition
*table
= NULL
;
486 struct HDTBPartition
*partition
;
488 get(resizemovegadgets
.pt
, PTCT_PartitionTable
, &table
);
489 partition
= (struct HDTBPartition
*)table
->listnode
.list
.lh_Head
;
490 while (partition
->listnode
.ln
.ln_Succ
)
492 if (partition
->listnode
.flags
& LNF_IntermedChange
)
494 partition
->listnode
.flags
&= ~LNF_IntermedChange
;
495 GetPartitionAttrsA(partition
->ph
, PT_DOSENVEC
, &partition
->de
, TAG_DONE
);
497 partition
= (struct HDTBPartition
*)partition
->listnode
.ln
.ln_Succ
;
500 else if (object
== resizemovegadgets
.pt
)
503 struct DosEnvec
*de
= NULL
;
506 D(bug("[HDToolBox] buttons_function() - Resize/Move Partition Display:\n"));
507 get(resizemovegadgets
.pt
, PTCT_ActiveType
, &type
);
508 if (type
== PTS_EMPTY_AREA
)
510 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &de
);
514 struct HDTBPartition
*partition
= NULL
;
516 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &partition
);
518 if (*arg
== PTCT_PartitionMove
)
520 partition
->listnode
.flags
|= LNF_IntermedChange
;
523 nnset(resizemovegadgets
.lowcyl
, MUIA_String_Integer
, de
->de_LowCyl
);
524 nnset(resizemovegadgets
.highcyl
, MUIA_String_Integer
, de
->de_HighCyl
);
525 nnset(resizemovegadgets
.totalcyl
, MUIA_String_Integer
, de
->de_HighCyl
-de
->de_LowCyl
+1);
526 getSizeStr(str
, (((de
->de_HighCyl
- de
->de_LowCyl
+ 1) * de
->de_Surfaces
* de
->de_BlocksPerTrack
)-1)/2);
527 nnset(resizemovegadgets
.size
, MUIA_String_Contents
, str
);
528 D(bug("[HDToolBox] buttons_function() - Resize/Move Partition Display successful\n"));
530 else if (object
== resizemovegadgets
.lowcyl
)
535 D(bug("[HDToolBox] buttons_function() - Resize/Move Lowcyl:\n"));
536 get(object
, MUIA_String_Integer
, &value
);
537 get(resizemovegadgets
.pt
, PTCT_ActiveType
, &type
);
538 if (type
== PTS_PARTITION
)
540 struct HDTBPartition
*table
= NULL
;
541 struct HDTBPartition
*partition
= NULL
;
544 get(resizemovegadgets
.pt
, PTCT_PartitionTable
, &table
);
545 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &partition
);
546 D(bug("[HDToolBox] - Type : Partition\n"));
547 D(bug("[HDToolBox] - Old value : %ld\n", partition
->de
.de_LowCyl
));
548 D(bug("[HDToolBox] - New value : %ld\n", value
));
549 D(bug("[HDToolBox] - Partition table : %p\n", table
));
550 D(bug("[HDToolBox] - Active partition : %p\n", partition
));
551 if (value
!= partition
->de
.de_LowCyl
)
554 value
*partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
;
555 if (validValue(table
, partition
, block
))
558 partition
->listnode
.flags
|= LNF_IntermedChange
;
559 partition
->de
.de_LowCyl
= value
;
560 set(resizemovegadgets
.totalcyl
, MUIA_String_Integer
, partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1);
561 set(resizemovegadgets
.pt
, PTCT_PartitionTable
, table
);
567 (partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1)*
568 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
572 set(resizemovegadgets
.size
, MUIA_String_Contents
, str
);
575 set(object
, MUIA_String_Integer
, partition
->de
.de_LowCyl
);
578 else if (type
== PTS_EMPTY_AREA
)
580 struct DosEnvec
*de
= NULL
;
582 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &de
);
583 if (value
!= de
->de_LowCyl
)
584 set(object
, MUIA_String_Integer
, de
->de_LowCyl
);
587 set(object
, MUIA_String_Integer
, 0);
589 else if (object
== resizemovegadgets
.highcyl
)
594 D(bug("[HDToolBox] buttons_function() - Resize/Move Highcyl:\n"));
595 get(object
, MUIA_String_Integer
, &value
);
596 get(resizemovegadgets
.pt
, PTCT_ActiveType
, &type
);
597 if (type
== PTS_PARTITION
)
599 struct HDTBPartition
*table
= NULL
;
600 struct HDTBPartition
*partition
= NULL
;
603 get(resizemovegadgets
.pt
, PTCT_PartitionTable
, &table
);
604 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &partition
);
605 D(bug("[HDToolBox] - Type : Partition\n"));
606 D(bug("[HDToolBox] - Old value : %ld\n", partition
->de
.de_HighCyl
));
607 D(bug("[HDToolBox] - New value : %ld\n", value
));
608 D(bug("[HDToolBox] - Partition table : %p\n", table
));
609 D(bug("[HDToolBox] - Active partition : %p\n", partition
));
610 if (value
!= partition
->de
.de_HighCyl
)
615 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
617 if (validValue(table
, partition
, block
))
620 partition
->listnode
.flags
|= LNF_IntermedChange
;
621 partition
->de
.de_HighCyl
= value
;
622 nnset(resizemovegadgets
.totalcyl
, MUIA_String_Integer
, partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1);
623 nnset(resizemovegadgets
.pt
, PTCT_PartitionTable
, table
);
629 (partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1)*
630 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
634 nnset(resizemovegadgets
.size
, MUIA_String_Contents
, str
);
637 nnset(object
, MUIA_String_Integer
, partition
->de
.de_HighCyl
);
640 else if (type
== PTS_EMPTY_AREA
)
642 struct DosEnvec
*de
= NULL
;
644 D(bug("[HDToolBox] - Type : Empty Area\n"));
645 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &de
);
646 if (value
!= de
->de_HighCyl
)
647 set(object
, MUIA_String_Integer
, de
->de_HighCyl
);
650 nnset(object
, MUIA_String_Integer
, 0);
652 else if (object
== resizemovegadgets
.totalcyl
)
657 get(object
, MUIA_String_Integer
, &value
);
658 get(resizemovegadgets
.pt
, PTCT_ActiveType
, &type
);
659 if (type
== PTS_PARTITION
)
661 struct HDTBPartition
*table
= NULL
;
662 struct HDTBPartition
*partition
= NULL
;
665 get(resizemovegadgets
.pt
, PTCT_PartitionTable
, &table
);
666 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &partition
);
667 if (value
!= (partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1))
671 (partition
->de
.de_LowCyl
+value
)*
672 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
674 if (validValue(table
, partition
, block
))
677 partition
->listnode
.flags
|= LNF_IntermedChange
;
678 partition
->de
.de_HighCyl
= partition
->de
.de_LowCyl
+value
-1;
679 set(resizemovegadgets
.highcyl
, MUIA_String_Integer
, partition
->de
.de_HighCyl
);
680 set(resizemovegadgets
.pt
, PTCT_PartitionTable
, table
);
686 (partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1)*
687 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
691 set(resizemovegadgets
.size
, MUIA_String_Contents
, str
);
694 set(object
, MUIA_String_Integer
, partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1);
697 else if (type
== PTS_EMPTY_AREA
)
699 struct DosEnvec
*de
= NULL
;
701 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &de
);
702 if (value
!= (de
->de_HighCyl
-de
->de_LowCyl
+1))
703 set(object
, MUIA_String_Integer
, de
->de_HighCyl
-de
->de_LowCyl
+1);
706 set(object
, MUIA_String_Integer
, 0);
708 else if (object
== resizemovegadgets
.size
)
711 struct DosEnvec
*de
= NULL
;
716 get(resizemovegadgets
.pt
, PTCT_ActiveType
, &type
);
717 if (type
== PTS_PARTITION
)
719 struct HDTBPartition
*partition
= NULL
;
721 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &partition
);
723 get(object
, MUIA_String_Contents
, &str
);
724 size
= sizeStrToUL((STRPTR
)str
);
725 size
= (size
*2+1)/partition
->de
.de_BlocksPerTrack
/partition
->de
.de_Surfaces
+1;
727 else if (type
== PTS_EMPTY_AREA
)
729 get(resizemovegadgets
.pt
, PTCT_ActivePartition
, &de
);
731 set(resizemovegadgets
.totalcyl
, MUIA_String_Integer
, size
);
732 set(resizemovegadgets
.totalcyl
, MUIA_String_Acknowledge
, TRUE
);
738 (de
->de_HighCyl
-de
->de_LowCyl
+1)*
739 de
->de_Surfaces
*de
->de_BlocksPerTrack
743 set(resizemovegadgets
.size
, MUIA_String_Contents
, val
);
745 else if (object
== renamegadgets
.ok
)
747 struct HDTBPartition
*partition
;
750 partition
= (struct HDTBPartition
*)renamegadgets
.iln
;
751 get(renamegadgets
.name
, MUIA_String_Contents
, &name
);
752 if (strcmp(name
, partition
->listnode
.ln
.ln_Name
) != 0)
754 SetPartitionAttrsA(partition
->ph
, PT_NAME
, name
, TAG_DONE
);
755 strcpy(partition
->listnode
.ln
.ln_Name
, name
);
756 renamegadgets
.iln
->parent
->flags
|= LNF_ToSave
;
757 setChanged(renamegadgets
.iln
);
760 else if (object
== dosenvecgadgets
.ok
)
762 BOOL changed
= FALSE
;
767 struct HDTBPartition
*partition
;
769 partition
= (struct HDTBPartition
*)dosenvecgadgets
.iln
;
770 get(dosenvecgadgets
.mask
, MUIA_String_Integer
, &value
);
771 if (value
!= partition
->de
.de_Mask
)
773 partition
->de
.de_Mask
= value
;
776 get(dosenvecgadgets
.maxtransfer
, MUIA_String_Contents
, &str
);
777 value
= strtoul(str
, &end
, 0);
780 if (value
!= partition
->de
.de_MaxTransfer
)
782 partition
->de
.de_MaxTransfer
= value
;
786 get(dosenvecgadgets
.custboot
, MUIA_Selected
, &check
);
789 if (partition
->de
.de_TableSize
<(DE_BOOTBLOCKS
+1))
791 partition
->de
.de_TableSize
= DE_BOOTBLOCKS
+1;
794 get(dosenvecgadgets
.numcustboot
, MUIA_String_Integer
, &value
);
795 if (value
!= partition
->de
.de_BootBlocks
)
797 partition
->de
.de_BootBlocks
= value
;
803 if (partition
->de
.de_TableSize
>=(DE_BOOTBLOCKS
+1))
805 partition
->de
.de_TableSize
= DE_BOOTBLOCKS
;
806 partition
->de
.de_BootBlocks
= 0;
810 get(dosenvecgadgets
.reservedblocksstart
, MUIA_String_Integer
, &value
);
811 if (value
!= partition
->de
.de_Reserved
)
813 partition
->de
.de_Reserved
= value
;
816 get(dosenvecgadgets
.reservedblocksend
, MUIA_String_Integer
, &value
);
817 if (value
!= partition
->de
.de_PreAlloc
)
819 partition
->de
.de_PreAlloc
= value
;
822 get(dosenvecgadgets
.blocksize
, MUIA_Cycle_Active
, &value
);
823 value
= 1<<(value
+7);
824 if (value
!= partition
->de
.de_SizeBlock
)
826 partition
->de
.de_SizeBlock
= value
;
829 get(dosenvecgadgets
.buffers
, MUIA_String_Integer
, &value
);
830 if (value
!= partition
->de
.de_NumBuffers
)
832 partition
->de
.de_NumBuffers
= value
;
837 SetPartitionAttrsA(partition
->ph
, PT_DOSENVEC
, &partition
->de
, TAG_DONE
);
838 dosenvecgadgets
.iln
->parent
->flags
|= LNF_ToSave
;
839 setChanged(dosenvecgadgets
.iln
);
842 else if (object
== mountbootgadgets
.ok
)
844 struct HDTBPartition
*partition
;
845 BOOL changeda
= FALSE
;
846 BOOL changed
= FALSE
;
850 partition
= (struct HDTBPartition
*)mountbootgadgets
.iln
;
851 get(mountbootgadgets
.active
, MUIA_Selected
, &check
);
854 if (!(partition
->flags
& PNF_ACTIVE
))
856 partition
->flags
|= PNF_ACTIVE
;
862 if (partition
->flags
& PNF_ACTIVE
)
864 partition
->flags
&= ~PNF_ACTIVE
;
870 if (partition
->flags
& PNF_ACTIVE
)
872 struct HDTBPartition
*other
;
873 other
= (struct HDTBPartition
*)partition
->listnode
.ln
.ln_Pred
;
874 while (other
->listnode
.ln
.ln_Pred
)
876 if (other
->listnode
.ln
.ln_Type
== LNT_Partition
)
878 if (other
->flags
& PNF_ACTIVE
)
880 other
->flags
&= ~PNF_ACTIVE
;
881 SetPartitionAttrsA(other
->ph
, PT_ACTIVE
, FALSE
, TAG_DONE
);
882 setChanged(&other
->listnode
);
885 other
= (struct HDTBPartition
*)other
->listnode
.ln
.ln_Pred
;
887 other
= (struct HDTBPartition
*)partition
->listnode
.ln
.ln_Succ
;
888 while (other
->listnode
.ln
.ln_Succ
)
890 if (other
->listnode
.ln
.ln_Type
== LNT_Partition
)
892 if (other
->flags
& PNF_ACTIVE
)
894 other
->flags
&= ~PNF_ACTIVE
;
895 SetPartitionAttrsA(other
->ph
, PT_ACTIVE
, FALSE
, TAG_DONE
);
896 setChanged(&other
->listnode
);
899 other
= (struct HDTBPartition
*)other
->listnode
.ln
.ln_Succ
;
902 SetPartitionAttrsA(partition
->ph
, PT_ACTIVE
, check
, TAG_DONE
);
906 get(mountbootgadgets
.automount
, MUIA_Selected
, &check
);
909 if (!(partition
->flags
& PNF_AUTOMOUNT
))
911 partition
->flags
|= PNF_AUTOMOUNT
;
917 if (partition
->flags
& PNF_AUTOMOUNT
)
919 partition
->flags
&= ~PNF_AUTOMOUNT
;
925 SetPartitionAttrsA(partition
->ph
, PT_AUTOMOUNT
, check
, TAG_DONE
);
929 get(mountbootgadgets
.bootable
, MUIA_Selected
, &check
);
932 if (!(partition
->flags
& PNF_BOOTABLE
))
934 partition
->flags
|= PNF_BOOTABLE
;
937 get(mountbootgadgets
.bootpri
, MUIA_String_Integer
, &value
);
938 if (value
!= partition
->de
.de_BootPri
)
940 partition
->de
.de_BootPri
= value
;
946 if (partition
->flags
& PNF_BOOTABLE
)
948 partition
->flags
&= ~PNF_BOOTABLE
;
949 partition
->de
.de_BootPri
= 0;
955 SetPartitionAttrsA(partition
->ph
, PT_BOOTABLE
, check
, PT_DOSENVEC
, &partition
->de
, TAG_DONE
);
960 mountbootgadgets
.iln
->parent
->flags
|= LNF_ToSave
;
961 setChanged(mountbootgadgets
.iln
);
970 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, 0, (IPTR
)&iln
);
973 ((iln
) && (iln
->parent
->parent
== NULL
))
976 set(adddevicegadgets
.win
, MUIA_Window_Open
, TRUE
);
978 else if ((iln
->parent
->ln
.ln_Type
== LNT_Harddisk
) || (iln
->parent
->ln
.ln_Type
== LNT_Partition
))
980 struct HDTBPartition
*table
;
981 table
= (struct HDTBPartition
*)iln
->parent
;
984 (table
->table
->max_partitions
) &&
985 (countNodes(&table
->listnode
.list
, LNT_Partition
)<table
->table
->max_partitions
)
987 (table
->table
->max_partitions
== 0)
992 addpartitiongadgets
.win
,
993 MUIM_Notify
, MUIA_Window_Open
, TRUE
, (IPTR
)addpartitiongadgets
.pt
, 3,
994 MUIM_Set
, PTCT_PartitionTable
, (IPTR
)table
996 set(addpartitiongadgets
.win
, MUIA_Window_Open
, TRUE
);
999 set(gadgets
.text
, MUIA_Text_Contents
, MSG(MSG_PARTITION_TABLE_FULL
));
1002 case GB_REMOVE_ENTRY
:
1003 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1004 if (active
!= MUIV_List_Active_Off
)
1006 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
1007 switch (iln
->ln
.ln_Type
)
1010 DoMethod(gadgets
.leftlv
, MUIM_List_Remove
, active
);
1012 freeDeviceNode((struct HDTBDevice
*)iln
);
1016 struct HDTBPartition
*partition
;
1017 partition
= (struct HDTBPartition
*)iln
;
1018 iln
->parent
->flags
|= LNF_ToSave
;
1020 DoMethod(gadgets
.leftlv
, MUIM_List_Remove
, active
);
1022 DeletePartition(partition
->ph
);
1023 freePartitionNode(partition
);
1028 case GB_CREATE_TABLE
:
1029 case GB_CHANGE_TYPE
:
1030 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1031 if (active
!= MUIV_List_Active_Off
)
1033 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
1035 (iln
->ln
.ln_Type
== LNT_Harddisk
) ||
1036 ((i
==2) && (iln
->ln
.ln_Type
== LNT_Partition
))
1039 struct HDTBPartition
*table
;
1041 partitiontabletypegadgets
.iln
= iln
;
1042 table
= (struct HDTBPartition
*)iln
;
1044 type
= table
->table
->type
;
1045 DoMethod(partitiontabletypegadgets
.lv
, MUIM_List_Clear
);
1046 for (i
=0;PartitionBase
->tables
[i
] != NULL
;i
++)
1050 partitiontabletypegadgets
.lv
,
1051 MUIM_List_InsertSingle
, (IPTR
)PartitionBase
->tables
[i
]->pti_Name
, MUIV_List_Insert_Bottom
1053 if (type
== PartitionBase
->tables
[i
]->pti_Type
)
1054 set(partitiontabletypegadgets
.lv
, MUIA_List_Active
, i
);
1056 set(partitiontabletypegadgets
.win
, MUIA_Window_Open
, TRUE
);
1058 else if ((i
==3) && (iln
->ln
.ln_Type
== LNT_Partition
))
1060 struct TypeNode
*tn
;
1061 struct HDTBPartition
*partition
;
1062 partitiontypegadgets
.iln
= iln
;
1064 DoMethod(partitiontypegadgets
.lv
, MUIM_List_Clear
);
1065 partition
= (struct HDTBPartition
*)iln
;
1066 partitiontypegadgets
.ttn
= findTableTypeNode(partition
->root
->table
->type
);
1067 if (partitiontypegadgets
.ttn
)
1069 tn
= (struct TypeNode
*)partitiontypegadgets
.ttn
->typelist
->lh_Head
;
1070 while (tn
->ln
.ln_Succ
)
1074 partitiontypegadgets
.lv
,
1075 MUIM_List_InsertSingle
, (IPTR
)tn
->ln
.ln_Name
, MUIV_List_Insert_Bottom
1077 if (tn
->type
.id_len
== partition
->type
.id_len
)
1078 if (memcmp(tn
->type
.id
, partition
->type
.id
, tn
->type
.id_len
) == 0)
1079 set(partitiontypegadgets
.lv
, MUIA_List_Active
, i
);
1080 tn
= (struct TypeNode
*)tn
->ln
.ln_Succ
;
1084 setTypeString(&partition
->type
, partitiontypegadgets
.hexid
);
1085 set(partitiontypegadgets
.win
, MUIA_Window_Open
, TRUE
);
1089 case GB_RESIZE_MOVE
:
1092 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, 0, (IPTR
)&iln
);
1093 if (iln
->ln
.ln_Type
== LNT_Parent
)
1095 set(gadgets
.leftlv
, MUIA_List_Active
, 0);
1096 set(gadgets
.leftlv
, MUIA_Listview_DoubleClick
, TRUE
);
1100 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1101 if (active
!= MUIV_List_Active_Off
)
1103 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
1104 if (iln
->ln
.ln_Type
== LNT_Partition
)
1106 struct HDTBPartition
*partition
;
1107 partition
= (struct HDTBPartition
*)iln
;
1108 if (getAttrInfo(partition
->root
->table
->pattrlist
, PTA_NAME
) & PLAM_READ
)
1110 renamegadgets
.iln
= iln
;
1111 set(renamegadgets
.name
, MUIA_String_Contents
, iln
->ln
.ln_Name
);
1112 set(renamegadgets
.win
, MUIA_Window_Open
, TRUE
);
1118 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1119 if (active
!= MUIV_List_Active_Off
)
1121 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
1122 if (iln
->ln
.ln_Type
== LNT_Partition
)
1124 struct HDTBPartition
*partition
;
1125 partition
= (struct HDTBPartition
*)iln
;
1126 if (getAttrInfo(partition
->root
->table
->pattrlist
, PTA_DOSENVEC
) & PLAM_READ
)
1129 dosenvecgadgets
.iln
= iln
;
1130 set(dosenvecgadgets
.mask
, MUIA_String_Integer
, partition
->de
.de_Mask
);
1131 sprintf(str
, "0x%08lx", partition
->de
.de_MaxTransfer
);
1132 set(dosenvecgadgets
.maxtransfer
, MUIA_String_Contents
, str
);
1133 if (partition
->de
.de_TableSize
>=(DE_BOOTBLOCKS
+1))
1135 set(dosenvecgadgets
.custboot
, MUIA_Selected
, TRUE
);
1136 set(dosenvecgadgets
.numcustboot
, MUIA_String_Integer
, partition
->de
.de_BootBlocks
);
1139 set(dosenvecgadgets
.custboot
, MUIA_Selected
, FALSE
);
1140 set(dosenvecgadgets
.reservedblocksstart
, MUIA_String_Integer
, partition
->de
.de_Reserved
);
1141 set(dosenvecgadgets
.reservedblocksend
, MUIA_String_Integer
, partition
->de
.de_PreAlloc
);
1142 set(dosenvecgadgets
.blocksize
, MUIA_Cycle_Active
, getBitNum(partition
->de
.de_SizeBlock
>>7));
1143 set(dosenvecgadgets
.buffers
, MUIA_String_Integer
, partition
->de
.de_NumBuffers
);
1144 set(dosenvecgadgets
.win
, MUIA_Window_Open
, TRUE
);
1150 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1151 if (active
!= MUIV_List_Active_Off
)
1153 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
1154 if (iln
->ln
.ln_Type
== LNT_Partition
)
1156 struct HDTBPartition
*partition
;
1160 partition
= (struct HDTBPartition
*)iln
;
1161 active
= getAttrInfo(partition
->root
->table
->pattrlist
, PTA_ACTIVE
);
1162 automount
= getAttrInfo(partition
->root
->table
->pattrlist
, PTA_AUTOMOUNT
);
1163 bootable
= getAttrInfo(partition
->root
->table
->pattrlist
, PTA_BOOTABLE
);
1164 if ((active
| automount
| bootable
) & PLAM_READ
)
1166 mountbootgadgets
.iln
= iln
;
1167 set(mountbootgadgets
.active
, MUIA_Disabled
, !(active
& PLAM_READ
));
1168 set(mountbootgadgets
.automount
, MUIA_Disabled
, !(automount
& PLAM_READ
));
1169 set(mountbootgadgets
.bootable
, MUIA_Disabled
, !(bootable
& PLAM_READ
));
1170 set(mountbootgadgets
.bootpri
, MUIA_Disabled
, !(bootable
& PLAM_READ
));
1171 set(mountbootgadgets
.active
, MUIA_Selected
, (partition
->flags
& PNF_ACTIVE
) ? TRUE
: FALSE
);
1172 set(mountbootgadgets
.automount
, MUIA_Selected
, (partition
->flags
& PNF_AUTOMOUNT
) ? TRUE
: FALSE
);
1173 if (partition
->flags
& PNF_BOOTABLE
)
1175 set(mountbootgadgets
.bootable
, MUIA_Selected
, TRUE
);
1176 set(mountbootgadgets
.bootpri
, MUIA_String_Integer
, partition
->de
.de_BootPri
);
1179 set(mountbootgadgets
.bootable
, MUIA_Selected
, FALSE
);
1180 set(mountbootgadgets
.win
, MUIA_Window_Open
, TRUE
);
1185 case GB_SAVE_CHANGES
:
1186 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1187 if (active
!= MUIV_List_Active_Off
)
1189 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, (IPTR
)&iln
);
1190 saveChanges(iln
, TRUE
);
1200 * DosEnvec of all partitions holds cylinder numbers relative to partition start.
1201 * This function returns absolute start cylinder number for the partition.
1203 static ULONG
GetStartCyl(struct HDTBPartition
*part
)
1205 ULONG blockspercyl
= part
->de
.de_Surfaces
* part
->de
.de_BlocksPerTrack
;
1208 while (part
->listnode
.parent
)
1210 part
= (struct HDTBPartition
*)part
->listnode
.parent
;
1212 if (part
->listnode
.ln
.ln_Type
!= LNT_Partition
)
1216 * Calculate start offset in blocks. This can be done because theoretically
1217 * partitions can have different virtual geometries.
1219 ret
+= part
->de
.de_LowCyl
* part
->de
.de_Surfaces
* part
->de
.de_BlocksPerTrack
;
1223 * FIXME: What if this can't be divided in interegs?
1224 * This can happen for example if the disk was partitioned on another machine where
1225 * disk driver reported different (virtual) geometry. In this case we should be able
1226 * to adjust mountlist geometry (Surfaces and BlocksPerTrack) so that division works
1227 * correctly and CHS-LBA relationship is still not broken.
1229 return ret
/ blockspercyl
;
1232 static struct FileSysEntry
*FindFileSysEntry(ULONG dostype
)
1234 struct FileSysEntry
*fse
;
1235 struct FileSysResource
*fsr
= OpenResource("FileSystem.resource");
1240 ForeachNode(&fsr
->fsr_FileSysEntries
, fse
)
1242 if (fse
->fse_DosType
== dostype
)
1249 AROS_UFH3(void, createml_function
,
1250 AROS_UFHA(struct Hook
*, h
, A0
),
1251 AROS_UFHA(Object
*, object
, A2
),
1252 AROS_UFHA(ULONG
*, arg
, A1
))
1256 IPTR active
= MUIA_List_Active
;
1257 struct HDTBPartition
*partition
= NULL
;
1259 get(gadgets
.leftlv
, MUIA_List_Active
, &active
);
1260 if (active
!= MUIV_List_Active_Off
)
1262 struct FileRequester
*req
;
1263 struct TagItem asltags
[] =
1265 {ASLFR_InitialDrawer
, (IPTR
)"SYS:Storage/DOSDrivers"},
1266 {ASLFR_InitialFile
, 0},
1267 {ASLFR_DoSaveMode
, TRUE
},
1271 DoMethod(gadgets
.leftlv
, MUIM_List_GetEntry
, active
, &partition
);
1272 asltags
[1].ti_Data
= (IPTR
)partition
->listnode
.ln
.ln_Name
;
1274 req
= MUI_AllocAslRequest(ASL_FileRequest
, asltags
);
1279 if (MUI_AslRequest(req
, NULL
))
1281 ULONG len
= strlen(req
->fr_Drawer
) + strlen(req
->fr_File
) + 2;
1282 STRPTR pathname
= AllocMem(len
, MEMF_ANY
);
1288 strcpy(pathname
, req
->fr_Drawer
);
1289 AddPart(pathname
, req
->fr_File
, len
);
1291 file
= Open(pathname
, MODE_NEWFILE
);
1292 FreeMem(pathname
, len
);
1296 struct DiskObject
*icon
;
1298 struct FileSysEntry
*fse
;
1299 ULONG startcyl
= GetStartCyl(partition
);
1301 args
[ 0] = (IPTR
)"";
1302 args
[ 1] = (IPTR
)partition
->ph
->bd
->ioreq
->iotd_Req
.io_Device
->dd_Library
.lib_Node
.ln_Name
;
1303 args
[ 2] = ((struct HDNode
*)partition
->root
)->unit
;
1304 args
[ 3] = partition
->de
.de_SizeBlock
* 4; /* block size in longs */
1305 args
[ 4] = partition
->de
.de_Surfaces
;
1306 args
[ 5] = partition
->de
.de_SectorPerBlock
;
1307 args
[ 6] = partition
->de
.de_BlocksPerTrack
;
1308 args
[ 7] = partition
->de
.de_Reserved
;
1309 args
[ 8] = partition
->de
.de_PreAlloc
;
1310 args
[ 9] = partition
->de
.de_Interleave
;
1311 args
[10] = partition
->de
.de_MaxTransfer
;
1312 args
[11] = partition
->de
.de_Mask
;
1313 args
[12] = partition
->de
.de_LowCyl
+ startcyl
;
1314 args
[13] = partition
->de
.de_HighCyl
+ startcyl
;
1315 args
[14] = partition
->de
.de_NumBuffers
;
1316 args
[15] = partition
->de
.de_BufMemType
;
1320 args
[19] = partition
->de
.de_DosType
;
1323 * Some things can be fetched only from FileSystem.resource.
1324 * Let's try to do it.
1326 fse
= FindFileSysEntry(partition
->de
.de_DosType
);
1329 if (fse
->fse_PatchFlags
& FSEF_HANDLER
)
1330 args
[0] = (IPTR
)AROS_BSTR_ADDR(fse
->fse_Handler
);
1332 if (fse
->fse_PatchFlags
& FSEF_STACKSIZE
)
1333 args
[16] = fse
->fse_StackSize
;
1335 if (fse
->fse_PatchFlags
& FSEF_PRIORITY
)
1336 args
[17] = fse
->fse_Priority
;
1338 if (fse
->fse_PatchFlags
& FSEF_GLOBALVEC
)
1339 args
[18] = (IPTR
)fse
->fse_GlobalVec
;
1342 VFPrintf(file
, "FileSystem = %s\n"
1347 "SectorsPerBlock = %ld\n"
1348 "BlocksPerTrack = %ld\n"
1351 "Interleave = %ld\n"
1352 "MaxTransfer = 0x%08lx\n"
1357 "BufMemType = %ld\n"
1361 "DosType = 0x%08lx\n"
1367 icon
= GetDiskObject("ENVARC:Sys/def_Mountlist");
1370 PutDiskObject(pathname
, icon
);
1371 FreeDiskObject(icon
);
1377 MUI_FreeAslRequest(req
);
1383 /************************* general List functions ***************************/
1385 LONG
InitListNode(struct ListNode
*node
, struct ListNode
*parent
)
1387 struct ListNode
*new;
1389 D(bug("[HDToolBox] InitListNode()\n"));
1391 NEWLIST(&node
->list
);
1392 new = AllocMem(sizeof(struct ListNode
), MEMF_PUBLIC
| MEMF_CLEAR
);
1395 node
->parent
= parent
;
1396 new->ln
.ln_Name
= "..";
1397 new->ln
.ln_Type
= LNT_Parent
;
1398 new->ln
.ln_Pri
= 127;
1400 AddTail(&node
->list
, &new->ln
);
1406 void UninitListNode(struct ListNode
*node
)
1408 struct ListNode
*parent
, *next
;
1410 D(bug("[HDToolBox] UninitListNode()\n"));
1412 /* free parent entry */
1413 parent
= (struct ListNode
*)node
->list
.lh_Head
;
1414 while (parent
->ln
.ln_Succ
)
1416 next
= (struct ListNode
*)parent
->ln
.ln_Succ
;
1417 if (parent
->ln
.ln_Type
== LNT_Parent
)
1419 Remove(&parent
->ln
);
1420 FreeMem(parent
, sizeof(struct ListNode
));
1427 void InsertList(Object
*list
, struct ListNode
*node
)
1429 D(bug("[HDToolBox] InsertList()\n"));
1431 DoMethod(list
, MUIM_List_InsertSingle
, (IPTR
)node
, MUIV_List_Insert_Bottom
);
1434 void ShowList(Object
*list
, struct List
*lh
)
1436 struct ListNode
*lnode
;
1438 D(bug("[HDToolBox] ShowList()\n"));
1440 DoMethod(list
, MUIM_List_Clear
);
1441 lnode
= (struct ListNode
*)lh
->lh_Head
;
1442 while (lnode
->ln
.ln_Succ
)
1446 ((lnode
->ln
.ln_Type
== LNT_Parent
) && (lnode
->parent
->parent
!= NULL
)) ||
1447 (lnode
->ln
.ln_Type
!= LNT_Parent
)
1449 (!(lnode
->flags
& LNF_Invalid
))
1452 DoMethod(list
, MUIM_List_InsertSingle
, (IPTR
)lnode
, MUIV_List_Insert_Bottom
);
1454 lnode
= (struct ListNode
*)lnode
->ln
.ln_Succ
;
1458 void disableObject(Object
*object
)
1460 LONG disabled
= FALSE
;
1462 D(bug("[HDToolBox] disableObject()\n"));
1464 get(object
, MUIA_Disabled
, &disabled
);
1465 if (disabled
== FALSE
)
1467 set(object
, MUIA_Disabled
, TRUE
);
1471 void enableObject(Object
*object
)
1473 LONG disabled
= FALSE
;
1475 D(bug("[HDToolBox] enableObject()\n"));
1477 get(object
, MUIA_Disabled
, &disabled
);
1478 if (disabled
== TRUE
)
1480 set(object
, MUIA_Disabled
, FALSE
);
1485 /********************************** Left Listview ***************************/
1487 AROS_UFH3(void, lv_doubleclick
,
1488 AROS_UFHA(struct Hook
*, h
, A0
),
1489 AROS_UFHA(Object
*, object
, A2
),
1490 AROS_UFHA(void *, arg
, A1
))
1494 LONG active
= MUIV_List_Active_Off
;
1496 struct ListNode
*iln
;
1498 D(bug("[HDToolBox] lv_doubleclick()\n"));
1500 get(object
, MUIA_List_Active
, &active
);
1501 if (active
!= MUIV_List_Active_Off
)
1503 DoMethod(object
,MUIM_List_GetEntry
,active
, (IPTR
)&iln
);
1504 if (iln
->flags
& LNF_Listable
)
1506 ShowList(object
, &iln
->list
);
1507 type
= iln
->ln
.ln_Type
;
1509 else if (iln
->ln
.ln_Type
== LNT_Parent
)
1511 if (iln
->parent
->parent
)
1513 ShowList(object
, &iln
->parent
->parent
->list
);
1514 type
= iln
->parent
->parent
->ln
.ln_Type
;
1521 enableObject(gadgets
.buttons
[GB_ADD_ENTRY
]);
1522 disableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
1523 disableObject(gadgets
.buttons
[GB_CREATE_TABLE
]);
1524 disableObject(gadgets
.buttons
[GB_CHANGE_TYPE
]);
1525 disableObject(gadgets
.buttons
[GB_RESIZE_MOVE
]);
1526 disableObject(gadgets
.buttons
[GB_PARENT
]);
1527 disableObject(gadgets
.buttons
[GB_RENAME
]);
1528 disableObject(gadgets
.buttons
[GB_DOSENVEC
]);
1529 disableObject(gadgets
.buttons
[GB_SWITCHES
]);
1530 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1533 disableObject(gadgets
.buttons
[GB_ADD_ENTRY
]);
1534 disableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
1535 disableObject(gadgets
.buttons
[GB_CREATE_TABLE
]);
1536 disableObject(gadgets
.buttons
[GB_CHANGE_TYPE
]);
1537 disableObject(gadgets
.buttons
[GB_RESIZE_MOVE
]);
1538 enableObject(gadgets
.buttons
[GB_PARENT
]);
1539 disableObject(gadgets
.buttons
[GB_RENAME
]);
1540 disableObject(gadgets
.buttons
[GB_DOSENVEC
]);
1541 disableObject(gadgets
.buttons
[GB_SWITCHES
]);
1542 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1546 enableObject(gadgets
.buttons
[GB_ADD_ENTRY
]);
1547 disableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
1548 disableObject(gadgets
.buttons
[GB_CREATE_TABLE
]);
1549 disableObject(gadgets
.buttons
[GB_CHANGE_TYPE
]);
1550 enableObject(gadgets
.buttons
[GB_RESIZE_MOVE
]);
1551 enableObject(gadgets
.buttons
[GB_PARENT
]);
1552 disableObject(gadgets
.buttons
[GB_RENAME
]);
1553 disableObject(gadgets
.buttons
[GB_DOSENVEC
]);
1554 disableObject(gadgets
.buttons
[GB_SWITCHES
]);
1555 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1556 DoMethod(gadgets
.buttons
[GB_RESIZE_MOVE
], MUIM_KillNotify
, MUIA_Pressed
);
1559 gadgets
.buttons
[GB_RESIZE_MOVE
],
1560 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.win
, 3,
1561 MUIM_Set
, MUIA_Window_Open
, TRUE
1565 resizemovegadgets
.win
,
1566 MUIM_Notify
, MUIA_Window_Open
, TRUE
, (IPTR
)resizemovegadgets
.pt
, 3,
1567 MUIM_Set
, PTCT_PartitionTable
, (IPTR
)iln
1576 AROS_UFH3(void, lv_click
,
1577 AROS_UFHA(struct Hook
*, h
, A0
),
1578 AROS_UFHA(Object
*, object
, A2
),
1579 AROS_UFHA(void *, arg
, A1
))
1583 LONG active
= MUIV_List_Active_Off
;
1584 struct ListNode
*iln
;
1588 D(bug("[HDToolBox] lv_click()\n"));
1590 get(object
, MUIA_List_Active
, &active
);
1591 if (active
!= MUIV_List_Active_Off
)
1593 DoMethod(object
,MUIM_List_GetEntry
,active
, (IPTR
)&iln
);
1594 DoMethod(gadgets
.rightlv
, MUIM_List_Clear
);
1595 switch (iln
->ln
.ln_Type
)
1598 sprintf(str
, "%s: %d", MSG(WORD_Units
),(int)countNodes(&iln
->list
, LNT_Harddisk
));
1599 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1600 enableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
1601 if (iln
->change_count
> 0)
1602 enableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1604 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1609 struct HDTBPartition
*partition
;
1610 partition
= (struct HDTBPartition
*)iln
;
1616 (partition
->de
.de_HighCyl
-partition
->de
.de_LowCyl
+1)*
1617 partition
->de
.de_Surfaces
*partition
->de
.de_BlocksPerTrack
1621 sprintf(str
, "%s: %s", MSG(WORD_Size
), sizestr
);
1622 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1623 sprintf(str
, "%s: ", MSG(WORD_Partition_Table
));
1624 if (partition
->table
)
1626 struct TableTypeNode
*ttn
;
1627 ttn
= findTableTypeNode(partition
->table
->type
);
1628 strcat(str
, ttn
->pti
->pti_Name
);
1629 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1630 sprintf(str
, "%s: %d", MSG(WORD_Partitions
), (int)countNodes(&iln
->list
, LNT_Partition
));
1631 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1635 strcat(str
, MSG(WORD_Unknown
));
1636 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1638 if (iln
->ln
.ln_Type
== LNT_Partition
)
1640 struct TypeNode
*type
;
1641 type
= findPartitionType(&partition
->type
, partition
->root
->table
->type
);
1642 sprintf(str
, "%s: ", MSG(WORD_Partition_Type
));
1644 strcat(str
, type
->ln
.ln_Name
);
1646 strcat(str
, MSG(WORD_Unknown
));
1647 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1648 sprintf(str
, "%s: ", MSG(WORD_Active
));
1649 if (partition
->flags
& PNF_ACTIVE
)
1650 strcat(str
, MSG_STD(YESSTR
));
1652 strcat(str
, MSG_STD(NOSTR
));
1653 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1654 sprintf(str
, "%s: ", MSG(WORD_Bootable
));
1655 if (partition
->flags
& PNF_BOOTABLE
)
1656 strcat(str
, MSG_STD(YESSTR
));
1658 strcat(str
, MSG_STD(NOSTR
));
1659 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1660 sprintf(str
, "%s: ", MSG(WORD_Automount
));
1661 if (partition
->flags
& PNF_AUTOMOUNT
)
1662 strcat(str
, MSG_STD(YESSTR
));
1664 strcat(str
, MSG_STD(NOSTR
));
1665 DoMethod(gadgets
.rightlv
, MUIM_List_InsertSingle
, (IPTR
)str
, MUIV_List_Insert_Bottom
);
1666 enableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
1667 enableObject(gadgets
.buttons
[GB_RENAME
]);
1668 enableObject(gadgets
.buttons
[GB_DOSENVEC
]);
1669 enableObject(gadgets
.buttons
[GB_SWITCHES
]);
1670 SetAttrs(part_item
, MUIA_Menuitem_Enabled
, !partition
->table
, TAG_DONE
);
1672 else if (iln
->ln
.ln_Type
== LNT_Harddisk
)
1674 if (iln
->change_count
> 0)
1675 enableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1677 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1679 enableObject(gadgets
.buttons
[GB_CREATE_TABLE
]);
1680 enableObject(gadgets
.buttons
[GB_CHANGE_TYPE
]);
1684 disableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
1685 disableObject(gadgets
.buttons
[GB_RENAME
]);
1686 disableObject(gadgets
.buttons
[GB_DOSENVEC
]);
1687 disableObject(gadgets
.buttons
[GB_SWITCHES
]);
1688 disableObject(gadgets
.buttons
[GB_CREATE_TABLE
]);
1689 disableObject(gadgets
.buttons
[GB_CHANGE_TYPE
]);
1690 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
1691 SetAttrs(part_item
, MUIA_Menuitem_Enabled
, FALSE
, TAG_DONE
);
1699 /**************************************** Main ******************************/
1705 D(bug("[HDToolBox] initGUI()\n"));
1707 MUIMasterBase
= OpenLibrary("muimaster.library", 0);
1709 return ERR_MUIMASTER
;
1711 ptclass
= makePTClass();
1712 if (ptclass
== NULL
)
1715 hook_display
.h_Entry
= (HOOKFUNC
)display_function
;
1716 hook_buttons
.h_Entry
= (HOOKFUNC
)buttons_function
;
1717 hook_createml
.h_Entry
= (HOOKFUNC
)createml_function
;
1718 hook_lv_doubleclick
.h_Entry
= (HOOKFUNC
)lv_doubleclick
;
1719 hook_lv_click
.h_Entry
= (HOOKFUNC
)lv_click
;
1720 partitiontypegadgets
.hook_hexidedit
.h_Entry
= (HOOKFUNC
)hexidedit_function
;
1722 app
= ApplicationObject
,
1723 MUIA_Application_Title
, "HDToolBox",
1724 MUIA_Application_Version
, "$VER: HDToolBox 0.2 (2.11.2012)",
1725 MUIA_Application_Copyright
, "(c) 1995-2012 AROS Development Team",
1726 MUIA_Application_Author
, "Bearly, Ogun, Fats and others at AROS",
1727 MUIA_Application_Description
, "Partition your disks.",
1728 MUIA_Application_Base
, "HDTOOLBOX",
1729 MUIA_Application_Menustrip
, MenuitemObject
,
1730 MUIA_Family_Child
, MenuitemObject
,
1731 MUIA_Menuitem_Title
, MSG(WORD_MENU_Project
),
1733 about_item
= MenuitemObject
, MUIA_Menuitem_Title
, MSG(WORD_MENU_About
),
1736 quit_item
= MenuitemObject
, MUIA_Menuitem_Title
, MSG(WORD_MENU_Quit
),
1740 part_item
= MenuitemObject
,
1741 MUIA_Menuitem_Title
, MSG(WORD_MENU_Partition
),
1742 MUIA_Menuitem_Enabled
, FALSE
,
1744 createml_item
= MenuitemObject
,
1745 MUIA_Menuitem_Title
, MSG(WORD_MENU_CreateMountlist
),
1749 SubWindow
, mainwin
= WindowObject
,
1750 MUIA_Window_Title
, "HDToolBox",
1751 MUIA_Window_ID
, MAKE_ID('H','D','T','B'),
1752 MUIA_Window_Activate
, TRUE
,
1753 MUIA_Window_Height
, MUIV_Window_Height_Visible(50),
1754 MUIA_Window_Width
, MUIV_Window_Width_Visible(60),
1755 WindowContents
, VGroup
,
1758 Child
, gadgets
.text
= TextObject
,
1760 MUIA_Text_Contents
, MSG(MSG_Welcome
),
1763 Child
, ListviewObject
,
1764 MUIA_Listview_List
, (gadgets
.leftlv
= ListObject
,
1766 MUIA_List_DisplayHook
, &hook_display
,
1767 MUIA_List_Format
, ",",
1768 MUIA_List_Title
, TRUE
,
1771 Child
, ListviewObject
,
1772 MUIA_Listview_List
, (gadgets
.rightlv
= ListObject
,
1774 MUIA_Listview_Input
, FALSE
,
1775 MUIA_List_Title
, TRUE
,
1776 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
1777 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
1786 Child
, gadgets
.buttons
[GB_ADD_ENTRY
] = SIMPLEBUTTON(WORD_AddEntry
),
1787 Child
, gadgets
.buttons
[GB_REMOVE_ENTRY
] = SIMPLEBUTTON(WORD_RemoveEntry
),
1790 Child
, gadgets
.buttons
[GB_CREATE_TABLE
] = SIMPLEBUTTON(WORD_Create_Table
),
1791 Child
, gadgets
.buttons
[GB_CHANGE_TYPE
] = SIMPLEBUTTON(WORD_Change_Type
),
1794 Child
, gadgets
.buttons
[GB_RESIZE_MOVE
] = SIMPLEBUTTON(WORD_Resize_Move
),
1795 Child
, gadgets
.buttons
[GB_PARENT
] = SIMPLEBUTTON(WORD_Parent
),
1798 Child
, gadgets
.buttons
[GB_RENAME
] = SIMPLEBUTTON(WORD_Rename
),
1799 Child
, gadgets
.buttons
[GB_DOSENVEC
] = SIMPLEBUTTON(WORD_DosEnvec
),
1802 Child
, gadgets
.buttons
[GB_SWITCHES
] = SIMPLEBUTTON(WORD_Switches
),
1807 MUIA_Group_SameWidth
, TRUE
,
1809 Child
, gadgets
.buttons
[GB_SAVE_CHANGES
] = IMAGEBUTTON(WORD_Save_Changes
, COOL_SAVEIMAGE_ID
),
1810 Child
, gadgets
.buttons
[GB_EXIT
] = IMAGEBUTTON(WORD_Exit
, COOL_CANCELIMAGE_ID
),
1815 SubWindow
, adddevicegadgets
.win
= WindowObject
,
1816 MUIA_Window_Title
, MSG(WORD_Devices
),
1817 MUIA_Window_Activate
, TRUE
,
1818 WindowContents
, VGroup
,
1819 Child
, PopaslObject
,
1820 MUIA_Popstring_String
, adddevicegadgets
.file
= StringObject
,
1823 MUIA_Popstring_Button
, PopButton(MUII_PopFile
),
1826 MUIA_Group_SameWidth
, TRUE
,
1828 Child
, adddevicegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
1829 Child
, adddevicegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
1833 SubWindow
, addpartitiongadgets
.win
= WindowObject
,
1834 MUIA_Window_Title
, MSG(MSG_Select_Empty_Area
),
1835 MUIA_Window_Activate
, TRUE
,
1836 WindowContents
, VGroup
,
1837 Child
, addpartitiongadgets
.pt
= BoopsiObject
,
1839 MUIA_Boopsi_Class
, ptclass
,
1840 MUIA_Boopsi_MinWidth
, 600,
1841 MUIA_Boopsi_MinHeight
, 100,
1842 MUIA_Boopsi_TagDrawInfo
, GA_DrawInfo
,
1843 MUIA_Boopsi_Remember
, PTCT_PartitionTable
,
1844 MUIA_Boopsi_Remember
, PTCT_Flags
,
1845 PTCT_Flags
, PTCTF_NoPartitionMove
| PTCTF_EmptySelectOnly
,
1851 MUIA_VertWeight
, 10,
1852 ICA_TARGET
, ICTARGET_IDCMP
,
1855 MUIA_Group_SameWidth
, TRUE
,
1857 Child
, addpartitiongadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
1858 Child
, addpartitiongadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
1862 SubWindow
, partitiontypegadgets
.win
= WindowObject
,
1863 MUIA_Window_Title
, MSG(WORD_Partition_Type
),
1864 MUIA_Window_Activate
, TRUE
,
1865 WindowContents
, VGroup
,
1866 Child
, ListviewObject
,
1867 MUIA_Listview_List
, partitiontypegadgets
.lv
=ListObject
,
1869 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
1870 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
1871 MUIA_List_Title
, TRUE
,
1875 Child
, partitiontypegadgets
.base
= CycleObject
,
1877 MUIA_Cycle_Entries
, editcycleentries
,
1878 MUIA_HorizWeight
, 1,
1880 Child
, partitiontypegadgets
.hexid
= StringObject
,
1882 MUIA_String_EditHook
, &partitiontypegadgets
.hook_hexidedit
,
1886 MUIA_Group_SameWidth
, TRUE
,
1888 Child
, partitiontypegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
1889 Child
, partitiontypegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
1893 SubWindow
, partitiontabletypegadgets
.win
= WindowObject
,
1894 MUIA_Window_Title
, MSG(WORD_Partition_Table_Type
),
1895 MUIA_Window_Activate
, TRUE
,
1896 WindowContents
, VGroup
,
1897 Child
, ListviewObject
,
1898 MUIA_Listview_List
, partitiontabletypegadgets
.lv
=ListObject
,
1900 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
1901 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
1902 MUIA_List_Title
, TRUE
,
1906 MUIA_Group_SameWidth
, TRUE
,
1908 Child
, partitiontabletypegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
1909 Child
, partitiontabletypegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
1913 SubWindow
, resizemovegadgets
.win
= WindowObject
,
1914 MUIA_Window_Title
, MSG(MSG_Select_Partition_Resize_Move
),
1915 MUIA_Window_Activate
, TRUE
,
1916 WindowContents
, VGroup
,
1917 Child
, resizemovegadgets
.pt
= BoopsiObject
,
1919 MUIA_Boopsi_Class
, ptclass
,
1920 MUIA_Boopsi_MinWidth
, 600,
1921 MUIA_Boopsi_MinHeight
, 100,
1922 MUIA_Boopsi_TagDrawInfo
, GA_DrawInfo
,
1923 MUIA_Boopsi_Remember
, PTCT_PartitionTable
,
1924 MUIA_Boopsi_Remember
, PTCT_Flags
,
1931 MUIA_VertWeight
, 10,
1932 ICA_TARGET
, ICTARGET_IDCMP
,
1936 MUIA_FrameTitle
, MSG(WORD_Geometry
),
1940 Child
, Label2("Low Cyl"),
1941 Child
, resizemovegadgets
.lowcyl
=StringObject
,
1943 MUIA_String_Integer
, 0,
1944 MUIA_String_Accept
, "0123456789",
1948 Child
, Label2("High Cyl"),
1949 Child
, resizemovegadgets
.highcyl
=StringObject
,
1951 MUIA_String_Integer
, 0,
1952 MUIA_String_Accept
, "0123456789",
1956 Child
, Label2("Total Cyl"),
1957 Child
, resizemovegadgets
.totalcyl
=StringObject
,
1959 MUIA_String_Integer
, 0,
1960 MUIA_String_Accept
, "0123456789",
1963 MUIA_HorizWeight
, 10,
1965 Child
, Label2("Size"),
1966 Child
, resizemovegadgets
.size
=StringObject
,
1968 MUIA_String_Accept
, "0123456789GM.",
1969 MUIA_HorizWeight
, 3,
1974 MUIA_Group_SameWidth
, TRUE
,
1976 Child
, resizemovegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
1977 Child
, resizemovegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
1981 SubWindow
, renamegadgets
.win
= WindowObject
,
1982 MUIA_Window_Title
, MSG(WORD_Rename
),
1983 MUIA_Window_Activate
, TRUE
,
1984 WindowContents
, VGroup
,
1985 Child
, renamegadgets
.name
= StringObject
,
1989 MUIA_Group_SameWidth
, TRUE
,
1991 Child
, renamegadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
1992 Child
, renamegadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
1996 SubWindow
, dosenvecgadgets
.win
= WindowObject
,
1997 MUIA_Window_Title
, MSG(WORD_DosEnvec
),
1998 MUIA_Window_Activate
, TRUE
,
1999 WindowContents
, VGroup
,
2003 Child
, Label2("Mask"),
2004 Child
, dosenvecgadgets
.mask
=StringObject
,
2006 MUIA_String_Integer
, -2,
2007 MUIA_String_Accept
, "0123456789",
2011 Child
, Label2("MaxTransfer"),
2012 Child
, dosenvecgadgets
.maxtransfer
=StringObject
,
2014 MUIA_String_Contents
, "0x7FFFFF",
2015 MUIA_String_Accept
, "0123456789x",
2022 Child
, Label("_Custom Bootcode"),
2024 Child
, dosenvecgadgets
.custboot
=MUI_MakeObject
2027 (IPTR
)"_Custom Bootcode"
2031 Child
, Label2("Nr. of Custom Bootblocks"),
2032 Child
, dosenvecgadgets
.numcustboot
=StringObject
,
2034 MUIA_String_Integer
, 0,
2035 MUIA_String_Accept
, "0123456789",
2041 MUIA_FrameTitle
, "Reserved Blocks at",
2043 Child
, Label2("Beginning"),
2044 Child
, dosenvecgadgets
.reservedblocksstart
=StringObject
,
2046 MUIA_String_Integer
, 0,
2047 MUIA_String_Accept
, "0123456789",
2051 Child
, Label2("End"),
2052 Child
, dosenvecgadgets
.reservedblocksend
=StringObject
,
2054 MUIA_String_Integer
, 0,
2055 MUIA_String_Accept
, "0123456789",
2062 Child
, Label("BlockSize"),
2063 Child
, dosenvecgadgets
.blocksize
=CycleObject
,
2065 MUIA_Cycle_Entries
, blocksizecycleentries
,
2069 Child
, Label2("Buffers"),
2070 Child
, dosenvecgadgets
.buffers
=StringObject
,
2072 MUIA_String_Integer
, 20,
2073 MUIA_String_Accept
, "0123456789",
2078 MUIA_Group_SameWidth
, TRUE
,
2080 Child
, dosenvecgadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
2081 Child
, dosenvecgadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
2085 SubWindow
, mountbootgadgets
.win
= WindowObject
,
2086 MUIA_Window_Title
, MSG(WORD_Switches
),
2087 MUIA_Window_Activate
, TRUE
,
2088 WindowContents
, VGroup
,
2090 Child
, Label(MSG(WORD_Active
)),
2092 Child
, mountbootgadgets
.active
=MUI_MakeObject
2099 Child
, Label(MSG(WORD_Automount
)),
2101 Child
, mountbootgadgets
.automount
=MUI_MakeObject
2108 Child
, Label(MSG(WORD_Bootable
)),
2110 Child
, mountbootgadgets
.bootable
=MUI_MakeObject
2117 Child
, Label(MSG(WORD_BootPri
)),
2118 Child
, mountbootgadgets
.bootpri
=StringObject
,
2120 MUIA_String_Integer
, 0,
2121 MUIA_String_Accept
, "-0123456789",
2125 MUIA_Group_SameWidth
, TRUE
,
2127 Child
, mountbootgadgets
.ok
= IMAGEBUTTON(WORD_Ok
, COOL_USEIMAGE_ID
),
2128 Child
, mountbootgadgets
.cancel
= IMAGEBUTTON(WORD_Cancel
, COOL_CANCELIMAGE_ID
),
2140 mainwin
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)app
, 2,
2141 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
2145 gadgets
.buttons
[GB_EXIT
], MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)app
, 2,
2146 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
2151 MUIM_Notify
, MUIA_Listview_DoubleClick
, TRUE
, (IPTR
)gadgets
.leftlv
, 2,
2152 MUIM_CallHook
, (IPTR
)&hook_lv_doubleclick
2157 MUIM_Notify
, MUIA_Listview_SelectChange
, TRUE
, (IPTR
)gadgets
.leftlv
, 2,
2158 MUIM_CallHook
, (IPTR
)&hook_lv_click
2160 for (i
=GB_FIRST
;i
<GB_EXIT
;i
++)
2165 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)gadgets
.buttons
[i
], 2,
2166 MUIM_CallHook
, (IPTR
)&hook_buttons
2168 /* MUIM_CallHook, hook */
2170 disableObject(gadgets
.buttons
[GB_REMOVE_ENTRY
]);
2171 disableObject(gadgets
.buttons
[GB_CREATE_TABLE
]);
2172 disableObject(gadgets
.buttons
[GB_CHANGE_TYPE
]);
2173 disableObject(gadgets
.buttons
[GB_RESIZE_MOVE
]);
2174 disableObject(gadgets
.buttons
[GB_PARENT
]);
2175 disableObject(gadgets
.buttons
[GB_RENAME
]);
2176 disableObject(gadgets
.buttons
[GB_DOSENVEC
]);
2177 disableObject(gadgets
.buttons
[GB_SWITCHES
]);
2178 disableObject(gadgets
.buttons
[GB_SAVE_CHANGES
]);
2182 MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
, (IPTR
)app
, 2,
2183 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
2185 DoMethod(createml_item
,
2186 MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
, app
, 2,
2187 MUIM_CallHook
, &hook_createml
);
2188 /* add device window */
2191 adddevicegadgets
.win
,
2192 MUIM_Notify
, MUIA_Window_Open
, TRUE
, (IPTR
)mainwin
, 3,
2193 MUIM_Set
, MUIA_Window_Sleep
, TRUE
2197 adddevicegadgets
.win
,
2198 MUIM_Notify
, MUIA_Window_Open
, FALSE
, (IPTR
)mainwin
, 3,
2199 MUIM_Set
, MUIA_Window_Sleep
, FALSE
2203 adddevicegadgets
.win
,
2204 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)adddevicegadgets
.win
, 3,
2205 MUIM_Set
, MUIA_Window_Open
, FALSE
2209 adddevicegadgets
.ok
,
2210 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)adddevicegadgets
.ok
, 2,
2211 MUIM_CallHook
, (IPTR
)&hook_buttons
2215 adddevicegadgets
.ok
,
2216 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)adddevicegadgets
.win
, 3,
2217 MUIM_Set
, MUIA_Window_Open
, FALSE
2221 adddevicegadgets
.cancel
,
2222 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)adddevicegadgets
.win
, 3,
2223 MUIM_Set
, MUIA_Window_Open
, FALSE
2225 /* add partition window */
2228 addpartitiongadgets
.win
,
2229 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)addpartitiongadgets
.win
, 3,
2230 MUIM_Set
, MUIA_Window_Open
, FALSE
2234 addpartitiongadgets
.ok
,
2235 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)addpartitiongadgets
.ok
, 2,
2236 MUIM_CallHook
, (IPTR
)&hook_buttons
2240 addpartitiongadgets
.ok
,
2241 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)addpartitiongadgets
.win
, 3,
2242 MUIM_Set
, MUIA_Window_Open
, FALSE
2246 addpartitiongadgets
.cancel
,
2247 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)addpartitiongadgets
.win
, 3,
2248 MUIM_Set
, MUIA_Window_Open
, FALSE
2252 addpartitiongadgets
.pt
,
2253 MUIM_Notify
, PTCT_Selected
, TRUE
, (IPTR
)addpartitiongadgets
.pt
, 2,
2254 MUIM_CallHook
, (IPTR
)&hook_buttons
2256 /* partition type window */
2259 partitiontypegadgets
.win
,
2260 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)partitiontypegadgets
.win
, 3,
2261 MUIM_Set
, MUIA_Window_Open
, FALSE
2265 partitiontypegadgets
.hexid
,
2266 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
2267 (IPTR
)partitiontypegadgets
.hexid
, 2,
2268 MUIM_CallHook
, (IPTR
)&hook_buttons
2270 /* "FIXME: notify doesn't work" */
2273 partitiontypegadgets
.ok
,
2274 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontypegadgets
.ok
, 2,
2275 MUIM_CallHook
, (IPTR
)&hook_buttons
2279 partitiontypegadgets
.ok
,
2280 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontypegadgets
.win
, 3,
2281 MUIM_Set
, MUIA_Window_Open
, FALSE
2285 partitiontypegadgets
.cancel
,
2286 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontypegadgets
.win
, 3,
2287 MUIM_Set
, MUIA_Window_Open
, FALSE
2291 partitiontypegadgets
.lv
,
2292 MUIM_Notify
, MUIA_Listview_SelectChange
, TRUE
, (IPTR
)partitiontypegadgets
.lv
, 2,
2293 MUIM_CallHook
, (IPTR
)&hook_buttons
2295 /* partition table type window */
2298 partitiontabletypegadgets
.win
,
2299 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)partitiontabletypegadgets
.win
, 3,
2300 MUIM_Set
, MUIA_Window_Open
, FALSE
2304 partitiontabletypegadgets
.ok
,
2305 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontabletypegadgets
.ok
, 2,
2306 MUIM_CallHook
, (IPTR
)&hook_buttons
2310 partitiontabletypegadgets
.ok
,
2311 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontabletypegadgets
.win
, 3,
2312 MUIM_Set
, MUIA_Window_Open
, FALSE
2316 partitiontabletypegadgets
.cancel
,
2317 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)partitiontabletypegadgets
.win
, 3,
2318 MUIM_Set
, MUIA_Window_Open
, FALSE
2320 /* resize/move window */
2323 resizemovegadgets
.win
,
2324 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)resizemovegadgets
.win
, 3,
2325 MUIM_Set
, MUIA_Window_Open
, FALSE
2329 resizemovegadgets
.ok
,
2330 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.ok
, 2,
2331 MUIM_CallHook
, (IPTR
)&hook_buttons
2335 resizemovegadgets
.ok
,
2336 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.win
, 3,
2337 MUIM_Set
, MUIA_Window_Open
, FALSE
2341 resizemovegadgets
.size
,
2342 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
2343 (IPTR
)resizemovegadgets
.size
, 2,
2344 MUIM_CallHook
, (IPTR
)&hook_buttons
2348 resizemovegadgets
.cancel
,
2349 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.cancel
, 2,
2350 MUIM_CallHook
, (IPTR
)&hook_buttons
2354 resizemovegadgets
.cancel
,
2355 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)resizemovegadgets
.win
, 3,
2356 MUIM_Set
, MUIA_Window_Open
, FALSE
2360 resizemovegadgets
.pt
,
2361 MUIM_Notify
, PTCT_Selected
, TRUE
, (IPTR
)resizemovegadgets
.pt
, 3,
2362 MUIM_CallHook
, (IPTR
)&hook_buttons
, PTCT_Selected
2366 resizemovegadgets
.pt
,
2367 MUIM_Notify
, PTCT_PartitionMove
, TRUE
, (IPTR
)resizemovegadgets
.pt
, 3,
2368 MUIM_CallHook
, (IPTR
)&hook_buttons
, PTCT_PartitionMove
2372 resizemovegadgets
.highcyl
,
2373 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
, (IPTR
)resizemovegadgets
.highcyl
, 2,
2374 MUIM_CallHook
, (IPTR
)&hook_buttons
2378 resizemovegadgets
.lowcyl
,
2379 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
, (IPTR
)resizemovegadgets
.lowcyl
, 2,
2380 MUIM_CallHook
, (IPTR
)&hook_buttons
2384 resizemovegadgets
.totalcyl
,
2385 MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
, (IPTR
)resizemovegadgets
.totalcyl
, 2,
2386 MUIM_CallHook
, (IPTR
)&hook_buttons
2392 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)renamegadgets
.win
, 3,
2393 MUIM_Set
, MUIA_Window_Open
, FALSE
2398 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)renamegadgets
.ok
, 2,
2399 MUIM_CallHook
, (IPTR
)&hook_buttons
2404 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)renamegadgets
.win
, 3,
2405 MUIM_Set
, MUIA_Window_Open
, FALSE
2409 renamegadgets
.cancel
,
2410 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)renamegadgets
.win
, 3,
2411 MUIM_Set
, MUIA_Window_Open
, FALSE
2413 /* dosenvec window */
2416 dosenvecgadgets
.win
,
2417 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)dosenvecgadgets
.win
, 3,
2418 MUIM_Set
, MUIA_Window_Open
, FALSE
2423 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)dosenvecgadgets
.ok
, 2,
2424 MUIM_CallHook
, (IPTR
)&hook_buttons
2429 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)dosenvecgadgets
.win
, 3,
2430 MUIM_Set
, MUIA_Window_Open
, FALSE
2434 dosenvecgadgets
.cancel
,
2435 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)dosenvecgadgets
.win
, 3,
2436 MUIM_Set
, MUIA_Window_Open
, FALSE
2438 /* automount/boot window */
2441 mountbootgadgets
.win
,
2442 MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)mountbootgadgets
.win
, 3,
2443 MUIM_Set
, MUIA_Window_Open
, FALSE
2447 mountbootgadgets
.ok
,
2448 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)mountbootgadgets
.ok
, 2,
2449 MUIM_CallHook
, (IPTR
)&hook_buttons
2453 mountbootgadgets
.ok
,
2454 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)mountbootgadgets
.win
, 3,
2455 MUIM_Set
, MUIA_Window_Open
, FALSE
2459 mountbootgadgets
.cancel
,
2460 MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)mountbootgadgets
.win
, 3,
2461 MUIM_Set
, MUIA_Window_Open
, FALSE
2463 set(mainwin
, MUIA_Window_Open
, TRUE
);
2469 D(bug("[HDToolBox] deinitGUI()\n"));
2472 MUI_DisposeObject(app
);
2473 if (ptclass
!= NULL
)
2476 CloseLibrary(MUIMasterBase
);
2479 BOOL
QuitGUI(ULONG
*sigs
)
2481 // moved debug from this place because it produces too much garbage
2483 if ((IPTR
)DoMethod(app
, MUIM_Application_NewInput
, (IPTR
)sigs
) == MUIV_Application_ReturnID_Quit
)
2485 D(bug("[HDToolBox] QuitGUI()\n"));