Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / tools / HDToolBox / gui.c
blob591602d3795744b7e3708b61b23059461e502552
1 /*
2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #warning "TODO: fs support"
7 //#error "Continue: clean (disable other windows) + check mount"
9 #include <proto/alib.h>
10 #include <proto/exec.h>
11 #include <proto/intuition.h>
12 #include <proto/muimaster.h>
14 #include <exec/memory.h>
15 #include <intuition/gadgetclass.h>
16 #include <intuition/icclass.h>
17 #include <intuition/intuition.h>
18 #include <intuition/sghooks.h>
19 #include <libraries/locale.h>
20 #include <libraries/mui.h>
21 #ifdef HAVE_COOLIMAGES
22 #include <libraries/coolimages.h>
23 #endif
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <strings.h>
29 #define DEBUG 0
30 #include "debug.h"
32 #include "gui.h"
33 #include "devices.h"
34 #include "error.h"
35 #include "harddisks.h"
36 #include "hdtoolbox_support.h"
37 #include "locale.h"
38 #include "platform.h"
39 #include "ptclass.h"
40 #include "prefs.h"
42 #undef CATCOMP_STRINGS
43 #undef CATCOMP_NUMBERS
44 #define CATCOMP_NUMBERS
45 #include "strings.h"
47 #define SIMPLEBUTTON(text) SimpleButton(MSG(text))
49 #ifdef HAVE_COOLIMAGES
50 #define IMAGEBUTTON(text,imgid) CoolImageIDButton(MSG(text),imgid)
51 #else
52 #define IMAGEBUTTON(text,imgid) SIMPLEBUTTON(text)
53 #endif
55 struct Library *MUIMasterBase = NULL;
57 Object *app;
58 Object *mainwin;
59 Object *about_item;
60 Object *quit_item;
61 struct GUIGadgets gadgets;
63 struct Hook hook_display;
64 struct Hook hook_buttons;
65 struct Hook hook_lv_doubleclick;
66 struct Hook hook_lv_click;
68 struct AddDeviceGadgets {
69 Object *win;
70 Object *disk;
71 Object *file;
72 Object *ok;
73 Object *cancel;
74 } adddevicegadgets;
76 Class *ptclass;
78 struct AddPartitionGadgets {
79 Object *win;
80 Object *pt;
81 Object *ok;
82 Object *cancel;
83 } addpartitiongadgets;
85 struct PartitionTypeGadgets {
86 Object *win;
87 struct TableTypeNode *ttn;
88 Object *lv;
89 Object *base;
90 struct Hook hook_hexidedit;
91 Object *hexid;
92 struct PartitionType type;
93 struct ListNode *iln;
94 Object *ok;
95 Object *cancel;
96 } partitiontypegadgets;
98 struct PartitionTableTypeGadgets {
99 Object *win;
100 Object *lv;
101 struct ListNode *iln;
102 Object *ok;
103 Object *cancel;
104 } partitiontabletypegadgets;
106 struct ResizeMoveGadgets {
107 Object *win;
108 Object *pt;
109 Object *lowcyl;
110 Object *highcyl;
111 Object *totalcyl;
112 Object *size;
113 Object *ok;
114 Object *cancel;
115 } resizemovegadgets;
117 struct RenameGadgets {
118 Object *win;
119 Object *name;
120 struct ListNode *iln;
121 Object *ok;
122 Object *cancel;
123 } renamegadgets;
125 struct DosEnvecGadgets {
126 Object *win;
127 Object *mask;
128 Object *maxtransfer;
129 Object *custboot;
130 Object *numcustboot;
131 Object *reservedblocksstart;
132 Object *reservedblocksend;
133 Object *blocksize;
134 Object *buffers;
135 struct ListNode *iln;
136 Object *ok;
137 Object *cancel;
138 } dosenvecgadgets;
140 struct MountBootGadgets {
141 Object *win;
142 Object *active;
143 Object *automount;
144 Object *bootable;
145 Object *bootpri;
146 struct ListNode *iln;
147 Object *ok;
148 Object *cancel;
149 } mountbootgadgets;
151 char *editcycleentries[] = {"0x", NULL};
152 char *blocksizecycleentries[] = {"512","1024","2048","4096", NULL};
154 void setChanged(struct ListNode *iln)
156 struct ListNode *parent = iln;
158 D(bug("[HDToolBox] setChanged()\n"));
160 while (parent)
162 parent->change_count++;
163 parent = parent->parent;
165 DoMethod(gadgets.leftlv, MUIM_List_Redraw, MUIV_List_Redraw_All);
166 set(gadgets.leftlv, MUIA_Listview_SelectChange, TRUE);
169 void unsetChanged(struct ListNode *iln)
171 struct ListNode *sub = iln;
172 struct ListNode *parent;
174 D(bug("[HDToolBox] unsetChanged()\n"));
176 /* remove changed from all first generation child partitions */
177 sub = (struct ListNode *)iln->list.lh_Head;
178 while (sub->ln.ln_Succ)
180 if (sub->change_count)
182 parent = sub->parent;
183 while (parent)
185 parent->change_count -= sub->change_count;
186 parent = parent->parent;
188 sub->change_count = 0;
190 sub = (struct ListNode *)sub->ln.ln_Succ;
192 if (iln->flags & LNF_ToSave)
194 iln->flags &= ~LNF_ToSave;
195 /* we saved it so there can't be a change_count */
196 if (iln->change_count)
198 parent = iln->parent;
199 while (parent)
201 parent->change_count -= iln->change_count;
202 parent = parent->parent;
204 iln->change_count = 0;
207 DoMethod(gadgets.leftlv, MUIM_List_Redraw, MUIV_List_Redraw_Active);
210 AROS_UFH3(void, hexidedit_function,
211 AROS_UFHA(struct Hook *, h, A0),
212 AROS_UFHA(struct SGWork *, sgwork, A2),
213 AROS_UFHA(ULONG *, msg, A1))
215 AROS_USERFUNC_INIT
217 D(bug("[HDToolBox] hexidedit_function()\n"));
219 if (*msg == SGH_KEY)
221 D(bug("[HDToolBox] hexidedit_function: KEY PRESS\n"));
224 AROS_USERFUNC_EXIT
227 AROS_UFH3(void, display_function,
228 AROS_UFHA(struct Hook *, h, A0),
229 AROS_UFHA(char **, strings, A2),
230 AROS_UFHA(struct ListNode *, entry, A1))
232 AROS_USERFUNC_INIT
234 static char buf[16];
235 static char bu2[64];
237 D(bug("[HDToolBox] display_function()\n"));
239 if (entry)
241 int i=0;
242 if (entry->change_count)
243 buf[i++] = '*';
244 if (entry->flags & LNF_ToSave)
245 buf[i++] = 'S';
246 buf[i] = 0;
247 strings[0] = buf;
248 if ((entry->flags & LNF_Listable) || (entry->ln.ln_Type == LNT_Parent))
250 sprintf(bu2,"\0333%s",entry->ln.ln_Name);
251 strings[1] = bu2;
253 else
254 strings[1] = entry->ln.ln_Name;
256 else
258 strings[0] = MSG(WORD_Changed);
259 strings[1] = MSG(WORD_Name);
262 AROS_USERFUNC_EXIT
265 void setTypeString(struct PartitionType *type, Object *strgad)
267 char str[256];
268 char *cur=str;
269 LONG len=0;
271 D(bug("[HDToolBox] setTypeString()\n"));
273 while (len!=type->id_len)
275 sprintf(cur, "%02x ", type->id[len]);
276 cur += 3;
277 len++;
279 cur[-1]=0;
280 set(strgad, MUIA_String_Contents, str);
283 LONG askSave(STRPTR name)
285 struct EasyStruct es =
287 sizeof(struct EasyStruct), 0,
288 "HDToolBox",
289 MSG(MSG_ASK_SAVE),
290 NULL
292 char yesno[32];
294 D(bug("[HDToolBox] askSave('%s')\n", name));
296 sprintf(yesno, "%s|%s|%s", MSG_STD(YESSTR), MSG(WORD_All), MSG_STD(NOSTR));
297 es.es_GadgetFormat = yesno;
298 return EasyRequestArgs(0, &es, 0, &name);
302 LONG saveChanges(struct ListNode *iln, LONG asksave)
304 struct ListNode *sub;
306 D(bug("[HDToolBox] saveChanges()\n"));
308 if (iln->change_count)
310 sub = (struct ListNode *)iln->list.lh_Head;
311 while (sub->ln.ln_Succ)
313 asksave = saveChanges(sub, asksave);
314 sub = (struct ListNode *)sub->ln.ln_Succ;
316 if (iln->flags & LNF_ToSave)
318 struct HDTBPartition *partition;
319 partition = (struct HDTBPartition *)iln;
320 if (partition->table)
322 LONG result=1;
323 if (asksave)
324 result = askSave(iln->ln.ln_Name);
325 if (result == 2)
326 asksave = FALSE;
327 if (result)
329 if (WritePartitionTable(partition->ph) == 0)
330 unsetChanged(iln);
331 else
332 set(gadgets.text, MUIA_Text_Contents, MSG(MSG_WriteTableError));
337 return asksave;
340 AROS_UFH3(void, buttons_function,
341 AROS_UFHA(struct Hook *, h, A0),
342 AROS_UFHA(Object *, object, A2),
343 AROS_UFHA(ULONG *, arg, A1))
345 AROS_USERFUNC_INIT
347 LONG active;
348 struct ListNode *iln;
349 int i;
351 D(bug("[HDToolBox] buttons_function()\n"));
353 for (i=GB_FIRST;i<=GB_LAST;i++)
354 if (object == gadgets.buttons[i])
355 break;
357 if (i > GB_LAST)
359 if (object == gadgets.leftlv)
362 else if (object == adddevicegadgets.ok)
364 char *str;
365 struct HDTBDevice *dn;
366 get(adddevicegadgets.file, MUIA_String_Contents, &str);
367 if (str[0])
368 dn = addDeviceName(str);
370 else if (object == addpartitiongadgets.ok)
372 struct DosEnvec *de;
373 get(addpartitiongadgets.pt, PTCT_ActivePartition, &de);
374 if (de)
376 struct HDTBPartition *table;
377 struct HDTBPartition *partition;
378 get(addpartitiongadgets.pt, PTCT_PartitionTable, &iln);
379 table = (struct HDTBPartition *)iln;
380 partition = addPartition(table, de);
381 if (partition)
383 setChanged(&partition->listnode);
384 partition->listnode.parent->flags |= LNF_ToSave;
385 InsertList(gadgets.leftlv, &partition->listnode);
387 else
388 set(gadgets.text, MUIA_Text_Contents, MSG(MSG_NO_MEMORY));
391 else if (object == addpartitiongadgets.pt);
392 else if (object == partitiontypegadgets.hexid)
394 char *str;
395 struct HDTBPartition *partition;
396 partition = (struct HDTBPartition *)partitiontypegadgets.iln;
397 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
398 get(object, MUIA_String_Contents, &str);
399 partitiontypegadgets.type.id_len=strcpyESC(partitiontypegadgets.type.id, str);
401 else if (object == partitiontypegadgets.lv)
403 get(partitiontypegadgets.lv, MUIA_List_Active, &active);
404 if (active != MUIV_List_Active_Off)
406 struct TypeNode *tn;
407 STRPTR name;
408 DoMethod(partitiontypegadgets.lv, MUIM_List_GetEntry, active, (IPTR)&name);
409 tn = (struct TypeNode *)FindName(partitiontypegadgets.ttn->typelist, name);
410 setTypeString(&tn->type, partitiontypegadgets.hexid);
411 CopyMem(&tn->type, &partitiontypegadgets.type, sizeof(struct PartitionType));
414 else if (object == partitiontypegadgets.ok)
416 struct HDTBPartition *partition;
417 partition = (struct HDTBPartition *)partitiontypegadgets.iln;
418 CopyMem(&partitiontypegadgets.type, &partition->type, sizeof(struct PartitionType));
419 SetPartitionAttrsA(partition->ph, PT_TYPE, &partition->type, TAG_DONE);
420 GetPartitionAttrsA(partition->ph, PT_DOSENVEC, &partition->de, TAG_DONE);
421 partitiontypegadgets.iln->parent->flags |= LNF_ToSave;
422 setChanged(partitiontypegadgets.iln);
424 else if (object == partitiontabletypegadgets.ok)
426 get(partitiontabletypegadgets.lv, MUIA_List_Active, &active);
427 if (active != MUIV_List_Active_Off)
429 struct TableTypeNode *ttn;
430 struct HDTBPartition *table;
431 STRPTR name;
432 DoMethod(partitiontabletypegadgets.lv, MUIM_List_GetEntry, active, (IPTR)&name);
433 ttn = findTableTypeNodeName(name);
434 table = (struct HDTBPartition *)partitiontabletypegadgets.iln;
435 if (
436 (table->table == NULL) ||
437 (ttn->pti->pti_Type != table->table->type)
440 if (makePartitionTable(table, ttn->pti->pti_Type))
442 table->listnode.flags |= LNF_Listable;
443 table->listnode.flags |= LNF_ToSave;
444 setChanged(partitiontabletypegadgets.iln);
446 else
447 set(gadgets.text, MUIA_Text_Contents, MSG(MSG_CreateTableError));
451 else if (object == resizemovegadgets.ok)
453 struct HDTBPartition *table;
454 struct HDTBPartition *partition;
455 get(resizemovegadgets.pt, PTCT_PartitionTable, &table);
456 partition = (struct HDTBPartition *)table->listnode.list.lh_Head;
457 table->listnode.flags |= LNF_ToSave;
458 while (partition->listnode.ln.ln_Succ)
460 if (partition->listnode.flags & LNF_IntermedChange)
462 partition->listnode.flags &= ~LNF_IntermedChange;
463 setChanged(&partition->listnode);
464 SetPartitionAttrsA(partition->ph, PT_DOSENVEC, &partition->de, TAG_DONE);
466 partition = (struct HDTBPartition *)partition->listnode.ln.ln_Succ;
469 else if (object == resizemovegadgets.cancel)
471 struct HDTBPartition *table;
472 struct HDTBPartition *partition;
473 get(resizemovegadgets.pt, PTCT_PartitionTable, &table);
474 partition = (struct HDTBPartition *)table->listnode.list.lh_Head;
475 while (partition->listnode.ln.ln_Succ)
477 if (partition->listnode.flags & LNF_IntermedChange)
479 partition->listnode.flags &= ~LNF_IntermedChange;
480 GetPartitionAttrsA(partition->ph, PT_DOSENVEC, &partition->de, TAG_DONE);
482 partition = (struct HDTBPartition *)partition->listnode.ln.ln_Succ;
485 else if (object == resizemovegadgets.pt)
487 LONG type;
488 struct DosEnvec *de;
489 char str[32];
490 D(bug("[HDToolBox] buttons_function() - Resize/Move Partition Display:\n"));
491 get(resizemovegadgets.pt, PTCT_ActiveType, &type);
492 if (type == PTS_EMPTY_AREA)
494 get(resizemovegadgets.pt, PTCT_ActivePartition, &de);
496 else
498 struct HDTBPartition *partition;
499 get(resizemovegadgets.pt, PTCT_ActivePartition, &partition);
500 de = &partition->de;
501 if (*arg == PTCT_PartitionMove)
503 partition->listnode.flags |= LNF_IntermedChange;
506 nnset(resizemovegadgets.lowcyl, MUIA_String_Integer, de->de_LowCyl);
507 nnset(resizemovegadgets.highcyl, MUIA_String_Integer, de->de_HighCyl);
508 nnset(resizemovegadgets.totalcyl, MUIA_String_Integer, de->de_HighCyl-de->de_LowCyl+1);
509 getSizeStr(str, (((de->de_HighCyl - de->de_LowCyl + 1) * de->de_Surfaces * de->de_BlocksPerTrack)-1)/2);
510 nnset(resizemovegadgets.size, MUIA_String_Contents, str);
511 D(bug("[HDToolBox] buttons_function() - Resize/Move Partition Display successful\n"));
513 else if (object == resizemovegadgets.lowcyl)
515 LONG type;
516 ULONG value;
517 D(bug("[HDToolBox] buttons_function() - Resize/Move Lowcyl:\n"));
518 get(object, MUIA_String_Integer, &value);
519 get(resizemovegadgets.pt, PTCT_ActiveType, &type);
520 if (type == PTS_PARTITION)
522 struct HDTBPartition *table;
523 struct HDTBPartition *partition;
524 ULONG block;
525 get(resizemovegadgets.pt, PTCT_PartitionTable, &table);
526 get(resizemovegadgets.pt, PTCT_ActivePartition, &partition);
527 D(bug("[HDToolBox] - Type : Partition\n"));
528 D(bug("[HDToolBox] - Old value : %ld\n", partition->de.de_LowCyl));
529 D(bug("[HDToolBox] - New value : %ld\n", value));
530 D(bug("[HDToolBox] - Partition table : %p\n", table));
531 D(bug("[HDToolBox] - Active partition : %p\n", partition));
532 if (value != partition->de.de_LowCyl)
534 block =
535 value*partition->de.de_Surfaces*partition->de.de_BlocksPerTrack;
536 if (validValue(table, partition, block))
538 char str[32];
539 partition->listnode.flags |= LNF_IntermedChange;
540 partition->de.de_LowCyl = value;
541 set(resizemovegadgets.totalcyl, MUIA_String_Integer, partition->de.de_HighCyl-partition->de.de_LowCyl+1);
542 set(resizemovegadgets.pt, PTCT_PartitionTable, table);
543 getSizeStr
545 str,
548 (partition->de.de_HighCyl-partition->de.de_LowCyl+1)*
549 partition->de.de_Surfaces*partition->de.de_BlocksPerTrack
553 set(resizemovegadgets.size, MUIA_String_Contents, str);
555 else
556 set(object, MUIA_String_Integer, partition->de.de_LowCyl);
559 else if (type == PTS_EMPTY_AREA)
561 struct DosEnvec *de;
562 get(resizemovegadgets.pt, PTCT_ActivePartition, &de);
563 if (value != de->de_LowCyl)
564 set(object, MUIA_String_Integer, de->de_LowCyl);
566 else
567 set(object, MUIA_String_Integer, 0);
569 else if (object == resizemovegadgets.highcyl)
571 LONG type;
572 ULONG value;
573 D(bug("[HDToolBox] buttons_function() - Resize/Move Highcyl:\n"));
574 get(object, MUIA_String_Integer, &value);
575 get(resizemovegadgets.pt, PTCT_ActiveType, &type);
576 if (type == PTS_PARTITION)
578 struct HDTBPartition *table;
579 struct HDTBPartition *partition;
580 ULONG block;
581 get(resizemovegadgets.pt, PTCT_PartitionTable, &table);
582 get(resizemovegadgets.pt, PTCT_ActivePartition, &partition);
583 D(bug("[HDToolBox] - Type : Partition\n"));
584 D(bug("[HDToolBox] - Old value : %ld\n", partition->de.de_HighCyl));
585 D(bug("[HDToolBox] - New value : %ld\n", value));
586 D(bug("[HDToolBox] - Partition table : %p\n", table));
587 D(bug("[HDToolBox] - Active partition : %p\n", partition));
588 if (value != partition->de.de_HighCyl)
590 block =
592 (value+1)*
593 partition->de.de_Surfaces*partition->de.de_BlocksPerTrack
594 )-1;
595 if (validValue(table, partition, block))
597 char str[32];
598 partition->listnode.flags |= LNF_IntermedChange;
599 partition->de.de_HighCyl = value;
600 nnset(resizemovegadgets.totalcyl, MUIA_String_Integer, partition->de.de_HighCyl-partition->de.de_LowCyl+1);
601 nnset(resizemovegadgets.pt, PTCT_PartitionTable, table);
602 getSizeStr
604 str,
607 (partition->de.de_HighCyl-partition->de.de_LowCyl+1)*
608 partition->de.de_Surfaces*partition->de.de_BlocksPerTrack
612 nnset(resizemovegadgets.size, MUIA_String_Contents, str);
614 else
615 nnset(object, MUIA_String_Integer, partition->de.de_HighCyl);
618 else if (type == PTS_EMPTY_AREA)
620 struct DosEnvec *de;
621 D(bug("[HDToolBox] - Type : Empty Area\n"));
622 get(resizemovegadgets.pt, PTCT_ActivePartition, &de);
623 if (value != de->de_HighCyl)
624 set(object, MUIA_String_Integer, de->de_HighCyl);
626 else
627 nnset(object, MUIA_String_Integer, 0);
629 else if (object == resizemovegadgets.totalcyl)
631 LONG type;
632 ULONG value;
633 get(object, MUIA_String_Integer, &value);
634 get(resizemovegadgets.pt, PTCT_ActiveType, &type);
635 if (type == PTS_PARTITION)
637 struct HDTBPartition *table;
638 struct HDTBPartition *partition;
639 ULONG block;
640 get(resizemovegadgets.pt, PTCT_PartitionTable, &table);
641 get(resizemovegadgets.pt, PTCT_ActivePartition, &partition);
642 if (value != (partition->de.de_HighCyl-partition->de.de_LowCyl+1))
644 block =
646 (partition->de.de_LowCyl+value)*
647 partition->de.de_Surfaces*partition->de.de_BlocksPerTrack
648 )-1;
649 if (validValue(table, partition, block))
651 char str[32];
652 partition->listnode.flags |= LNF_IntermedChange;
653 partition->de.de_HighCyl = partition->de.de_LowCyl+value-1;
654 set(resizemovegadgets.highcyl, MUIA_String_Integer, partition->de.de_HighCyl);
655 set(resizemovegadgets.pt, PTCT_PartitionTable, table);
656 getSizeStr
658 str,
661 (partition->de.de_HighCyl-partition->de.de_LowCyl+1)*
662 partition->de.de_Surfaces*partition->de.de_BlocksPerTrack
666 set(resizemovegadgets.size, MUIA_String_Contents, str);
668 else
669 set(object, MUIA_String_Integer, partition->de.de_HighCyl-partition->de.de_LowCyl+1);
672 else if (type == PTS_EMPTY_AREA)
674 struct DosEnvec *de;
675 get(resizemovegadgets.pt, PTCT_ActivePartition, &de);
676 if (value != (de->de_HighCyl-de->de_LowCyl+1))
677 set(object, MUIA_String_Integer, de->de_HighCyl-de->de_LowCyl+1);
679 else
680 set(object, MUIA_String_Integer, 0);
682 else if (object == resizemovegadgets.size)
684 char val[32];
685 struct DosEnvec *de;
686 STRPTR *str;
687 ULONG size = 0;
688 ULONG type;
689 get(resizemovegadgets.pt, PTCT_ActiveType, &type);
690 if (type == PTS_PARTITION)
692 struct HDTBPartition *partition;
693 get(resizemovegadgets.pt, PTCT_ActivePartition, &partition);
694 de = &partition->de;
695 get(object, MUIA_String_Contents, &str);
696 size = sizeStrToUL((STRPTR)str);
697 size = (size*2+1)/partition->de.de_BlocksPerTrack/partition->de.de_Surfaces+1;
699 else if (type == PTS_EMPTY_AREA)
701 get(resizemovegadgets.pt, PTCT_ActivePartition, &de);
703 set(resizemovegadgets.totalcyl, MUIA_String_Integer, size);
704 set(resizemovegadgets.totalcyl, MUIA_String_Acknowledge, TRUE);
705 getSizeStr
707 val,
710 (de->de_HighCyl-de->de_LowCyl+1)*
711 de->de_Surfaces*de->de_BlocksPerTrack
715 set(resizemovegadgets.size, MUIA_String_Contents, val);
717 else if (object == renamegadgets.ok)
719 struct HDTBPartition *partition;
720 STRPTR name;
721 partition = (struct HDTBPartition *)renamegadgets.iln;
722 get(renamegadgets.name, MUIA_String_Contents, &name);
723 if (strcmp(name, partition->listnode.ln.ln_Name) != 0)
725 SetPartitionAttrsA(partition->ph, PT_NAME, name, TAG_DONE);
726 strcpy(partition->listnode.ln.ln_Name, name);
727 renamegadgets.iln->parent->flags |= LNF_ToSave;
728 setChanged(renamegadgets.iln);
731 else if (object == dosenvecgadgets.ok)
733 BOOL changed = FALSE;
734 LONG check;
735 ULONG value;
736 STRPTR str;
737 char *end;
738 struct HDTBPartition *partition;
739 partition = (struct HDTBPartition *)dosenvecgadgets.iln;
740 get(dosenvecgadgets.mask, MUIA_String_Integer, &value);
741 if (value != partition->de.de_Mask)
743 partition->de.de_Mask = value;
744 changed = TRUE;
746 get(dosenvecgadgets.maxtransfer, MUIA_String_Contents, &str);
747 value = strtoul(str, &end, 0);
748 if (*end == 0)
750 if (value != partition->de.de_MaxTransfer)
752 partition->de.de_MaxTransfer = value;
753 changed = TRUE;
756 get(dosenvecgadgets.custboot, MUIA_Selected, &check);
757 if (check)
759 if (partition->de.de_TableSize<(DE_BOOTBLOCKS+1))
761 partition->de.de_TableSize = DE_BOOTBLOCKS+1;
762 changed = TRUE;
764 get(dosenvecgadgets.numcustboot, MUIA_String_Integer, &value);
765 if (value != partition->de.de_BootBlocks)
767 partition->de.de_BootBlocks = value;
768 changed = TRUE;
771 else
773 if (partition->de.de_TableSize>=(DE_BOOTBLOCKS+1))
775 partition->de.de_TableSize = DE_BOOTBLOCKS;
776 partition->de.de_BootBlocks = 0;
777 changed = TRUE;
780 get(dosenvecgadgets.reservedblocksstart, MUIA_String_Integer, &value);
781 if (value != partition->de.de_Reserved)
783 partition->de.de_Reserved = value;
784 changed = TRUE;
786 get(dosenvecgadgets.reservedblocksend, MUIA_String_Integer, &value);
787 if (value != partition->de.de_PreAlloc)
789 partition->de.de_PreAlloc = value;
790 changed = TRUE;
792 get(dosenvecgadgets.blocksize, MUIA_Cycle_Active, &value);
793 value = 1<<(value+7);
794 if (value != partition->de.de_SizeBlock)
796 partition->de.de_SizeBlock = value;
797 changed = TRUE;
799 get(dosenvecgadgets.buffers, MUIA_String_Integer, &value);
800 if (value != partition->de.de_NumBuffers)
802 partition->de.de_NumBuffers = value;
803 changed = TRUE;
805 if (changed)
807 SetPartitionAttrsA(partition->ph, PT_DOSENVEC, &partition->de, TAG_DONE);
808 dosenvecgadgets.iln->parent->flags |= LNF_ToSave;
809 setChanged(dosenvecgadgets.iln);
812 else if (object == mountbootgadgets.ok)
814 struct HDTBPartition *partition;
815 BOOL changeda = FALSE;
816 BOOL changed = FALSE;
817 LONG check;
818 ULONG value;
819 partition = (struct HDTBPartition *)mountbootgadgets.iln;
820 get(mountbootgadgets.active, MUIA_Selected, &check);
821 if (check)
823 if (!(partition->flags & PNF_ACTIVE))
825 partition->flags |= PNF_ACTIVE;
826 changeda = TRUE;
829 else
831 if (partition->flags & PNF_ACTIVE)
833 partition->flags &= ~PNF_ACTIVE;
834 changeda = TRUE;
837 if (changeda)
839 if (partition->flags & PNF_ACTIVE)
841 struct HDTBPartition *other;
842 other = (struct HDTBPartition *)partition->listnode.ln.ln_Pred;
843 while (other->listnode.ln.ln_Pred)
845 if (other->listnode.ln.ln_Type == LNT_Partition)
847 if (other->flags & PNF_ACTIVE)
849 other->flags &= ~PNF_ACTIVE;
850 SetPartitionAttrsA(other->ph, PT_ACTIVE, FALSE, TAG_DONE);
851 setChanged(&other->listnode);
854 other = (struct HDTBPartition *)other->listnode.ln.ln_Pred;
856 other = (struct HDTBPartition *)partition->listnode.ln.ln_Succ;
857 while (other->listnode.ln.ln_Succ)
859 if (other->listnode.ln.ln_Type == LNT_Partition)
861 if (other->flags & PNF_ACTIVE)
863 other->flags &= ~PNF_ACTIVE;
864 SetPartitionAttrsA(other->ph, PT_ACTIVE, FALSE, TAG_DONE);
865 setChanged(&other->listnode);
868 other = (struct HDTBPartition *)other->listnode.ln.ln_Succ;
871 SetPartitionAttrsA(partition->ph, PT_ACTIVE, check, TAG_DONE);
872 changed = TRUE;
874 changeda = FALSE;
875 get(mountbootgadgets.automount, MUIA_Selected, &check);
876 if (check)
878 if (!(partition->flags & PNF_AUTOMOUNT))
880 partition->flags |= PNF_AUTOMOUNT;
881 changeda = TRUE;
884 else
886 if (partition->flags & PNF_AUTOMOUNT)
888 partition->flags &= ~PNF_AUTOMOUNT;
889 changeda = TRUE;
892 if (changeda)
894 SetPartitionAttrsA(partition->ph, PT_AUTOMOUNT, check, TAG_DONE);
895 changed = TRUE;
897 changeda = FALSE;
898 get(mountbootgadgets.bootable, MUIA_Selected, &check);
899 if (check)
901 if (!(partition->flags & PNF_BOOTABLE))
903 partition->flags |= PNF_BOOTABLE;
904 changeda = TRUE;
906 get(mountbootgadgets.bootpri, MUIA_String_Integer, &value);
907 if (value != partition->de.de_BootPri)
909 partition->de.de_BootPri = value;
910 changeda = TRUE;
913 else
915 if (partition->flags & PNF_BOOTABLE)
917 partition->flags &= ~PNF_BOOTABLE;
918 partition->de.de_BootPri = 0;
919 changeda = TRUE;
922 if (changeda)
924 SetPartitionAttrsA(partition->ph, PT_BOOTABLE, check, PT_DOSENVEC, &partition->de, TAG_DONE);
925 changed = TRUE;
927 if (changed)
929 mountbootgadgets.iln->parent->flags |= LNF_ToSave;
930 setChanged(mountbootgadgets.iln);
934 else
936 switch (i)
938 case GB_ADD_ENTRY:
939 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, 0, (IPTR)&iln);
940 if (
941 (iln == NULL) ||
942 ((iln) && (iln->parent->parent == NULL))
945 set(adddevicegadgets.win, MUIA_Window_Open, TRUE);
947 else if ((iln->parent->ln.ln_Type == LNT_Harddisk) || (iln->parent->ln.ln_Type == LNT_Partition))
949 struct HDTBPartition *table;
950 table = (struct HDTBPartition *)iln->parent;
951 if (
953 (table->table->max_partitions) &&
954 (countNodes(&table->listnode.list, LNT_Partition)<table->table->max_partitions)
955 ) ||
956 (table->table->max_partitions == 0)
959 DoMethod
961 addpartitiongadgets.win,
962 MUIM_Notify, MUIA_Window_Open, TRUE, (IPTR)addpartitiongadgets.pt, 3,
963 MUIM_Set, PTCT_PartitionTable, (IPTR)table
965 set(addpartitiongadgets.win, MUIA_Window_Open, TRUE);
967 else
968 set(gadgets.text, MUIA_Text_Contents, MSG(MSG_PARTITION_TABLE_FULL));
970 break;
971 case GB_REMOVE_ENTRY:
972 get(gadgets.leftlv, MUIA_List_Active, &active);
973 if (active != MUIV_List_Active_Off)
975 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
976 switch (iln->ln.ln_Type)
978 case LNT_Device:
979 DoMethod(gadgets.leftlv, MUIM_List_Remove, active);
980 Remove(&iln->ln);
981 freeDeviceNode((struct HDTBDevice *)iln);
982 break;
983 case LNT_Partition:
985 struct HDTBPartition *partition;
986 partition = (struct HDTBPartition *)iln;
987 iln->parent->flags |= LNF_ToSave;
988 setChanged(iln);
989 DoMethod(gadgets.leftlv, MUIM_List_Remove, active);
990 Remove(&iln->ln);
991 DeletePartition(partition->ph);
992 freePartitionNode(partition);
996 break;
997 case GB_CREATE_TABLE:
998 case GB_CHANGE_TYPE:
999 get(gadgets.leftlv, MUIA_List_Active, &active);
1000 if (active != MUIV_List_Active_Off)
1002 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
1003 if (
1004 (iln->ln.ln_Type == LNT_Harddisk) ||
1005 ((i==2) && (iln->ln.ln_Type == LNT_Partition))
1008 struct HDTBPartition *table;
1009 ULONG type = 0;
1010 partitiontabletypegadgets.iln = iln;
1011 table = (struct HDTBPartition *)iln;
1012 if (table->table)
1013 type = table->table->type;
1014 DoMethod(partitiontabletypegadgets.lv, MUIM_List_Clear);
1015 for (i=0;PartitionBase->tables[i] != NULL;i++)
1017 DoMethod
1019 partitiontabletypegadgets.lv,
1020 MUIM_List_InsertSingle, (IPTR)PartitionBase->tables[i]->pti_Name, MUIV_List_Insert_Bottom
1022 if (type == PartitionBase->tables[i]->pti_Type)
1023 set(partitiontabletypegadgets.lv, MUIA_List_Active, i);
1025 set(partitiontabletypegadgets.win, MUIA_Window_Open, TRUE);
1027 else if ((i==3) && (iln->ln.ln_Type == LNT_Partition))
1029 struct TypeNode *tn;
1030 struct HDTBPartition *partition;
1031 partitiontypegadgets.iln = iln;
1032 i = 0;
1033 DoMethod(partitiontypegadgets.lv, MUIM_List_Clear);
1034 partition = (struct HDTBPartition *)iln;
1035 partitiontypegadgets.ttn = findTableTypeNode(partition->root->table->type);
1036 if (partitiontypegadgets.ttn)
1038 tn = (struct TypeNode *)partitiontypegadgets.ttn->typelist->lh_Head;
1039 while (tn->ln.ln_Succ)
1041 DoMethod
1043 partitiontypegadgets.lv,
1044 MUIM_List_InsertSingle, (IPTR)tn->ln.ln_Name, MUIV_List_Insert_Bottom
1046 if (tn->type.id_len == partition->type.id_len)
1047 if (memcmp(tn->type.id, partition->type.id, tn->type.id_len) == 0)
1048 set(partitiontypegadgets.lv, MUIA_List_Active, i);
1049 tn = (struct TypeNode *)tn->ln.ln_Succ;
1050 i++;
1053 setTypeString(&partition->type, partitiontypegadgets.hexid);
1054 set(partitiontypegadgets.win, MUIA_Window_Open, TRUE);
1057 break;
1058 case GB_RESIZE_MOVE:
1059 break;
1060 case GB_PARENT:
1061 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, 0, (IPTR)&iln);
1062 if (iln->ln.ln_Type == LNT_Parent)
1064 set(gadgets.leftlv, MUIA_List_Active, 0);
1065 set(gadgets.leftlv, MUIA_Listview_DoubleClick, TRUE);
1067 break;
1068 case GB_RENAME:
1069 get(gadgets.leftlv, MUIA_List_Active, &active);
1070 if (active != MUIV_List_Active_Off)
1072 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
1073 if (iln->ln.ln_Type == LNT_Partition)
1075 struct HDTBPartition *partition;
1076 partition = (struct HDTBPartition *)iln;
1077 if (getAttrInfo(partition->root->table->pattrlist, PTA_NAME) & PLAM_READ)
1079 renamegadgets.iln = iln;
1080 set(renamegadgets.name, MUIA_String_Contents, iln->ln.ln_Name);
1081 set(renamegadgets.win, MUIA_Window_Open, TRUE);
1085 break;
1086 case GB_DOSENVEC:
1087 get(gadgets.leftlv, MUIA_List_Active, &active);
1088 if (active != MUIV_List_Active_Off)
1090 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
1091 if (iln->ln.ln_Type == LNT_Partition)
1093 struct HDTBPartition *partition;
1094 partition = (struct HDTBPartition *)iln;
1095 if (getAttrInfo(partition->root->table->pattrlist, PTA_DOSENVEC) & PLAM_READ)
1097 char str[32];
1098 dosenvecgadgets.iln = iln;
1099 set(dosenvecgadgets.mask, MUIA_String_Integer, partition->de.de_Mask);
1100 sprintf(str, "0x%08lx", partition->de.de_MaxTransfer);
1101 set(dosenvecgadgets.maxtransfer, MUIA_String_Contents, str);
1102 if (partition->de.de_TableSize>=(DE_BOOTBLOCKS+1))
1104 set(dosenvecgadgets.custboot, MUIA_Selected, TRUE);
1105 set(dosenvecgadgets.numcustboot, MUIA_String_Integer, partition->de.de_BootBlocks);
1107 else
1108 set(dosenvecgadgets.custboot, MUIA_Selected, FALSE);
1109 set(dosenvecgadgets.reservedblocksstart, MUIA_String_Integer, partition->de.de_Reserved);
1110 set(dosenvecgadgets.reservedblocksend, MUIA_String_Integer, partition->de.de_PreAlloc);
1111 set(dosenvecgadgets.blocksize, MUIA_Cycle_Active, getBitNum(partition->de.de_SizeBlock>>7));
1112 set(dosenvecgadgets.buffers, MUIA_String_Integer, partition->de.de_NumBuffers);
1113 set(dosenvecgadgets.win, MUIA_Window_Open, TRUE);
1117 break;
1118 case GB_SWITCHES:
1119 get(gadgets.leftlv, MUIA_List_Active, &active);
1120 if (active != MUIV_List_Active_Off)
1122 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
1123 if (iln->ln.ln_Type == LNT_Partition)
1125 struct HDTBPartition *partition;
1126 BOOL active;
1127 BOOL automount;
1128 BOOL bootable;
1129 partition = (struct HDTBPartition *)iln;
1130 active = getAttrInfo(partition->root->table->pattrlist, PTA_ACTIVE);
1131 automount = getAttrInfo(partition->root->table->pattrlist, PTA_AUTOMOUNT);
1132 bootable = getAttrInfo(partition->root->table->pattrlist, PTA_BOOTABLE);
1133 if ((active | automount | bootable) & PLAM_READ)
1135 mountbootgadgets.iln = iln;
1136 set(mountbootgadgets.active, MUIA_Disabled, !(active & PLAM_READ));
1137 set(mountbootgadgets.automount, MUIA_Disabled, !(automount & PLAM_READ));
1138 set(mountbootgadgets.bootable, MUIA_Disabled, !(bootable & PLAM_READ));
1139 set(mountbootgadgets.bootpri, MUIA_Disabled, !(bootable & PLAM_READ));
1140 set(mountbootgadgets.active, MUIA_Selected, (partition->flags & PNF_ACTIVE) ? TRUE : FALSE);
1141 set(mountbootgadgets.automount, MUIA_Selected, (partition->flags & PNF_AUTOMOUNT) ? TRUE : FALSE);
1142 if (partition->flags & PNF_BOOTABLE)
1144 set(mountbootgadgets.bootable, MUIA_Selected, TRUE);
1145 set(mountbootgadgets.bootpri, MUIA_String_Integer, partition->de.de_BootPri);
1147 else
1148 set(mountbootgadgets.bootable, MUIA_Selected, FALSE);
1149 set(mountbootgadgets.win, MUIA_Window_Open, TRUE);
1153 break;
1154 case GB_SAVE_CHANGES:
1155 get(gadgets.leftlv, MUIA_List_Active, &active);
1156 if (active != MUIV_List_Active_Off)
1158 DoMethod(gadgets.leftlv, MUIM_List_GetEntry, active, (IPTR)&iln);
1159 saveChanges(iln, TRUE);
1161 break;
1165 AROS_USERFUNC_EXIT
1168 /************************* general List functions ***************************/
1170 LONG InitListNode(struct ListNode *node, struct ListNode *parent)
1172 struct ListNode *new;
1174 D(bug("[HDToolBox] InitListNode()\n"));
1176 NEWLIST(&node->list);
1177 new = AllocMem(sizeof(struct ListNode), MEMF_PUBLIC | MEMF_CLEAR);
1178 if (new)
1180 node->parent = parent;
1181 new->ln.ln_Name = "..";
1182 new->ln.ln_Type = LNT_Parent;
1183 new->ln.ln_Pri = 127;
1184 new->parent = node;
1185 AddTail(&node->list, &new->ln);
1186 return TRUE;
1188 return FALSE;
1191 void UninitListNode(struct ListNode *node)
1193 struct ListNode *parent;
1195 D(bug("[HDToolBox] UninitListNode()\n"));
1197 /* free parent entry */
1198 parent = (struct ListNode *)node->list.lh_Head;
1199 while (parent->ln.ln_Succ)
1201 if (parent->ln.ln_Type == LNT_Parent)
1203 Remove(&parent->ln);
1204 FreeMem(parent, sizeof(struct ListNode));
1205 return;
1207 parent = (struct ListNode *)parent->ln.ln_Succ;
1211 void InsertList(Object *list, struct ListNode *node)
1213 D(bug("[HDToolBox] InsertList()\n"));
1215 DoMethod(list, MUIM_List_InsertSingle, (IPTR)node, MUIV_List_Insert_Bottom);
1218 void ShowList(Object *list, struct List *lh)
1220 struct ListNode *lnode;
1222 D(bug("[HDToolBox] ShowList()\n"));
1224 DoMethod(list, MUIM_List_Clear);
1225 lnode = (struct ListNode *)lh->lh_Head;
1226 while (lnode->ln.ln_Succ)
1228 if (
1230 ((lnode->ln.ln_Type == LNT_Parent) && (lnode->parent->parent != NULL)) ||
1231 (lnode->ln.ln_Type != LNT_Parent)
1232 ) &&
1233 (!(lnode->flags & LNF_Invalid))
1236 DoMethod(list, MUIM_List_InsertSingle, (IPTR)lnode, MUIV_List_Insert_Bottom);
1238 lnode = (struct ListNode *)lnode->ln.ln_Succ;
1242 void disableObject(Object *object)
1244 LONG disabled;
1246 D(bug("[HDToolBox] disableObject()\n"));
1248 get(object, MUIA_Disabled, &disabled);
1249 if (disabled == FALSE)
1251 set(object, MUIA_Disabled, TRUE);
1255 void enableObject(Object *object)
1257 LONG disabled;
1259 D(bug("[HDToolBox] enableObject()\n"));
1261 get(object, MUIA_Disabled, &disabled);
1262 if (disabled == TRUE)
1264 set(object, MUIA_Disabled, FALSE);
1269 /********************************** Left Listview ***************************/
1271 AROS_UFH3(void, lv_doubleclick,
1272 AROS_UFHA(struct Hook *, h, A0),
1273 AROS_UFHA(Object *, object, A2),
1274 AROS_UFHA(void *, arg, A1))
1276 AROS_USERFUNC_INIT
1278 LONG active;
1279 LONG type=-1;
1280 struct ListNode *iln;
1282 D(bug("[HDToolBox] lv_doubleclick()\n"));
1284 get(object, MUIA_List_Active, &active);
1285 if (active != MUIV_List_Active_Off)
1287 DoMethod(object,MUIM_List_GetEntry,active, (IPTR)&iln);
1288 if (iln->flags & LNF_Listable)
1290 ShowList(object, &iln->list);
1291 type = iln->ln.ln_Type;
1293 else if (iln->ln.ln_Type == LNT_Parent)
1295 if (iln->parent->parent)
1297 ShowList(object, &iln->parent->parent->list);
1298 type = iln->parent->parent->ln.ln_Type;
1299 iln = iln->parent;
1302 switch (type)
1304 case LNT_Root:
1305 enableObject(gadgets.buttons[GB_ADD_ENTRY]);
1306 disableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
1307 disableObject(gadgets.buttons[GB_CREATE_TABLE]);
1308 disableObject(gadgets.buttons[GB_CHANGE_TYPE]);
1309 disableObject(gadgets.buttons[GB_RESIZE_MOVE]);
1310 disableObject(gadgets.buttons[GB_PARENT]);
1311 disableObject(gadgets.buttons[GB_RENAME]);
1312 disableObject(gadgets.buttons[GB_DOSENVEC]);
1313 disableObject(gadgets.buttons[GB_SWITCHES]);
1314 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1315 break;
1316 case LNT_Device:
1317 disableObject(gadgets.buttons[GB_ADD_ENTRY]);
1318 disableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
1319 disableObject(gadgets.buttons[GB_CREATE_TABLE]);
1320 disableObject(gadgets.buttons[GB_CHANGE_TYPE]);
1321 disableObject(gadgets.buttons[GB_RESIZE_MOVE]);
1322 enableObject(gadgets.buttons[GB_PARENT]);
1323 disableObject(gadgets.buttons[GB_RENAME]);
1324 disableObject(gadgets.buttons[GB_DOSENVEC]);
1325 disableObject(gadgets.buttons[GB_SWITCHES]);
1326 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1327 break;
1328 case LNT_Harddisk:
1329 case LNT_Partition:
1330 enableObject(gadgets.buttons[GB_ADD_ENTRY]);
1331 disableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
1332 disableObject(gadgets.buttons[GB_CREATE_TABLE]);
1333 disableObject(gadgets.buttons[GB_CHANGE_TYPE]);
1334 enableObject(gadgets.buttons[GB_RESIZE_MOVE]);
1335 enableObject(gadgets.buttons[GB_PARENT]);
1336 disableObject(gadgets.buttons[GB_RENAME]);
1337 disableObject(gadgets.buttons[GB_DOSENVEC]);
1338 disableObject(gadgets.buttons[GB_SWITCHES]);
1339 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1340 DoMethod(gadgets.buttons[GB_RESIZE_MOVE], MUIM_KillNotify, MUIA_Pressed);
1341 DoMethod
1343 gadgets.buttons[GB_RESIZE_MOVE],
1344 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)resizemovegadgets.win, 3,
1345 MUIM_Set, MUIA_Window_Open, TRUE
1347 DoMethod
1349 resizemovegadgets.win,
1350 MUIM_Notify, MUIA_Window_Open, TRUE, (IPTR)resizemovegadgets.pt, 3,
1351 MUIM_Set, PTCT_PartitionTable, (IPTR)iln
1353 break;
1357 AROS_USERFUNC_EXIT
1360 AROS_UFH3(void, lv_click,
1361 AROS_UFHA(struct Hook *, h, A0),
1362 AROS_UFHA(Object *, object, A2),
1363 AROS_UFHA(void *, arg, A1))
1365 AROS_USERFUNC_INIT
1367 LONG active;
1368 struct ListNode *iln;
1369 char str[64];
1370 char sizestr[16];
1372 D(bug("[HDToolBox] lv_click()\n"));
1374 get(object, MUIA_List_Active, &active);
1375 if (active != MUIV_List_Active_Off)
1377 DoMethod(object,MUIM_List_GetEntry,active, (IPTR)&iln);
1378 DoMethod(gadgets.rightlv, MUIM_List_Clear);
1379 switch (iln->ln.ln_Type)
1381 case LNT_Device:
1382 sprintf(str, "%s: %ld", MSG(WORD_Units),countNodes(&iln->list, LNT_Harddisk));
1383 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1384 enableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
1385 if (iln->change_count > 0)
1386 enableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1387 else
1388 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1389 break;
1390 case LNT_Harddisk:
1391 case LNT_Partition:
1393 struct HDTBPartition *partition;
1394 partition = (struct HDTBPartition *)iln;
1395 getSizeStr
1397 sizestr,
1400 (partition->de.de_HighCyl-partition->de.de_LowCyl+1)*
1401 partition->de.de_Surfaces*partition->de.de_BlocksPerTrack
1405 sprintf(str, "%s: %s", MSG(WORD_Size), sizestr);
1406 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1407 sprintf(str, "%s: ", MSG(WORD_Partition_Table));
1408 if (partition->table)
1410 struct TableTypeNode *ttn;
1411 ttn = findTableTypeNode(partition->table->type);
1412 strcat(str, ttn->pti->pti_Name);
1413 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1414 sprintf(str, "%s: %ld", MSG(WORD_Partitions), countNodes(&iln->list, LNT_Partition));
1415 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1417 else
1419 strcat(str, MSG(WORD_Unknown));
1420 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1422 if (iln->ln.ln_Type == LNT_Partition)
1424 struct TypeNode *type;
1425 type = findPartitionType(&partition->type, partition->root->table->type);
1426 sprintf(str, "%s: ", MSG(WORD_Partition_Type));
1427 if (type)
1428 strcat(str, type->ln.ln_Name);
1429 else
1430 strcat(str, MSG(WORD_Unknown));
1431 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1432 sprintf(str, "%s: ", MSG(WORD_Active));
1433 if (partition->flags & PNF_ACTIVE)
1434 strcat(str, MSG_STD(YESSTR));
1435 else
1436 strcat(str, MSG_STD(NOSTR));
1437 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1438 sprintf(str, "%s: ", MSG(WORD_Bootable));
1439 if (partition->flags & PNF_BOOTABLE)
1440 strcat(str, MSG_STD(YESSTR));
1441 else
1442 strcat(str, MSG_STD(NOSTR));
1443 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1444 sprintf(str, "%s: ", MSG(WORD_Automount));
1445 if (partition->flags & PNF_AUTOMOUNT)
1446 strcat(str, MSG_STD(YESSTR));
1447 else
1448 strcat(str, MSG_STD(NOSTR));
1449 DoMethod(gadgets.rightlv, MUIM_List_InsertSingle, (IPTR)str, MUIV_List_Insert_Bottom);
1450 enableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
1451 enableObject(gadgets.buttons[GB_RENAME]);
1452 enableObject(gadgets.buttons[GB_DOSENVEC]);
1453 enableObject(gadgets.buttons[GB_SWITCHES]);
1455 else if (iln->ln.ln_Type == LNT_Harddisk)
1457 if (iln->change_count > 0)
1458 enableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1459 else
1460 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1462 enableObject(gadgets.buttons[GB_CREATE_TABLE]);
1463 enableObject(gadgets.buttons[GB_CHANGE_TYPE]);
1465 break;
1466 case LNT_Parent:
1467 disableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
1468 disableObject(gadgets.buttons[GB_RENAME]);
1469 disableObject(gadgets.buttons[GB_DOSENVEC]);
1470 disableObject(gadgets.buttons[GB_SWITCHES]);
1471 disableObject(gadgets.buttons[GB_CREATE_TABLE]);
1472 disableObject(gadgets.buttons[GB_CHANGE_TYPE]);
1473 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1474 break;
1478 AROS_USERFUNC_EXIT
1481 /**************************************** Main ******************************/
1483 LONG initGUI(void)
1485 int i;
1487 D(bug("[HDToolBox] initGUI()\n"));
1489 MUIMasterBase = OpenLibrary("muimaster.library", 0);
1490 if (!MUIMasterBase)
1491 return ERR_MUIMASTER;
1493 ptclass = makePTClass();
1494 if (ptclass == NULL)
1495 return ERR_GADGETS;
1497 hook_display.h_Entry = (HOOKFUNC)display_function;
1498 hook_buttons.h_Entry = (HOOKFUNC)buttons_function;
1499 hook_lv_doubleclick.h_Entry = (HOOKFUNC)lv_doubleclick;
1500 hook_lv_click.h_Entry = (HOOKFUNC)lv_click;
1501 partitiontypegadgets.hook_hexidedit.h_Entry = (HOOKFUNC)hexidedit_function;
1503 app = ApplicationObject,
1504 MUIA_Application_Title , "HDToolBox",
1505 MUIA_Application_Version , "$VER: HDToolbox 0.1 (09-Apr-2003)",
1506 MUIA_Application_Copyright , "(c) 1995-2003 by the AROS Development Team",
1507 MUIA_Application_Author , "Bearly, Ogun, Fats and others at AROS",
1508 MUIA_Application_Description, "Partition your disks.",
1509 MUIA_Application_Base , "HDTOOLBOX",
1510 MUIA_Application_Menustrip, MenuitemObject,
1511 MUIA_Family_Child, MenuitemObject,
1512 MUIA_Menuitem_Title, MSG(WORD_MENU_Project),
1513 MUIA_Family_Child,
1514 about_item = MenuitemObject, MUIA_Menuitem_Title, MSG(WORD_MENU_About),
1515 End,
1516 MUIA_Family_Child,
1517 quit_item = MenuitemObject, MUIA_Menuitem_Title, MSG(WORD_MENU_Quit),
1518 End,
1519 End,
1520 End,
1521 SubWindow, mainwin = WindowObject,
1522 MUIA_Window_Title, "HDToolBox",
1523 MUIA_Window_ID, MAKE_ID('H','D','T','B'),
1524 MUIA_Window_Activate, TRUE,
1525 MUIA_Window_Height, MUIV_Window_Height_Visible(50),
1526 MUIA_Window_Width, MUIV_Window_Width_Visible(60),
1527 WindowContents, VGroup,
1528 Child, VGroup,
1529 GroupFrame,
1530 Child, gadgets.text = TextObject,
1531 TextFrame,
1532 MUIA_Text_Contents, MSG(MSG_Welcome),
1533 End,
1534 Child, HGroup,
1535 Child, ListviewObject,
1536 MUIA_Listview_List, (gadgets.leftlv = ListObject,
1537 InputListFrame,
1538 MUIA_List_DisplayHook, &hook_display,
1539 MUIA_List_Format, ",",
1540 MUIA_List_Title, TRUE,
1541 End),
1542 End,
1543 Child, ListviewObject,
1544 MUIA_Listview_List, (gadgets.rightlv = ListObject,
1545 ReadListFrame,
1546 MUIA_Listview_Input, FALSE,
1547 MUIA_List_Title, TRUE,
1548 MUIA_List_ConstructHook, MUIV_List_ConstructHook_String,
1549 MUIA_List_DestructHook, MUIV_List_DestructHook_String,
1550 End),
1551 End,
1552 End,
1553 End,
1554 Child, VGroup,
1555 GroupFrame,
1556 Child, HGroup,
1557 Child, VGroup,
1558 Child, gadgets.buttons[GB_ADD_ENTRY] = SIMPLEBUTTON(WORD_AddEntry),
1559 Child, gadgets.buttons[GB_REMOVE_ENTRY] = SIMPLEBUTTON(WORD_RemoveEntry),
1560 End,
1561 Child, VGroup,
1562 Child, gadgets.buttons[GB_CREATE_TABLE] = SIMPLEBUTTON(WORD_Create_Table),
1563 Child, gadgets.buttons[GB_CHANGE_TYPE] = SIMPLEBUTTON(WORD_Change_Type),
1564 End,
1565 Child, VGroup,
1566 Child, gadgets.buttons[GB_RESIZE_MOVE] = SIMPLEBUTTON(WORD_Resize_Move),
1567 Child, gadgets.buttons[GB_PARENT] = SIMPLEBUTTON(WORD_Parent),
1568 End,
1569 Child, VGroup,
1570 Child, gadgets.buttons[GB_RENAME] = SIMPLEBUTTON(WORD_Rename),
1571 Child, gadgets.buttons[GB_DOSENVEC] = SIMPLEBUTTON(WORD_DosEnvec),
1572 End,
1573 Child, VGroup,
1574 Child, gadgets.buttons[GB_SWITCHES] = SIMPLEBUTTON(WORD_Switches),
1575 Child, HVSpace,
1576 End,
1577 End,
1578 Child, HGroup,
1579 MUIA_Group_SameWidth, TRUE,
1580 MUIA_FixHeight, 1,
1581 Child, gadgets.buttons[GB_SAVE_CHANGES] = IMAGEBUTTON(WORD_Save_Changes, COOL_SAVEIMAGE_ID),
1582 Child, gadgets.buttons[GB_EXIT] = IMAGEBUTTON(WORD_Exit, COOL_CANCELIMAGE_ID),
1583 End,
1584 End,
1585 End,
1586 End,
1587 SubWindow, adddevicegadgets.win = WindowObject,
1588 MUIA_Window_Title, MSG(WORD_Devices),
1589 MUIA_Window_Activate, TRUE,
1590 WindowContents, VGroup,
1591 Child, PopaslObject,
1592 MUIA_Popstring_String, adddevicegadgets.file = StringObject,
1593 StringFrame,
1594 End,
1595 MUIA_Popstring_Button, PopButton(MUII_PopFile),
1596 End,
1597 Child, HGroup,
1598 MUIA_Group_SameWidth, TRUE,
1599 MUIA_FixHeight, 1,
1600 Child, adddevicegadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
1601 Child, adddevicegadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
1602 End,
1603 End,
1604 End,
1605 SubWindow, addpartitiongadgets.win = WindowObject,
1606 MUIA_Window_Title, MSG(MSG_Select_Empty_Area),
1607 MUIA_Window_Activate, TRUE,
1608 WindowContents, VGroup,
1609 Child, addpartitiongadgets.pt = BoopsiObject,
1610 GroupFrame,
1611 MUIA_Boopsi_Class, ptclass,
1612 MUIA_Boopsi_MinWidth, 600,
1613 MUIA_Boopsi_MinHeight, 100,
1614 MUIA_Boopsi_TagDrawInfo, GA_DrawInfo,
1615 MUIA_Boopsi_Remember, PTCT_PartitionTable,
1616 MUIA_Boopsi_Remember, PTCT_Flags,
1617 PTCT_Flags, PTCTF_NoPartitionMove | PTCTF_EmptySelectOnly,
1618 GA_Left, 0,
1619 GA_Top, 0,
1620 GA_Width, 0,
1621 GA_Height, 0,
1622 GA_DrawInfo, 0,
1623 MUIA_VertWeight, 10,
1624 ICA_TARGET, ICTARGET_IDCMP,
1625 End,
1626 Child, HGroup,
1627 MUIA_Group_SameWidth, TRUE,
1628 MUIA_FixHeight, 1,
1629 Child, addpartitiongadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
1630 Child, addpartitiongadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
1631 End,
1632 End,
1633 End,
1634 SubWindow, partitiontypegadgets.win = WindowObject,
1635 MUIA_Window_Title, MSG(WORD_Partition_Type),
1636 MUIA_Window_Activate, TRUE,
1637 WindowContents, VGroup,
1638 Child, ListviewObject,
1639 MUIA_Listview_List, partitiontypegadgets.lv=ListObject,
1640 InputListFrame,
1641 MUIA_List_ConstructHook, MUIV_List_ConstructHook_String,
1642 MUIA_List_DestructHook, MUIV_List_DestructHook_String,
1643 MUIA_List_Title, TRUE,
1644 End,
1645 End,
1646 Child, HGroup,
1647 Child, partitiontypegadgets.base = CycleObject,
1648 ButtonFrame,
1649 MUIA_Cycle_Entries, editcycleentries,
1650 MUIA_HorizWeight, 1,
1651 End,
1652 Child, partitiontypegadgets.hexid = StringObject,
1653 StringFrame,
1654 MUIA_String_EditHook, &partitiontypegadgets.hook_hexidedit,
1655 End,
1656 End,
1657 Child, HGroup,
1658 MUIA_Group_SameWidth, TRUE,
1659 MUIA_FixHeight, 1,
1660 Child, partitiontypegadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
1661 Child, partitiontypegadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
1662 End,
1663 End,
1664 End,
1665 SubWindow, partitiontabletypegadgets.win = WindowObject,
1666 MUIA_Window_Title, MSG(WORD_Partition_Table_Type),
1667 MUIA_Window_Activate, TRUE,
1668 WindowContents, VGroup,
1669 Child, ListviewObject,
1670 MUIA_Listview_List, partitiontabletypegadgets.lv=ListObject,
1671 InputListFrame,
1672 MUIA_List_ConstructHook, MUIV_List_ConstructHook_String,
1673 MUIA_List_DestructHook, MUIV_List_DestructHook_String,
1674 MUIA_List_Title, TRUE,
1675 End,
1676 End,
1677 Child, HGroup,
1678 MUIA_Group_SameWidth, TRUE,
1679 MUIA_FixHeight, 1,
1680 Child, partitiontabletypegadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
1681 Child, partitiontabletypegadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
1682 End,
1683 End,
1684 End,
1685 SubWindow, resizemovegadgets.win = WindowObject,
1686 MUIA_Window_Title, MSG(MSG_Select_Partition_Resize_Move),
1687 MUIA_Window_Activate, TRUE,
1688 WindowContents, VGroup,
1689 Child, resizemovegadgets.pt = BoopsiObject,
1690 GroupFrame,
1691 MUIA_Boopsi_Class, ptclass,
1692 MUIA_Boopsi_MinWidth, 600,
1693 MUIA_Boopsi_MinHeight, 100,
1694 MUIA_Boopsi_TagDrawInfo, GA_DrawInfo,
1695 MUIA_Boopsi_Remember, PTCT_PartitionTable,
1696 MUIA_Boopsi_Remember, PTCT_Flags,
1697 PTCT_Flags, 0,
1698 GA_Left, 0,
1699 GA_Top, 0,
1700 GA_Width, 0,
1701 GA_Height, 0,
1702 GA_DrawInfo, 0,
1703 MUIA_VertWeight, 10,
1704 ICA_TARGET, ICTARGET_IDCMP,
1705 End,
1706 Child, VGroup,
1707 GroupFrame,
1708 MUIA_FrameTitle, MSG(WORD_Geometry),
1709 Child, HGroup,
1710 Child, VGroup,
1711 Child, HGroup,
1712 Child, Label2("Low Cyl"),
1713 Child, resizemovegadgets.lowcyl=StringObject,
1714 StringFrame,
1715 MUIA_String_Integer, 0,
1716 MUIA_String_Accept, "0123456789",
1717 End,
1718 End,
1719 Child, HGroup,
1720 Child, Label2("High Cyl"),
1721 Child, resizemovegadgets.highcyl=StringObject,
1722 StringFrame,
1723 MUIA_String_Integer, 0,
1724 MUIA_String_Accept, "0123456789",
1725 End,
1726 End,
1727 Child, HGroup,
1728 Child, Label2("Total Cyl"),
1729 Child, resizemovegadgets.totalcyl=StringObject,
1730 StringFrame,
1731 MUIA_String_Integer, 0,
1732 MUIA_String_Accept, "0123456789",
1733 End,
1734 End,
1735 MUIA_HorizWeight, 10,
1736 End,
1737 Child, Label2("Size"),
1738 Child, resizemovegadgets.size=StringObject,
1739 ButtonFrame,
1740 MUIA_String_Accept, "0123456789GM.",
1741 MUIA_HorizWeight, 3,
1742 End,
1743 End,
1744 End,
1745 Child, HGroup,
1746 MUIA_Group_SameWidth, TRUE,
1747 MUIA_FixHeight, 1,
1748 Child, resizemovegadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
1749 Child, resizemovegadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
1750 End,
1751 End,
1752 End,
1753 SubWindow, renamegadgets.win = WindowObject,
1754 MUIA_Window_Title, MSG(WORD_Rename),
1755 MUIA_Window_Activate, TRUE,
1756 WindowContents, VGroup,
1757 Child, renamegadgets.name = StringObject,
1758 StringFrame,
1759 End,
1760 Child, HGroup,
1761 MUIA_Group_SameWidth, TRUE,
1762 MUIA_FixHeight, 1,
1763 Child, renamegadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
1764 Child, renamegadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
1765 End,
1766 End,
1767 End,
1768 SubWindow, dosenvecgadgets.win = WindowObject,
1769 MUIA_Window_Title, MSG(WORD_DosEnvec),
1770 MUIA_Window_Activate, TRUE,
1771 WindowContents, VGroup,
1772 Child, VGroup,
1773 GroupFrame,
1774 Child, HGroup,
1775 Child, Label2("Mask"),
1776 Child, dosenvecgadgets.mask=StringObject,
1777 StringFrame,
1778 MUIA_String_Integer, -2,
1779 MUIA_String_Accept, "0123456789",
1780 End,
1781 End,
1782 Child, HGroup,
1783 Child, Label2("MaxTransfer"),
1784 Child, dosenvecgadgets.maxtransfer=StringObject,
1785 StringFrame,
1786 MUIA_String_Contents, "0x7FFFFF",
1787 MUIA_String_Accept, "0123456789x",
1788 End,
1789 End,
1790 End,
1791 Child, VGroup,
1792 GroupFrame,
1793 Child, HGroup,
1794 Child, Label("_Custom Bootcode"),
1795 Child, HVSpace,
1796 Child, dosenvecgadgets.custboot=MUI_MakeObject
1798 MUIO_Checkmark,
1799 (IPTR)"_Custom Bootcode"
1801 End,
1802 Child, HGroup,
1803 Child, Label2("Nr. of Custom Bootblocks"),
1804 Child, dosenvecgadgets.numcustboot=StringObject,
1805 StringFrame,
1806 MUIA_String_Integer, 0,
1807 MUIA_String_Accept, "0123456789",
1808 End,
1809 End,
1810 End,
1811 Child, VGroup,
1812 GroupFrame,
1813 MUIA_FrameTitle, "Reserved Blocks at",
1814 Child, HGroup,
1815 Child, Label2("Beginning"),
1816 Child, dosenvecgadgets.reservedblocksstart=StringObject,
1817 StringFrame,
1818 MUIA_String_Integer, 0,
1819 MUIA_String_Accept, "0123456789",
1820 End,
1821 End,
1822 Child, HGroup,
1823 Child, Label2("End"),
1824 Child, dosenvecgadgets.reservedblocksend=StringObject,
1825 StringFrame,
1826 MUIA_String_Integer, 0,
1827 MUIA_String_Accept, "0123456789",
1828 End,
1829 End,
1830 End,
1831 Child, VGroup,
1832 GroupFrame,
1833 Child, HGroup,
1834 Child, Label("BlockSize"),
1835 Child, dosenvecgadgets.blocksize=CycleObject,
1836 ButtonFrame,
1837 MUIA_Cycle_Entries, blocksizecycleentries,
1838 End,
1839 End,
1840 Child, HGroup,
1841 Child, Label2("Buffers"),
1842 Child, dosenvecgadgets.buffers=StringObject,
1843 StringFrame,
1844 MUIA_String_Integer, 20,
1845 MUIA_String_Accept, "0123456789",
1846 End,
1847 End,
1848 End,
1849 Child, HGroup,
1850 MUIA_Group_SameWidth, TRUE,
1851 MUIA_FixHeight, 1,
1852 Child, dosenvecgadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
1853 Child, dosenvecgadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
1854 End,
1855 End,
1856 End,
1857 SubWindow, mountbootgadgets.win = WindowObject,
1858 MUIA_Window_Title, MSG(WORD_Switches),
1859 MUIA_Window_Activate, TRUE,
1860 WindowContents, VGroup,
1861 Child, HGroup,
1862 Child, Label(MSG(WORD_Active)),
1863 Child, HVSpace,
1864 Child, mountbootgadgets.active=MUI_MakeObject
1866 MUIO_Checkmark,
1867 MSG(WORD_Active)
1869 End,
1870 Child, HGroup,
1871 Child, Label(MSG(WORD_Automount)),
1872 Child, HVSpace,
1873 Child, mountbootgadgets.automount=MUI_MakeObject
1875 MUIO_Checkmark,
1876 MSG(WORD_Automount)
1878 End,
1879 Child, HGroup,
1880 Child, Label(MSG(WORD_Bootable)),
1881 Child, HVSpace,
1882 Child, mountbootgadgets.bootable=MUI_MakeObject
1884 MUIO_Checkmark,
1885 MSG(WORD_Bootable)
1887 End,
1888 Child, HGroup,
1889 Child, Label(MSG(WORD_BootPri)),
1890 Child, mountbootgadgets.bootpri=StringObject,
1891 StringFrame,
1892 MUIA_String_Integer, 0,
1893 MUIA_String_Accept, "-0123456789",
1894 End,
1895 End,
1896 Child, HGroup,
1897 MUIA_Group_SameWidth, TRUE,
1898 MUIA_FixHeight, 1,
1899 Child, mountbootgadgets.ok = IMAGEBUTTON(WORD_Ok, COOL_USEIMAGE_ID),
1900 Child, mountbootgadgets.cancel = IMAGEBUTTON(WORD_Cancel, COOL_CANCELIMAGE_ID),
1901 End,
1902 End,
1903 End,
1904 End;
1906 if (!app)
1907 return ERR_GADGETS;
1909 /* Main Window */
1910 DoMethod
1912 mainwin, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)app, 2,
1913 MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
1915 DoMethod
1917 gadgets.buttons[GB_EXIT], MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)app, 2,
1918 MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
1920 DoMethod
1922 gadgets.leftlv,
1923 MUIM_Notify, MUIA_Listview_DoubleClick, TRUE, (IPTR)gadgets.leftlv, 2,
1924 MUIM_CallHook, (IPTR)&hook_lv_doubleclick
1926 DoMethod
1928 gadgets.leftlv,
1929 MUIM_Notify, MUIA_Listview_SelectChange, TRUE, (IPTR)gadgets.leftlv, 2,
1930 MUIM_CallHook, (IPTR)&hook_lv_click
1932 for (i=GB_FIRST;i<GB_EXIT;i++)
1934 DoMethod
1936 gadgets.buttons[i],
1937 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)gadgets.buttons[i], 2,
1938 MUIM_CallHook, (IPTR)&hook_buttons
1940 /* MUIM_CallHook, hook */
1942 disableObject(gadgets.buttons[GB_REMOVE_ENTRY]);
1943 disableObject(gadgets.buttons[GB_CREATE_TABLE]);
1944 disableObject(gadgets.buttons[GB_CHANGE_TYPE]);
1945 disableObject(gadgets.buttons[GB_RESIZE_MOVE]);
1946 disableObject(gadgets.buttons[GB_PARENT]);
1947 disableObject(gadgets.buttons[GB_RENAME]);
1948 disableObject(gadgets.buttons[GB_DOSENVEC]);
1949 disableObject(gadgets.buttons[GB_SWITCHES]);
1950 disableObject(gadgets.buttons[GB_SAVE_CHANGES]);
1951 DoMethod
1953 quit_item,
1954 MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, (IPTR)app, 2,
1955 MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
1957 /* add device window */
1958 DoMethod
1960 adddevicegadgets.win,
1961 MUIM_Notify, MUIA_Window_Open, TRUE, (IPTR)mainwin, 3,
1962 MUIM_Set, MUIA_Window_Sleep, TRUE
1964 DoMethod
1966 adddevicegadgets.win,
1967 MUIM_Notify, MUIA_Window_Open, FALSE, (IPTR)mainwin, 3,
1968 MUIM_Set, MUIA_Window_Sleep, FALSE
1970 DoMethod
1972 adddevicegadgets.win,
1973 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)adddevicegadgets.win, 3,
1974 MUIM_Set, MUIA_Window_Open, FALSE
1976 DoMethod
1978 adddevicegadgets.ok,
1979 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)adddevicegadgets.ok, 2,
1980 MUIM_CallHook, (IPTR)&hook_buttons
1982 DoMethod
1984 adddevicegadgets.ok,
1985 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)adddevicegadgets.win, 3,
1986 MUIM_Set, MUIA_Window_Open, FALSE
1988 DoMethod
1990 adddevicegadgets.cancel,
1991 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)adddevicegadgets.win, 3,
1992 MUIM_Set, MUIA_Window_Open, FALSE
1994 /* add partition window */
1995 DoMethod
1997 addpartitiongadgets.win,
1998 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)addpartitiongadgets.win, 3,
1999 MUIM_Set, MUIA_Window_Open, FALSE
2001 DoMethod
2003 addpartitiongadgets.ok,
2004 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)addpartitiongadgets.ok, 2,
2005 MUIM_CallHook, (IPTR)&hook_buttons
2007 DoMethod
2009 addpartitiongadgets.ok,
2010 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)addpartitiongadgets.win, 3,
2011 MUIM_Set, MUIA_Window_Open, FALSE
2013 DoMethod
2015 addpartitiongadgets.cancel,
2016 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)addpartitiongadgets.win, 3,
2017 MUIM_Set, MUIA_Window_Open, FALSE
2019 DoMethod
2021 addpartitiongadgets.pt,
2022 MUIM_Notify, PTCT_Selected, TRUE, (IPTR)addpartitiongadgets.pt, 2,
2023 MUIM_CallHook, (IPTR)&hook_buttons
2025 /* partition type window */
2026 DoMethod
2028 partitiontypegadgets.win,
2029 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)partitiontypegadgets.win, 3,
2030 MUIM_Set, MUIA_Window_Open, FALSE
2032 DoMethod
2034 partitiontypegadgets.hexid,
2035 MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
2036 (IPTR)partitiontypegadgets.hexid, 2,
2037 MUIM_CallHook, (IPTR)&hook_buttons
2039 #warning "FIXME: notify doesn't work"
2040 DoMethod
2042 partitiontypegadgets.ok,
2043 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)partitiontypegadgets.ok, 2,
2044 MUIM_CallHook, (IPTR)&hook_buttons
2046 DoMethod
2048 partitiontypegadgets.ok,
2049 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)partitiontypegadgets.win, 3,
2050 MUIM_Set, MUIA_Window_Open, FALSE
2052 DoMethod
2054 partitiontypegadgets.cancel,
2055 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)partitiontypegadgets.win, 3,
2056 MUIM_Set, MUIA_Window_Open, FALSE
2058 DoMethod
2060 partitiontypegadgets.lv,
2061 MUIM_Notify, MUIA_Listview_SelectChange, TRUE, (IPTR)partitiontypegadgets.lv, 2,
2062 MUIM_CallHook, (IPTR)&hook_buttons
2064 /* partition table type window */
2065 DoMethod
2067 partitiontabletypegadgets.win,
2068 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)partitiontabletypegadgets.win, 3,
2069 MUIM_Set, MUIA_Window_Open, FALSE
2071 DoMethod
2073 partitiontabletypegadgets.ok,
2074 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)partitiontabletypegadgets.ok, 2,
2075 MUIM_CallHook, (IPTR)&hook_buttons
2077 DoMethod
2079 partitiontabletypegadgets.ok,
2080 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)partitiontabletypegadgets.win, 3,
2081 MUIM_Set, MUIA_Window_Open, FALSE
2083 DoMethod
2085 partitiontabletypegadgets.cancel,
2086 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)partitiontabletypegadgets.win, 3,
2087 MUIM_Set, MUIA_Window_Open, FALSE
2089 /* resize/move window */
2090 DoMethod
2092 resizemovegadgets.win,
2093 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)resizemovegadgets.win, 3,
2094 MUIM_Set, MUIA_Window_Open, FALSE
2096 DoMethod
2098 resizemovegadgets.ok,
2099 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)resizemovegadgets.ok, 2,
2100 MUIM_CallHook, (IPTR)&hook_buttons
2102 DoMethod
2104 resizemovegadgets.ok,
2105 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)resizemovegadgets.win, 3,
2106 MUIM_Set, MUIA_Window_Open, FALSE
2108 DoMethod
2110 resizemovegadgets.size,
2111 MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
2112 (IPTR)resizemovegadgets.size, 2,
2113 MUIM_CallHook, (IPTR)&hook_buttons
2115 DoMethod
2117 resizemovegadgets.cancel,
2118 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)resizemovegadgets.cancel, 2,
2119 MUIM_CallHook, (IPTR)&hook_buttons
2121 DoMethod
2123 resizemovegadgets.cancel,
2124 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)resizemovegadgets.win, 3,
2125 MUIM_Set, MUIA_Window_Open, FALSE
2127 DoMethod
2129 resizemovegadgets.pt,
2130 MUIM_Notify, PTCT_Selected, TRUE, (IPTR)resizemovegadgets.pt, 3,
2131 MUIM_CallHook, (IPTR)&hook_buttons, PTCT_Selected
2133 DoMethod
2135 resizemovegadgets.pt,
2136 MUIM_Notify, PTCT_PartitionMove, TRUE, (IPTR)resizemovegadgets.pt, 3,
2137 MUIM_CallHook, (IPTR)&hook_buttons, PTCT_PartitionMove
2139 DoMethod
2141 resizemovegadgets.highcyl,
2142 MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, (IPTR)resizemovegadgets.highcyl, 2,
2143 MUIM_CallHook, (IPTR)&hook_buttons
2145 DoMethod
2147 resizemovegadgets.lowcyl,
2148 MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, (IPTR)resizemovegadgets.lowcyl, 2,
2149 MUIM_CallHook, (IPTR)&hook_buttons
2151 DoMethod
2153 resizemovegadgets.totalcyl,
2154 MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, (IPTR)resizemovegadgets.totalcyl, 2,
2155 MUIM_CallHook, (IPTR)&hook_buttons
2157 /* rename window */
2158 DoMethod
2160 renamegadgets.win,
2161 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)renamegadgets.win, 3,
2162 MUIM_Set, MUIA_Window_Open, FALSE
2164 DoMethod
2166 renamegadgets.ok,
2167 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)renamegadgets.ok, 2,
2168 MUIM_CallHook, (IPTR)&hook_buttons
2170 DoMethod
2172 renamegadgets.ok,
2173 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)renamegadgets.win, 3,
2174 MUIM_Set, MUIA_Window_Open, FALSE
2176 DoMethod
2178 renamegadgets.cancel,
2179 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)renamegadgets.win, 3,
2180 MUIM_Set, MUIA_Window_Open, FALSE
2182 /* dosenvec window */
2183 DoMethod
2185 dosenvecgadgets.win,
2186 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)dosenvecgadgets.win, 3,
2187 MUIM_Set, MUIA_Window_Open, FALSE
2189 DoMethod
2191 dosenvecgadgets.ok,
2192 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)dosenvecgadgets.ok, 2,
2193 MUIM_CallHook, (IPTR)&hook_buttons
2195 DoMethod
2197 dosenvecgadgets.ok,
2198 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)dosenvecgadgets.win, 3,
2199 MUIM_Set, MUIA_Window_Open, FALSE
2201 DoMethod
2203 dosenvecgadgets.cancel,
2204 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)dosenvecgadgets.win, 3,
2205 MUIM_Set, MUIA_Window_Open, FALSE
2207 /* automount/boot window */
2208 DoMethod
2210 mountbootgadgets.win,
2211 MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)mountbootgadgets.win, 3,
2212 MUIM_Set, MUIA_Window_Open, FALSE
2214 DoMethod
2216 mountbootgadgets.ok,
2217 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)mountbootgadgets.ok, 2,
2218 MUIM_CallHook, (IPTR)&hook_buttons
2220 DoMethod
2222 mountbootgadgets.ok,
2223 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)mountbootgadgets.win, 3,
2224 MUIM_Set, MUIA_Window_Open, FALSE
2226 DoMethod
2228 mountbootgadgets.cancel,
2229 MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)mountbootgadgets.win, 3,
2230 MUIM_Set, MUIA_Window_Open, FALSE
2232 set(mainwin, MUIA_Window_Open, TRUE);
2233 return 0;
2236 void deinitGUI()
2238 D(bug("[HDToolBox] deinitGUI()\n"));
2240 if (app)
2241 MUI_DisposeObject(app);
2242 if (ptclass != NULL)
2243 FreeClass(ptclass);
2244 if (MUIMasterBase)
2245 CloseLibrary(MUIMasterBase);
2248 BOOL QuitGUI(ULONG *sigs)
2250 // moved debug from this place because it produces too much garbage
2252 if ((IPTR)DoMethod(app, MUIM_Application_NewInput, (IPTR)sigs) == MUIV_Application_ReturnID_Quit)
2254 D(bug("[HDToolBox] QuitGUI()\n"));
2255 return TRUE;
2257 return FALSE;