2 Copyright © 2003, 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 VERSION "$VER: Info 0.1 ("ADATE") © AROS Dev Team"
54 #define MAX_PATH_LEN 1024
55 #define MAX_TOOLTYPE_LINE 256
56 #define BUFFERSIZE 1024
58 #define USE_TEXTEDITOR 1
60 static Object
*window
, *commentspace
, *filename_string
, *stackspace
, *savebutton
;
62 static Object
*editor
, *slider
;
64 static Object
*list
, *editor
, *liststr
;
67 BOOL file_altered
= FALSE
;
68 BOOL icon_altered
= FALSE
;
70 UBYTE
**BuildToolTypes(UBYTE
**src_ttypes
)
73 APTR pool
= CreatePool(MEMF_CLEAR
, 200, 200);
74 STRPTR contents
, sp
, *dst_ttypes
;
77 if (!pool
) return NULL
;
78 contents
= (STRPTR
)DoMethod(editor
, MUIM_TextEditor_ExportText
);
80 if (!contents
|| !contents
[0])
88 while((sp
= strchr(sp
, '\n')))
94 dst_ttypes
= AllocPooled(pool
, (lines
+ 3) * sizeof(STRPTR
));
102 *dst_ttypes
++ = (STRPTR
)pool
;
103 *dst_ttypes
++ = (STRPTR
)contents
;
105 for(sp
= contents
, lines
= 0; sp
; lines
++)
107 dst_ttypes
[lines
] = sp
;
108 sp
= strchr(sp
, '\n');
115 dst_ttypes
[lines
] = 0;
118 dst_ttypes
[lines
] = 0;
122 APTR pool
= CreatePool(MEMF_CLEAR
, 200, 200);
123 Object
*listobj
= list
;
124 WORD list_index
= 0, num_ttypes
= 0, alloc_ttypes
= 10;
127 if (!pool
) return NULL
;
129 dst_ttypes
= AllocPooled(pool
, (alloc_ttypes
+ 2) * sizeof(UBYTE
*));
136 get(listobj
, MUIA_List_Entries
, &list_index
);
137 while(num_ttypes
<list_index
)
140 DoMethod(listobj
, MUIM_List_GetEntry
, num_ttypes
, (IPTR
)&text
);
141 if (num_ttypes
>= alloc_ttypes
)
143 UBYTE
**new_dst_ttypes
= AllocPooled(pool
, (alloc_ttypes
+ 10 + 2) * sizeof(UBYTE
*));
149 CopyMem(dst_ttypes
+ 1, new_dst_ttypes
+ 1, alloc_ttypes
* sizeof(UBYTE
*));
150 dst_ttypes
= new_dst_ttypes
;
153 dst_ttypes
[num_ttypes
+ 1] = AllocPooled(pool
, strlen(text
) + 1);
154 if (!dst_ttypes
[num_ttypes
+ 1])
159 CopyMem(text
, dst_ttypes
[num_ttypes
+ 1], strlen(text
) + 1);
160 D(bug("[WBInfo] tooltype #%ld %s\n", num_ttypes
+ 1, text
));
163 dst_ttypes
[0] = (APTR
)pool
;
164 return dst_ttypes
+ 1;
168 void FreeToolTypes(UBYTE
**ttypes
)
173 DeletePool((APTR
)ttypes
[-2]);
174 FreeVec((APTR
)ttypes
[-1]);
179 DeletePool((APTR
)ttypes
[-1]);
184 void SaveIcon(struct DiskObject
*icon
, STRPTR name
, BPTR cd
)
186 STRPTR tool
= NULL
, stack
= NULL
;
189 UBYTE
**ttypes
= NULL
, **old_ttypes
= NULL
;
191 restored_cd
= CurrentDir(cd
);
193 switch(icon
->do_Type
)
196 get(filename_string
, MUIA_String_Contents
, &tool
);
197 icon
->do_DefaultTool
= tool
;
200 get(stackspace
, MUIA_String_Contents
, &stack
);
202 icon
->do_StackSize
= ls
;
206 old_ttypes
= (UBYTE
**)icon
->do_ToolTypes
;
207 if ((ttypes
= BuildToolTypes(old_ttypes
)))
209 icon
->do_ToolTypes
= ttypes
;
211 PutIconTags(name
, icon
, TAG_DONE
);
214 icon
->do_ToolTypes
= old_ttypes
;
215 FreeToolTypes(ttypes
);
217 CurrentDir(restored_cd
);
218 icon_altered
= FALSE
;
221 void SaveFile(struct AnchorPath
* ap
, BPTR cd
)
225 restored_cd
= CurrentDir(cd
);
226 get(commentspace
, MUIA_String_Contents
, &text
);
228 SetComment(ap
->ap_Buf
, text
);
229 CurrentDir(restored_cd
);
230 file_altered
= FALSE
;
234 void ListToString(void)
237 DoMethod(list
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
) &text
);
240 set(liststr
, MUIA_String_Contents
, text
);
241 nnset(liststr
, MUIA_Disabled
, FALSE
);
242 set(window
, MUIA_Window_ActiveObject
, (IPTR
)liststr
);
246 void StringToKey(void)
253 DoMethod(list
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
) &text
);
256 get(liststr
, MUIA_String_Contents
, &input
);
257 DoMethod(list
, MUIM_List_InsertSingle
, input
, MUIV_List_Insert_Active
);
258 set(list
, MUIA_List_Active
, MUIV_List_Active_Down
);
259 DoMethod(list
, MUIM_List_Remove
, MUIV_List_Remove_Active
);
260 nnset(liststr
, MUIA_String_Contents
, (IPTR
) "");
261 nnset(liststr
, MUIA_Disabled
, TRUE
);
262 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
268 nnset(liststr
, MUIA_String_Contents
, "");
269 nnset(liststr
, MUIA_Disabled
, FALSE
);
270 DoMethod(list
, MUIM_List_InsertSingle
, "", MUIV_List_Insert_Bottom
);
271 nnset(list
, MUIA_List_Active
, MUIV_List_Active_Bottom
);
272 set(window
, MUIA_Window_ActiveObject
, (IPTR
) liststr
);
278 DoMethod(list
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
)&text
);
282 DoMethod(list
, MUIM_List_Remove
, MUIV_List_Remove_Active
);
283 DoMethod(list
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
)&text
);
286 nnset(liststr
, MUIA_String_Contents
, (IPTR
) "");
287 nnset(liststr
, MUIA_Disabled
, TRUE
);
296 static char * GetVersion(STRPTR name
, BPTR cd
)
298 D(bug("[WBINFO/Getversion] Name %s\n", name
));
299 STRPTR commandline
= NULL
;
300 ULONG commandlineSize
;
301 static TEXT result
[100]; // must be static because we return its address
302 char *retval
= result
;
303 TEXT tmpfilename
[40];
307 BPTR restored_cd
= (BPTR
)-1;
311 D(bug("[WBINFO/Getversion] Name is Null\n"));
315 memset(result
, 0, sizeof(result
));
318 commandlineSize
= strlen(name
) + 20;
319 commandline
= AllocVec(commandlineSize
, MEMF_CLEAR
);
320 if (commandline
== NULL
)
322 D(bug("[WBInfo/GetVersion] Can't allocate RAM for commandline\n"));
326 restored_cd
= CurrentDir(cd
);
328 //search for non-existing temp file name
334 D(bug("[WBINFO/Getversion] Can't find non-existing tmpfile"));
337 sprintf(tmpfilename
, "t:tmp_version_%d", nr
);
338 output
= Open(tmpfilename
, MODE_OLDFILE
);
343 } while (output
!= NULL
);
345 D(bug("[WBInfo/Getversion] tmpfilename %s\n", tmpfilename
));
346 output
= Open(tmpfilename
, MODE_NEWFILE
);
349 D(bug("[WBInfo/Getversion] Can't create tmpfile\n"));
354 sprintf(commandline
, "c:version \"%s\" full", name
);
355 D(bug("[WBInfo/GetVersion] Commandline %s\n", commandline
));
356 if (SystemTags(commandline
,
358 SYS_Output
, (IPTR
) output
,
359 //SYS_Error, (IPTR) NULL,
363 D(bug("[WBInfo/Getversion] SystemTags failed\n"));
367 // Seek didn't work for me on RAM-Disk, so we reopen the file
369 output
= Open(tmpfilename
, MODE_OLDFILE
);
372 D(bug("[WBInfo/GetVersion] Can't open tmpfile\n"));
376 if (Read(output
, result
, sizeof(result
) - 1) == -1)
378 D(bug("[WBInfo/GetVersion] Can't read from tmpfile\n"));
381 D(bug("[WBInfo/GetVersion] Result %s\n", result
));
383 // remove illegal chars (e.g. newline) from result
384 for (i
= 0 ; result
[i
] != 0 ; i
++)
390 // set string pointer after program name
391 while (*retval
!= ' ')
395 FreeVec(commandline
);
399 DeleteFile(tmpfilename
);
401 if (restored_cd
!= (BPTR
)-1)
402 CurrentDir(restored_cd
);
407 int main(int argc
, char **argv
)
409 Object
*application
, *group
, *toolspace
=NULL
, *toollabel
=NULL
;
410 Object
*registergroup
=NULL
, *infomenu
=NULL
, *protectmenu
=NULL
, *toolmenu
=NULL
;
411 Object
*stacklabel
=NULL
, *drawerspace
=NULL
;
412 Object
*sizespace
=NULL
, *typespace
=NULL
, *quit
=NULL
, *aboutmenu
=NULL
;
413 Object
*datespace
=NULL
, *versionspace
=NULL
;
414 Object
*cancelbutton
=NULL
;
416 Object
*newkey
=NULL
, *delkey
=NULL
;
418 Object
*readobject
=NULL
, *writeobject
=NULL
, *executeobject
=NULL
, *deleteobject
=NULL
;
419 Object
*scriptobject
=NULL
, *pureobject
=NULL
, *archiveobject
=NULL
;
420 struct WBStartup
*startup
;
421 struct DiskObject
*icon
=NULL
;
422 struct AnchorPath
*ap
=NULL
;
423 struct DateStamp
*ds
=NULL
;
426 STRPTR name
=NULL
, type
=NULL
;
427 BPTR cd
, lock
, icon_cd
;
431 char deftool
[MAX_PATH_LEN
];
432 char comment
[MAXCOMMENTLENGTH
];
434 char date
[LEN_DATSTRING
];
435 char time
[LEN_DATSTRING
];
436 char dow
[LEN_DATSTRING
];
437 char datetime
[2*LEN_DATSTRING
];
438 UBYTE flags
[8], lname
[MAXFILENAMELENGTH
];
440 char *pages
[] = {_(MSG_INFORMATION
),_(MSG_PROTECTION
),_(MSG_TOOLTYPES
),NULL
};
445 _(MSG_DRAWER
), /* 2 */
447 _(MSG_PROJECT
), /* 4 */
448 _(MSG_GARBAGE
), /* 5 */
449 _(MSG_DEVICE
), /* 6 */
451 _(MSG_APPICON
) /* 8 */
456 /* start from wanderer only */
457 PrintFault(ERROR_FILE_NOT_OBJECT
, argv
[0]);
461 startup
= (struct WBStartup
*) argv
;
463 if (startup
->sm_NumArgs
< 2)
465 /* need atleast 1 arg */
466 PrintFault(ERROR_REQUIRED_ARG_MISSING
, argv
[0]);
467 D(bug("[WBInfo] required arg missing\n"));
471 lock
= startup
->sm_ArgList
[1].wa_Lock
;
472 NameFromLock(lock
, lname
, MAXFILENAMELENGTH
);
473 D(bug("[WBInfo] name from lock: %s\n",lname
));
474 name
= startup
->sm_ArgList
[1].wa_Name
;
475 cd
= CurrentDir(lock
);
478 /* directory not found*/
479 PrintFault(ERROR_DIR_NOT_FOUND
, argv
[0]);
480 D(bug("[WBInfo] dir not found\n"));
484 ap
= AllocVec(sizeof(struct AnchorPath
) + MAX_PATH_LEN
, MEMF_CLEAR
);
487 PrintFault(ERROR_NO_FREE_STORE
, argv
[0]);
488 D(bug("[WBInfo] no free store\n"));
492 ap
->ap_Strlen
= MAX_PATH_LEN
;
494 if (0 != MatchFirst(name
, ap
))
496 D(bug("[WBInfo] pass to diskinfo\n"));
498 "WANDERER:Tools/DiskInfo",
499 WBOPENA_ArgLock
, (IPTR
) startup
->sm_ArgList
[1].wa_Lock
,
500 WBOPENA_ArgName
, (IPTR
) startup
->sm_ArgList
[1].wa_Name
,
506 ap
->ap_BreakBits
= SIGBREAKF_CTRL_C
;
508 if (!(ap
->ap_Flags
& APF_DIDDIR
))
510 D(bug("[WBInfo] scan file\n"));
512 sprintf(comment
,"%s",ap
->ap_Info
.fib_Comment
);
514 /* fill date and time */
515 ds
= &ap
->ap_Info
.fib_Date
;
516 DateStamp((struct DateStamp
*)&dt
);
517 CopyMem(ds
, &dt
.dat_Stamp
, sizeof(struct DateStamp
));
518 dt
.dat_Format
= FORMAT_DOS
;
521 dt
.dat_StrDate
= date
;
522 dt
.dat_StrTime
= time
;
523 dte
= DateToStr(&dt
);
524 sprintf(datetime
, "%s %s", time
, date
);
527 sprintf(size
, "%ld", ap
->ap_Info
.fib_Size
);
529 /* fill protection */
530 protection
= ap
->ap_Info
.fib_Protection
;
532 /* Convert the protection bits to a boolean */
533 flags
[0] = protection
& FIBF_SCRIPT
? 1 : 0; /* s */
534 flags
[1] = protection
& FIBF_PURE
? 1 : 0; /* p */
535 flags
[2] = protection
& FIBF_ARCHIVE
? 1 : 0; /* a */
537 /* The following flags are high-active! */
538 flags
[3] = protection
& FIBF_READ
? 0 : 1; /* r */
539 flags
[4] = protection
& FIBF_WRITE
? 0 : 1; /* w */
540 flags
[5] = protection
& FIBF_EXECUTE
? 0 : 1; /* e */
541 flags
[6] = protection
& FIBF_DELETE
? 0 : 1; /* d */
542 flags
[7] = 0x00; /* h */
547 icon
= GetIconTags(name
,
548 ICONGETA_FailIfUnavailable
, FALSE
,
549 ICONGETA_IsDefaultIcon
, FALSE
,
554 D(bug("[WBInfo] file has icon\n"));
555 type
= (char *) typeNames
[icon
->do_Type
];
556 D(bug("[WBInfo] icon type is: %s\n", type
));
557 sprintf(stack
, "%ld", icon
->do_StackSize
);
558 if (icon
->do_DefaultTool
)
559 sprintf(deftool
, "%s", icon
->do_DefaultTool
);
564 PrintFault(ERROR_OBJECT_WRONG_TYPE
, argv
[0]);
568 application
= ApplicationObject
,
569 MUIA_Application_Title
, __(MSG_TITLE
),
570 MUIA_Application_Version
, (IPTR
) "$VER: Info 0.2 ("ADATE
") © AROS Dev Team",
571 MUIA_Application_Description
, __(MSG_DESCRIPTION
),
572 MUIA_Application_Base
, (IPTR
) "INFO",
573 MUIA_Application_Menustrip
, (IPTR
) MenuitemObject
,
574 MUIA_Family_Child
, (IPTR
) MenuitemObject
,
575 MUIA_Menuitem_Title
, __(MSG_PROJECT
),
576 MUIA_Family_Child
, (IPTR
)(infomenu
= MenuitemObject
, MUIA_Menuitem_Title
,
577 __(MSG_INFORMATION
), MUIA_Menuitem_Shortcut
, (IPTR
) "I", End
),
578 MUIA_Family_Child
, (IPTR
)(protectmenu
= MenuitemObject
, MUIA_Menuitem_Title
,
579 __(MSG_PROTECTION
),MUIA_Menuitem_Shortcut
, (IPTR
) "P", End
),
580 MUIA_Family_Child
, (IPTR
)(toolmenu
= MenuitemObject
, MUIA_Menuitem_Title
,
581 __(MSG_TOOLTYPES
),MUIA_Menuitem_Shortcut
, (IPTR
) "T", End
),
582 MUIA_Family_Child
, (IPTR
) MenuitemObject
, MUIA_Menuitem_Title
, ~0, End
,
583 MUIA_Family_Child
, (IPTR
) (aboutmenu
= MenuitemObject
, MUIA_Menuitem_Title
,
584 __(MSG_ABOUT
), (IPTR
) MUIA_Menuitem_Shortcut
, (IPTR
) "?", End
),
585 MUIA_Family_Child
, (IPTR
) MenuitemObject
, MUIA_Menuitem_Title
, ~0, End
,
586 MUIA_Family_Child
, (IPTR
) (quit
= MenuitemObject
, MUIA_Menuitem_Title
,
587 __(MSG_QUIT
), MUIA_Menuitem_Shortcut
, (IPTR
) "Q", End
),
590 SubWindow
, (IPTR
) (window
= WindowObject
,
591 MUIA_Window_Title
, (IPTR
) __(MSG_ICON
),
592 MUIA_Window_ID
, MAKE_ID('I','N','F','O'),
593 MUIA_Window_Activate
, TRUE
,
594 WindowContents
, (IPTR
) VGroup
,
595 Child
, (IPTR
) HGroup
,
596 Child
, (IPTR
) VGroup
,
597 Child
, (IPTR
) IconImageObject
,
598 MUIA_InputMode
, MUIV_InputMode_Toggle
,
599 MUIA_IconImage_File
, (IPTR
) name
,
602 Child
, (IPTR
) VGroup
,
603 Child
, (IPTR
) TextObject
,
605 MUIA_Background
, MUII_TextBack
,
606 MUIA_Text_PreParse
, (IPTR
) "\33l",
607 MUIA_Text_Contents
, (IPTR
) FilePart(name
),
611 Child
, (IPTR
) RegisterGroup(pages
),
613 Child
, (IPTR
) HGroup
, /* hgroup information pannel */
614 Child
, (IPTR
) VGroup
,
615 Child
, (IPTR
) HGroup
,
616 Child
, (IPTR
) ColGroup(2),
617 Child
, (IPTR
) Label2(__(MSG_SIZE
)),
618 Child
, (IPTR
) (sizespace
= TextObject
,
620 MUIA_Background
, MUII_TextBack
,
621 MUIA_Text_PreParse
, (IPTR
) "\33r",
622 MUIA_Text_Contents
, (IPTR
) size
,
624 Child
, (IPTR
) Label2(__(MSG_DATE
)),
625 Child
, (IPTR
) (datespace
= TextObject
,
627 MUIA_Background
, MUII_TextBack
,
628 MUIA_Text_PreParse
, (IPTR
) "\33r",
629 MUIA_Text_Contents
, (IPTR
) datetime
,
631 Child
, (IPTR
) Label2(__(MSG_TYPE
)),
632 Child
, (IPTR
) (typespace
= TextObject
,
634 MUIA_Background
, MUII_TextBack
,
635 MUIA_Text_PreParse
, (IPTR
) "\33r",
636 MUIA_Text_Contents
, (IPTR
) type
,
638 Child
, (IPTR
) Label2(__(MSG_VERSION
)),
639 Child
, (IPTR
) (versionspace
= TextObject
,
641 MUIA_Background
, MUII_TextBack
,
642 MUIA_Text_PreParse
, (IPTR
) "\33r",
643 MUIA_Text_Contents
, (IPTR
) NULL
,
644 MUIA_Text_Contents
, (IPTR
) "?",
645 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
649 Child
, (IPTR
) HVSpace
,
650 Child
, (IPTR
) (group
= HGroup
,
652 Child
, (IPTR
) HGroup
,
653 Child
, (IPTR
) Label2(__(MSG_COMMENT
)),
654 Child
, (IPTR
) (commentspace
= StringObject
,
660 End
, /* end hgroup information pannel */
661 Child
, (IPTR
) HGroup
, /* hgroup protections pannel */
662 Child
, (IPTR
) VGroup
,
663 Child
, (IPTR
) ColGroup(2),
664 Child
, (IPTR
) HVSpace
,
665 Child
, (IPTR
) ColGroup(2),
666 Child
, (IPTR
) Label2(_(MSG_READ
)),
667 Child
, (IPTR
) (readobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
668 Child
, (IPTR
) Label2(_(MSG_WRITE
)),
669 Child
, (IPTR
) (writeobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
670 Child
, (IPTR
) Label2(_(MSG_EXECUTE
)),
671 Child
, (IPTR
) (executeobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
672 Child
, (IPTR
) Label2(_(MSG_DELETE
)),
673 Child
, (IPTR
) (deleteobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
674 Child
, (IPTR
) Label2(_(MSG_SCRIPT
)),
675 Child
, (IPTR
) (scriptobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
676 Child
, (IPTR
) Label2(_(MSG_PURE
)),
677 Child
, (IPTR
) (pureobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
678 Child
, (IPTR
) Label2(_(MSG_ARCHIVED
)),
679 Child
, (IPTR
) (archiveobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
683 End
, /* end hgroup protections pannel */
684 Child
, (IPTR
) HGroup
, /* hgroup tooltypes pannel */
685 Child
, (IPTR
) VGroup
,
686 Child
, (IPTR
) HGroup
,
687 Child
, (IPTR
) VGroup
,
690 Child
, (IPTR
) ListviewObject
,
691 MUIA_Listview_List
, (IPTR
) (list
= ListObject
,
693 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
694 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
695 MUIA_List_AutoVisible
, TRUE
,
698 Child
, (IPTR
) (liststr
= StringObject
,
703 Child
, (IPTR
) HGroup
,
705 Child
, (IPTR
) (editor
= MUI_NewObject(MUIC_TextEditor
,
707 Child
, (IPTR
) (slider
= ScrollbarObject
,
714 Child
, (IPTR
) HGroup
,
715 MUIA_Group_SameSize
, TRUE
,
716 Child
, (IPTR
) (newkey
= SimpleButton(__(MSG_NEW_KEY
))),
717 Child
, (IPTR
) (delkey
= SimpleButton(__(MSG_DELETE_KEY
))),
721 End
, /* end hgroup tooltypes pannel */
723 Child
, (IPTR
) HGroup
,
724 MUIA_Group_SameSize
, TRUE
,
725 Child
, (IPTR
) (savebutton
=
726 ImageButton(_(MSG_SAVE
),"THEME:Images/Gadgets/Prefs/Save")),
727 Child
, (IPTR
) (cancelbutton
=
728 ImageButton(_(MSG_CANCEL
),"THEME:Images/Gadgets/Prefs/Cancel")),
734 icon_cd
= CurrentDir(cd
);
736 if (application
!= NULL
)
741 set(liststr
, MUIA_String_AttachedList
, (IPTR
)list
);
745 DoMethod(aboutmenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
746 (IPTR
) application
, 2,
747 MUIM_Application_ReturnID
, RETURNID_ABOUT
);
748 DoMethod(infomenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
749 (IPTR
) registergroup
, 3, MUIM_Set
, MUIA_Group_ActivePage
, 0);
750 DoMethod(protectmenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
751 (IPTR
) registergroup
, 3, MUIM_Set
, MUIA_Group_ActivePage
, 1);
752 DoMethod(toolmenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
753 (IPTR
) registergroup
, 3, MUIM_Set
, MUIA_Group_ActivePage
, 2);
754 DoMethod(quit
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
755 (IPTR
) application
, 2, MUIM_Application_ReturnID
,
756 MUIV_Application_ReturnID_Quit
);
758 DoMethod(cancelbutton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
759 (IPTR
) application
, 2,
760 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
761 DoMethod(savebutton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
762 (IPTR
) application
, 2,
763 MUIM_Application_ReturnID
, RETURNID_SAVE
);
764 DoMethod(application
, MUIM_Notify
, MUIA_Application_Sleep
, FALSE
,
765 (IPTR
) application
, 2,
766 MUIM_Application_ReturnID
, RETURNID_WAKE
);
767 DoMethod(application
, MUIM_Notify
, MUIA_Application_Sleep
, TRUE
,
768 (IPTR
) application
, 2,
769 MUIM_Application_ReturnID
, RETURNID_SLEEP
);
770 DoMethod(window
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
771 (IPTR
) application
, 2, MUIM_Application_ReturnID
,
772 MUIV_Application_ReturnID_Quit
);
774 DoMethod(newkey
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
775 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_NEWKEY
);
776 DoMethod(delkey
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
777 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_DELKEY
);
778 DoMethod(list
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
,
779 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_LVACK
);
780 DoMethod(liststr
, MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
781 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_STRINGACK
);
783 DoMethod(commentspace
, MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
784 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_COMMENTACK
);
785 DoMethod(versionspace
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
786 (IPTR
) application
, 2,
787 MUIM_Application_ReturnID
, RETURNID_VERSION
);
790 set(editor
, MUIA_TextEditor_Slider
, slider
);
792 if (icon
->do_ToolTypes
)
794 char *tt
= NULL
, *contents
;
798 while ((tt
= icon
->do_ToolTypes
[i
]) != NULL
)
800 len
= len
+ strlen(icon
->do_ToolTypes
[i
]) + 1;
804 contents
= AllocVec(len
+ 1, MEMF_ANY
);
810 while ((tt
= icon
->do_ToolTypes
[i
]) != NULL
)
812 strcat(contents
, icon
->do_ToolTypes
[i
]);
813 strcat(contents
, "\n");
817 set(editor
, MUIA_TextEditor_Contents
, contents
);
823 if (icon
->do_ToolTypes
)
827 while ((tt
= icon
->do_ToolTypes
[i
]) != NULL
)
829 DoMethod(list
, MUIM_List_InsertSingle
, tt
, MUIV_List_Insert_Bottom
);
835 switch(icon
->do_Type
)
838 toolspace
= MUI_NewObject(MUIC_Popasl
, ASLFR_DoSaveMode
, TRUE
,
839 MUIA_Popstring_String
,
840 filename_string
= MUI_MakeObject(MUIO_String
, NULL
, MAX_PATH_LEN
),
841 MUIA_Popstring_Button
, PopButton(MUII_PopFile
), TAG_DONE
);
842 toollabel
= MUI_MakeObject(MUIO_Label
, _(MSG_DEFTOOL
), NULL
);
843 if ((toolspace
!= NULL
)&&(toollabel
!= NULL
)&&(filename_string
!= NULL
))
845 DoMethod(group
, MUIM_Group_InitChange
);
846 DoMethod(group
, OM_ADDMEMBER
, toollabel
);
847 DoMethod(group
, OM_ADDMEMBER
, toolspace
);
848 DoMethod(group
, MUIM_Group_ExitChange
);
850 set(filename_string
, MUIA_String_Contents
, deftool
);
851 set(toolspace
, MUIA_CycleChain
, 1);
852 DoMethod(filename_string
, MUIM_Notify
,
853 MUIA_String_Acknowledge
, MUIV_EveryTime
,
854 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_TOOLACK
);
858 stackspace
= MUI_MakeObject(MUIO_String
, NULL
, 16);
859 stacklabel
= MUI_MakeObject(MUIO_Label
, _(MSG_STACK
), NULL
);
860 if ((stackspace
!= NULL
)&&(stacklabel
!=NULL
))
862 DoMethod(group
, MUIM_Group_InitChange
);
863 DoMethod(group
, OM_ADDMEMBER
, stacklabel
);
864 DoMethod(group
, OM_ADDMEMBER
, stackspace
);
865 DoMethod(group
, MUIM_Group_ExitChange
);
866 SetAttrs(stackspace
, MUIA_String_Contents
, stack
,
868 MUIA_String_Accept
, (IPTR
)"0123456789",TAG_DONE
);
869 DoMethod(stackspace
, MUIM_Notify
,
870 MUIA_String_Acknowledge
, MUIV_EveryTime
,
871 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_STACKACK
);
875 drawerspace
= MUI_NewObject(MUIC_Rectangle
, TAG_DONE
);
876 if ((drawerspace
!= NULL
))
878 DoMethod(group
, MUIM_Group_InitChange
);
879 DoMethod(group
, OM_ADDMEMBER
, drawerspace
);
880 DoMethod(group
, MUIM_Group_ExitChange
);
886 set(commentspace
, MUIA_String_Contents
, comment
);
888 set(readobject
, MUIA_Selected
, flags
[3]);
889 set(writeobject
, MUIA_Selected
, flags
[4]);
890 set(executeobject
, MUIA_Selected
, flags
[5]);
891 set(deleteobject
, MUIA_Selected
, flags
[6]);
893 set(scriptobject
, MUIA_Selected
, flags
[0]);
894 set(pureobject
, MUIA_Selected
, flags
[1]);
895 set(archiveobject
, MUIA_Selected
, flags
[2]);
897 SetAttrs(window
, MUIA_Window_Open
, TRUE
, TAG_DONE
);
899 while (returnid
!= MUIV_Application_ReturnID_Quit
)
904 D(bug("[WBInfo] broker command received: %ld\n", returnid
));
909 set(window
, MUIA_Window_Open
, FALSE
);
910 set(window
, MUIA_Window_Activate
, TRUE
);
913 set(window
, MUIA_Window_Open
, TRUE
);
916 if (MUI_RequestA(application
,NULL
,0,
917 _(MSG_ABOUT
), _(MSG_OK
), _(MSG_COPYRIGHT
), NULL
))
920 case RETURNID_NEWKEY
:
923 case RETURNID_DELKEY
:
930 case RETURNID_STRINGACK
:
939 SaveIcon(icon
, name
, lock
);
942 DoMethod(application
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
944 case RETURNID_STACKACK
:
945 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
948 case RETURNID_TOOLACK
:
949 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
952 case RETURNID_COMMENTACK
:
953 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
956 case RETURNID_VERSION
:
957 set(versionspace
, MUIA_Text_Contents
, GetVersion(name
, lock
));
965 signals
= Wait(signals
| SIGBREAKF_CTRL_C
);
966 if(signals
& SIGBREAKF_CTRL_C
) break;
969 returnid
= ((LONG
) DoMethod(application
, MUIM_Application_NewInput
, (IPTR
) &signals
));
971 SetAttrs(window
, MUIA_Window_Open
, FALSE
, TAG_DONE
);
972 MUI_DisposeObject(application
);
974 PrintFault(ERROR_INVALID_RESIDENT_LIBRARY
, argv
[0]);
975 D(bug("[WBInfo: Couldn't create app\n"));
977 FreeDiskObject(icon
);