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
) sprintf(deftool
, "%s", icon
->do_DefaultTool
);
561 PrintFault(ERROR_OBJECT_WRONG_TYPE
, argv
[0]);
565 application
= ApplicationObject
,
566 MUIA_Application_Title
, __(MSG_TITLE
),
567 MUIA_Application_Version
, (IPTR
) "$VER: Info 0.2 ("ADATE
") © AROS Dev Team",
568 MUIA_Application_Description
, __(MSG_DESCRIPTION
),
569 MUIA_Application_Base
, (IPTR
) "INFO",
570 MUIA_Application_Menustrip
, (IPTR
) MenuitemObject
,
571 MUIA_Family_Child
, (IPTR
) MenuitemObject
,
572 MUIA_Menuitem_Title
, __(MSG_PROJECT
),
573 MUIA_Family_Child
, (IPTR
)(infomenu
= MenuitemObject
, MUIA_Menuitem_Title
,
574 __(MSG_INFORMATION
), MUIA_Menuitem_Shortcut
, (IPTR
) "I", End
),
575 MUIA_Family_Child
, (IPTR
)(protectmenu
= MenuitemObject
, MUIA_Menuitem_Title
,
576 __(MSG_PROTECTION
),MUIA_Menuitem_Shortcut
, (IPTR
) "P", End
),
577 MUIA_Family_Child
, (IPTR
)(toolmenu
= MenuitemObject
, MUIA_Menuitem_Title
,
578 __(MSG_TOOLTYPES
),MUIA_Menuitem_Shortcut
, (IPTR
) "T", End
),
579 MUIA_Family_Child
, (IPTR
) MenuitemObject
, MUIA_Menuitem_Title
, ~0, End
,
580 MUIA_Family_Child
, (IPTR
) (aboutmenu
= MenuitemObject
, MUIA_Menuitem_Title
,
581 __(MSG_ABOUT
), (IPTR
) MUIA_Menuitem_Shortcut
, (IPTR
) "?", End
),
582 MUIA_Family_Child
, (IPTR
) MenuitemObject
, MUIA_Menuitem_Title
, ~0, End
,
583 MUIA_Family_Child
, (IPTR
) (quit
= MenuitemObject
, MUIA_Menuitem_Title
,
584 __(MSG_QUIT
), MUIA_Menuitem_Shortcut
, (IPTR
) "Q", End
),
587 SubWindow
, (IPTR
) (window
= WindowObject
,
588 MUIA_Window_Title
, (IPTR
) __(MSG_ICON
),
589 MUIA_Window_ID
, MAKE_ID('I','N','F','O'),
590 MUIA_Window_Activate
, TRUE
,
591 WindowContents
, (IPTR
) VGroup
,
592 Child
, (IPTR
) HGroup
,
593 Child
, (IPTR
) VGroup
,
594 Child
, (IPTR
) IconImageObject
,
595 MUIA_InputMode
, MUIV_InputMode_Toggle
,
596 MUIA_IconImage_File
, (IPTR
) name
,
599 Child
, (IPTR
) VGroup
,
600 Child
, (IPTR
) TextObject
,
602 MUIA_Background
, MUII_TextBack
,
603 MUIA_Text_PreParse
, (IPTR
) "\33l",
604 MUIA_Text_Contents
, (IPTR
) FilePart(name
),
608 Child
, (IPTR
) RegisterGroup(pages
),
610 Child
, (IPTR
) HGroup
, /* hgroup information pannel */
611 Child
, (IPTR
) VGroup
,
612 Child
, (IPTR
) HGroup
,
613 Child
, (IPTR
) ColGroup(2),
614 Child
, (IPTR
) Label2(__(MSG_SIZE
)),
615 Child
, (IPTR
) (sizespace
= TextObject
,
617 MUIA_Background
, MUII_TextBack
,
618 MUIA_Text_PreParse
, (IPTR
) "\33r",
619 MUIA_Text_Contents
, (IPTR
) size
,
621 Child
, (IPTR
) Label2(__(MSG_DATE
)),
622 Child
, (IPTR
) (datespace
= TextObject
,
624 MUIA_Background
, MUII_TextBack
,
625 MUIA_Text_PreParse
, (IPTR
) "\33r",
626 MUIA_Text_Contents
, (IPTR
) datetime
,
628 Child
, (IPTR
) Label2(__(MSG_TYPE
)),
629 Child
, (IPTR
) (typespace
= TextObject
,
631 MUIA_Background
, MUII_TextBack
,
632 MUIA_Text_PreParse
, (IPTR
) "\33r",
633 MUIA_Text_Contents
, (IPTR
) type
,
635 Child
, (IPTR
) Label2(__(MSG_VERSION
)),
636 Child
, (IPTR
) (versionspace
= TextObject
,
638 MUIA_Background
, MUII_TextBack
,
639 MUIA_Text_PreParse
, (IPTR
) "\33r",
640 MUIA_Text_Contents
, (IPTR
) NULL
,
641 MUIA_Text_Contents
, (IPTR
) "?",
642 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
646 Child
, (IPTR
) HVSpace
,
647 Child
, (IPTR
) (group
= HGroup
,
649 Child
, (IPTR
) HGroup
,
650 Child
, (IPTR
) Label2(__(MSG_COMMENT
)),
651 Child
, (IPTR
) (commentspace
= StringObject
,
657 End
, /* end hgroup information pannel */
658 Child
, (IPTR
) HGroup
, /* hgroup protections pannel */
659 Child
, (IPTR
) VGroup
,
660 Child
, (IPTR
) ColGroup(2),
661 Child
, (IPTR
) HVSpace
,
662 Child
, (IPTR
) ColGroup(2),
663 Child
, (IPTR
) Label2(_(MSG_READ
)),
664 Child
, (IPTR
) (readobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
665 Child
, (IPTR
) Label2(_(MSG_WRITE
)),
666 Child
, (IPTR
) (writeobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
667 Child
, (IPTR
) Label2(_(MSG_EXECUTE
)),
668 Child
, (IPTR
) (executeobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
669 Child
, (IPTR
) Label2(_(MSG_DELETE
)),
670 Child
, (IPTR
) (deleteobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
671 Child
, (IPTR
) Label2(_(MSG_SCRIPT
)),
672 Child
, (IPTR
) (scriptobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
673 Child
, (IPTR
) Label2(_(MSG_PURE
)),
674 Child
, (IPTR
) (pureobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
675 Child
, (IPTR
) Label2(_(MSG_ARCHIVED
)),
676 Child
, (IPTR
) (archiveobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
680 End
, /* end hgroup protections pannel */
681 Child
, (IPTR
) HGroup
, /* hgroup tooltypes pannel */
682 Child
, (IPTR
) VGroup
,
683 Child
, (IPTR
) HGroup
,
684 Child
, (IPTR
) VGroup
,
687 Child
, (IPTR
) ListviewObject
,
688 MUIA_Listview_List
, (IPTR
) (list
= ListObject
,
690 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
691 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
692 MUIA_List_AutoVisible
, TRUE
,
695 Child
, (IPTR
) (liststr
= StringObject
,
700 Child
, (IPTR
) HGroup
,
702 Child
, (IPTR
) (editor
= MUI_NewObject(MUIC_TextEditor
,
704 Child
, (IPTR
) (slider
= ScrollbarObject
,
711 Child
, (IPTR
) HGroup
,
712 MUIA_Group_SameSize
, TRUE
,
713 Child
, (IPTR
) (newkey
= SimpleButton(__(MSG_NEW_KEY
))),
714 Child
, (IPTR
) (delkey
= SimpleButton(__(MSG_DELETE_KEY
))),
718 End
, /* end hgroup tooltypes pannel */
720 Child
, (IPTR
) HGroup
,
721 MUIA_Group_SameSize
, TRUE
,
722 Child
, (IPTR
) (savebutton
=
723 ImageButton(_(MSG_SAVE
),"THEME:Images/Gadgets/Prefs/Save")),
724 Child
, (IPTR
) (cancelbutton
=
725 ImageButton(_(MSG_CANCEL
),"THEME:Images/Gadgets/Prefs/Cancel")),
731 icon_cd
= CurrentDir(cd
);
733 if (application
!= NULL
)
738 set(liststr
, MUIA_String_AttachedList
, (IPTR
)list
);
742 DoMethod(aboutmenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
743 (IPTR
) application
, 2,
744 MUIM_Application_ReturnID
, RETURNID_ABOUT
);
745 DoMethod(infomenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
746 (IPTR
) registergroup
, 3, MUIM_Set
, MUIA_Group_ActivePage
, 0);
747 DoMethod(protectmenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
748 (IPTR
) registergroup
, 3, MUIM_Set
, MUIA_Group_ActivePage
, 1);
749 DoMethod(toolmenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
750 (IPTR
) registergroup
, 3, MUIM_Set
, MUIA_Group_ActivePage
, 2);
751 DoMethod(quit
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
752 (IPTR
) application
, 2, MUIM_Application_ReturnID
,
753 MUIV_Application_ReturnID_Quit
);
755 DoMethod(cancelbutton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
756 (IPTR
) application
, 2,
757 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
758 DoMethod(savebutton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
759 (IPTR
) application
, 2,
760 MUIM_Application_ReturnID
, RETURNID_SAVE
);
761 DoMethod(application
, MUIM_Notify
, MUIA_Application_Sleep
, FALSE
,
762 (IPTR
) application
, 2,
763 MUIM_Application_ReturnID
, RETURNID_WAKE
);
764 DoMethod(application
, MUIM_Notify
, MUIA_Application_Sleep
, TRUE
,
765 (IPTR
) application
, 2,
766 MUIM_Application_ReturnID
, RETURNID_SLEEP
);
767 DoMethod(window
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
768 (IPTR
) application
, 2, MUIM_Application_ReturnID
,
769 MUIV_Application_ReturnID_Quit
);
771 DoMethod(newkey
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
772 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_NEWKEY
);
773 DoMethod(delkey
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
774 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_DELKEY
);
775 DoMethod(list
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
,
776 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_LVACK
);
777 DoMethod(liststr
, MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
778 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_STRINGACK
);
780 DoMethod(commentspace
, MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
781 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_COMMENTACK
);
782 DoMethod(versionspace
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
783 (IPTR
) application
, 2,
784 MUIM_Application_ReturnID
, RETURNID_VERSION
);
787 set(editor
, MUIA_TextEditor_Slider
, slider
);
789 if (icon
->do_ToolTypes
)
791 char *tt
= NULL
, *contents
;
795 while ((tt
= icon
->do_ToolTypes
[i
]) != NULL
)
797 len
= len
+ strlen(icon
->do_ToolTypes
[i
]) + 1;
801 contents
= AllocVec(len
+ 1, MEMF_ANY
);
807 while ((tt
= icon
->do_ToolTypes
[i
]) != NULL
)
809 strcat(contents
, icon
->do_ToolTypes
[i
]);
810 strcat(contents
, "\n");
814 set(editor
, MUIA_TextEditor_Contents
, contents
);
820 if (icon
->do_ToolTypes
)
824 while ((tt
= icon
->do_ToolTypes
[i
]) != NULL
)
826 DoMethod(list
, MUIM_List_InsertSingle
, tt
, MUIV_List_Insert_Bottom
);
832 switch(icon
->do_Type
)
835 toolspace
= MUI_NewObject(MUIC_Popasl
, ASLFR_DoSaveMode
, TRUE
,
836 MUIA_Popstring_String
,
837 filename_string
= MUI_MakeObject(MUIO_String
, NULL
, MAX_PATH_LEN
),
838 MUIA_Popstring_Button
, PopButton(MUII_PopFile
), TAG_DONE
);
839 toollabel
= MUI_MakeObject(MUIO_Label
, _(MSG_DEFTOOL
), NULL
);
840 if ((toolspace
!= NULL
)&&(toollabel
!= NULL
)&&(filename_string
!= NULL
))
842 DoMethod(group
, MUIM_Group_InitChange
);
843 DoMethod(group
, OM_ADDMEMBER
, toollabel
);
844 DoMethod(group
, OM_ADDMEMBER
, toolspace
);
845 DoMethod(group
, MUIM_Group_ExitChange
);
847 set(filename_string
, MUIA_String_Contents
, deftool
);
848 set(toolspace
, MUIA_CycleChain
, 1);
849 DoMethod(filename_string
, MUIM_Notify
,
850 MUIA_String_Acknowledge
, MUIV_EveryTime
,
851 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_TOOLACK
);
855 stackspace
= MUI_MakeObject(MUIO_String
, NULL
, 16);
856 stacklabel
= MUI_MakeObject(MUIO_Label
, _(MSG_STACK
), NULL
);
857 if ((stackspace
!= NULL
)&&(stacklabel
!=NULL
))
859 DoMethod(group
, MUIM_Group_InitChange
);
860 DoMethod(group
, OM_ADDMEMBER
, stacklabel
);
861 DoMethod(group
, OM_ADDMEMBER
, stackspace
);
862 DoMethod(group
, MUIM_Group_ExitChange
);
863 SetAttrs(stackspace
, MUIA_String_Contents
, stack
,
865 MUIA_String_Accept
, (IPTR
)"0123456789",TAG_DONE
);
866 DoMethod(stackspace
, MUIM_Notify
,
867 MUIA_String_Acknowledge
, MUIV_EveryTime
,
868 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_STACKACK
);
872 drawerspace
= MUI_NewObject(MUIC_Rectangle
, TAG_DONE
);
873 if ((drawerspace
!= NULL
))
875 DoMethod(group
, MUIM_Group_InitChange
);
876 DoMethod(group
, OM_ADDMEMBER
, drawerspace
);
877 DoMethod(group
, MUIM_Group_ExitChange
);
883 set(commentspace
, MUIA_String_Contents
, comment
);
885 set(readobject
, MUIA_Selected
, flags
[3]);
886 set(writeobject
, MUIA_Selected
, flags
[4]);
887 set(executeobject
, MUIA_Selected
, flags
[5]);
888 set(deleteobject
, MUIA_Selected
, flags
[6]);
890 set(scriptobject
, MUIA_Selected
, flags
[0]);
891 set(pureobject
, MUIA_Selected
, flags
[1]);
892 set(archiveobject
, MUIA_Selected
, flags
[2]);
894 SetAttrs(window
, MUIA_Window_Open
, TRUE
, TAG_DONE
);
896 while (returnid
!= MUIV_Application_ReturnID_Quit
)
901 D(bug("[WBInfo] broker command received: %ld\n", returnid
));
906 set(window
, MUIA_Window_Open
, FALSE
);
907 set(window
, MUIA_Window_Activate
, TRUE
);
910 set(window
, MUIA_Window_Open
, TRUE
);
913 if (MUI_RequestA(application
,NULL
,0,
914 _(MSG_ABOUT
), _(MSG_OK
), _(MSG_COPYRIGHT
), NULL
))
917 case RETURNID_NEWKEY
:
920 case RETURNID_DELKEY
:
927 case RETURNID_STRINGACK
:
936 SaveIcon(icon
, name
, lock
);
939 DoMethod(application
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
941 case RETURNID_STACKACK
:
942 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
945 case RETURNID_TOOLACK
:
946 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
949 case RETURNID_COMMENTACK
:
950 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
953 case RETURNID_VERSION
:
954 set(versionspace
, MUIA_Text_Contents
, GetVersion(name
, lock
));
962 signals
= Wait(signals
| SIGBREAKF_CTRL_C
);
963 if(signals
& SIGBREAKF_CTRL_C
) break;
966 returnid
= ((LONG
) DoMethod(application
, MUIM_Application_NewInput
, (IPTR
) &signals
));
968 SetAttrs(window
, MUIA_Window_Open
, FALSE
, TAG_DONE
);
969 MUI_DisposeObject(application
);
971 PrintFault(ERROR_INVALID_RESIDENT_LIBRARY
, argv
[0]);
972 D(bug("[WBInfo: Couldn't create app\n"));
974 FreeDiskObject(icon
);