2 Copyright © 2003-2009, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
9 #include <aros/debug.h>
11 #include <proto/exec.h>
12 #include <proto/intuition.h>
13 #include <proto/muimaster.h>
14 #include <proto/workbench.h>
15 #include <proto/dos.h>
16 #include <proto/alib.h>
17 #include <proto/icon.h>
20 #include <dos/datetime.h>
21 #include <exec/memory.h>
22 #include <libraries/asl.h>
23 #include <libraries/commodities.h>
24 #include <libraries/mui.h>
25 #include <workbench/startup.h>
26 #include <workbench/workbench.h>
27 #include <workbench/icon.h>
28 #include <devices/inputevent.h>
30 #include <mui/TextEditor_mcc.h>
31 #include <zune/iconimage.h>
39 #define RETURNID_SLEEP 1
40 #define RETURNID_WAKE 2
41 #define RETURNID_ABOUT 3
42 #define RETURNID_NEWKEY 4
43 #define RETURNID_DELKEY 5
44 #define RETURNID_LVACK 6
45 #define RETURNID_STRINGACK 7
46 #define RETURNID_SAVE 8
47 #define RETURNID_TOOLACK 9
48 #define RETURNID_STACKACK 10
49 #define RETURNID_COMMENTACK 11
50 #define RETURNID_VERSION 12
52 #define MAX_PATH_LEN 1024
53 #define MAX_TOOLTYPE_LINE 256
54 #define BUFFERSIZE 1024
56 #define USE_TEXTEDITOR 1
58 static Object
*window
, *commentspace
, *filename_string
, *stackspace
, *savebutton
;
60 static Object
*editor
, *slider
;
62 static Object
*list
, *editor
, *liststr
;
65 BOOL file_altered
= FALSE
;
66 BOOL icon_altered
= FALSE
;
68 UBYTE
**BuildToolTypes(UBYTE
**src_ttypes
)
71 APTR pool
= CreatePool(MEMF_CLEAR
, 200, 200);
72 STRPTR contents
, sp
, *dst_ttypes
;
75 if (!pool
) return NULL
;
76 contents
= (STRPTR
)DoMethod(editor
, MUIM_TextEditor_ExportText
);
78 if (!contents
|| !contents
[0])
86 while((sp
= strchr(sp
, '\n')))
92 dst_ttypes
= AllocPooled(pool
, (lines
+ 3) * sizeof(STRPTR
));
100 *dst_ttypes
++ = (STRPTR
)pool
;
101 *dst_ttypes
++ = (STRPTR
)contents
;
103 for(sp
= contents
, lines
= 0; sp
; lines
++)
105 dst_ttypes
[lines
] = sp
;
106 sp
= strchr(sp
, '\n');
112 dst_ttypes
[lines
] = 0;
116 APTR pool
= CreatePool(MEMF_CLEAR
, 200, 200);
117 Object
*listobj
= list
;
118 WORD list_index
= 0, num_ttypes
= 0, alloc_ttypes
= 10;
121 if (!pool
) return NULL
;
123 dst_ttypes
= AllocPooled(pool
, (alloc_ttypes
+ 2) * sizeof(UBYTE
*));
130 get(listobj
, MUIA_List_Entries
, &list_index
);
131 while(num_ttypes
<list_index
)
134 DoMethod(listobj
, MUIM_List_GetEntry
, num_ttypes
, (IPTR
)&text
);
135 if (num_ttypes
>= alloc_ttypes
)
137 UBYTE
**new_dst_ttypes
= AllocPooled(pool
, (alloc_ttypes
+ 10 + 2) * sizeof(UBYTE
*));
143 CopyMem(dst_ttypes
+ 1, new_dst_ttypes
+ 1, alloc_ttypes
* sizeof(UBYTE
*));
144 dst_ttypes
= new_dst_ttypes
;
147 dst_ttypes
[num_ttypes
+ 1] = AllocPooled(pool
, strlen(text
) + 1);
148 if (!dst_ttypes
[num_ttypes
+ 1])
153 CopyMem(text
, dst_ttypes
[num_ttypes
+ 1], strlen(text
) + 1);
154 D(bug("[WBInfo] tooltype #%ld %s\n", num_ttypes
+ 1, text
));
157 dst_ttypes
[0] = (APTR
)pool
;
158 return dst_ttypes
+ 1;
162 void FreeToolTypes(UBYTE
**ttypes
)
167 DeletePool((APTR
)ttypes
[-2]);
168 FreeVec((APTR
)ttypes
[-1]);
173 DeletePool((APTR
)ttypes
[-1]);
178 void SaveIcon(struct DiskObject
*icon
, STRPTR name
, BPTR cd
)
180 STRPTR tool
= NULL
, stack
= NULL
;
183 UBYTE
**ttypes
= NULL
, **old_ttypes
= NULL
;
185 restored_cd
= CurrentDir(cd
);
187 switch(icon
->do_Type
)
190 get(filename_string
, MUIA_String_Contents
, &tool
);
191 icon
->do_DefaultTool
= tool
;
194 get(stackspace
, MUIA_String_Contents
, &stack
);
196 icon
->do_StackSize
= ls
;
200 old_ttypes
= (UBYTE
**)icon
->do_ToolTypes
;
201 ttypes
= BuildToolTypes(old_ttypes
);
202 icon
->do_ToolTypes
= ttypes
;
204 PutIconTags(name
, icon
, TAG_DONE
);
206 icon
->do_ToolTypes
= old_ttypes
;
209 FreeToolTypes(ttypes
);
211 CurrentDir(restored_cd
);
212 icon_altered
= FALSE
;
215 void SaveFile(struct AnchorPath
* ap
, BPTR cd
)
219 restored_cd
= CurrentDir(cd
);
220 get(commentspace
, MUIA_String_Contents
, &text
);
222 SetComment(ap
->ap_Buf
, text
);
223 CurrentDir(restored_cd
);
224 file_altered
= FALSE
;
228 void ListToString(void)
231 DoMethod(list
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
) &text
);
234 set(liststr
, MUIA_String_Contents
, text
);
235 nnset(liststr
, MUIA_Disabled
, FALSE
);
236 set(window
, MUIA_Window_ActiveObject
, (IPTR
)liststr
);
240 void StringToKey(void)
247 DoMethod(list
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
) &text
);
250 get(liststr
, MUIA_String_Contents
, &input
);
251 DoMethod(list
, MUIM_List_InsertSingle
, input
, MUIV_List_Insert_Active
);
252 set(list
, MUIA_List_Active
, MUIV_List_Active_Down
);
253 DoMethod(list
, MUIM_List_Remove
, MUIV_List_Remove_Active
);
254 nnset(liststr
, MUIA_String_Contents
, (IPTR
) "");
255 nnset(liststr
, MUIA_Disabled
, TRUE
);
256 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
262 nnset(liststr
, MUIA_String_Contents
, "");
263 nnset(liststr
, MUIA_Disabled
, FALSE
);
264 DoMethod(list
, MUIM_List_InsertSingle
, "", MUIV_List_Insert_Bottom
);
265 nnset(list
, MUIA_List_Active
, MUIV_List_Active_Bottom
);
266 set(window
, MUIA_Window_ActiveObject
, (IPTR
) liststr
);
272 DoMethod(list
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
)&text
);
276 DoMethod(list
, MUIM_List_Remove
, MUIV_List_Remove_Active
);
277 DoMethod(list
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
)&text
);
280 nnset(liststr
, MUIA_String_Contents
, (IPTR
) "");
281 nnset(liststr
, MUIA_Disabled
, TRUE
);
290 static char * GetVersion(STRPTR name
, BPTR cd
)
292 D(bug("[WBINFO/Getversion] Name %s\n", name
));
293 STRPTR commandline
= NULL
;
294 ULONG commandlineSize
;
295 static TEXT result
[100]; // must be static because we return its address
296 char *retval
= result
;
297 TEXT tmpfilename
[40];
301 BPTR restored_cd
= (BPTR
)-1;
305 D(bug("[WBINFO/Getversion] Name is Null\n"));
309 memset(result
, 0, sizeof(result
));
312 commandlineSize
= strlen(name
) + 20;
313 commandline
= AllocVec(commandlineSize
, MEMF_CLEAR
);
314 if (commandline
== NULL
)
316 D(bug("[WBInfo/GetVersion] Can't allocate RAM for commandline\n"));
320 restored_cd
= CurrentDir(cd
);
322 //search for non-existing temp file name
328 D(bug("[WBINFO/Getversion] Can't find non-existing tmpfile"));
331 sprintf(tmpfilename
, "t:tmp_version_%d", nr
);
332 output
= Open(tmpfilename
, MODE_OLDFILE
);
337 } while (output
!= NULL
);
339 D(bug("[WBInfo/Getversion] tmpfilename %s\n", tmpfilename
));
340 output
= Open(tmpfilename
, MODE_NEWFILE
);
343 D(bug("[WBInfo/Getversion] Can't create tmpfile\n"));
348 sprintf(commandline
, "c:version \"%s\" full", name
);
349 D(bug("[WBInfo/GetVersion] Commandline %s\n", commandline
));
350 if (SystemTags(commandline
,
352 SYS_Output
, (IPTR
) output
,
353 //SYS_Error, (IPTR) NULL,
357 D(bug("[WBInfo/Getversion] SystemTags failed\n"));
361 // Seek didn't work for me on RAM-Disk, so we reopen the file
363 output
= Open(tmpfilename
, MODE_OLDFILE
);
366 D(bug("[WBInfo/GetVersion] Can't open tmpfile\n"));
370 if (Read(output
, result
, sizeof(result
) - 1) == -1)
372 D(bug("[WBInfo/GetVersion] Can't read from tmpfile\n"));
375 D(bug("[WBInfo/GetVersion] Result %s\n", result
));
377 // remove illegal chars (e.g. newline) from result
378 for (i
= 0 ; result
[i
] != 0 ; i
++)
384 // set string pointer after program name
385 while (*retval
!= ' ')
389 FreeVec(commandline
);
393 DeleteFile(tmpfilename
);
395 if (restored_cd
!= (BPTR
)-1)
396 CurrentDir(restored_cd
);
401 int main(int argc
, char **argv
)
403 Object
*application
, *group
, *toolspace
=NULL
, *toollabel
=NULL
;
404 Object
*registergroup
=NULL
, *infomenu
=NULL
, *protectmenu
=NULL
, *toolmenu
=NULL
;
405 Object
*stacklabel
=NULL
, *drawerspace
=NULL
;
406 Object
*sizespace
=NULL
, *typespace
=NULL
, *quit
=NULL
, *aboutmenu
=NULL
;
407 Object
*datespace
=NULL
, *versionspace
=NULL
;
408 Object
*cancelbutton
=NULL
;
410 Object
*newkey
=NULL
, *delkey
=NULL
;
412 Object
*readobject
=NULL
, *writeobject
=NULL
, *executeobject
=NULL
, *deleteobject
=NULL
;
413 Object
*scriptobject
=NULL
, *pureobject
=NULL
, *archiveobject
=NULL
;
414 struct WBStartup
*startup
;
415 struct DiskObject
*icon
=NULL
;
416 struct AnchorPath
*ap
=NULL
;
417 struct DateStamp
*ds
=NULL
;
420 STRPTR name
=NULL
, type
=NULL
;
421 BPTR cd
, lock
, icon_cd
;
425 char deftool
[MAX_PATH_LEN
];
426 char comment
[MAXCOMMENTLENGTH
];
428 char date
[LEN_DATSTRING
];
429 char time
[LEN_DATSTRING
];
430 char dow
[LEN_DATSTRING
];
431 char datetime
[2*LEN_DATSTRING
];
432 UBYTE flags
[8], lname
[MAXFILENAMELENGTH
];
434 char *pages
[] = {_(MSG_INFORMATION
),_(MSG_PROTECTION
),_(MSG_TOOLTYPES
),NULL
};
439 _(MSG_DRAWER
), /* 2 */
441 _(MSG_PROJECT
), /* 4 */
442 _(MSG_GARBAGE
), /* 5 */
443 _(MSG_DEVICE
), /* 6 */
445 _(MSG_APPICON
) /* 8 */
450 /* start from wanderer only */
451 PrintFault(ERROR_FILE_NOT_OBJECT
, argv
[0]);
455 startup
= (struct WBStartup
*) argv
;
457 if (startup
->sm_NumArgs
< 2)
459 /* need atleast 1 arg */
460 PrintFault(ERROR_REQUIRED_ARG_MISSING
, argv
[0]);
461 D(bug("[WBInfo] required arg missing\n"));
465 lock
= startup
->sm_ArgList
[1].wa_Lock
;
466 NameFromLock(lock
, lname
, MAXFILENAMELENGTH
);
467 D(bug("[WBInfo] name from lock: %s\n",lname
));
468 name
= startup
->sm_ArgList
[1].wa_Name
;
469 cd
= CurrentDir(lock
);
472 /* directory not found*/
473 PrintFault(ERROR_DIR_NOT_FOUND
, argv
[0]);
474 D(bug("[WBInfo] dir not found\n"));
478 ap
= AllocVec(sizeof(struct AnchorPath
) + MAX_PATH_LEN
, MEMF_CLEAR
);
481 PrintFault(ERROR_NO_FREE_STORE
, argv
[0]);
482 D(bug("[WBInfo] no free store\n"));
486 ap
->ap_Strlen
= MAX_PATH_LEN
;
488 if (0 != MatchFirst(name
, ap
))
490 D(bug("[WBInfo] pass to diskinfo\n"));
492 "WANDERER:Tools/DiskInfo",
493 WBOPENA_ArgLock
, (IPTR
) startup
->sm_ArgList
[1].wa_Lock
,
494 WBOPENA_ArgName
, (IPTR
) startup
->sm_ArgList
[1].wa_Name
,
500 ap
->ap_BreakBits
= SIGBREAKF_CTRL_C
;
502 if (!(ap
->ap_Flags
& APF_DIDDIR
))
504 D(bug("[WBInfo] scan file\n"));
506 sprintf(comment
,"%s",ap
->ap_Info
.fib_Comment
);
508 /* fill date and time */
509 ds
= &ap
->ap_Info
.fib_Date
;
510 DateStamp((struct DateStamp
*)&dt
);
511 CopyMem(ds
, &dt
.dat_Stamp
, sizeof(struct DateStamp
));
512 dt
.dat_Format
= FORMAT_DOS
;
515 dt
.dat_StrDate
= date
;
516 dt
.dat_StrTime
= time
;
517 dte
= DateToStr(&dt
);
518 sprintf(datetime
, "%s %s", time
, date
);
521 sprintf(size
, "%d", ap
->ap_Info
.fib_Size
);
523 /* fill protection */
524 protection
= ap
->ap_Info
.fib_Protection
;
526 /* Convert the protection bits to a boolean */
527 flags
[0] = protection
& FIBF_SCRIPT
? 1 : 0; /* s */
528 flags
[1] = protection
& FIBF_PURE
? 1 : 0; /* p */
529 flags
[2] = protection
& FIBF_ARCHIVE
? 1 : 0; /* a */
531 /* The following flags are high-active! */
532 flags
[3] = protection
& FIBF_READ
? 0 : 1; /* r */
533 flags
[4] = protection
& FIBF_WRITE
? 0 : 1; /* w */
534 flags
[5] = protection
& FIBF_EXECUTE
? 0 : 1; /* e */
535 flags
[6] = protection
& FIBF_DELETE
? 0 : 1; /* d */
536 flags
[7] = 0x00; /* h */
541 icon
= GetIconTags(name
,
542 ICONGETA_FailIfUnavailable
, FALSE
,
543 ICONGETA_IsDefaultIcon
, FALSE
,
548 D(bug("[WBInfo] file has icon\n"));
549 type
= (char *) typeNames
[icon
->do_Type
];
550 D(bug("[WBInfo] icon type is: %s\n", type
));
551 sprintf(stack
, "%d", icon
->do_StackSize
);
552 if (icon
->do_DefaultTool
)
553 sprintf(deftool
, "%s", icon
->do_DefaultTool
);
558 PrintFault(ERROR_OBJECT_WRONG_TYPE
, argv
[0]);
562 if (icon
->do_Type
== 2)
564 sizespace
= (Object
*)TextObject
,
566 MUIA_Background
, MUII_TextBack
,
567 MUIA_Text_PreParse
, (IPTR
) "\33r",
568 MUIA_Text_Contents
, (IPTR
) NULL
,
569 MUIA_Text_Contents
, (IPTR
) "?",
570 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
575 sizespace
= (Object
*)TextObject
,
577 MUIA_Background
, MUII_TextBack
,
578 MUIA_Text_PreParse
, (IPTR
) "\33r",
579 MUIA_Text_Contents
, (IPTR
) size
,
583 application
= (Object
*)ApplicationObject
,
584 MUIA_Application_Title
, __(MSG_TITLE
),
585 MUIA_Application_Version
, (IPTR
) "$VER: Info 0.3 ("ADATE
") © AROS Dev Team",
586 MUIA_Application_Description
, __(MSG_DESCRIPTION
),
587 MUIA_Application_Base
, (IPTR
) "INFO",
588 MUIA_Application_Menustrip
, (IPTR
) MenuitemObject
,
589 MUIA_Family_Child
, (IPTR
) MenuitemObject
,
590 MUIA_Menuitem_Title
, __(MSG_PROJECT
),
591 MUIA_Family_Child
, (IPTR
)(infomenu
= (Object
*)MenuitemObject
, MUIA_Menuitem_Title
,
592 __(MSG_INFORMATION
), MUIA_Menuitem_Shortcut
, (IPTR
) "I", End
),
593 MUIA_Family_Child
, (IPTR
)(protectmenu
= (Object
*)MenuitemObject
, MUIA_Menuitem_Title
,
594 __(MSG_PROTECTION
),MUIA_Menuitem_Shortcut
, (IPTR
) "P", End
),
595 MUIA_Family_Child
, (IPTR
)(toolmenu
= (Object
*)MenuitemObject
, MUIA_Menuitem_Title
,
596 __(MSG_TOOLTYPES
),MUIA_Menuitem_Shortcut
, (IPTR
) "T", End
),
597 MUIA_Family_Child
, (IPTR
) MenuitemObject
, MUIA_Menuitem_Title
, ~0, End
,
598 MUIA_Family_Child
, (IPTR
) (aboutmenu
= (Object
*)MenuitemObject
, MUIA_Menuitem_Title
,
599 __(MSG_ABOUT
), (IPTR
) MUIA_Menuitem_Shortcut
, (IPTR
) "?", End
),
600 MUIA_Family_Child
, (IPTR
) MenuitemObject
, MUIA_Menuitem_Title
, ~0, End
,
601 MUIA_Family_Child
, (IPTR
) (quit
= (Object
*)MenuitemObject
, MUIA_Menuitem_Title
,
602 __(MSG_QUIT
), MUIA_Menuitem_Shortcut
, (IPTR
) "Q", End
),
605 SubWindow
, (IPTR
) (window
= (Object
*)WindowObject
,
606 MUIA_Window_Title
, (IPTR
) __(MSG_ICON
),
607 MUIA_Window_ID
, MAKE_ID('I','N','F','O'),
608 MUIA_Window_Activate
, TRUE
,
609 WindowContents
, (IPTR
) VGroup
,
610 Child
, (IPTR
) HGroup
,
611 Child
, (IPTR
) VGroup
,
612 Child
, (IPTR
) IconImageObject
,
613 MUIA_InputMode
, MUIV_InputMode_Toggle
,
614 MUIA_IconImage_File
, (IPTR
) name
,
617 Child
, (IPTR
) VGroup
,
618 Child
, (IPTR
) TextObject
,
620 MUIA_Background
, MUII_TextBack
,
621 MUIA_Text_PreParse
, (IPTR
) "\33l",
622 MUIA_Text_Contents
, (IPTR
) FilePart(name
),
626 Child
, (IPTR
) (registergroup
= RegisterGroup(pages
),
628 Child
, (IPTR
) HGroup
, /* hgroup information pannel */
629 Child
, (IPTR
) VGroup
,
630 Child
, (IPTR
) HGroup
,
631 Child
, (IPTR
) ColGroup(2),
632 Child
, (IPTR
) Label2(__(MSG_TYPE
)),
633 Child
, (IPTR
) (typespace
= (Object
*)TextObject
,
635 MUIA_Background
, MUII_TextBack
,
636 MUIA_Text_PreParse
, (IPTR
) "\33r",
637 MUIA_Text_Contents
, (IPTR
) type
,
639 Child
, (IPTR
) Label2(__(MSG_DATE
)),
640 Child
, (IPTR
) (datespace
= (Object
*)TextObject
,
642 MUIA_Background
, MUII_TextBack
,
643 MUIA_Text_PreParse
, (IPTR
) "\33r",
644 MUIA_Text_Contents
, (IPTR
) datetime
,
646 Child
, (IPTR
) Label2(__(MSG_VERSION
)),
647 Child
, (IPTR
) (versionspace
= (Object
*)TextObject
,
649 MUIA_Background
, MUII_TextBack
,
650 MUIA_Text_PreParse
, (IPTR
) "\33r",
651 MUIA_Text_Contents
, (IPTR
) NULL
,
652 MUIA_Text_Contents
, (IPTR
) "?",
653 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
655 Child
, (IPTR
) Label2(__(MSG_SIZE
)),
656 Child
, (IPTR
) sizespace
,
659 Child
, (IPTR
) HVSpace
,
660 Child
, (IPTR
) (group
= (Object
*)HGroup
,
662 Child
, (IPTR
) HGroup
,
663 Child
, (IPTR
) Label2(__(MSG_COMMENT
)),
664 Child
, (IPTR
) (commentspace
= (Object
*)StringObject
,
670 End
, /* end hgroup information pannel */
671 Child
, (IPTR
) HGroup
, /* hgroup protections pannel */
672 Child
, (IPTR
) VGroup
,
673 Child
, (IPTR
) ColGroup(2),
674 Child
, (IPTR
) HVSpace
,
675 Child
, (IPTR
) ColGroup(2),
676 Child
, (IPTR
) Label2(_(MSG_READ
)),
677 Child
, (IPTR
) (readobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
678 Child
, (IPTR
) Label2(_(MSG_WRITE
)),
679 Child
, (IPTR
) (writeobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
680 Child
, (IPTR
) Label2(_(MSG_EXECUTE
)),
681 Child
, (IPTR
) (executeobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
682 Child
, (IPTR
) Label2(_(MSG_DELETE
)),
683 Child
, (IPTR
) (deleteobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
684 Child
, (IPTR
) Label2(_(MSG_SCRIPT
)),
685 Child
, (IPTR
) (scriptobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
686 Child
, (IPTR
) Label2(_(MSG_PURE
)),
687 Child
, (IPTR
) (pureobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
688 Child
, (IPTR
) Label2(_(MSG_ARCHIVED
)),
689 Child
, (IPTR
) (archiveobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
693 End
, /* end hgroup protections pannel */
694 Child
, (IPTR
) HGroup
, /* hgroup tooltypes pannel */
695 Child
, (IPTR
) VGroup
,
696 Child
, (IPTR
) HGroup
,
697 Child
, (IPTR
) VGroup
,
700 Child
, (IPTR
) ListviewObject
,
701 MUIA_Listview_List
, (IPTR
) (list
= ListObject
,
703 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
704 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
705 MUIA_List_AutoVisible
, TRUE
,
708 Child
, (IPTR
) (liststr
= StringObject
,
713 Child
, (IPTR
) HGroup
,
715 Child
, (IPTR
) (editor
= MUI_NewObject(MUIC_TextEditor
,
717 Child
, (IPTR
) (slider
= (Object
*)ScrollbarObject
,
724 Child
, (IPTR
) HGroup
,
725 MUIA_Group_SameSize
, TRUE
,
726 Child
, (IPTR
) (newkey
= SimpleButton(__(MSG_NEW_KEY
))),
727 Child
, (IPTR
) (delkey
= SimpleButton(__(MSG_DELETE_KEY
))),
731 End
, /* end hgroup tooltypes pannel */
733 Child
, (IPTR
) HGroup
,
734 MUIA_Group_SameSize
, TRUE
,
735 Child
, (IPTR
) (savebutton
=
736 ImageButton(_(MSG_SAVE
),"THEME:Images/Gadgets/Prefs/Save")),
737 Child
, (IPTR
) (cancelbutton
=
738 ImageButton(_(MSG_CANCEL
),"THEME:Images/Gadgets/Prefs/Cancel")),
744 icon_cd
= CurrentDir(cd
);
746 if (application
!= NULL
)
751 set(liststr
, MUIA_String_AttachedList
, (IPTR
)list
);
755 DoMethod(aboutmenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
756 (IPTR
) application
, 2,
757 MUIM_Application_ReturnID
, RETURNID_ABOUT
);
758 DoMethod(infomenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
759 (IPTR
) registergroup
, 3, MUIM_Set
, MUIA_Group_ActivePage
, 0);
760 DoMethod(protectmenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
761 (IPTR
) registergroup
, 3, MUIM_Set
, MUIA_Group_ActivePage
, 1);
762 DoMethod(toolmenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
763 (IPTR
) registergroup
, 3, MUIM_Set
, MUIA_Group_ActivePage
, 2);
764 DoMethod(quit
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
765 (IPTR
) application
, 2, MUIM_Application_ReturnID
,
766 MUIV_Application_ReturnID_Quit
);
768 DoMethod(cancelbutton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
769 (IPTR
) application
, 2,
770 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
771 DoMethod(savebutton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
772 (IPTR
) application
, 2,
773 MUIM_Application_ReturnID
, RETURNID_SAVE
);
774 DoMethod(application
, MUIM_Notify
, MUIA_Application_Sleep
, FALSE
,
775 (IPTR
) application
, 2,
776 MUIM_Application_ReturnID
, RETURNID_WAKE
);
777 DoMethod(application
, MUIM_Notify
, MUIA_Application_Sleep
, TRUE
,
778 (IPTR
) application
, 2,
779 MUIM_Application_ReturnID
, RETURNID_SLEEP
);
780 DoMethod(window
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
781 (IPTR
) application
, 2, MUIM_Application_ReturnID
,
782 MUIV_Application_ReturnID_Quit
);
784 DoMethod(newkey
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
785 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_NEWKEY
);
786 DoMethod(delkey
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
787 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_DELKEY
);
788 DoMethod(list
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
,
789 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_LVACK
);
790 DoMethod(liststr
, MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
791 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_STRINGACK
);
793 DoMethod(commentspace
, MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
794 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_COMMENTACK
);
795 DoMethod(versionspace
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
796 (IPTR
) application
, 2,
797 MUIM_Application_ReturnID
, RETURNID_VERSION
);
800 set(editor
, MUIA_TextEditor_Slider
, slider
);
802 if (icon
->do_ToolTypes
)
804 char *tt
= NULL
, *contents
;
808 while ((tt
= icon
->do_ToolTypes
[i
]) != NULL
)
810 len
+= strlen(icon
->do_ToolTypes
[i
]) + 1;
814 contents
= AllocVec(len
+ 1, MEMF_ANY
);
821 while ((icon
->do_ToolTypes
[i
]) != NULL
)
825 strcat(contents
, "\n");
828 strcat(contents
, icon
->do_ToolTypes
[i
]);
833 set(editor
, MUIA_TextEditor_Contents
, contents
);
839 if (icon
->do_ToolTypes
)
843 while ((tt
= icon
->do_ToolTypes
[i
]) != NULL
)
845 DoMethod(list
, MUIM_List_InsertSingle
, tt
, MUIV_List_Insert_Bottom
);
851 switch(icon
->do_Type
)
854 toolspace
= MUI_NewObject(MUIC_Popasl
, ASLFR_DoSaveMode
, TRUE
,
855 MUIA_Popstring_String
,
856 filename_string
= MUI_MakeObject(MUIO_String
, NULL
, MAX_PATH_LEN
),
857 MUIA_Popstring_Button
, PopButton(MUII_PopFile
), TAG_DONE
);
858 toollabel
= MUI_MakeObject(MUIO_Label
, _(MSG_DEFTOOL
), NULL
);
859 if ((toolspace
!= NULL
)&&(toollabel
!= NULL
)&&(filename_string
!= NULL
))
861 DoMethod(group
, MUIM_Group_InitChange
);
862 DoMethod(group
, OM_ADDMEMBER
, toollabel
);
863 DoMethod(group
, OM_ADDMEMBER
, toolspace
);
864 DoMethod(group
, MUIM_Group_ExitChange
);
866 set(filename_string
, MUIA_String_Contents
, deftool
);
867 set(toolspace
, MUIA_CycleChain
, 1);
868 DoMethod(filename_string
, MUIM_Notify
,
869 MUIA_String_Acknowledge
, MUIV_EveryTime
,
870 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_TOOLACK
);
874 stackspace
= MUI_MakeObject(MUIO_String
, NULL
, 16);
875 stacklabel
= MUI_MakeObject(MUIO_Label
, _(MSG_STACK
), NULL
);
876 if ((stackspace
!= NULL
)&&(stacklabel
!=NULL
))
878 DoMethod(group
, MUIM_Group_InitChange
);
879 DoMethod(group
, OM_ADDMEMBER
, stacklabel
);
880 DoMethod(group
, OM_ADDMEMBER
, stackspace
);
881 DoMethod(group
, MUIM_Group_ExitChange
);
882 SetAttrs(stackspace
, MUIA_String_Contents
, stack
,
884 MUIA_String_Accept
, (IPTR
)"0123456789",TAG_DONE
);
885 DoMethod(stackspace
, MUIM_Notify
,
886 MUIA_String_Acknowledge
, MUIV_EveryTime
,
887 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_STACKACK
);
891 drawerspace
= MUI_NewObject(MUIC_Rectangle
, TAG_DONE
);
892 if ((drawerspace
!= NULL
))
894 DoMethod(group
, MUIM_Group_InitChange
);
895 DoMethod(group
, OM_ADDMEMBER
, drawerspace
);
896 DoMethod(group
, MUIM_Group_ExitChange
);
902 set(commentspace
, MUIA_String_Contents
, comment
);
904 set(readobject
, MUIA_Selected
, flags
[3]);
905 set(writeobject
, MUIA_Selected
, flags
[4]);
906 set(executeobject
, MUIA_Selected
, flags
[5]);
907 set(deleteobject
, MUIA_Selected
, flags
[6]);
909 set(scriptobject
, MUIA_Selected
, flags
[0]);
910 set(pureobject
, MUIA_Selected
, flags
[1]);
911 set(archiveobject
, MUIA_Selected
, flags
[2]);
913 SetAttrs(window
, MUIA_Window_Open
, TRUE
, TAG_DONE
);
915 while (returnid
!= MUIV_Application_ReturnID_Quit
)
920 D(bug("[WBInfo] broker command received: %ld\n", returnid
));
925 set(window
, MUIA_Window_Open
, FALSE
);
926 set(window
, MUIA_Window_Activate
, TRUE
);
929 set(window
, MUIA_Window_Open
, TRUE
);
932 if (MUI_RequestA(application
,NULL
,0,
933 _(MSG_ABOUT
), _(MSG_OK
), _(MSG_COPYRIGHT
), NULL
))
936 case RETURNID_NEWKEY
:
939 case RETURNID_DELKEY
:
946 case RETURNID_STRINGACK
:
955 SaveIcon(icon
, name
, lock
);
958 DoMethod(application
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
960 case RETURNID_STACKACK
:
961 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
964 case RETURNID_TOOLACK
:
965 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
968 case RETURNID_COMMENTACK
:
969 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
972 case RETURNID_VERSION
:
973 set(versionspace
, MUIA_Text_Contents
, GetVersion(name
, lock
));
981 signals
= Wait(signals
| SIGBREAKF_CTRL_C
);
982 if(signals
& SIGBREAKF_CTRL_C
) break;
985 returnid
= ((LONG
) DoMethod(application
, MUIM_Application_NewInput
, (IPTR
) &signals
));
987 SetAttrs(window
, MUIA_Window_Open
, FALSE
, TAG_DONE
);
988 MUI_DisposeObject(application
);
990 PrintFault(ERROR_INVALID_RESIDENT_LIBRARY
, argv
[0]);
991 D(bug("[WBInfo: Couldn't create app\n"));
993 FreeDiskObject(icon
);