6 #include <exec/types.h>
7 #include <intuition/classes.h>
8 #include <intuition/classusr.h>
9 #include <utility/hooks.h>
10 #include <workbench/workbench.h>
11 #include <workbench/startup.h>
12 #include <libraries/asl.h>
17 #include <proto/asl.h>
18 #include <proto/dos.h>
19 #include <proto/exec.h>
20 #include <proto/graphics.h>
21 #include <proto/intuition.h>
22 #include <proto/iconobject.h>
23 #include <proto/utility.h>
26 #include <proto/scalos.h>
28 #include <clib/alib_protos.h>
31 #include <datatypes/iconobject.h>
32 #include <scalos/scalos.h>
42 #include "scalos_structures.h"
44 #include "functions.h"
45 #include "Variables.h"
47 //----------------------------------------------------------------------------
49 // local data structures
54 struct List ust_EventList
; // List of events in this step
56 STRPTR ust_Description
;
57 Object
*ust_FileTransObj
; // valid during Undo and Redo processing
62 struct UndoStep
*upa_UndoStep
;
63 struct internalScaWindowTask
*upa_iwt
;
66 //----------------------------------------------------------------------------
70 static struct UndoStep
*UndoCreateStep(void);
71 static void UndoDisposeStep(struct UndoStep
*ust
);
72 static struct UndoEvent
*UndoCreateEvent(void);
73 static void UndoDisposeEvent(struct UndoEvent
*uev
);
74 static SAVEDS(LONG
) UndoDummyFunc(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
75 static void RedoCleanup(void);
76 static SAVEDS(ULONG
) UndoTask(struct UndoProcArg
*upa
, struct SM_RunProcess
*msg
);
77 static SAVEDS(ULONG
) RedoTask(struct UndoProcArg
*upa
, struct SM_RunProcess
*msg
);
79 static BOOL
UndoAddCopyMoveEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
80 static BOOL
AddChangeIconPosEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
81 static BOOL
AddSnapshotEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
82 static BOOL
AddCleanupEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
83 static BOOL
AddRenameEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
84 static BOOL
AddRelabelEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
85 static BOOL
AddDeleteEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
86 static BOOL
AddSizeWindowEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
87 static BOOL
AddNewDrawerEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
88 static BOOL
AddLeaveOutPutAwayEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
89 static BOOL
AddSetProtectionEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
90 static BOOL
AddSetCommentEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
91 static BOOL
AddSetToolTypesEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
92 static BOOL
AddChangeIconObjectEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
93 static BOOL
AddCloseWindowEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
);
95 static SAVEDS(void) UndoDisposeCopyMoveData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
96 static SAVEDS(void) UndoDisposeNewDrawerData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
97 static SAVEDS(void) UndoDisposeIconData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
98 static SAVEDS(void) UndoDisposeCleanupData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
99 static SAVEDS(void) UndoDisposeSnapshotData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
100 static SAVEDS(void) UndoDisposeSizeWindowData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
101 static SAVEDS(void) UndoDisposeSetProtectionData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
102 static SAVEDS(void) UndoDisposeSetCommentData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
103 static SAVEDS(void) UndoDisposeSetToolTypesData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
104 static SAVEDS(void) UndoDisposeChangeIconObjectData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
105 static SAVEDS(void) UndoDisposeCloseWindowData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
107 static SAVEDS(LONG
) UndoCopyEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
108 static SAVEDS(LONG
) UndoMoveEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
109 static SAVEDS(LONG
) RedoCopyEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
110 static SAVEDS(LONG
) RedoMoveEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
111 static SAVEDS(LONG
) RedoCreateLinkEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
112 static SAVEDS(LONG
) UndoChangeIconPosEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
113 static SAVEDS(LONG
) RedoChangeIconPosEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
114 static SAVEDS(LONG
) UndoCleanupEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
115 static SAVEDS(LONG
) UndoLeaveOutEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
116 static SAVEDS(LONG
) RedoLeaveOutEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
117 static SAVEDS(LONG
) RedoCleanupEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
118 static SAVEDS(LONG
) UndoSnapshotEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
119 static SAVEDS(LONG
) RedoSnapshotPosEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
120 static SAVEDS(LONG
) UndoRenameEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
121 static SAVEDS(LONG
) RedoRenameEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
122 static SAVEDS(LONG
) UndoRelabelEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
123 static SAVEDS(LONG
) RedoRelabelEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
124 static SAVEDS(LONG
) UndoSizeWindowEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
125 static SAVEDS(LONG
) RedoSizeWindowEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
126 static SAVEDS(LONG
) UndoNewDrawerEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
127 static SAVEDS(LONG
) RedoNewDrawerEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
128 static SAVEDS(LONG
) UndoSetProtectionEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
129 static SAVEDS(LONG
) RedoSetProtectionEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
130 static SAVEDS(LONG
) UndoSetCommentEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
131 static SAVEDS(LONG
) RedoSetCommentEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
132 static SAVEDS(LONG
) UndoSetToolTypesEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
133 static SAVEDS(LONG
) RedoSetToolTypesEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
134 static SAVEDS(LONG
) UndoChangeIconObjectEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
135 static SAVEDS(LONG
) RedoChangeIconObjectEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
136 static SAVEDS(LONG
) UndoCloseWindowEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
137 static SAVEDS(LONG
) RedoCloseWindowEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
);
139 static BOOL
MoveIconTo(CONST_STRPTR DirName
, CONST_STRPTR IconName
, LONG x
, LONG y
);
140 static STRPTR
UndoBuildIconName(CONST_STRPTR ObjName
);
141 static struct internalScaWindowTask
*UndoFindWindowByDir(CONST_STRPTR DirName
);
142 static struct internalScaWindowTask
*UndoFindWindowByWindowTask(const struct ScaWindowTask
*iwt
);
143 static const struct UndoCleanupIconEntry
*UndoFindCleanupIconEntry(const struct UndoEvent
*uev
, const struct ScaIconNode
*in
);
144 static struct ScaIconNode
*UndoFindIconByName(struct internalScaWindowTask
*iwt
, CONST_STRPTR IconName
);
145 static BOOL
UndoSnapshotIcon(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
146 static BOOL
UndoUnsnapshotIcon(struct internalScaWindowTask
*iwt
,
147 struct ScaIconNode
*in
, BOOL SaveIcon
);
148 static BOOL
UndoFindWindowAndIcon(CONST_STRPTR DirName
, CONST_STRPTR IconName
,
149 struct internalScaWindowTask
**iwt
, struct ScaIconNode
**in
);
151 //----------------------------------------------------------------------------
155 //----------------------------------------------------------------------------
159 struct List globalUndoList
; // global Undo list for all file-related actions
160 SCALOSSEMAPHORE UndoListListSemaphore
; // Semaphore to protect globalUndoList
161 static ULONG UndoCount
; // Number of entries in globalUndoList
163 struct List globalRedoList
; // global Redo list for all file-related actions
164 SCALOSSEMAPHORE RedoListListSemaphore
; // Semaphore to protect globalRedoList
166 //----------------------------------------------------------------------------
168 void UndoCleanup(void)
170 struct UndoStep
*ust
;
172 ScalosObtainSemaphore(&UndoListListSemaphore
);
174 while ((ust
= (struct UndoStep
*) RemHead(&globalUndoList
)))
177 UndoDisposeStep(ust
);
179 ScalosReleaseSemaphore(&UndoListListSemaphore
);
184 //----------------------------------------------------------------------------
186 BOOL
UndoAddEvent(struct internalScaWindowTask
*iwt
, enum ScalosUndoType type
, ULONG FirstTag
, ...)
189 struct TagItem
*TagList
;
193 va_start(args
, FirstTag
);
195 TagList
= ScalosVTagList(FirstTag
, args
);
196 Success
= UndoAddEventTagList(iwt
, type
, TagList
);
201 FreeTagItems(TagList
);
206 //----------------------------------------------------------------------------
208 BOOL
UndoAddEventTagList(struct internalScaWindowTask
*iwt
, enum ScalosUndoType type
, struct TagItem
*TagList
)
212 struct UndoEvent
*uev
;
214 uev
= UndoCreateEvent();
217 struct UndoStep
*ustMulti
;
218 struct UndoStep
*ust
;
220 ust
= ustMulti
= (struct UndoStep
*) GetTagData(UNDOTAG_UndoMultiStep
, (ULONG
) NULL
, TagList
);
221 d1(kprintf("%s/%s/%ld: ust=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ust
));
224 ust
= (struct UndoStep
*) UndoBeginStep();
227 d1(kprintf("%s/%s/%ld: ust=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ust
));
231 BOOL Success
= FALSE
;
235 uev
->uev_Type
= type
;
237 uev
->uev_CustomAddHook
= (struct Hook
*) GetTagData(UNDOTAG_CustomAddHook
, (ULONG
) NULL
, TagList
);
239 uev
->uev_NewPosX
= GetTagData(UNDOTAG_IconPosX
, NO_ICON_POSITION_SHORT
, TagList
);
240 uev
->uev_NewPosY
= GetTagData(UNDOTAG_IconPosY
, NO_ICON_POSITION_SHORT
, TagList
);
242 d1(kprintf("%s/%s/%ld: uev=%08lx uev_Type=%ld\n", __FILE__
, __FUNC__
, __LINE__
, uev
, uev
->uev_Type
));
243 d1(kprintf("%s/%s/%ld: uev_NewPosX=%ld uev_NewPosY=%ld\n", __FILE__
, __FUNC__
, __LINE__
, uev
->uev_NewPosX
, uev
->uev_NewPosY
));
245 switch (uev
->uev_Type
)
249 case UNDO_CreateLink
:
250 Success
= UndoAddCopyMoveEvent(uev
, TagList
);
252 case UNDO_ChangeIconPos
:
253 Success
= AddChangeIconPosEvent(uev
, TagList
);
256 Success
= AddCleanupEvent(uev
, TagList
);
259 case UNDO_Unsnapshot
:
260 Success
= AddSnapshotEvent(uev
, TagList
);
263 Success
= AddRenameEvent(uev
, TagList
);
266 Success
= AddRelabelEvent(uev
, TagList
);
268 case UNDO_SizeWindow
:
269 Success
= AddSizeWindowEvent(uev
, TagList
);
272 Success
= AddDeleteEvent(uev
, TagList
);
275 Success
= AddNewDrawerEvent(uev
, TagList
);
279 Success
= AddLeaveOutPutAwayEvent(uev
, TagList
);
281 case UNDO_SetProtection
:
282 Success
= AddSetProtectionEvent(uev
, TagList
);
284 case UNDO_SetComment
:
285 Success
= AddSetCommentEvent(uev
, TagList
);
287 case UNDO_SetToolTypes
:
288 Success
= AddSetToolTypesEvent(uev
, TagList
);
290 case UNDO_ChangeIconObject
:
291 Success
= AddChangeIconObjectEvent(uev
, TagList
);
293 case UNDO_CloseWindow
:
294 Success
= AddCloseWindowEvent(uev
, TagList
);
297 if (uev
->uev_CustomAddHook
)
299 Success
= CallHookPkt(uev
->uev_CustomAddHook
, NULL
, uev
);
304 d1(kprintf("%s/%s/%ld: Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
308 uev
->uev_UndoStep
= ust
;
309 ust
->ust_EventCount
++;
311 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
313 AddTail(&ust
->ust_EventList
, &uev
->uev_Node
);
316 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
318 if (NULL
== ustMulti
)
320 UndoEndStep(iwt
, (APTR
) ust
);
323 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
328 d1(kprintf("%s/%s/%ld: uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
331 UndoDisposeEvent(uev
);
334 d1(kprintf("%s/%s/%ld: END\n", __FILE__
, __FUNC__
, __LINE__
));
339 //----------------------------------------------------------------------------
341 APTR
UndoBeginStep(void)
343 struct UndoStep
*ust
;
346 ust
= UndoCreateStep();
354 //----------------------------------------------------------------------------
356 void UndoEndStep(struct internalScaWindowTask
*iwt
, APTR event
)
358 struct UndoStep
*ust
= (struct UndoStep
*) event
;
360 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
366 if (IsListEmpty(&ust
->ust_EventList
))
369 ScalosObtainSemaphore(&UndoListListSemaphore
);
370 AddTail(&globalUndoList
, &ust
->ust_Node
);
371 if (++UndoCount
> CurrentPrefs
.pref_MaxUndoSteps
)
373 // pref_MaxUndoSteps exceeded - dispose oldest list entry
374 ust
= (struct UndoStep
*) RemHead(&globalUndoList
);
379 ust
= NULL
; // do not dipose ust here!
382 ScalosReleaseSemaphore(&UndoListListSemaphore
);
385 d1(kprintf("%s/%s/%ld: ust=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ust
));
388 UndoDisposeStep(ust
);
390 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
394 d1(kprintf("%s/%s/%ld: END\n", __FILE__
, __FUNC__
, __LINE__
));
397 //----------------------------------------------------------------------------
399 static struct UndoStep
*UndoCreateStep(void)
401 struct UndoStep
*ust
;
404 ust
= ScalosAlloc(sizeof(struct UndoStep
));
408 NewList(&ust
->ust_EventList
);
409 ust
->ust_EventCount
= 0;
410 ust
->ust_Description
= NULL
;
411 ust
->ust_FileTransObj
= NULL
;
417 //----------------------------------------------------------------------------
419 static void UndoDisposeStep(struct UndoStep
*ust
)
423 struct UndoEvent
*uev
;
425 while ((uev
= (struct UndoEvent
*) RemHead(&ust
->ust_EventList
)))
427 ust
->ust_EventCount
--;
428 UndoDisposeEvent(uev
);
431 if (ust
->ust_Description
)
433 FreeCopyString(ust
->ust_Description
);
434 ust
->ust_Description
= NULL
;
441 //----------------------------------------------------------------------------
443 static struct UndoEvent
*UndoCreateEvent(void)
445 struct UndoEvent
*uev
;
448 static struct Hook DummyHook
=
451 HOOKFUNC_DEF(UndoDummyFunc
), // h_Entry + h_SubEntry
455 uev
= ScalosAlloc(sizeof(struct UndoEvent
));
459 memset(uev
, 0, sizeof(struct UndoEvent
));
461 uev
->uev_UndoHook
= &DummyHook
;
462 uev
->uev_RedoHook
= &DummyHook
;
463 uev
->uev_DisposeHook
= &DummyHook
;
468 //----------------------------------------------------------------------------
470 static void UndoDisposeEvent(struct UndoEvent
*uev
)
474 if (uev
->uev_DisposeHook
)
475 CallHookPkt(uev
->uev_DisposeHook
, NULL
, uev
); // cleanup type-specific data
480 //----------------------------------------------------------------------------
482 static SAVEDS(LONG
) UndoDummyFunc(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
491 //----------------------------------------------------------------------------
493 static void RedoCleanup(void)
495 struct UndoStep
*ust
;
497 ScalosObtainSemaphore(&RedoListListSemaphore
);
499 while ((ust
= (struct UndoStep
*) RemHead(&globalRedoList
)))
501 UndoDisposeStep(ust
);
503 ScalosReleaseSemaphore(&RedoListListSemaphore
);
506 //----------------------------------------------------------------------------
508 BOOL
Undo(struct internalScaWindowTask
*iwt
)
510 struct UndoProcArg upa
;
511 BOOL Success
= FALSE
;
515 ScalosObtainSemaphore(&UndoListListSemaphore
);
516 upa
.upa_UndoStep
= (struct UndoStep
*) RemTail(&globalUndoList
);
518 ScalosReleaseSemaphore(&UndoListListSemaphore
);
520 d1(kprintf("%s/%s/%ld: ust=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, upa
.upa_UndoStep
));
522 if (upa
.upa_UndoStep
)
524 Success
= DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_RunProcess
, UndoTask
,
525 &upa
, sizeof(upa
), iInfos
.xii_iinfos
.ii_MainMsgPort
);
531 //----------------------------------------------------------------------------
533 BOOL
Redo(struct internalScaWindowTask
*iwt
)
535 struct UndoProcArg upa
;
536 BOOL Success
= FALSE
;
540 ScalosObtainSemaphore(&RedoListListSemaphore
);
541 upa
.upa_UndoStep
= (struct UndoStep
*) RemTail(&globalRedoList
);
542 ScalosReleaseSemaphore(&RedoListListSemaphore
);
544 d1(kprintf("%s/%s/%ld: ust=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, upa
.upa_UndoStep
));
546 if (upa
.upa_UndoStep
)
548 Success
= DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_RunProcess
, RedoTask
,
549 &upa
, sizeof(upa
), iInfos
.xii_iinfos
.ii_MainMsgPort
);
555 //----------------------------------------------------------------------------
557 CONST_STRPTR
UndoGetDescription(void)
559 static char buffer
[200];
561 ScalosObtainSemaphore(&UndoListListSemaphore
);
563 if (IsListEmpty(&globalUndoList
))
565 snprintf(buffer
, sizeof(buffer
),
566 GetLocString(MSGID_UNDO_NOT_AVAILABLE
),
567 GetLocString(MSGID_UNDO_UNDO
));
571 struct UndoStep
*ust
= (struct UndoStep
*) globalUndoList
.lh_TailPred
;
573 stccpy(buffer
, GetLocString(MSGID_UNDO_UNDO
), sizeof(buffer
));
575 d1(kprintf("%s/%s/%ld: ust=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ust
));
577 if (!IsListEmpty(&ust
->ust_EventList
))
579 struct UndoEvent
*uev
= (struct UndoEvent
*) ust
->ust_EventList
.lh_Head
;
581 if (ust
->ust_EventCount
> 1)
583 snprintf(buffer
, sizeof(buffer
),
584 GetLocString(uev
->uev_DescrMsgIDMultiple
),
585 GetLocString(MSGID_UNDO_UNDO
),
586 ust
->ust_EventCount
);
588 else if (uev
->uev_DescrObjName
&& *uev
->uev_DescrObjName
)
590 snprintf(buffer
, sizeof(buffer
),
591 GetLocString(uev
->uev_DescrMsgIDSingle
),
592 GetLocString(MSGID_UNDO_UNDO
),
593 *uev
->uev_DescrObjName
);
598 ScalosReleaseSemaphore(&UndoListListSemaphore
);
603 //----------------------------------------------------------------------------
605 CONST_STRPTR
RedoGetDescription(void)
607 static char buffer
[200];
609 ScalosObtainSemaphore(&RedoListListSemaphore
);
611 if (IsListEmpty(&globalRedoList
))
613 snprintf(buffer
, sizeof(buffer
),
614 GetLocString(MSGID_UNDO_NOT_AVAILABLE
),
615 GetLocString(MSGID_UNDO_REDO
));
619 struct UndoStep
*ust
= (struct UndoStep
*) globalRedoList
.lh_TailPred
;
621 stccpy(buffer
, GetLocString(MSGID_UNDO_REDO
), sizeof(buffer
));
623 d1(kprintf("%s/%s/%ld: ust=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ust
));
625 if (!IsListEmpty(&ust
->ust_EventList
))
627 struct UndoEvent
*uev
= (struct UndoEvent
*) ust
->ust_EventList
.lh_Head
;
629 if (ust
->ust_EventCount
> 1)
631 snprintf(buffer
, sizeof(buffer
),
632 GetLocString(uev
->uev_DescrMsgIDMultiple
),
633 GetLocString(MSGID_UNDO_REDO
),
634 ust
->ust_EventCount
);
636 else if (uev
->uev_DescrObjName
&& *uev
->uev_DescrObjName
)
638 snprintf(buffer
, sizeof(buffer
),
639 GetLocString(uev
->uev_DescrMsgIDSingle
),
640 GetLocString(MSGID_UNDO_REDO
),
641 *uev
->uev_DescrObjName
);
646 ScalosReleaseSemaphore(&RedoListListSemaphore
);
651 //----------------------------------------------------------------------------
653 static SAVEDS(ULONG
) UndoTask(struct UndoProcArg
*upa
, struct SM_RunProcess
*msg
)
655 static CONST_STRPTR ProgTaskName
= "Scalos_UndoTask";
657 struct Process
*myProc
= (struct Process
*) FindTask(NULL
);
661 d1(kprintf("%s/%s/%ld: START ust=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, upa
->upa_UndoStep
));
663 prWindowPtr
= myProc
->pr_WindowPtr
;
664 myProc
->pr_WindowPtr
= (APTR
) ~0; // suppress error requesters
666 myProc
->pr_Task
.tc_Node
.ln_Name
= (STRPTR
) ProgTaskName
;
667 SetProgramName(ProgTaskName
);
669 upa
->upa_UndoStep
->ust_FileTransObj
= SCA_NewScalosObjectTags((STRPTR
) "FileTransfer.sca",
670 SCCA_FileTrans_Screen
, (ULONG
) iInfos
.xii_iinfos
.ii_Screen
,
671 SCCA_FileTrans_ReplaceMode
, SCCV_ReplaceMode_Ask
,
674 if (upa
->upa_UndoStep
->ust_FileTransObj
)
676 struct UndoEvent
*uev
;
678 for (uev
= (struct UndoEvent
*) upa
->upa_UndoStep
->ust_EventList
.lh_Head
;
679 uev
!= (struct UndoEvent
*) &upa
->upa_UndoStep
->ust_EventList
.lh_Tail
;
680 uev
= (struct UndoEvent
*) uev
->uev_Node
.ln_Succ
)
682 d1(kprintf("%s/%s/%ld: uev=%08lx uev_Type=%ld uev_UndoHook=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
, uev
->uev_Type
, uev
->uev_UndoHook
));
683 if (uev
->uev_UndoHook
)
684 CallHookPkt(uev
->uev_UndoHook
, NULL
, uev
);
686 // Move undo step to redo list
687 ScalosObtainSemaphore(&RedoListListSemaphore
);
688 AddTail(&globalRedoList
, &upa
->upa_UndoStep
->ust_Node
);
689 ScalosReleaseSemaphore(&RedoListListSemaphore
);
691 SCA_DisposeScalosObject(upa
->upa_UndoStep
->ust_FileTransObj
);
692 upa
->upa_UndoStep
->ust_FileTransObj
= NULL
;
696 UndoDisposeStep(upa
->upa_UndoStep
);
699 SetMenuOnOff(upa
->upa_iwt
);
701 // restore pr_WindowPtr
702 myProc
->pr_WindowPtr
= prWindowPtr
;
704 d1(kprintf("%s/%s/%ld: END\n", __FILE__
, __FUNC__
, __LINE__
));
709 //----------------------------------------------------------------------------
711 static SAVEDS(ULONG
) RedoTask(struct UndoProcArg
*upa
, struct SM_RunProcess
*msg
)
713 static CONST_STRPTR ProgTaskName
= "Scalos_RedoTask";
715 struct Process
*myProc
= (struct Process
*) FindTask(NULL
);
719 d1(kprintf("%s/%s/%ld: START ust=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, upa
->upa_UndoStep
));
721 prWindowPtr
= myProc
->pr_WindowPtr
;
722 myProc
->pr_WindowPtr
= (APTR
) ~0; // suppress error requesters
724 myProc
->pr_Task
.tc_Node
.ln_Name
= (STRPTR
) ProgTaskName
;
725 SetProgramName(ProgTaskName
);
727 upa
->upa_UndoStep
->ust_FileTransObj
= SCA_NewScalosObjectTags((STRPTR
) "FileTransfer.sca",
728 SCCA_FileTrans_Screen
, (ULONG
) iInfos
.xii_iinfos
.ii_Screen
,
729 SCCA_FileTrans_ReplaceMode
, SCCV_ReplaceMode_Ask
,
732 if (upa
->upa_UndoStep
->ust_FileTransObj
)
734 struct UndoEvent
*uev
;
736 for (uev
= (struct UndoEvent
*) upa
->upa_UndoStep
->ust_EventList
.lh_Head
;
737 uev
!= (struct UndoEvent
*) &upa
->upa_UndoStep
->ust_EventList
.lh_Tail
;
738 uev
= (struct UndoEvent
*) uev
->uev_Node
.ln_Succ
)
740 d1(kprintf("%s/%s/%ld: uev=%08lx uev_Type=%ld uev_RedoHook=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
, uev
->uev_Type
, uev
->uev_RedoHook
));
741 if (uev
->uev_RedoHook
)
742 CallHookPkt(uev
->uev_RedoHook
, NULL
, uev
);
745 // Move redo step to undo list
746 ScalosObtainSemaphore(&UndoListListSemaphore
);
747 AddTail(&globalUndoList
, &upa
->upa_UndoStep
->ust_Node
);
749 ScalosReleaseSemaphore(&UndoListListSemaphore
);
751 SCA_DisposeScalosObject(upa
->upa_UndoStep
->ust_FileTransObj
);
752 upa
->upa_UndoStep
->ust_FileTransObj
= NULL
;
756 UndoDisposeStep(upa
->upa_UndoStep
);
759 SetMenuOnOff(upa
->upa_iwt
);
761 // restore pr_WindowPtr
762 myProc
->pr_WindowPtr
= prWindowPtr
;
767 //----------------------------------------------------------------------------
769 static BOOL
UndoAddCopyMoveEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
771 BOOL Success
= FALSE
;
774 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
779 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
780 static struct Hook UndoDisposeCopyMoveDataHook
=
783 HOOKFUNC_DEF(UndoDisposeCopyMoveData
), // h_Entry + h_SubEntry
786 static struct Hook UndoCopyEventHook
=
789 HOOKFUNC_DEF(UndoCopyEvent
), // h_Entry + h_SubEntry
792 static struct Hook RedoCopyEventHook
=
795 HOOKFUNC_DEF(RedoCopyEvent
), // h_Entry + h_SubEntry
798 static struct Hook UndoMoveEventHook
=
801 HOOKFUNC_DEF(UndoMoveEvent
), // h_Entry + h_SubEntry
804 static struct Hook RedoMoveEventHook
=
807 HOOKFUNC_DEF(RedoMoveEvent
), // h_Entry + h_SubEntry
810 static struct Hook RedoCreateLinkEventHook
=
813 HOOKFUNC_DEF(RedoCreateLinkEvent
), // h_Entry + h_SubEntry
817 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &UndoDisposeCopyMoveDataHook
, TagList
);
819 if (UNDO_Copy
== uev
->uev_Type
)
821 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoCopyEventHook
, TagList
);
822 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoCopyEventHook
, TagList
);
823 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_COPY_SINGLE
;
824 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_COPY_MORE
;
826 else if (UNDO_Move
== uev
->uev_Type
)
828 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoMoveEventHook
, TagList
);
829 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoMoveEventHook
, TagList
);
830 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_MOVE_SINGLE
;
831 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_MOVE_MORE
;
833 else if (UNDO_CreateLink
== uev
->uev_Type
)
835 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoCopyEventHook
, TagList
);
836 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoCreateLinkEventHook
, TagList
);
837 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_CREATELINK_SINGLE
;
838 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_CREATELINK_MORE
;
841 uev
->uev_OldPosX
= GetTagData(UNDOTAG_OldIconPosX
, NO_ICON_POSITION_SHORT
, TagList
);
842 uev
->uev_OldPosY
= GetTagData(UNDOTAG_OldIconPosY
, NO_ICON_POSITION_SHORT
, TagList
);
844 uev
->uev_DescrObjName
= &ucmed
->ucmed_srcName
;
846 name
= AllocPathBuffer();
850 dirLock
= (BPTR
) GetTagData(UNDOTAG_CopySrcDirLock
, 0, TagList
);
851 if (BNULL
== dirLock
)
854 if (!NameFromLock(dirLock
, name
, Max_PathLen
))
857 d1(kprintf("%s/%s/%ld: UNDOTAG_CopySrcDirLock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, name
));
859 ucmed
->ucmed_srcDirName
= AllocCopyString(name
);
860 if (NULL
== ucmed
->ucmed_srcDirName
)
863 dirLock
= (BPTR
) GetTagData(UNDOTAG_CopyDestDirLock
, 0, TagList
);
864 if (BNULL
== dirLock
)
867 if (!NameFromLock(dirLock
, name
, Max_PathLen
))
870 d1(kprintf("%s/%s/%ld: UNDOTAG_CopyDestDirLock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, name
));
872 ucmed
->ucmed_destDirName
= AllocCopyString(name
);
873 if (NULL
== ucmed
->ucmed_destDirName
)
876 fName
= (CONST_STRPTR
) GetTagData(UNDOTAG_CopySrcName
, (ULONG
) NULL
, TagList
);
880 d1(kprintf("%s/%s/%ld: UNDOTAG_CopySrcName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, fName
));
882 ucmed
->ucmed_srcName
= AllocCopyString(fName
);
883 if (NULL
== ucmed
->ucmed_srcName
)
886 // special handling for volume copying: here is ucmed_srcName empty
887 if ((NULL
== ucmed
->ucmed_srcName
) || (0 == strlen(ucmed
->ucmed_srcName
)))
888 uev
->uev_DescrObjName
= &ucmed
->ucmed_srcDirName
;
890 fName
= (CONST_STRPTR
) GetTagData(UNDOTAG_CopyDestName
, (ULONG
) ucmed
->ucmed_srcName
, TagList
);
892 fName
= ucmed
->ucmed_srcName
;
894 d1(kprintf("%s/%s/%ld: UNDOTAG_CopyDestName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, fName
));
896 ucmed
->ucmed_destName
= AllocCopyString(fName
);
897 if (NULL
== ucmed
->ucmed_destName
)
900 if ((NO_ICON_POSITION_SHORT
== uev
->uev_OldPosX
) || (NO_ICON_POSITION_SHORT
== uev
->uev_OldPosY
))
902 struct internalScaWindowTask
*iwt
;
903 struct ScaIconNode
*in
= NULL
;
906 struct ExtGadget
*gg
;
908 if (!UndoFindWindowAndIcon(ucmed
->ucmed_srcDirName
, ucmed
->ucmed_srcName
, &iwt
, &in
))
914 gg
= (struct ExtGadget
*) in
->in_Icon
;
916 uev
->uev_OldPosX
= gg
->LeftEdge
;
917 uev
->uev_OldPosY
= gg
->TopEdge
;
923 ScalosUnLockIconList(iwt
);
924 SCA_UnLockWindowList();
932 FreePathBuffer(name
);
934 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
939 //----------------------------------------------------------------------------
941 static BOOL
AddChangeIconPosEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
943 BOOL Success
= FALSE
;
948 struct ScaIconNode
*in
;
949 const struct ExtGadget
*gg
;
950 static struct Hook DisposeIconDataHook
=
953 HOOKFUNC_DEF(UndoDisposeIconData
), // h_Entry + h_SubEntry
956 static struct Hook UndoChangeIconPosEventHook
=
959 HOOKFUNC_DEF(UndoChangeIconPosEvent
), // h_Entry + h_SubEntry
962 static struct Hook RedoChangeIconPosEventHook
=
965 HOOKFUNC_DEF(RedoChangeIconPosEvent
), // h_Entry + h_SubEntry
969 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &DisposeIconDataHook
, TagList
);
970 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoChangeIconPosEventHook
, TagList
);
971 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoChangeIconPosEventHook
, TagList
);
973 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_CHANGEICONPOS_SINGLE
;
974 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_CHANGEICONPOS_MORE
;
976 uev
->uev_DescrObjName
= &uev
->uev_Data
.uev_IconData
.uid_IconName
;
978 name
= AllocPathBuffer();
982 dirLock
= (BPTR
) GetTagData(UNDOTAG_IconDirLock
, 0, TagList
);
983 if (BNULL
== dirLock
)
986 if (!NameFromLock(dirLock
, name
, Max_PathLen
))
989 d1(kprintf("%s/%s/%ld: UNDOTAG_IconDirLock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, name
));
991 uev
->uev_Data
.uev_IconData
.uid_DirName
= AllocCopyString(name
);
992 if (NULL
== uev
->uev_Data
.uev_IconData
.uid_DirName
)
995 in
= (struct ScaIconNode
*) GetTagData(UNDOTAG_IconNode
, (ULONG
) NULL
, TagList
);
999 d1(kprintf("%s/%s/%ld: UNDOTAG_IconNode=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
)));
1001 uev
->uev_Data
.uev_IconData
.uid_IconName
= AllocCopyString(GetIconName(in
));
1002 if (NULL
== uev
->uev_Data
.uev_IconData
.uid_IconName
)
1005 gg
= (const struct ExtGadget
*) in
->in_Icon
;
1007 uev
->uev_OldPosX
= gg
->LeftEdge
;
1008 uev
->uev_OldPosY
= gg
->TopEdge
;
1010 d1(kprintf("%s/%s/%ld: UNDOTAG_IconOldPosX=%ld UNDOTAG_IconOldPosY=%ld\n", \
1011 __FILE__
, __FUNC__
, __LINE__
, uev
->uev_OldPosX
, \
1018 FreePathBuffer(name
);
1023 //----------------------------------------------------------------------------
1025 static BOOL
AddSnapshotEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
1027 BOOL Success
= FALSE
;
1033 struct ScaIconNode
*in
;
1034 const struct ExtGadget
*gg
;
1035 struct UndoSnaphotIconData
*usid
= &uev
->uev_Data
.uev_SnapshotData
;
1036 static struct Hook DisposeIconDataHook
=
1039 HOOKFUNC_DEF(UndoDisposeSnapshotData
), // h_Entry + h_SubEntry
1042 static struct Hook UndoSnapshotEventHook
=
1045 HOOKFUNC_DEF(UndoSnapshotEvent
), // h_Entry + h_SubEntry
1048 static struct Hook RedoSnapshotPosEventHook
=
1051 HOOKFUNC_DEF(RedoSnapshotPosEvent
), // h_Entry + h_SubEntry
1055 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &DisposeIconDataHook
, TagList
);
1056 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoSnapshotEventHook
, TagList
);
1057 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoSnapshotPosEventHook
, TagList
);
1059 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_SNAPSHOT_SINGLE
;
1060 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_SNAPSHOT_MORE
;
1062 uev
->uev_DescrObjName
= &usid
->usid_IconName
;
1064 name
= AllocPathBuffer();
1068 dirLock
= (BPTR
) GetTagData(UNDOTAG_IconDirLock
, 0, TagList
);
1069 if (BNULL
== dirLock
)
1072 if (!NameFromLock(dirLock
, name
, Max_PathLen
))
1075 d1(kprintf("%s/%s/%ld: UNDOTAG_IconDirLock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1077 usid
->usid_DirName
= AllocCopyString(name
);
1078 if (NULL
== usid
->usid_DirName
)
1081 usid
->usid_SaveIcon
= GetTagData(UNDOTAG_SaveIcon
, FALSE
, TagList
);
1083 d1(kprintf("%s/%s/%ld: UNDOTAG_SaveIcon=%ld\n", __FILE__
, __FUNC__
, __LINE__
, usid
->usid_SaveIcon
));
1085 in
= (struct ScaIconNode
*) GetTagData(UNDOTAG_IconNode
, (ULONG
) NULL
, TagList
);
1089 d1(kprintf("%s/%s/%ld: UNDOTAG_IconNode=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
)));
1091 usid
->usid_IconName
= AllocCopyString(GetIconName(in
));
1092 if (NULL
== usid
->usid_IconName
)
1095 oldDir
= CurrentDir(dirLock
);
1097 usid
->usid_IconObj
= (Object
*) NewIconObjectTags(usid
->usid_IconName
,
1098 IDTA_SupportedIconTypes
, CurrentPrefs
.pref_SupportedIconTypes
,
1099 IDTA_SizeConstraints
, (ULONG
) &CurrentPrefs
.pref_IconSizeConstraints
,
1100 IDTA_ScalePercentage
, CurrentPrefs
.pref_IconScaleFactor
,
1101 IDTA_Text
, (ULONG
) usid
->usid_IconName
,
1102 DTA_Name
, (ULONG
) usid
->usid_IconName
,
1107 d1(kprintf("%s/%s/%ld: usid_IconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, usid
->usid_IconObj
));
1109 if (NULL
== usid
->usid_IconObj
)
1112 gg
= (const struct ExtGadget
*) in
->in_Icon
;
1114 uev
->uev_OldPosX
= gg
->LeftEdge
;
1115 uev
->uev_OldPosY
= gg
->TopEdge
;
1117 d1(kprintf("%s/%s/%ld: UNDOTAG_IconOldPosX=%ld UNDOTAG_IconOldPosY=%ld\n", \
1118 __FILE__
, __FUNC__
, __LINE__
, uev
->uev_OldPosX
, \
1125 FreePathBuffer(name
);
1130 //----------------------------------------------------------------------------
1132 static BOOL
AddCleanupEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
1134 BOOL Success
= FALSE
;
1136 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
1139 struct UndoCleanupData
*ucd
= &uev
->uev_Data
.uev_CleanupData
;
1140 const struct ScaIconNode
*IconList
;
1141 const struct ScaIconNode
*in
;
1142 struct UndoCleanupIconEntry
*ucie
;
1143 static struct Hook DisposeCleanupDataHook
=
1146 HOOKFUNC_DEF(UndoDisposeCleanupData
), // h_Entry + h_SubEntry
1149 static struct Hook UndoCleanupEventHook
=
1152 HOOKFUNC_DEF(UndoCleanupEvent
), // h_Entry + h_SubEntry
1155 static struct Hook RedoCleanupEventHook
=
1158 HOOKFUNC_DEF(RedoCleanupEvent
), // h_Entry + h_SubEntry
1162 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &DisposeCleanupDataHook
, TagList
);
1163 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoCleanupEventHook
, TagList
);
1164 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoCleanupEventHook
, TagList
);
1166 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_CLEANUP
;
1167 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_CLEANUP
;
1169 ucd
->ucd_CleanupMode
= GetTagData(UNDOTAG_CleanupMode
, CLEANUP_Default
, TagList
);
1171 d1(kprintf("%s/%s/%ld: UNDOTAG_CleanupMode=%ld\n", __FILE__
, __FUNC__
, __LINE__
, ucd
->ucd_CleanupMode
));
1173 ucd
->ucd_WindowTask
= (struct ScaWindowTask
*) GetTagData(UNDOTAG_WindowTask
, (ULONG
) NULL
, TagList
);
1174 if (NULL
== ucd
->ucd_WindowTask
)
1177 ucd
->ucd_WindowTitle
= AllocCopyString(((struct internalScaWindowTask
*) ucd
->ucd_WindowTask
)->iwt_WinTitle
);
1178 if (NULL
== ucd
->ucd_WindowTitle
)
1181 uev
->uev_DescrObjName
= &ucd
->ucd_WindowTitle
;
1183 d1(kprintf("%s/%s/%ld: UNDOTAG_WindowTask=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ucd
->ucd_WindowTask
));
1184 d1(kprintf("%s/%s/%ld: ucd_WindowTitle=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, ucd
->ucd_WindowTitle
));
1186 IconList
= (struct ScaIconNode
*) GetTagData(UNDOTAG_IconList
, (ULONG
) NULL
, TagList
);
1187 if (NULL
== IconList
)
1190 d1(kprintf("%s/%s/%ld: UNDOTAG_IconList=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, IconList
));
1192 ScalosLockIconListShared((struct internalScaWindowTask
*) ucd
->ucd_WindowTask
);
1194 // count number of icons
1195 for (in
= IconList
; in
; in
= (const struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
1197 ucd
->ucd_IconCount
++;
1200 d1(kprintf("%s/%s/%ld: ucd_IconCount=%lu\n", __FILE__
, __FUNC__
, __LINE__
, ucd
->ucd_IconCount
));
1202 // create array to store icon positions
1203 ucd
->ucd_Icons
= ScalosAlloc(ucd
->ucd_IconCount
* sizeof(struct UndoCleanupIconEntry
));
1204 if (NULL
== ucd
->ucd_Icons
)
1207 // store icon positions in array
1208 for (ucie
= ucd
->ucd_Icons
, in
= IconList
;
1209 in
; in
= (const struct ScaIconNode
*) in
->in_Node
.mln_Succ
, ucie
++)
1211 const struct ExtGadget
*gg
= (const struct ExtGadget
*) in
->in_Icon
;
1213 ucie
->ucin_IconNode
= in
;
1214 ucie
->ucin_Left
= gg
->LeftEdge
;
1215 ucie
->ucin_Top
= gg
->TopEdge
;
1217 d1(kprintf("%s/%s/%ld: in=%08lx <%s> Left=%ld Top=%ld\n", \
1218 __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
), \
1219 ucie
->ucin_Left
, ucie
->ucin_Top
));
1222 ScalosUnLockIconList((struct internalScaWindowTask
*) ucd
->ucd_WindowTask
);
1224 d1(kprintf("%s/%s/%ld: ucd_WindowTask=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ucd
->ucd_WindowTask
));
1229 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
1234 //----------------------------------------------------------------------------
1236 static BOOL
AddRenameEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
1238 BOOL Success
= FALSE
;
1241 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
1246 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
1247 static struct Hook UndoDisposeCopyMoveDataHook
=
1250 HOOKFUNC_DEF(UndoDisposeCopyMoveData
), // h_Entry + h_SubEntry
1253 static struct Hook UndoRenameHook
=
1256 HOOKFUNC_DEF(UndoRenameEvent
), // h_Entry + h_SubEntry
1259 static struct Hook RedoRenameHook
=
1262 HOOKFUNC_DEF(RedoRenameEvent
), // h_Entry + h_SubEntry
1266 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &UndoDisposeCopyMoveDataHook
, TagList
);
1268 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoRenameHook
, TagList
);
1269 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoRenameHook
, TagList
);
1271 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_RENAME_SINGLE
;
1272 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_RENAME_MORE
;
1274 uev
->uev_DescrObjName
= &ucmed
->ucmed_srcName
;
1276 name
= AllocPathBuffer();
1280 d1(kprintf("%s/%s/%ld: name=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1282 dirLock
= (BPTR
) GetTagData(UNDOTAG_CopySrcDirLock
, 0, TagList
);
1283 d1(kprintf("%s/%s/%ld: dirLock=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, dirLock
));
1284 if (BNULL
== dirLock
)
1287 if (!NameFromLock(dirLock
, name
, Max_PathLen
))
1290 d1(kprintf("%s/%s/%ld: UNDOTAG_CopySrcDirLock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1292 ucmed
->ucmed_srcDirName
= AllocCopyString(name
);
1293 if (NULL
== ucmed
->ucmed_srcDirName
)
1296 fName
= (CONST_STRPTR
) GetTagData(UNDOTAG_CopySrcName
, (ULONG
) NULL
, TagList
);
1300 d1(kprintf("%s/%s/%ld: UNDOTAG_CopySrcName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, fName
));
1302 ucmed
->ucmed_srcName
= AllocCopyString(fName
);
1303 if (NULL
== ucmed
->ucmed_srcName
)
1306 fName
= (CONST_STRPTR
) GetTagData(UNDOTAG_CopyDestName
, (ULONG
) NULL
, TagList
);
1309 d1(kprintf("%s/%s/%ld: UNDOTAG_CopyDestName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, fName
));
1311 ucmed
->ucmed_destName
= AllocCopyString(fName
);
1312 if (NULL
== ucmed
->ucmed_destName
)
1319 FreePathBuffer(name
);
1321 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
1326 //----------------------------------------------------------------------------
1328 static BOOL
AddRelabelEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
1330 BOOL Success
= FALSE
;
1333 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
1337 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
1338 static struct Hook UndoDisposeCopyMoveDataHook
=
1341 HOOKFUNC_DEF(UndoDisposeCopyMoveData
), // h_Entry + h_SubEntry
1344 static struct Hook UndoRelabelHook
=
1347 HOOKFUNC_DEF(UndoRelabelEvent
), // h_Entry + h_SubEntry
1350 static struct Hook RedoRelabelHook
=
1353 HOOKFUNC_DEF(RedoRelabelEvent
), // h_Entry + h_SubEntry
1357 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &UndoDisposeCopyMoveDataHook
, TagList
);
1359 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoRelabelHook
, TagList
);
1360 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoRelabelHook
, TagList
);
1362 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_RELABEL_SINGLE
;
1363 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_RELABEL_MORE
;
1365 uev
->uev_DescrObjName
= &ucmed
->ucmed_srcName
;
1367 name
= AllocPathBuffer();
1371 d1(kprintf("%s/%s/%ld: name=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1373 ucmed
->ucmed_srcDirName
= AllocCopyString(name
);
1374 if (NULL
== ucmed
->ucmed_srcDirName
)
1377 fName
= (CONST_STRPTR
) GetTagData(UNDOTAG_CopySrcName
, (ULONG
) NULL
, TagList
);
1382 d1(kprintf("%s/%s/%ld: UNDOTAG_CopySrcName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, fName
));
1384 ucmed
->ucmed_srcName
= AllocCopyString(fName
);
1385 if (NULL
== ucmed
->ucmed_srcName
)
1388 fName
= (CONST_STRPTR
) GetTagData(UNDOTAG_CopyDestName
, (ULONG
) NULL
, TagList
);
1393 d1(kprintf("%s/%s/%ld: UNDOTAG_CopyDestName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, fName
));
1395 ucmed
->ucmed_destName
= AllocCopyString(fName
);
1396 if (NULL
== ucmed
->ucmed_destName
)
1403 FreePathBuffer(name
);
1405 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
1410 //----------------------------------------------------------------------------
1412 static BOOL
AddDeleteEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
1414 BOOL Success
= FALSE
;
1417 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
1422 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
1423 static struct Hook UndoDisposeCopyMoveDataHook
=
1426 HOOKFUNC_DEF(UndoDisposeCopyMoveData
), // h_Entry + h_SubEntry
1429 static struct Hook UndoDeleteHook
=
1432 HOOKFUNC_DEF(UndoMoveEvent
), // h_Entry + h_SubEntry
1435 static struct Hook RedoDeleteHook
=
1438 HOOKFUNC_DEF(RedoMoveEvent
), // h_Entry + h_SubEntry
1442 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &UndoDisposeCopyMoveDataHook
, TagList
);
1444 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoDeleteHook
, TagList
);
1445 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoDeleteHook
, TagList
);
1447 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_DELETE_SINGLE
;
1448 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_DELETE_MORE
;
1450 uev
->uev_DescrObjName
= &ucmed
->ucmed_srcName
;
1452 name
= AllocPathBuffer();
1456 d1(kprintf("%s/%s/%ld: name=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1458 dirLock
= (BPTR
) GetTagData(UNDOTAG_CopySrcDirLock
, 0, TagList
);
1459 d1(kprintf("%s/%s/%ld: dirLock=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, dirLock
));
1460 if (BNULL
== dirLock
)
1463 if (!NameFromLock(dirLock
, name
, Max_PathLen
))
1466 d1(kprintf("%s/%s/%ld: UNDOTAG_CopySrcDirLock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1468 ucmed
->ucmed_srcDirName
= AllocCopyString(name
);
1469 if (NULL
== ucmed
->ucmed_srcDirName
)
1472 fName
= (CONST_STRPTR
) GetTagData(UNDOTAG_CopySrcName
, (ULONG
) NULL
, TagList
);
1476 d1(kprintf("%s/%s/%ld: UNDOTAG_CopySrcName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, fName
));
1478 ucmed
->ucmed_srcName
= AllocCopyString(fName
);
1479 if (NULL
== ucmed
->ucmed_srcName
)
1482 fName
= (CONST_STRPTR
) GetTagData(UNDOTAG_CopyDestName
, (ULONG
) "SYS:Trashcan", TagList
);
1485 d1(kprintf("%s/%s/%ld: UNDOTAG_CopyDestName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, fName
));
1487 ucmed
->ucmed_destName
= AllocCopyString(fName
);
1488 if (NULL
== ucmed
->ucmed_destName
)
1495 FreePathBuffer(name
);
1497 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
1502 //----------------------------------------------------------------------------
1504 static BOOL
AddSizeWindowEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
1506 BOOL Success
= FALSE
;
1508 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
1511 struct UndoSizeWindowData
*uswd
= &uev
->uev_Data
.uev_SizeWindowData
;
1512 static struct Hook DisposeSizeWindowDataHook
=
1515 HOOKFUNC_DEF(UndoDisposeSizeWindowData
), // h_Entry + h_SubEntry
1518 static struct Hook UndoSizeWindowHook
=
1521 HOOKFUNC_DEF(UndoSizeWindowEvent
), // h_Entry + h_SubEntry
1524 static struct Hook RedoSizeWindowHook
=
1527 HOOKFUNC_DEF(RedoSizeWindowEvent
), // h_Entry + h_SubEntry
1531 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &DisposeSizeWindowDataHook
, TagList
);
1532 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoSizeWindowHook
, TagList
);
1533 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoSizeWindowHook
, TagList
);
1535 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_SIZEWINDOW
;
1536 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_SIZEWINDOW
;
1538 uswd
->uswd_WindowTask
= (struct ScaWindowTask
*) GetTagData(UNDOTAG_WindowTask
, (ULONG
) NULL
, TagList
);
1539 if (NULL
== uswd
->uswd_WindowTask
)
1542 uswd
->uswd_WindowTitle
= AllocCopyString(((struct internalScaWindowTask
*) uswd
->uswd_WindowTask
)->iwt_WinTitle
);
1543 if (NULL
== uswd
->uswd_WindowTitle
)
1546 uev
->uev_DescrObjName
= &uswd
->uswd_WindowTitle
;
1548 d1(kprintf("%s/%s/%ld: UNDOTAG_WindowTask=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uswd
->uswd_WindowTask
));
1550 uswd
->uswd_OldLeft
= GetTagData(UNDOTAG_OldWindowLeft
, 0, TagList
);
1551 uswd
->uswd_OldTop
= GetTagData(UNDOTAG_OldWindowTop
, 0, TagList
);
1552 uswd
->uswd_OldWidth
= GetTagData(UNDOTAG_OldWindowWidth
, 0, TagList
);
1553 uswd
->uswd_OldHeight
= GetTagData(UNDOTAG_OldWindowHeight
, 0, TagList
);
1554 uswd
->uswd_OldVirtX
= GetTagData(UNDOTAG_OldWindowVirtX
, 0, TagList
);
1555 uswd
->uswd_OldVirtY
= GetTagData(UNDOTAG_OldWindowVirtY
, 0, TagList
);
1557 uswd
->uswd_NewLeft
= GetTagData(UNDOTAG_NewWindowLeft
, uswd
->uswd_OldLeft
, TagList
);
1558 uswd
->uswd_NewTop
= GetTagData(UNDOTAG_NewWindowTop
, uswd
->uswd_OldTop
, TagList
);
1559 uswd
->uswd_NewWidth
= GetTagData(UNDOTAG_NewWindowWidth
, uswd
->uswd_OldWidth
, TagList
);
1560 uswd
->uswd_NewHeight
= GetTagData(UNDOTAG_NewWindowHeight
, uswd
->uswd_OldHeight
, TagList
);
1561 uswd
->uswd_NewVirtX
= GetTagData(UNDOTAG_NewWindowVirtX
, uswd
->uswd_OldVirtX
, TagList
);
1562 uswd
->uswd_NewVirtY
= GetTagData(UNDOTAG_NewWindowVirtY
, uswd
->uswd_OldVirtY
, TagList
);
1564 d1(kprintf("%s/%s/%ld: UNDOTAG_OldWindowLeft=%ld\n", __FILE__
, __FUNC__
, __LINE__
, uswd
->uswd_OldLeft
));
1565 d1(kprintf("%s/%s/%ld: UNDOTAG_OldWindowTop=%ld\n", __FILE__
, __FUNC__
, __LINE__
, uswd
->uswd_OldTop
));
1566 d1(kprintf("%s/%s/%ld: UNDOTAG_OldWindowWidth=%lu\n", __FILE__
, __FUNC__
, __LINE__
, uswd
->uswd_OldWidth
));
1567 d1(kprintf("%s/%s/%ld: UNDOTAG_OldWindowHeight=%lu\n", __FILE__
, __FUNC__
, __LINE__
, uswd
->uswd_OldHeight
));
1568 d1(kprintf("%s/%s/%ld: UNDOTAG_OldWindowVirtX=%ld\n", __FILE__
, __FUNC__
, __LINE__
, uswd
->uswd_OldVirtX
));
1569 d1(kprintf("%s/%s/%ld: UNDOTAG_OldWindowVirtY=%ld\n", __FILE__
, __FUNC__
, __LINE__
, uswd
->uswd_OldVirtY
));
1570 d1(kprintf("%s/%s/%ld: UNDOTAG_NewWindowLeft=%ld\n", __FILE__
, __FUNC__
, __LINE__
, uswd
->uswd_NewLeft
));
1571 d1(kprintf("%s/%s/%ld: UNDOTAG_NewWindowTop=%ld\n", __FILE__
, __FUNC__
, __LINE__
, uswd
->uswd_NewTop
));
1572 d1(kprintf("%s/%s/%ld: UNDOTAG_NewWindowWidth=%lu\n", __FILE__
, __FUNC__
, __LINE__
, uswd
->uswd_NewWidth
));
1573 d1(kprintf("%s/%s/%ld: UNDOTAG_NewWindowHeight=%lu\n", __FILE__
, __FUNC__
, __LINE__
, uswd
->uswd_NewHeight
));
1574 d1(kprintf("%s/%s/%ld: UNDOTAG_NewWindowVirtX=%ld\n", __FILE__
, __FUNC__
, __LINE__
, uswd
->uswd_NewVirtX
));
1575 d1(kprintf("%s/%s/%ld: UNDOTAG_NewWindowVirtY=%ld\n", __FILE__
, __FUNC__
, __LINE__
, uswd
->uswd_NewVirtY
));
1580 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
1585 //----------------------------------------------------------------------------
1587 static BOOL
AddNewDrawerEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
1589 BOOL Success
= FALSE
;
1592 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
1597 struct UndoNewDrawerData
*und
= &uev
->uev_Data
.uev_NewDrawerData
;
1598 static struct Hook UndoDisposeNewDrawerHook
=
1601 HOOKFUNC_DEF(UndoDisposeNewDrawerData
), // h_Entry + h_SubEntry
1604 static struct Hook UndoNewDrawerHook
=
1607 HOOKFUNC_DEF(UndoNewDrawerEvent
), // h_Entry + h_SubEntry
1610 static struct Hook RedoNewDrawerHook
=
1613 HOOKFUNC_DEF(RedoNewDrawerEvent
), // h_Entry + h_SubEntry
1617 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &UndoDisposeNewDrawerHook
, TagList
);
1619 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoNewDrawerHook
, TagList
);
1620 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoNewDrawerHook
, TagList
);
1622 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_NEWDRAWER_SINGLE
;
1623 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_NEWDRAWER_MORE
;
1624 uev
->uev_DescrObjName
= &und
->und_srcName
;
1626 name
= AllocPathBuffer();
1630 d1(kprintf("%s/%s/%ld: name=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1632 dirLock
= (BPTR
) GetTagData(UNDOTAG_IconDirLock
, 0, TagList
);
1633 d1(kprintf("%s/%s/%ld: dirLock=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, dirLock
));
1634 if (BNULL
== dirLock
)
1637 if (!NameFromLock(dirLock
, name
, Max_PathLen
))
1640 d1(kprintf("%s/%s/%ld: UNDOTAG_IconDirLock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1642 und
->und_DirName
= AllocCopyString(name
);
1643 if (NULL
== und
->und_DirName
)
1646 fName
= (CONST_STRPTR
) GetTagData(UNDOTAG_IconName
, (ULONG
) NULL
, TagList
);
1650 d1(kprintf("%s/%s/%ld: UNDOTAG_IconName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, fName
));
1652 und
->und_srcName
= AllocCopyString(fName
);
1653 if (NULL
== und
->und_srcName
)
1656 und
->und_CreateIcon
= GetTagData(UNDOTAG_CreateIcon
, TRUE
, TagList
);
1658 d1(kprintf("%s/%s/%ld: UNDOTAG_CreateIcon=%ld\n", __FILE__
, __FUNC__
, __LINE__
, und
->und_CreateIcon
));
1664 FreePathBuffer(name
);
1666 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
1671 //----------------------------------------------------------------------------
1673 static BOOL
AddLeaveOutPutAwayEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
1675 BOOL Success
= FALSE
;
1678 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
1681 struct UndoSnaphotIconData
*usid
= &uev
->uev_Data
.uev_SnapshotData
;
1683 CONST_STRPTR IconName
;
1684 static struct Hook UndoDisposeLeaveOutPutAwayHook
=
1687 HOOKFUNC_DEF(UndoDisposeSnapshotData
), // h_Entry + h_SubEntry
1690 static struct Hook UndoLeaveOutHook
=
1693 HOOKFUNC_DEF(UndoLeaveOutEvent
), // h_Entry + h_SubEntry
1696 static struct Hook RedoLeaveOutHook
=
1699 HOOKFUNC_DEF(RedoLeaveOutEvent
), // h_Entry + h_SubEntry
1703 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &UndoDisposeLeaveOutPutAwayHook
, TagList
);
1705 if (UNDO_PutAway
== uev
->uev_Type
)
1707 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &RedoLeaveOutHook
, TagList
);
1708 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &UndoLeaveOutHook
, TagList
);
1709 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_PUTAWAY_SINGLE
;
1710 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_PUTAWAY_MORE
;
1714 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoLeaveOutHook
, TagList
);
1715 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoLeaveOutHook
, TagList
);
1716 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_LEAVEOUT_SINGLE
;
1717 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_LEAVEOUT_MORE
;
1720 uev
->uev_DescrObjName
= &usid
->usid_IconName
;
1722 name
= AllocPathBuffer();
1726 d1(kprintf("%s/%s/%ld: name=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1728 dirLock
= (BPTR
) GetTagData(UNDOTAG_IconDirLock
, 0, TagList
);
1729 debugLock_d1(dirLock
);
1730 if (BNULL
== dirLock
)
1733 if (!NameFromLock(dirLock
, name
, Max_PathLen
))
1736 d1(kprintf("%s/%s/%ld: UNDOTAG_IconDirLock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1738 usid
->usid_DirName
= AllocCopyString(name
);
1739 if (NULL
== usid
->usid_DirName
)
1742 IconName
= (CONST_STRPTR
) GetTagData(UNDOTAG_IconName
, (ULONG
) NULL
, TagList
);
1743 if (NULL
== IconName
)
1746 usid
->usid_IconName
= AllocCopyString(IconName
);
1747 if (NULL
== usid
->usid_IconName
)
1750 d1(kprintf("%s/%s/%ld: UNDOTAG_IconName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, usid
->usid_IconName
));
1756 FreePathBuffer(name
);
1758 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
1763 //----------------------------------------------------------------------------
1765 static BOOL
AddSetProtectionEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
1767 BOOL Success
= FALSE
;
1770 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
1773 struct UndoSetProtectionData
*uspd
= &uev
->uev_Data
.uev_SetProtectionData
;
1775 CONST_STRPTR IconName
;
1776 static struct Hook UndoDisposeSetProtectionHook
=
1779 HOOKFUNC_DEF(UndoDisposeSetProtectionData
), // h_Entry + h_SubEntry
1782 static struct Hook UndoSetProtectionHook
=
1785 HOOKFUNC_DEF(UndoSetProtectionEvent
), // h_Entry + h_SubEntry
1788 static struct Hook RedoSetProtectionHook
=
1791 HOOKFUNC_DEF(RedoSetProtectionEvent
), // h_Entry + h_SubEntry
1795 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &UndoDisposeSetProtectionHook
, TagList
);
1797 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoSetProtectionHook
, TagList
);
1798 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoSetProtectionHook
, TagList
);
1799 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_SETPROTECTION_SINGLE
;
1800 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_SETPROTECTION_MORE
;
1802 uev
->uev_DescrObjName
= &uspd
->uspd_IconName
;
1804 name
= AllocPathBuffer();
1808 d1(kprintf("%s/%s/%ld: name=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1810 dirLock
= (BPTR
) GetTagData(UNDOTAG_IconDirLock
, 0, TagList
);
1811 debugLock_d1(dirLock
);
1812 if (BNULL
== dirLock
)
1815 if (!NameFromLock(dirLock
, name
, Max_PathLen
))
1818 d1(kprintf("%s/%s/%ld: UNDOTAG_IconDirLock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1820 uspd
->uspd_DirName
= AllocCopyString(name
);
1821 if (NULL
== uspd
->uspd_DirName
)
1824 IconName
= (CONST_STRPTR
) GetTagData(UNDOTAG_IconName
, (ULONG
) NULL
, TagList
);
1825 if (NULL
== IconName
)
1828 uspd
->uspd_IconName
= AllocCopyString(IconName
);
1829 if (NULL
== uspd
->uspd_IconName
)
1832 d1(kprintf("%s/%s/%ld: UNDOTAG_IconName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, uspd
->uspd_IconName
));
1834 uspd
->uspd_OldProtection
= GetTagData(UNDOTAG_OldProtection
, 0, TagList
);
1835 uspd
->uspd_NewProtection
= GetTagData(UNDOTAG_NewProtection
, uspd
->uspd_OldProtection
, TagList
);
1837 d1(kprintf("%s/%s/%ld: UNDOTAG_OldProtection=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uspd
->uspd_OldProtection
));
1838 d1(kprintf("%s/%s/%ld: UNDOTAG_NewProtection=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uspd
->uspd_NewProtection
));
1844 FreePathBuffer(name
);
1846 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
1851 //----------------------------------------------------------------------------
1853 static BOOL
AddSetCommentEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
1855 BOOL Success
= FALSE
;
1858 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
1861 struct UndoSetCommentData
*uscd
= &uev
->uev_Data
.uev_SetCommentData
;
1863 CONST_STRPTR IconName
;
1864 CONST_STRPTR Comment
;
1865 static struct Hook UndoDisposeSetCommentHook
=
1868 HOOKFUNC_DEF(UndoDisposeSetCommentData
), // h_Entry + h_SubEntry
1871 static struct Hook UndoSetCommentHook
=
1874 HOOKFUNC_DEF(UndoSetCommentEvent
), // h_Entry + h_SubEntry
1877 static struct Hook RedoSetCommentHook
=
1880 HOOKFUNC_DEF(RedoSetCommentEvent
), // h_Entry + h_SubEntry
1884 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &UndoDisposeSetCommentHook
, TagList
);
1886 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoSetCommentHook
, TagList
);
1887 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoSetCommentHook
, TagList
);
1888 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_SETCOMMENT_SINGLE
;
1889 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_SETCOMMENT_MORE
;
1891 uev
->uev_DescrObjName
= &uscd
->uscd_IconName
;
1893 name
= AllocPathBuffer();
1897 d1(kprintf("%s/%s/%ld: name=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1899 dirLock
= (BPTR
) GetTagData(UNDOTAG_IconDirLock
, 0, TagList
);
1900 debugLock_d1(dirLock
);
1901 if (BNULL
== dirLock
)
1904 if (!NameFromLock(dirLock
, name
, Max_PathLen
))
1907 d1(kprintf("%s/%s/%ld: UNDOTAG_IconDirLock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, name
));
1909 uscd
->uscd_DirName
= AllocCopyString(name
);
1910 if (NULL
== uscd
->uscd_DirName
)
1913 IconName
= (CONST_STRPTR
) GetTagData(UNDOTAG_IconName
, (ULONG
) NULL
, TagList
);
1914 if (NULL
== IconName
)
1917 uscd
->uscd_IconName
= AllocCopyString(IconName
);
1918 if (NULL
== uscd
->uscd_IconName
)
1921 d1(kprintf("%s/%s/%ld: UNDOTAG_IconName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, uscd
->uscd_IconName
));
1923 Comment
= (CONST_STRPTR
) GetTagData(UNDOTAG_OldComment
, (ULONG
) NULL
, TagList
);
1924 if (NULL
== Comment
)
1927 uscd
->uscd_OldComment
= AllocCopyString(Comment
);
1928 if (NULL
== uscd
->uscd_OldComment
)
1931 d1(kprintf("%s/%s/%ld: UNDOTAG_OldComment=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, uscd
->uscd_OldComment
));
1933 Comment
= (CONST_STRPTR
) GetTagData(UNDOTAG_NewComment
, (ULONG
) NULL
, TagList
);
1934 if (NULL
== Comment
)
1937 uscd
->uscd_NewComment
= AllocCopyString(Comment
);
1938 if (NULL
== uscd
->uscd_NewComment
)
1941 d1(kprintf("%s/%s/%ld: UNDOTAG_NewComment=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, uscd
->uscd_NewComment
));
1947 FreePathBuffer(name
);
1949 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
1954 //----------------------------------------------------------------------------
1956 static BOOL
AddSetToolTypesEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
1958 BOOL Success
= FALSE
;
1961 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
1964 struct UndoSetToolTypesData
*ustd
= &uev
->uev_Data
.uev_SetToolTypesData
;
1966 CONST_STRPTR IconName
;
1967 CONST_STRPTR
*ToolTypes
;
1968 static struct Hook UndoDisposeSetToolTypesHook
=
1971 HOOKFUNC_DEF(UndoDisposeSetToolTypesData
), // h_Entry + h_SubEntry
1974 static struct Hook UndoSetToolTypesHook
=
1977 HOOKFUNC_DEF(UndoSetToolTypesEvent
), // h_Entry + h_SubEntry
1980 static struct Hook RedoSetToolTypesHook
=
1983 HOOKFUNC_DEF(RedoSetToolTypesEvent
), // h_Entry + h_SubEntry
1987 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &UndoDisposeSetToolTypesHook
, TagList
);
1989 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoSetToolTypesHook
, TagList
);
1990 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoSetToolTypesHook
, TagList
);
1991 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_SETTOOLTYPES_SINGLE
;
1992 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_SETTOOLTYPES_MORE
;
1994 uev
->uev_DescrObjName
= &ustd
->ustd_IconName
;
1996 name
= AllocPathBuffer();
2000 d1(kprintf("%s/%s/%ld: name=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, name
));
2002 dirLock
= (BPTR
) GetTagData(UNDOTAG_IconDirLock
, 0, TagList
);
2003 debugLock_d1(dirLock
);
2004 if (BNULL
== dirLock
)
2007 if (!NameFromLock(dirLock
, name
, Max_PathLen
))
2010 d1(kprintf("%s/%s/%ld: UNDOTAG_IconDirLock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, name
));
2012 ustd
->ustd_DirName
= AllocCopyString(name
);
2013 if (NULL
== ustd
->ustd_DirName
)
2016 IconName
= (CONST_STRPTR
) GetTagData(UNDOTAG_IconName
, (ULONG
) NULL
, TagList
);
2017 if (NULL
== IconName
)
2020 ustd
->ustd_IconName
= AllocCopyString(IconName
);
2021 if (NULL
== ustd
->ustd_IconName
)
2024 d1(kprintf("%s/%s/%ld: UNDOTAG_IconName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, ustd
->ustd_IconName
));
2026 ToolTypes
= (CONST_STRPTR
*) GetTagData(UNDOTAG_OldToolTypes
, (ULONG
) NULL
, TagList
);
2027 if (NULL
== ToolTypes
)
2030 ustd
->ustd_OldToolTypes
= CloneToolTypeArray(ToolTypes
, 0);
2031 if (NULL
== ustd
->ustd_OldToolTypes
)
2034 d1(kprintf("%s/%s/%ld: UNDOTAG_OldToolTypes=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ustd
->ustd_OldToolTypes
));
2036 ToolTypes
= (CONST_STRPTR
*) GetTagData(UNDOTAG_NewToolTypes
, (ULONG
) NULL
, TagList
);
2037 if (NULL
== ToolTypes
)
2040 ustd
->ustd_NewToolTypes
= CloneToolTypeArray(ToolTypes
, 0);
2041 if (NULL
== ustd
->ustd_NewToolTypes
)
2044 d1(kprintf("%s/%s/%ld: UNDOTAG_NewToolTypes=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ustd
->ustd_NewToolTypes
));
2050 FreePathBuffer(name
);
2052 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
2057 //----------------------------------------------------------------------------
2059 static BOOL
AddChangeIconObjectEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
2061 BOOL Success
= FALSE
;
2064 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
2067 struct UndoChangeIconObjectData
*uciod
= &uev
->uev_Data
.uev_ChangeIconObjectData
;
2069 CONST_STRPTR IconName
;
2071 static struct Hook UndoDisposeChangeIconObjectHook
=
2074 HOOKFUNC_DEF(UndoDisposeChangeIconObjectData
), // h_Entry + h_SubEntry
2077 static struct Hook UndoChangeIconObjectHook
=
2080 HOOKFUNC_DEF(UndoChangeIconObjectEvent
), // h_Entry + h_SubEntry
2083 static struct Hook RedoChangeIconObjectHook
=
2086 HOOKFUNC_DEF(RedoChangeIconObjectEvent
), // h_Entry + h_SubEntry
2090 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &UndoDisposeChangeIconObjectHook
, TagList
);
2092 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoChangeIconObjectHook
, TagList
);
2093 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoChangeIconObjectHook
, TagList
);
2094 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_CHANGEICON_SINGLE
;
2095 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_CHANGEICON_MORE
;
2097 uev
->uev_DescrObjName
= &uciod
->uciod_IconName
;
2099 name
= AllocPathBuffer();
2103 d1(kprintf("%s/%s/%ld: name=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, name
));
2105 dirLock
= (BPTR
) GetTagData(UNDOTAG_IconDirLock
, 0, TagList
);
2106 debugLock_d1(dirLock
);
2107 if (BNULL
== dirLock
)
2110 if (!NameFromLock(dirLock
, name
, Max_PathLen
))
2113 d1(kprintf("%s/%s/%ld: UNDOTAG_IconDirLock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, name
));
2115 uciod
->uciod_DirName
= AllocCopyString(name
);
2116 if (NULL
== uciod
->uciod_DirName
)
2119 IconName
= (CONST_STRPTR
) GetTagData(UNDOTAG_IconName
, (ULONG
) NULL
, TagList
);
2120 if (NULL
== IconName
)
2123 uciod
->uciod_IconName
= AllocCopyString(IconName
);
2124 if (NULL
== uciod
->uciod_IconName
)
2127 d1(kprintf("%s/%s/%ld: UNDOTAG_IconName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, uciod
->uciod_IconName
));
2129 IconObj
= (Object
*) GetTagData(UNDOTAG_OldIconObject
, (ULONG
) NULL
, TagList
);
2130 if (NULL
== IconObj
)
2133 uciod
->uciod_OldIconObject
= CloneIconObject(IconObj
);
2134 if (NULL
== uciod
->uciod_OldIconObject
)
2137 d1(kprintf("%s/%s/%ld: UNDOTAG_OldIconObject=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uciod
->uciod_OldIconObject
));
2139 IconObj
= (Object
*) GetTagData(UNDOTAG_NewIconObject
, (ULONG
) NULL
, TagList
);
2140 if (NULL
== IconObj
)
2143 uciod
->uciod_NewIconObject
= CloneIconObject(IconObj
);
2144 if (NULL
== uciod
->uciod_NewIconObject
)
2147 d1(kprintf("%s/%s/%ld: UNDOTAG_NewIconObject=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uciod
->uciod_NewIconObject
));
2153 FreePathBuffer(name
);
2155 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
2160 //----------------------------------------------------------------------------
2162 static BOOL
AddCloseWindowEvent(struct UndoEvent
*uev
, struct TagItem
*TagList
)
2164 BOOL Success
= FALSE
;
2167 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
2170 struct internalScaWindowTask
*iwt
;
2171 struct ScaWindowStruct
*ws
;
2172 struct UndoCloseWindowData
*ucwd
= &uev
->uev_Data
.uev_CloseWindowData
;
2173 static struct Hook UndoDisposeCloseWindowHook
=
2176 HOOKFUNC_DEF(UndoDisposeCloseWindowData
), // h_Entry + h_SubEntry
2179 static struct Hook UndoCloseWindowHook
=
2182 HOOKFUNC_DEF(UndoCloseWindowEvent
), // h_Entry + h_SubEntry
2185 static struct Hook RedoCloseWindowHook
=
2188 HOOKFUNC_DEF(RedoCloseWindowEvent
), // h_Entry + h_SubEntry
2192 uev
->uev_DisposeHook
= (struct Hook
*) GetTagData(UNDOTAG_DisposeHook
, (ULONG
) &UndoDisposeCloseWindowHook
, TagList
);
2194 uev
->uev_UndoHook
= (struct Hook
*) GetTagData(UNDOTAG_UndoHook
, (ULONG
) &UndoCloseWindowHook
, TagList
);
2195 uev
->uev_RedoHook
= (struct Hook
*) GetTagData(UNDOTAG_RedoHook
, (ULONG
) &RedoCloseWindowHook
, TagList
);
2197 uev
->uev_DescrMsgIDSingle
= MSGID_UNDO_CLOSEWINDOW_SINGLE
;
2198 uev
->uev_DescrMsgIDMultiple
= MSGID_UNDO_CLOSEWINDOW_MORE
;
2200 name
= AllocPathBuffer();
2204 d1(kprintf("%s/%s/%ld: name=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, name
));
2206 iwt
= (struct internalScaWindowTask
*) GetTagData(UNDOTAG_WindowTask
, (ULONG
) NULL
, TagList
);
2210 ws
= iwt
->iwt_WindowTask
.mt_WindowStruct
;
2212 if (BNULL
== ws
->ws_Lock
)
2215 ucwd
->ucwd_WindowTitle
= AllocCopyString(iwt
->iwt_WinTitle
);
2216 if (NULL
== ucwd
->ucwd_WindowTitle
)
2219 d1(kprintf("%s/%s/%ld: ucwd_WindowTitle=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ucwd
->ucwd_WindowTitle
));
2221 uev
->uev_DescrObjName
= &ucwd
->ucwd_WindowTitle
;
2223 if (!NameFromLock(ws
->ws_Lock
, name
, Max_PathLen
))
2226 d1(kprintf("%s/%s/%ld: ws_lock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, name
));
2228 ucwd
->ucwd_DirName
= AllocCopyString(name
);
2229 if (NULL
== ucwd
->ucwd_DirName
)
2232 ucwd
->ucwd_Left
= ws
->ws_Left
;
2233 ucwd
->ucwd_Top
= ws
->ws_Top
;
2234 ucwd
->ucwd_Width
= ws
->ws_Width
;
2235 ucwd
->ucwd_Height
= ws
->ws_Height
;
2236 ucwd
->ucwd_VirtX
= ws
->ws_xoffset
;
2237 ucwd
->ucwd_VirtY
= ws
->ws_yoffset
;
2238 ucwd
->ucwd_ViewAll
= ws
->ws_ViewAll
;
2239 ucwd
->ucwd_Viewmodes
= ws
->ws_Viewmodes
;
2245 FreePathBuffer(name
);
2247 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
2251 //----------------------------------------------------------------------------
2253 static SAVEDS(LONG
) UndoCopyEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2255 BOOL Success
= FALSE
;
2257 STRPTR iconName
= NULL
;
2262 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
2265 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
2267 CONST_STRPTR iconExt
= ".info";
2270 destDirLock
= Lock(ucmed
->ucmed_destDirName
, ACCESS_READ
);
2271 d1(kprintf("%s/%s/%ld: destDirLock=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, destDirLock
, ucmed
->ucmed_destDirName
));
2272 if (BNULL
== destDirLock
)
2275 destName
= ucmed
->ucmed_destName
;
2276 if (0 == strlen(destName
))
2277 destName
= ucmed
->ucmed_srcName
;
2279 Result
= DoMethod(uev
->uev_UndoStep
->ust_FileTransObj
,
2280 SCCM_FileTrans_Delete
,
2281 destDirLock
, destName
);
2282 if (RETURN_OK
!= Result
)
2285 iconName
= ScalosAlloc(1 + strlen(destName
) + strlen(iconExt
));
2286 if (NULL
== iconName
)
2289 strcpy(iconName
, destName
);
2290 strcat(iconName
, iconExt
);
2292 /*Result =*/ DoMethod(uev
->uev_UndoStep
->ust_FileTransObj
,
2293 SCCM_FileTrans_Delete
,
2294 destDirLock
, iconName
);
2299 if (BNULL
!= destDirLock
)
2300 UnLock(destDirLock
);
2302 ScalosFree(iconName
);
2307 //----------------------------------------------------------------------------
2309 static SAVEDS(LONG
) RedoCopyEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2311 BOOL Success
= FALSE
;
2313 BPTR destDirLock
= BNULL
;
2318 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
2321 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
2324 srcDirLock
= Lock(ucmed
->ucmed_srcDirName
, ACCESS_READ
);
2325 if (BNULL
== srcDirLock
)
2328 destDirLock
= Lock(ucmed
->ucmed_destDirName
, ACCESS_READ
);
2329 if (BNULL
== destDirLock
)
2332 Result
= DoMethod(uev
->uev_UndoStep
->ust_FileTransObj
, SCCM_FileTrans_Copy
,
2333 srcDirLock
, destDirLock
,
2334 ucmed
->ucmed_srcName
,
2335 ucmed
->ucmed_destName
,
2336 uev
->uev_NewPosX
, uev
->uev_NewPosY
);
2337 if (RETURN_OK
!= Result
)
2343 if (BNULL
!= srcDirLock
)
2345 if (BNULL
!= destDirLock
)
2346 UnLock(destDirLock
);
2348 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
2353 //----------------------------------------------------------------------------
2355 // Move moved file system object back to original position
2356 static SAVEDS(LONG
) UndoMoveEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2358 BOOL Success
= FALSE
;
2360 BPTR destDirLock
= BNULL
;
2365 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
2368 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
2371 d1(kprintf("%s/%s/%ld: ucmed_srcDirName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, ucmed
->ucmed_srcDirName
));
2373 srcDirLock
= Lock(ucmed
->ucmed_srcDirName
, ACCESS_READ
);
2374 if (BNULL
== srcDirLock
)
2377 debugLock_d1(srcDirLock
);
2379 d1(kprintf("%s/%s/%ld: ucmed_destDirName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, ucmed
->ucmed_destDirName
));
2381 destDirLock
= Lock(ucmed
->ucmed_destDirName
, ACCESS_READ
);
2382 if (BNULL
== destDirLock
)
2385 debugLock_d1(destDirLock
);
2387 d1(kprintf("%s/%s/%ld: .ucmed_srcName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, ucmed
->ucmed_srcName
));
2389 Result
= DoMethod(uev
->uev_UndoStep
->ust_FileTransObj
, SCCM_FileTrans_Move
,
2390 destDirLock
, srcDirLock
,
2391 ucmed
->ucmed_srcName
,
2392 uev
->uev_OldPosX
, uev
->uev_OldPosY
);
2393 if (RETURN_OK
!= Result
)
2396 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
2401 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
2403 if (BNULL
!= srcDirLock
)
2405 if (BNULL
!= destDirLock
)
2406 UnLock(destDirLock
);
2408 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
2413 //----------------------------------------------------------------------------
2415 // Repeat Move of moved file system object
2416 static SAVEDS(LONG
) RedoMoveEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2418 BOOL Success
= FALSE
;
2420 BPTR destDirLock
= BNULL
;
2425 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
2428 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
2431 srcDirLock
= Lock(ucmed
->ucmed_srcDirName
, ACCESS_READ
);
2432 if (BNULL
== srcDirLock
)
2435 destDirLock
= Lock(ucmed
->ucmed_destDirName
, ACCESS_READ
);
2436 if (BNULL
== destDirLock
)
2439 Result
= DoMethod(uev
->uev_UndoStep
->ust_FileTransObj
, SCCM_FileTrans_Move
,
2440 srcDirLock
, destDirLock
,
2441 ucmed
->ucmed_srcName
,
2442 uev
->uev_NewPosX
, uev
->uev_NewPosY
);
2443 if (RETURN_OK
!= Result
)
2449 if (BNULL
!= srcDirLock
)
2451 if (BNULL
!= destDirLock
)
2452 UnLock(destDirLock
);
2457 //----------------------------------------------------------------------------
2459 static SAVEDS(LONG
) RedoCreateLinkEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2461 BOOL Success
= FALSE
;
2463 BPTR destDirLock
= BNULL
;
2468 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
2471 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
2474 srcDirLock
= Lock(ucmed
->ucmed_srcDirName
, ACCESS_READ
);
2475 if (BNULL
== srcDirLock
)
2478 destDirLock
= Lock(ucmed
->ucmed_destDirName
, ACCESS_READ
);
2479 if (BNULL
== destDirLock
)
2482 Result
= DoMethod(uev
->uev_UndoStep
->ust_FileTransObj
, SCCM_FileTrans_CreateLink
,
2483 srcDirLock
, destDirLock
,
2484 ucmed
->ucmed_srcName
,
2485 ucmed
->ucmed_destName
,
2486 uev
->uev_NewPosX
, uev
->uev_NewPosY
);
2487 if (RETURN_OK
!= Result
)
2493 if (BNULL
!= srcDirLock
)
2495 if (BNULL
!= destDirLock
)
2496 UnLock(destDirLock
);
2501 //----------------------------------------------------------------------------
2503 static STRPTR
UndoBuildIconName(CONST_STRPTR ObjName
)
2505 STRPTR iconName
= AllocPathBuffer();
2509 stccpy(iconName
, ObjName
, Max_PathLen
);
2510 SafeStrCat(iconName
, ".info", Max_PathLen
);
2516 //----------------------------------------------------------------------------
2518 static BOOL
MoveIconTo(CONST_STRPTR DirName
, CONST_STRPTR IconName
, LONG xNew
, LONG yNew
)
2520 BOOL Success
= FALSE
;
2521 struct internalScaWindowTask
*iwt
;
2522 struct ScaIconNode
*in
= NULL
;
2525 struct ScaIconNode
*MovedIconList
= NULL
;
2527 struct ExtGadget
*gg
;
2529 if (!UndoFindWindowAndIcon(DirName
, IconName
, &iwt
, &in
))
2532 SCA_MoveIconNode(&iwt
->iwt_WindowTask
.wt_IconList
, &MovedIconList
, in
);
2534 RemoveIcons(iwt
, &MovedIconList
); // visibly remove icon from window
2536 gg
= (struct ExtGadget
*) in
->in_Icon
;
2538 // Adjust icon position
2539 x0
= gg
->LeftEdge
- gg
->BoundsLeftEdge
;
2541 gg
->LeftEdge
= xNew
;
2542 gg
->BoundsLeftEdge
= gg
->LeftEdge
- x0
;
2544 y0
= gg
->TopEdge
- gg
->BoundsTopEdge
;
2547 gg
->BoundsTopEdge
= gg
->TopEdge
- y0
;
2549 RefreshIconList(iwt
, MovedIconList
, NULL
); // draw icon at new position in window
2551 SCA_MoveIconNode(&MovedIconList
, &iwt
->iwt_WindowTask
.wt_IconList
, in
);
2559 ScalosUnLockIconList(iwt
);
2560 SCA_UnLockWindowList();
2566 //----------------------------------------------------------------------------
2568 static struct internalScaWindowTask
*UndoFindWindowByDir(CONST_STRPTR DirName
)
2570 struct internalScaWindowTask
*iwt
= NULL
;
2573 DirLock
= Lock(DirName
, ACCESS_READ
);
2576 struct ScaWindowStruct
*ws
;
2578 SCA_LockWindowList(SCA_LockWindowList_Shared
);
2580 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
2581 debugLock_d1(DirLock
);
2583 for (ws
=winlist
.wl_WindowStruct
; (NULL
== iwt
) && ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
2585 if (ws
->ws_Lock
&& (LOCK_SAME
== ScaSameLock(DirLock
, ws
->ws_Lock
)))
2587 iwt
= (struct internalScaWindowTask
*) ws
->ws_WindowTask
;
2588 d1(KPrintF("%s/%s/%ld: Found iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2594 SCA_UnLockWindowList();
2599 d1(kprintf("%s/%s/%ld: iwt=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
));
2604 //----------------------------------------------------------------------------
2606 static struct internalScaWindowTask
*UndoFindWindowByWindowTask(const struct ScaWindowTask
*wt
)
2608 struct ScaWindowStruct
*ws
;
2610 SCA_LockWindowList(SCA_LockWindowList_Shared
);
2612 d1(kprintf("%s/%s/%ld: START wt=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, wt
));
2614 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
2616 if (wt
== ws
->ws_WindowTask
)
2618 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ws
->ws_WindowTask
;
2619 d1(KPrintF("%s/%s/%ld: Found iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2624 SCA_UnLockWindowList();
2626 d1(kprintf("%s/%s/%ld: iwt=NULL\n", __FILE__
, __FUNC__
, __LINE__
));
2631 //----------------------------------------------------------------------------
2633 static struct ScaIconNode
*UndoFindIconByName(struct internalScaWindowTask
*iwt
, CONST_STRPTR IconName
)
2635 struct ScaIconNode
*inFound
= NULL
;
2636 struct ScaIconNode
*in
;
2638 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2640 ScalosLockIconListShared(iwt
);
2642 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
2644 if (0 == Stricmp(GetIconName(in
), IconName
))
2647 d1(kprintf("%s/%s/%ld: inFound=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, inFound
, GetIconName(inFound
)));
2652 if (NULL
== inFound
)
2653 ScalosUnLockIconList(iwt
);
2655 d1(kprintf("%s/%s/%ld: inFound=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, inFound
));
2660 //----------------------------------------------------------------------------
2662 static SAVEDS(LONG
) UndoChangeIconPosEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2667 d1(kprintf("%s/%s/%ld: uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2668 return MoveIconTo(uev
->uev_Data
.uev_IconData
.uid_DirName
,
2669 uev
->uev_Data
.uev_IconData
.uid_IconName
,
2674 //----------------------------------------------------------------------------
2676 static SAVEDS(LONG
) RedoChangeIconPosEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2681 d1(kprintf("%s/%s/%ld: uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2682 return MoveIconTo(uev
->uev_Data
.uev_IconData
.uid_DirName
,
2683 uev
->uev_Data
.uev_IconData
.uid_IconName
,
2688 //----------------------------------------------------------------------------
2690 static SAVEDS(void) UndoDisposeCopyMoveData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2695 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2698 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
2700 if (ucmed
->ucmed_srcDirName
)
2702 FreeCopyString(ucmed
->ucmed_srcDirName
);
2703 ucmed
->ucmed_srcDirName
= NULL
;
2705 if (ucmed
->ucmed_destDirName
)
2707 FreeCopyString(ucmed
->ucmed_destDirName
);
2708 ucmed
->ucmed_destDirName
= NULL
;
2710 if (ucmed
->ucmed_srcName
)
2712 FreeCopyString(ucmed
->ucmed_srcName
);
2713 ucmed
->ucmed_srcName
= NULL
;
2715 if (ucmed
->ucmed_destName
)
2717 FreeCopyString(ucmed
->ucmed_destName
);
2718 ucmed
->ucmed_destName
= NULL
;
2721 d1(kprintf("%s/%s/%ld: END uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2724 //----------------------------------------------------------------------------
2726 static SAVEDS(void) UndoDisposeNewDrawerData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2731 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2734 struct UndoNewDrawerData
*und
= &uev
->uev_Data
.uev_NewDrawerData
;
2736 if (und
->und_DirName
)
2738 FreeCopyString(und
->und_DirName
);
2739 und
->und_DirName
= NULL
;
2741 if (und
->und_srcName
)
2743 FreeCopyString(und
->und_srcName
);
2744 und
->und_srcName
= NULL
;
2747 d1(kprintf("%s/%s/%ld: END uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2749 //----------------------------------------------------------------------------
2751 static SAVEDS(void) UndoDisposeIconData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2756 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2759 if (uev
->uev_Data
.uev_IconData
.uid_DirName
)
2761 FreeCopyString(uev
->uev_Data
.uev_IconData
.uid_DirName
);
2762 uev
->uev_Data
.uev_IconData
.uid_DirName
= NULL
;
2764 if (uev
->uev_Data
.uev_IconData
.uid_IconName
)
2766 FreeCopyString(uev
->uev_Data
.uev_IconData
.uid_IconName
);
2767 uev
->uev_Data
.uev_IconData
.uid_IconName
= NULL
;
2770 d1(kprintf("%s/%s/%ld: END uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2773 //----------------------------------------------------------------------------
2775 static SAVEDS(void) UndoDisposeCleanupData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2780 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2783 struct UndoCleanupData
*ucd
= &uev
->uev_Data
.uev_CleanupData
;
2785 if (ucd
->ucd_WindowTitle
)
2787 FreeCopyString(ucd
->ucd_WindowTitle
);
2788 ucd
->ucd_WindowTitle
= NULL
;
2792 ScalosFree(ucd
->ucd_Icons
);
2793 ucd
->ucd_Icons
= NULL
;
2796 d1(kprintf("%s/%s/%ld: END uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2799 //----------------------------------------------------------------------------
2801 static SAVEDS(void) UndoDisposeSnapshotData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2806 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2809 struct UndoSnaphotIconData
*usid
= &uev
->uev_Data
.uev_SnapshotData
;
2811 if (usid
->usid_DirName
)
2813 FreeCopyString(usid
->usid_DirName
);
2814 usid
->usid_DirName
= NULL
;
2816 if (usid
->usid_IconName
)
2818 FreeCopyString(usid
->usid_IconName
);
2819 usid
->usid_IconName
= NULL
;
2821 if (usid
->usid_IconObj
)
2823 DisposeIconObject(usid
->usid_IconObj
);
2824 usid
->usid_IconObj
= NULL
;
2827 d1(kprintf("%s/%s/%ld: END uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2830 //----------------------------------------------------------------------------
2832 static SAVEDS(void) UndoDisposeSizeWindowData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2837 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2840 struct UndoSizeWindowData
*uswd
= &uev
->uev_Data
.uev_SizeWindowData
;
2842 if (uswd
->uswd_WindowTitle
)
2844 FreeCopyString(uswd
->uswd_WindowTitle
);
2845 uswd
->uswd_WindowTitle
= NULL
;
2848 d1(kprintf("%s/%s/%ld: END uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2851 //----------------------------------------------------------------------------
2853 static SAVEDS(void) UndoDisposeSetProtectionData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2858 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2861 struct UndoSetProtectionData
*uspd
= &uev
->uev_Data
.uev_SetProtectionData
;
2863 if (uspd
->uspd_DirName
)
2865 FreeCopyString(uspd
->uspd_DirName
);
2866 uspd
->uspd_DirName
= NULL
;
2868 if (uspd
->uspd_IconName
)
2870 FreeCopyString(uspd
->uspd_IconName
);
2871 uspd
->uspd_IconName
= NULL
;
2874 d1(kprintf("%s/%s/%ld: END uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2877 //----------------------------------------------------------------------------
2879 static SAVEDS(void) UndoDisposeSetCommentData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2884 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2887 struct UndoSetCommentData
*uscd
= &uev
->uev_Data
.uev_SetCommentData
;
2889 if (uscd
->uscd_DirName
)
2891 FreeCopyString(uscd
->uscd_DirName
);
2892 uscd
->uscd_DirName
= NULL
;
2894 if (uscd
->uscd_IconName
)
2896 FreeCopyString(uscd
->uscd_IconName
);
2897 uscd
->uscd_IconName
= NULL
;
2899 if (uscd
->uscd_OldComment
)
2901 FreeCopyString(uscd
->uscd_OldComment
);
2902 uscd
->uscd_OldComment
= NULL
;
2904 if (uscd
->uscd_NewComment
)
2906 FreeCopyString(uscd
->uscd_NewComment
);
2907 uscd
->uscd_NewComment
= NULL
;
2910 d1(kprintf("%s/%s/%ld: END uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2913 //----------------------------------------------------------------------------
2915 static SAVEDS(void) UndoDisposeSetToolTypesData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2920 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2923 struct UndoSetToolTypesData
*ustd
= &uev
->uev_Data
.uev_SetToolTypesData
;
2925 if (ustd
->ustd_DirName
)
2927 FreeCopyString(ustd
->ustd_DirName
);
2928 ustd
->ustd_DirName
= NULL
;
2930 if (ustd
->ustd_IconName
)
2932 FreeCopyString(ustd
->ustd_IconName
);
2933 ustd
->ustd_IconName
= NULL
;
2935 if (ustd
->ustd_OldToolTypes
)
2937 ScalosFree(ustd
->ustd_OldToolTypes
);
2938 ustd
->ustd_OldToolTypes
= NULL
;
2940 if (ustd
->ustd_NewToolTypes
)
2942 ScalosFree(ustd
->ustd_NewToolTypes
);
2943 ustd
->ustd_NewToolTypes
= NULL
;
2946 d1(kprintf("%s/%s/%ld: END uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2949 //----------------------------------------------------------------------------
2951 static SAVEDS(void) UndoDisposeChangeIconObjectData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2956 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2959 struct UndoChangeIconObjectData
*uciod
= &uev
->uev_Data
.uev_ChangeIconObjectData
;
2961 if (uciod
->uciod_DirName
)
2963 FreeCopyString(uciod
->uciod_DirName
);
2964 uciod
->uciod_DirName
= NULL
;
2966 if (uciod
->uciod_IconName
)
2968 FreeCopyString(uciod
->uciod_IconName
);
2969 uciod
->uciod_IconName
= NULL
;
2971 if (uciod
->uciod_OldIconObject
)
2973 DisposeIconObject(uciod
->uciod_OldIconObject
);
2974 uciod
->uciod_OldIconObject
= NULL
;
2976 if (uciod
->uciod_NewIconObject
)
2978 DisposeIconObject(uciod
->uciod_NewIconObject
);
2979 uciod
->uciod_NewIconObject
= NULL
;
2982 d1(kprintf("%s/%s/%ld: END uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2985 //----------------------------------------------------------------------------
2987 static SAVEDS(void) UndoDisposeCloseWindowData(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
2992 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
2995 struct UndoCloseWindowData
*ucwd
= &uev
->uev_Data
.uev_CloseWindowData
;
2997 if (ucwd
->ucwd_DirName
)
2999 FreeCopyString(ucwd
->ucwd_DirName
);
3000 ucwd
->ucwd_DirName
= NULL
;
3002 if (ucwd
->ucwd_WindowTitle
)
3004 FreeCopyString(ucwd
->ucwd_WindowTitle
);
3005 ucwd
->ucwd_WindowTitle
= NULL
;
3008 d1(kprintf("%s/%s/%ld: END uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
3010 //----------------------------------------------------------------------------
3012 static SAVEDS(LONG
) UndoCleanupEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3014 struct internalScaWindowTask
*iwt
;
3015 BOOL Success
= FALSE
;
3020 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
3023 struct ScaIconNode
*in
;
3025 d1(kprintf("%s/%s/%ld: ucd_IconCount=%lu\n", __FILE__
, __FUNC__
, __LINE__
, uev
->uev_Data
.uev_CleanupData
.ucd_IconCount
));
3026 d1(kprintf("%s/%s/%ld: ucd_WindowTask=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
->uev_Data
.uev_CleanupData
.ucd_WindowTask
));
3028 iwt
= UndoFindWindowByWindowTask(uev
->uev_Data
.uev_CleanupData
.ucd_WindowTask
);
3032 ScalosLockIconListShared(iwt
);
3034 if (iwt
->iwt_WindowTask
.wt_Window
)
3036 EraseRect(iwt
->iwt_WindowTask
.wt_Window
->RPort
, 0, 0,
3037 iwt
->iwt_WindowTask
.wt_Window
->Width
- 1,
3038 iwt
->iwt_WindowTask
.wt_Window
->Height
-1);
3041 for (in
= iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
3043 const struct UndoCleanupIconEntry
*ucie
;
3045 ucie
= UndoFindCleanupIconEntry(uev
, in
);
3049 struct ExtGadget
*gg
= (struct ExtGadget
*) in
->in_Icon
;
3051 d1(kprintf("%s/%s/%ld: in=%08lx <%s> Left=%ld Top=%ld\n", \
3052 __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
), \
3053 ucie
->ucin_Left
, ucie
->ucin_Top
));
3055 // Adjust icon position
3056 x0
= gg
->LeftEdge
- gg
->BoundsLeftEdge
;
3058 gg
->LeftEdge
= ucie
->ucin_Left
;
3059 gg
->BoundsLeftEdge
= gg
->LeftEdge
- x0
;
3061 y0
= gg
->TopEdge
- gg
->BoundsTopEdge
;
3063 gg
->TopEdge
= ucie
->ucin_Top
;
3064 gg
->BoundsTopEdge
= gg
->TopEdge
- y0
;
3068 RefreshIconList(iwt
, iwt
->iwt_WindowTask
.wt_IconList
, NULL
);
3070 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_SetVirtSize
,
3071 SETVIRTF_AdjustBottomSlider
| SETVIRTF_AdjustRightSlider
);
3073 ScalosUnLockIconList(iwt
);
3079 SCA_UnLockWindowList();
3081 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
));
3086 //----------------------------------------------------------------------------
3088 static SAVEDS(LONG
) RedoCleanupEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3090 BOOL Success
= FALSE
;
3091 struct internalScaWindowTask
*iwt
;
3093 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3096 iwt
= UndoFindWindowByWindowTask(uev
->uev_Data
.uev_CleanupData
.ucd_WindowTask
);
3100 switch (uev
->uev_Data
.uev_CleanupData
.ucd_CleanupMode
)
3102 case CLEANUP_ByName
:
3103 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUpByName
);
3105 case CLEANUP_ByDate
:
3106 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUpByDate
);
3108 case CLEANUP_BySize
:
3109 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUpBySize
);
3111 case CLEANUP_ByType
:
3112 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUpByType
);
3114 case CLEANUP_Default
:
3122 SCA_UnLockWindowList();
3124 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
3129 //----------------------------------------------------------------------------
3131 static const struct UndoCleanupIconEntry
*UndoFindCleanupIconEntry(const struct UndoEvent
*uev
, const struct ScaIconNode
*in
)
3133 const struct UndoCleanupIconEntry
*ucie
= uev
->uev_Data
.uev_CleanupData
.ucd_Icons
;
3136 for (n
= 0; n
< uev
->uev_Data
.uev_CleanupData
.ucd_IconCount
; n
++, ucie
++)
3138 if (ucie
->ucin_IconNode
== in
)
3145 //----------------------------------------------------------------------------
3147 static SAVEDS(LONG
) UndoLeaveOutEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3149 BOOL Success
= FALSE
;
3150 struct UndoSnaphotIconData
*usid
= &uev
->uev_Data
.uev_SnapshotData
;
3151 struct internalScaWindowTask
*iwt
;
3152 BPTR oldDir
= BNULL
;
3155 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3160 iwt
= UndoFindWindowByDir(usid
->usid_DirName
);
3161 d1(kprintf("%s/%s/%ld: iwt=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
));
3165 oldDir
= CurrentDir(iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
);
3167 iconDirLock
= DupLock(iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
);
3168 debugLock_d1(iconDirLock
);
3169 if (BNULL
== iconDirLock
)
3172 // !!! side effects: UnLocks(iconDirLock) and frees <in> !!!
3173 PutAwayIcon((struct internalScaWindowTask
*) iInfos
.xii_iinfos
.ii_MainWindowStruct
->ws_WindowTask
,
3174 iconDirLock
, usid
->usid_IconName
, TRUE
);
3176 // add icon to owning drawer window
3177 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
,
3178 SCCM_IconWin_ReadIcon
,
3179 usid
->usid_IconName
,
3182 // Special handling for "view all" textwindows.
3183 // here both object and icon are separate entries, which must be removed both!
3184 if (!IsIwtViewByIcon(iwt
) && IsShowAll(iwt
->iwt_WindowTask
.mt_WindowStruct
))
3186 Path
= AllocPathBuffer();
3190 stccpy(Path
, usid
->usid_IconName
, Max_PathLen
);
3191 SafeStrCat(Path
, ".info", Max_PathLen
);
3193 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
,
3194 SCCM_IconWin_ReadIcon
,
3205 FreePathBuffer(Path
);
3207 SCA_UnLockWindowList();
3209 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
3214 //----------------------------------------------------------------------------
3216 static SAVEDS(LONG
) RedoLeaveOutEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3218 BOOL Success
= FALSE
;
3219 struct UndoSnaphotIconData
*usid
= &uev
->uev_Data
.uev_SnapshotData
;
3220 struct internalScaWindowTask
*iwt
;
3222 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3227 iwt
= UndoFindWindowByDir(usid
->usid_DirName
);
3231 iconDirLock
= DupLock(iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
);
3232 debugLock_d1(iconDirLock
);
3233 if (BNULL
== iconDirLock
)
3236 DoLeaveOutIcon(iwt
, iconDirLock
, usid
->usid_IconName
,
3237 uev
->uev_NewPosX
, uev
->uev_NewPosY
);
3243 SCA_UnLockWindowList();
3245 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
3250 //----------------------------------------------------------------------------
3252 static SAVEDS(LONG
) UndoSnapshotEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3254 struct internalScaWindowTask
*iwt
;
3255 struct ScaIconNode
*in
= NULL
;
3256 BOOL Success
= FALSE
;
3258 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3261 struct UndoSnaphotIconData
*usid
= &uev
->uev_Data
.uev_SnapshotData
;
3262 const struct IBox
*pWinRect
;
3265 LONG WinCurrentX
, WinCurrentY
;
3267 if (!UndoFindWindowAndIcon(usid
->usid_DirName
, usid
->usid_IconName
, &iwt
, &in
))
3270 d1(kprintf("%s/%s/%ld: iwt=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
));
3271 d1(kprintf("%s/%s/%ld: usid_IconName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, usid
->usid_IconName
));
3272 d1(kprintf("%s/%s/%ld: in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
)));
3274 if (uev
->uev_OldPosX
!= uev
->uev_NewPosX
|| uev
->uev_OldPosY
!= uev
->uev_NewPosY
)
3276 if (!MoveIconTo(usid
->usid_DirName
,
3277 usid
->usid_IconName
,
3278 uev
->uev_OldPosX
, uev
->uev_OldPosY
))
3282 GetAttr(IDTA_ViewModes
, usid
->usid_IconObj
, &IconViewMode
);
3283 GetAttr(IDTA_Flags
, usid
->usid_IconObj
, &ddFlags
);
3284 GetAttr(IDTA_WindowRect
, usid
->usid_IconObj
, (ULONG
*) &pWinRect
);
3285 GetAttr(IDTA_WinCurrentX
, usid
->usid_IconObj
, (ULONG
*) &WinCurrentX
);
3286 GetAttr(IDTA_WinCurrentY
, usid
->usid_IconObj
, (ULONG
*) &WinCurrentY
);
3288 SetAttrs(in
->in_Icon
,
3289 IDTA_ViewModes
, IconViewMode
,
3290 IDTA_Flags
, ddFlags
,
3291 pWinRect
? IDTA_WindowRect
: TAG_IGNORE
, (ULONG
) pWinRect
,
3292 IDTA_WinCurrentY
, WinCurrentY
,
3293 IDTA_WinCurrentX
, WinCurrentX
,
3296 if (usid
->usid_SaveIcon
)
3300 Result
= SaveIconObject(usid
->usid_IconObj
,
3301 iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
,
3302 usid
->usid_IconName
,
3306 if (RETURN_OK
!= Result
)
3316 ScalosUnLockIconList(iwt
);
3317 SCA_UnLockWindowList();
3320 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
3325 //----------------------------------------------------------------------------
3327 static SAVEDS(LONG
) RedoSnapshotPosEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3329 struct internalScaWindowTask
*iwt
;
3330 struct ScaIconNode
*in
= NULL
;
3331 BOOL Success
= FALSE
;
3333 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3336 struct UndoSnaphotIconData
*usid
= &uev
->uev_Data
.uev_SnapshotData
;
3338 if (!UndoFindWindowAndIcon(usid
->usid_DirName
, usid
->usid_IconName
, &iwt
, &in
))
3341 d1(kprintf("%s/%s/%ld: iwt=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
));
3342 d1(kprintf("%s/%s/%ld: usid_IconName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, usid
->usid_IconName
));
3344 if (uev
->uev_OldPosX
!= uev
->uev_NewPosX
|| uev
->uev_OldPosY
!= uev
->uev_NewPosY
)
3346 if (!MoveIconTo(usid
->usid_DirName
,
3347 usid
->usid_IconName
,
3348 uev
->uev_NewPosX
, uev
->uev_NewPosY
))
3352 SCA_LockWindowList(SCA_LockWindowList_Shared
);
3354 if (UNDO_Snapshot
== uev
->uev_Type
)
3355 Success
= UndoSnapshotIcon(iwt
, in
);
3358 struct ScaIconNode
*IconList
;
3360 SCA_MoveIconNode(&iwt
->iwt_WindowTask
.wt_IconList
, &IconList
, in
);
3362 RemoveIcons(iwt
, &IconList
); // visibly remove icon from window
3364 Success
= UndoUnsnapshotIcon(iwt
, in
, usid
->usid_SaveIcon
);
3366 SCA_MoveIconNode(&IconList
, &iwt
->iwt_WindowTask
.wt_LateIconList
, in
);
3368 if (IsIwtViewByIcon(iwt
))
3370 d1(KPrintF("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3371 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUp
);
3372 d1(KPrintF("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3373 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_SetVirtSize
,
3374 SETVIRTF_AdjustBottomSlider
| SETVIRTF_AdjustRightSlider
);
3378 SCA_UnLockWindowList();
3384 ScalosUnLockIconList(iwt
);
3385 SCA_UnLockWindowList();
3388 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
3393 //----------------------------------------------------------------------------
3395 static BOOL
UndoSnapshotIcon(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3397 BOOL Success
= FALSE
;
3400 d1(KPrintF("%s/%s/%ld: START iwt=%08lx in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, in
, GetIconName(in
)));
3402 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
3407 if (WBAPPICON
== IconType
)
3409 WindowSendAppIconMsg(iwt
, AMCLASSICON_Snapshot
, in
);
3416 SetIconWindowRect(in
);
3418 if (in
->in_DeviceIcon
)
3420 destDirLock
= DiskInfoLock(in
);
3426 Result
= ScalosPutIcon(in
, destDirLock
, in
->in_Flags
& INF_DefaultIcon
);
3428 if (RETURN_OK
== Result
)
3431 UnLock(destDirLock
);
3439 destDirLock
= in
->in_Lock
;
3441 destDirLock
= iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
;
3443 Result
= ScalosPutIcon(in
, destDirLock
, in
->in_Flags
& INF_DefaultIcon
);
3445 if (RETURN_OK
== Result
)
3449 in
->in_Flags
&= ~INF_FreeIconPosition
;
3450 in
->in_SupportFlags
&= ~INF_SupportsSnapshot
;
3451 in
->in_SupportFlags
|= INF_SupportsUnSnapshot
;
3454 d1(KPrintF("%s/%s/%ld: END in=%08lx <%s> inFlags=%08lx Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
), in
->in_Flags
, Success
));
3459 //----------------------------------------------------------------------------
3461 static BOOL
UndoUnsnapshotIcon(struct internalScaWindowTask
*iwt
,
3462 struct ScaIconNode
*in
, BOOL SaveIcon
)
3464 BOOL Success
= FALSE
;
3467 d1(KPrintF("%s/%s/%ld: iwt=%08lx in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, in
, GetIconName(in
)));
3469 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
3474 if (WBAPPICON
== IconType
)
3476 WindowSendAppIconMsg(iwt
, AMCLASSICON_UnSnapshot
, in
);
3481 struct ExtGadget
*gg
= (struct ExtGadget
*) in
->in_Icon
;
3483 WORD LeftEdge
, TopEdge
;
3485 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3487 SetIconWindowRect(in
);
3489 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3491 LeftEdge
= gg
->LeftEdge
;
3492 TopEdge
= gg
->TopEdge
;
3494 if (in
->in_DeviceIcon
)
3496 destDirLock
= DiskInfoLock(in
);
3498 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3503 gg
->LeftEdge
= gg
->TopEdge
= NO_ICON_POSITION_SHORT
;
3509 Result
= ScalosPutIcon(in
, destDirLock
, in
->in_Flags
& INF_DefaultIcon
);
3511 if (RETURN_OK
== Result
)
3519 UnLock(destDirLock
);
3524 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3527 destDirLock
= in
->in_Lock
;
3529 destDirLock
= iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
;
3531 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3533 gg
->LeftEdge
= gg
->TopEdge
= NO_ICON_POSITION_SHORT
;
3539 Result
= ScalosPutIcon(in
, destDirLock
, in
->in_Flags
& INF_DefaultIcon
);
3541 if (RETURN_OK
== Result
)
3549 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3552 gg
->LeftEdge
= LeftEdge
;
3553 gg
->TopEdge
= TopEdge
;
3555 in
->in_Flags
|= INF_FreeIconPosition
;
3556 in
->in_SupportFlags
|= INF_SupportsSnapshot
;
3557 in
->in_SupportFlags
&= ~INF_SupportsUnSnapshot
;
3560 d1(KPrintF("%s/%s/%ld: END in=%08lx <%s> inFlags=%08lx Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
), in
->in_Flags
, Success
));
3565 //----------------------------------------------------------------------------
3567 static SAVEDS(LONG
) UndoRenameEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3570 BOOL Success
= FALSE
;
3571 STRPTR destIconName
= NULL
;
3572 STRPTR srcIconName
= NULL
;
3577 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
3580 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
3583 d1(kprintf("%s/%s/%ld: ucmed_srcDirName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, ucmed
->ucmed_srcDirName
));
3585 srcDirLock
= Lock(ucmed
->ucmed_srcDirName
, ACCESS_READ
);
3586 if (BNULL
== srcDirLock
)
3589 debugLock_d1(srcDirLock
);
3591 destIconName
= UndoBuildIconName(ucmed
->ucmed_destName
);
3592 if (NULL
== destIconName
)
3595 srcIconName
= UndoBuildIconName(ucmed
->ucmed_srcName
);
3596 if (NULL
== srcIconName
)
3599 d1(kprintf("%s/%s/%ld: ucmed_srcName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, ucmed
->ucmed_srcName
));
3600 d1(kprintf("%s/%s/%ld: ucmed_destName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, ucmed
->ucmed_destName
));
3602 oldDir
= CurrentDir(srcDirLock
);
3604 Success
= Rename(ucmed
->ucmed_destName
, ucmed
->ucmed_srcName
);
3611 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3613 // Try to also rename icon
3614 oldDir
= CurrentDir(srcDirLock
);
3615 (void) Rename(destIconName
, srcIconName
);
3619 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3621 if (BNULL
!= srcDirLock
)
3624 FreePathBuffer(srcIconName
);
3626 FreePathBuffer(destIconName
);
3628 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
3633 //----------------------------------------------------------------------------
3635 static SAVEDS(LONG
) RedoRenameEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3638 BOOL Success
= FALSE
;
3639 STRPTR destIconName
= NULL
;
3640 STRPTR srcIconName
= NULL
;
3645 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
3648 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
3651 d1(kprintf("%s/%s/%ld: ucmed_srcDirName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, ucmed
->ucmed_srcDirName
));
3653 srcDirLock
= Lock(ucmed
->ucmed_srcDirName
, ACCESS_READ
);
3654 if (BNULL
== srcDirLock
)
3657 debugLock_d1(srcDirLock
);
3659 destIconName
= UndoBuildIconName(ucmed
->ucmed_destName
);
3660 if (NULL
== destIconName
)
3663 srcIconName
= UndoBuildIconName(ucmed
->ucmed_srcName
);
3664 if (NULL
== srcIconName
)
3667 d1(kprintf("%s/%s/%ld: .ucmed_srcName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, ucmed
->ucmed_srcName
));
3668 d1(kprintf("%s/%s/%ld: .ucmed_destName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, ucmed
->ucmed_destName
));
3670 oldDir
= CurrentDir(srcDirLock
);
3672 Success
= Rename(ucmed
->ucmed_srcName
, ucmed
->ucmed_destName
);
3679 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3681 // Try to also rename icon
3682 oldDir
= CurrentDir(srcDirLock
);
3683 (void) Rename(srcIconName
, destIconName
);
3687 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3689 if (BNULL
!= srcDirLock
)
3692 FreePathBuffer(srcIconName
);
3694 FreePathBuffer(destIconName
);
3696 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
3701 //----------------------------------------------------------------------------
3703 static SAVEDS(LONG
) UndoRelabelEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3705 BOOL Success
= FALSE
;
3706 STRPTR newName
= NULL
;
3712 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
3715 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
3717 driveName
= AllocPathBuffer();
3718 if (NULL
== driveName
)
3721 newName
= AllocPathBuffer();
3722 if (NULL
== newName
)
3725 stccpy(driveName
, ucmed
->ucmed_destName
, Max_PathLen
);
3726 SafeStrCat(driveName
, ":", Max_PathLen
);
3728 stccpy(newName
, ucmed
->ucmed_srcName
, Max_PathLen
);
3729 StripTrailingColon(newName
);
3731 Success
= Relabel(driveName
, newName
);
3735 FreePathBuffer(driveName
);
3737 FreePathBuffer(newName
);
3739 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
3744 //----------------------------------------------------------------------------
3746 static SAVEDS(LONG
) RedoRelabelEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3753 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
3756 struct UndoCopyMoveEventData
*ucmed
= &uev
->uev_Data
.uev_CopyMoveData
;
3758 Success
= Relabel(ucmed
->ucmed_srcName
, ucmed
->ucmed_destName
);
3761 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
3766 //----------------------------------------------------------------------------
3768 static SAVEDS(LONG
) UndoSizeWindowEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3770 struct internalScaWindowTask
*iwt
;
3771 BOOL Success
= FALSE
;
3776 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
3779 struct UndoSizeWindowData
*uswd
= &uev
->uev_Data
.uev_SizeWindowData
;
3781 d1(kprintf("%s/%s/%ld: ucd_WindowTask=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
->uev_Data
.uev_CleanupData
.ucd_WindowTask
));
3783 iwt
= UndoFindWindowByWindowTask(uswd
->uswd_WindowTask
);
3787 ScalosObtainSemaphoreShared(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
3789 d1(kprintf("%s/%s/%ld: XOffset=%ld YOffset=%ld\n", __FILE__
, __FUNC__
, __LINE__
, \
3790 iwt
->iwt_WindowTask
.wt_XOffset
, iwt
->iwt_WindowTask
.wt_YOffset
));
3792 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_DeltaMove
,
3793 uswd
->uswd_OldVirtX
- iwt
->iwt_WindowTask
.wt_XOffset
,
3794 uswd
->uswd_OldVirtY
- iwt
->iwt_WindowTask
.wt_YOffset
);
3796 d1(KPrintF("%s/%s/%ld: Left=%ld Top=%ld Width=%ld Height=%ld\n", __FILE__
, __FUNC__
, __LINE__
, \
3797 uswd
->uswd_OldLeft
, uswd
->uswd_OldTop
, \
3798 uswd
->uswd_OldWidth
, uswd
->uswd_OldHeight
));
3800 if (iwt
->iwt_WindowTask
.wt_Window
)
3802 ChangeWindowBox(iwt
->iwt_WindowTask
.wt_Window
,
3805 uswd
->uswd_OldWidth
,
3806 uswd
->uswd_OldHeight
);
3809 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
3815 SCA_UnLockWindowList();
3817 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
3822 //----------------------------------------------------------------------------
3824 static SAVEDS(LONG
) RedoSizeWindowEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3826 struct internalScaWindowTask
*iwt
;
3827 BOOL Success
= FALSE
;
3832 d1(kprintf("%s/%s/%ld: START uev=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
));
3835 struct UndoSizeWindowData
*uswd
= &uev
->uev_Data
.uev_SizeWindowData
;
3837 d1(kprintf("%s/%s/%ld: ucd_WindowTask=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
->uev_Data
.uev_CleanupData
.ucd_WindowTask
));
3839 iwt
= UndoFindWindowByWindowTask(uswd
->uswd_WindowTask
);
3843 ScalosObtainSemaphoreShared(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
3845 d1(kprintf("%s/%s/%ld: XOffset=%ld YOffset=%ld\n", __FILE__
, __FUNC__
, __LINE__
, \
3846 iwt
->iwt_WindowTask
.wt_XOffset
, iwt
->iwt_WindowTask
.wt_YOffset
));
3848 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_DeltaMove
,
3849 uswd
->uswd_NewVirtX
- iwt
->iwt_WindowTask
.wt_XOffset
,
3850 uswd
->uswd_NewVirtY
- iwt
->iwt_WindowTask
.wt_YOffset
);
3852 d1(KPrintF("%s/%s/%ld: Left=%ld Top=%ld Width=%ld Height=%ld\n", __FILE__
, __FUNC__
, __LINE__
, \
3853 uswd
->uswd_NewLeft
, uswd
->uswd_NewTop
, \
3854 uswd
->uswd_NewWidth
, uswd
->uswd_NewHeight
));
3856 if (iwt
->iwt_WindowTask
.wt_Window
)
3858 ChangeWindowBox(iwt
->iwt_WindowTask
.wt_Window
,
3861 uswd
->uswd_NewWidth
,
3862 uswd
->uswd_NewHeight
);
3865 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
3871 SCA_UnLockWindowList();
3873 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
3878 //----------------------------------------------------------------------------
3880 static SAVEDS(LONG
) UndoNewDrawerEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3882 BOOL Success
= FALSE
;
3884 STRPTR iconName
= NULL
;
3889 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
3892 struct UndoNewDrawerData
*und
= &uev
->uev_Data
.uev_NewDrawerData
;
3895 srcDirLock
= Lock(und
->und_DirName
, ACCESS_READ
);
3896 d1(kprintf("%s/%s/%ld: srcDirLock=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, srcDirLock
, und
->und_DirName
));
3897 if (BNULL
== srcDirLock
)
3900 if (0 == strlen(und
->und_srcName
))
3903 Result
= DoMethod(uev
->uev_UndoStep
->ust_FileTransObj
,
3904 SCCM_FileTrans_Delete
,
3905 srcDirLock
, und
->und_srcName
);
3907 if (RETURN_OK
!= Result
)
3908 break; // SCCM_FileTrans_Delete failed
3910 if (und
->und_CreateIcon
)
3912 CONST_STRPTR iconExt
= ".info";
3914 iconName
= ScalosAlloc(1 + strlen(und
->und_srcName
) + strlen(iconExt
));
3915 if (NULL
== iconName
)
3918 strcpy(iconName
, und
->und_srcName
);
3919 strcat(iconName
, iconExt
);
3921 Result
= DoMethod(uev
->uev_UndoStep
->ust_FileTransObj
,
3922 SCCM_FileTrans_Delete
,
3923 srcDirLock
, iconName
);
3925 if (RETURN_OK
!= Result
)
3926 break; // SCCM_FileTrans_Delete failed
3932 if (BNULL
!= srcDirLock
)
3935 ScalosFree(iconName
);
3940 //----------------------------------------------------------------------------
3942 static SAVEDS(LONG
) RedoNewDrawerEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
3944 BOOL Success
= FALSE
;
3946 BPTR newDirLock
= BNULL
;
3947 Object
*IconObj
= NULL
;
3948 BPTR oldDir
= BNULL
;
3953 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
3956 struct UndoNewDrawerData
*und
= &uev
->uev_Data
.uev_NewDrawerData
;
3958 srcDirLock
= Lock(und
->und_DirName
, ACCESS_READ
);
3959 if (BNULL
== srcDirLock
)
3962 oldDir
= CurrentDir(srcDirLock
);
3964 newDirLock
= CreateDir(und
->und_srcName
);
3965 debugLock_d1(newDirLock
);
3966 if (BNULL
== newDirLock
)
3969 if (und
->und_CreateIcon
)
3972 struct ScaUpdateIcon_IW upd
;
3974 IconObj
= GetDefIconObject(WBDRAWER
, NULL
);
3976 d1(kprintf(__FILE__
"/%s/%ld: IconObj=%08lx\n", __FUNC__
, __LINE__
, IconObj
));
3978 if (NULL
== IconObj
)
3981 upd
.ui_iw_Lock
= srcDirLock
;
3982 upd
.ui_iw_Name
= und
->und_srcName
;
3983 upd
.ui_IconType
= ICONTYPE_NONE
;
3985 rc
= PutIconObjectTags(IconObj
, und
->und_srcName
,
3987 d1(kprintf(__FILE__
"/%s/%ld: PutIconObjectTags returned rc=%ld\n", __FUNC__
, __LINE__
, rc
));
3988 if (RETURN_OK
!= rc
)
3991 SCA_UpdateIcon(WSV_Type_IconWindow
, &upd
, sizeof(upd
));
4000 DisposeIconObject(IconObj
);
4001 if (BNULL
!= srcDirLock
)
4003 if (BNULL
!= newDirLock
)
4006 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
4011 //----------------------------------------------------------------------------
4013 static SAVEDS(LONG
) UndoSetProtectionEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
4015 BOOL Success
= FALSE
;
4017 BPTR oldDir
= BNULL
;
4022 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
4025 struct UndoSetProtectionData
*uspd
= &uev
->uev_Data
.uev_SetProtectionData
;
4026 struct ScaUpdateIcon_IW upd
;
4028 dirLock
= Lock(uspd
->uspd_DirName
, ACCESS_READ
);
4029 debugLock_d1(dirLock
);
4030 if (BNULL
== dirLock
)
4033 oldDir
= CurrentDir(dirLock
);
4035 upd
.ui_iw_Lock
= dirLock
;
4036 upd
.ui_iw_Name
= uspd
->uspd_IconName
;
4037 upd
.ui_IconType
= ICONTYPE_NONE
;
4039 Success
= SetProtection(uspd
->uspd_IconName
, uspd
->uspd_OldProtection
);
4042 SCA_UpdateIcon(WSV_Type_IconWindow
, &upd
, sizeof(upd
));
4047 if (BNULL
!= dirLock
)
4050 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
4055 //----------------------------------------------------------------------------
4057 static SAVEDS(LONG
) RedoSetProtectionEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
4059 BOOL Success
= FALSE
;
4061 BPTR oldDir
= BNULL
;
4066 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
4069 struct UndoSetProtectionData
*uspd
= &uev
->uev_Data
.uev_SetProtectionData
;
4070 struct ScaUpdateIcon_IW upd
;
4072 dirLock
= Lock(uspd
->uspd_DirName
, ACCESS_READ
);
4073 debugLock_d1(dirLock
);
4074 if (BNULL
== dirLock
)
4077 oldDir
= CurrentDir(dirLock
);
4079 upd
.ui_iw_Lock
= dirLock
;
4080 upd
.ui_iw_Name
= uspd
->uspd_IconName
;
4081 upd
.ui_IconType
= ICONTYPE_NONE
;
4083 Success
= SetProtection(uspd
->uspd_IconName
, uspd
->uspd_OldProtection
);
4086 SCA_UpdateIcon(WSV_Type_IconWindow
, &upd
, sizeof(upd
));
4091 if (BNULL
!= dirLock
)
4094 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
4099 //----------------------------------------------------------------------------
4101 static SAVEDS(LONG
) UndoSetCommentEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
4103 BOOL Success
= FALSE
;
4105 BPTR oldDir
= BNULL
;
4110 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
4113 struct UndoSetCommentData
*uscd
= &uev
->uev_Data
.uev_SetCommentData
;
4114 struct ScaUpdateIcon_IW upd
;
4116 dirLock
= Lock(uscd
->uscd_DirName
, ACCESS_READ
);
4117 debugLock_d1(dirLock
);
4118 if (BNULL
== dirLock
)
4121 oldDir
= CurrentDir(dirLock
);
4123 upd
.ui_iw_Lock
= dirLock
;
4124 upd
.ui_iw_Name
= uscd
->uscd_IconName
;
4125 upd
.ui_IconType
= ICONTYPE_NONE
;
4127 Success
= SetComment(uscd
->uscd_IconName
, uscd
->uscd_OldComment
);
4130 SCA_UpdateIcon(WSV_Type_IconWindow
, &upd
, sizeof(upd
));
4135 if (BNULL
!= dirLock
)
4138 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
4143 //----------------------------------------------------------------------------
4145 static SAVEDS(LONG
) RedoSetCommentEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
4147 BOOL Success
= FALSE
;
4149 BPTR oldDir
= BNULL
;
4154 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
4157 struct UndoSetCommentData
*uscd
= &uev
->uev_Data
.uev_SetCommentData
;
4158 struct ScaUpdateIcon_IW upd
;
4160 dirLock
= Lock(uscd
->uscd_DirName
, ACCESS_READ
);
4161 debugLock_d1(dirLock
);
4162 if (BNULL
== dirLock
)
4165 oldDir
= CurrentDir(dirLock
);
4167 upd
.ui_iw_Lock
= dirLock
;
4168 upd
.ui_iw_Name
= uscd
->uscd_IconName
;
4169 upd
.ui_IconType
= ICONTYPE_NONE
;
4171 Success
= SetComment(uscd
->uscd_IconName
, uscd
->uscd_NewComment
);
4174 SCA_UpdateIcon(WSV_Type_IconWindow
, &upd
, sizeof(upd
));
4179 if (BNULL
!= dirLock
)
4182 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
4187 //----------------------------------------------------------------------------
4189 static SAVEDS(LONG
) UndoSetToolTypesEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
4191 BOOL Success
= FALSE
;
4193 BPTR oldDir
= BNULL
;
4194 struct internalScaWindowTask
*iwt
= NULL
;
4195 struct ScaIconNode
*in
= NULL
;
4200 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
4203 struct UndoSetToolTypesData
*ustd
= &uev
->uev_Data
.uev_SetToolTypesData
;
4204 struct ScaUpdateIcon_IW upd
;
4207 dirLock
= Lock(ustd
->ustd_DirName
, ACCESS_READ
);
4208 debugLock_d1(dirLock
);
4209 if (BNULL
== dirLock
)
4212 oldDir
= CurrentDir(dirLock
);
4214 if (!UndoFindWindowAndIcon(ustd
->ustd_DirName
, ustd
->ustd_IconName
, &iwt
, &in
))
4217 upd
.ui_iw_Lock
= dirLock
;
4218 upd
.ui_iw_Name
= ustd
->ustd_IconName
;
4219 upd
.ui_IconType
= ICONTYPE_NONE
;
4221 SetAttrs(in
->in_Icon
,
4222 IDTA_ToolTypes
, (ULONG
) ustd
->ustd_OldToolTypes
,
4225 rc
= PutIconObjectTags(in
->in_Icon
, ustd
->ustd_IconName
,
4226 ICONA_NoNewImage
, TRUE
,
4228 d1(kprintf(__FILE__
"/%s/%ld: PutIconObjectTags returned rc=%ld\n", __FUNC__
, __LINE__
, rc
));
4229 if (RETURN_OK
!= rc
)
4232 SCA_UpdateIcon(WSV_Type_IconWindow
, &upd
, sizeof(upd
));
4240 ScalosUnLockIconList(iwt
);
4241 SCA_UnLockWindowList();
4245 if (BNULL
!= dirLock
)
4248 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
4253 //----------------------------------------------------------------------------
4255 static SAVEDS(LONG
) RedoSetToolTypesEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
4257 BOOL Success
= FALSE
;
4259 BPTR oldDir
= BNULL
;
4260 struct internalScaWindowTask
*iwt
= NULL
;
4261 struct ScaIconNode
*in
= NULL
;
4266 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
4269 struct UndoSetToolTypesData
*ustd
= &uev
->uev_Data
.uev_SetToolTypesData
;
4270 struct ScaUpdateIcon_IW upd
;
4273 dirLock
= Lock(ustd
->ustd_DirName
, ACCESS_READ
);
4274 debugLock_d1(dirLock
);
4275 if (BNULL
== dirLock
)
4278 oldDir
= CurrentDir(dirLock
);
4280 if (!UndoFindWindowAndIcon(ustd
->ustd_DirName
, ustd
->ustd_IconName
, &iwt
, &in
))
4283 upd
.ui_iw_Lock
= dirLock
;
4284 upd
.ui_iw_Name
= ustd
->ustd_IconName
;
4285 upd
.ui_IconType
= ICONTYPE_NONE
;
4287 SetAttrs(in
->in_Icon
,
4288 IDTA_ToolTypes
, (ULONG
) ustd
->ustd_OldToolTypes
,
4291 rc
= PutIconObjectTags(in
->in_Icon
, ustd
->ustd_IconName
,
4292 ICONA_NoNewImage
, TRUE
,
4294 d1(kprintf(__FILE__
"/%s/%ld: PutIconObjectTags returned rc=%ld\n", __FUNC__
, __LINE__
, rc
));
4295 if (RETURN_OK
!= rc
)
4298 SCA_UpdateIcon(WSV_Type_IconWindow
, &upd
, sizeof(upd
));
4306 ScalosUnLockIconList(iwt
);
4307 SCA_UnLockWindowList();
4311 if (BNULL
!= dirLock
)
4314 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
4319 //----------------------------------------------------------------------------
4321 static SAVEDS(LONG
) UndoChangeIconObjectEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
4323 BOOL Success
= FALSE
;
4325 BPTR oldDir
= BNULL
;
4330 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
4333 struct UndoChangeIconObjectData
*uciod
= &uev
->uev_Data
.uev_ChangeIconObjectData
;
4334 struct ScaUpdateIcon_IW upd
;
4337 dirLock
= Lock(uciod
->uciod_DirName
, ACCESS_READ
);
4338 debugLock_d1(dirLock
);
4339 if (BNULL
== dirLock
)
4342 oldDir
= CurrentDir(dirLock
);
4344 upd
.ui_iw_Lock
= dirLock
;
4345 upd
.ui_iw_Name
= uciod
->uciod_IconName
;
4346 upd
.ui_IconType
= ICONTYPE_NONE
;
4348 rc
= PutIconObjectTags(uciod
->uciod_OldIconObject
, uciod
->uciod_IconName
,
4350 d1(kprintf(__FILE__
"/%s/%ld: PutIconObjectTags returned rc=%ld\n", __FUNC__
, __LINE__
, rc
));
4351 if (RETURN_OK
!= rc
)
4354 SCA_UpdateIcon(WSV_Type_IconWindow
, &upd
, sizeof(upd
));
4361 if (BNULL
!= dirLock
)
4364 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
4369 //----------------------------------------------------------------------------
4371 static SAVEDS(LONG
) RedoChangeIconObjectEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
4373 BOOL Success
= FALSE
;
4375 BPTR oldDir
= BNULL
;
4380 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
4383 struct UndoChangeIconObjectData
*uciod
= &uev
->uev_Data
.uev_ChangeIconObjectData
;
4384 struct ScaUpdateIcon_IW upd
;
4387 dirLock
= Lock(uciod
->uciod_DirName
, ACCESS_READ
);
4388 debugLock_d1(dirLock
);
4389 if (BNULL
== dirLock
)
4392 oldDir
= CurrentDir(dirLock
);
4394 upd
.ui_iw_Lock
= dirLock
;
4395 upd
.ui_iw_Name
= uciod
->uciod_IconName
;
4396 upd
.ui_IconType
= ICONTYPE_NONE
;
4398 rc
= PutIconObjectTags(uciod
->uciod_NewIconObject
, uciod
->uciod_IconName
,
4400 d1(kprintf(__FILE__
"/%s/%ld: PutIconObjectTags returned rc=%ld\n", __FUNC__
, __LINE__
, rc
));
4401 if (RETURN_OK
!= rc
)
4404 SCA_UpdateIcon(WSV_Type_IconWindow
, &upd
, sizeof(upd
));
4411 if (BNULL
!= dirLock
)
4414 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
4419 //----------------------------------------------------------------------------
4421 static SAVEDS(LONG
) UndoCloseWindowEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
4428 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
4431 struct UndoCloseWindowData
*ucwd
= &uev
->uev_Data
.uev_CloseWindowData
;
4432 struct IBox WindowBox
;
4434 WindowBox
.Left
= ucwd
->ucwd_Left
;
4435 WindowBox
.Top
= ucwd
->ucwd_Top
;
4436 WindowBox
.Width
= ucwd
->ucwd_Width
;
4437 WindowBox
.Height
= ucwd
->ucwd_Height
;
4439 Success
= SCA_OpenIconWindowTags(
4440 SCA_Path
, (ULONG
) ucwd
->ucwd_DirName
,
4441 SCA_WindowRect
, (ULONG
) &WindowBox
,
4442 SCA_ViewModes
, ucwd
->ucwd_Viewmodes
,
4443 SCA_ShowAllMode
, ucwd
->ucwd_ViewAll
,
4444 SCA_XOffset
, ucwd
->ucwd_VirtX
,
4445 SCA_YOffset
, ucwd
->ucwd_VirtY
,
4449 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
4454 //----------------------------------------------------------------------------
4456 static SAVEDS(LONG
) RedoCloseWindowEvent(struct Hook
*hook
, APTR object
, struct UndoEvent
*uev
)
4458 BOOL Success
= FALSE
;
4463 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
4466 struct UndoCloseWindowData
*ucwd
= &uev
->uev_Data
.uev_CloseWindowData
;
4467 struct internalScaWindowTask
*iwt
;
4469 iwt
= UndoFindWindowByDir(ucwd
->ucwd_DirName
);
4473 iwt
->iwt_CloseWindow
= TRUE
;
4475 SCA_UnLockWindowList();
4480 d1(kprintf("%s/%s/%ld: END Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
4485 //----------------------------------------------------------------------------
4487 // If window <iwt> is about to close, walk through Undo list
4488 // and remove all entries which refer to the opening window
4489 void UndoWindowSignalOpening(struct internalScaWindowTask
*iwt
)
4491 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
4493 if (iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
)
4495 struct UndoStep
*ust
;
4497 ScalosObtainSemaphore(&UndoListListSemaphore
);
4499 for (ust
= (struct UndoStep
*) globalUndoList
.lh_Head
;
4500 ust
!= (struct UndoStep
*) &globalUndoList
.lh_Tail
; )
4502 struct UndoStep
*ustNext
= (struct UndoStep
*) ust
->ust_Node
.ln_Succ
;
4504 struct UndoEvent
*uev
;
4506 d1(kprintf("%s/%s/%ld: ust=%08lx \n", __FILE__
, __FUNC__
, __LINE__
, ust
));
4508 for (uev
= (struct UndoEvent
*) ust
->ust_EventList
.lh_Head
;
4509 uev
!= (struct UndoEvent
*) &ust
->ust_EventList
.lh_Tail
;
4510 uev
= (struct UndoEvent
*) uev
->uev_Node
.ln_Succ
)
4512 d1(kprintf("%s/%s/%ld: uev=%08lx uev_Type=%ld uev_UndoHook=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
, uev
->uev_Type
, uev
->uev_UndoHook
));
4513 if (UNDO_CloseWindow
== uev
->uev_Type
)
4517 dirLock
= Lock(uev
->uev_Data
.uev_CloseWindowData
.ucwd_DirName
, ACCESS_READ
);
4520 if (LOCK_SAME
== SameLock(dirLock
, iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
))
4533 Remove(&ust
->ust_Node
);
4534 UndoDisposeStep(ust
);
4538 d1(kprintf("%s/%s/%ld: ust=%08lx \n", __FILE__
, __FUNC__
, __LINE__
, ust
));
4541 ScalosReleaseSemaphore(&UndoListListSemaphore
);
4546 d1(kprintf("%s/%s/%ld: END\n", __FILE__
, __FUNC__
, __LINE__
));
4549 //----------------------------------------------------------------------------
4551 // If window <iwt> is about to close, walk through Undo/Redo lists
4552 // and remove all entries which refer to the disappearing window
4553 void UndoWindowSignalClosing(struct internalScaWindowTask
*iwt
)
4555 struct UndoStep
*ust
;
4557 d1(kprintf("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
4559 UndoAddEvent(iwt
, UNDO_CloseWindow
,
4560 UNDOTAG_WindowTask
, iwt
,
4563 ScalosObtainSemaphore(&UndoListListSemaphore
);
4565 for (ust
= (struct UndoStep
*) globalUndoList
.lh_Head
;
4566 ust
!= (struct UndoStep
*) &globalUndoList
.lh_Tail
; )
4568 struct UndoStep
*ustNext
= (struct UndoStep
*) ust
->ust_Node
.ln_Succ
;
4570 struct UndoEvent
*uev
;
4572 d1(kprintf("%s/%s/%ld: ust=%08lx \n", __FILE__
, __FUNC__
, __LINE__
, ust
));
4574 for (uev
= (struct UndoEvent
*) ust
->ust_EventList
.lh_Head
;
4575 uev
!= (struct UndoEvent
*) &ust
->ust_EventList
.lh_Tail
;
4576 uev
= (struct UndoEvent
*) uev
->uev_Node
.ln_Succ
)
4578 d1(kprintf("%s/%s/%ld: uev=%08lx uev_Type=%ld uev_UndoHook=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
, uev
->uev_Type
, uev
->uev_UndoHook
));
4579 if (UNDO_Cleanup
== uev
->uev_Type
)
4581 if (uev
->uev_Data
.uev_CleanupData
.ucd_WindowTask
== &iwt
->iwt_WindowTask
)
4587 else if (UNDO_SizeWindow
== uev
->uev_Type
)
4589 if (uev
->uev_Data
.uev_SizeWindowData
.uswd_WindowTask
== &iwt
->iwt_WindowTask
)
4600 Remove(&ust
->ust_Node
);
4601 UndoDisposeStep(ust
);
4605 d1(kprintf("%s/%s/%ld: ust=%08lx \n", __FILE__
, __FUNC__
, __LINE__
, ust
));
4608 ScalosReleaseSemaphore(&UndoListListSemaphore
);
4610 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
4612 ScalosObtainSemaphore(&RedoListListSemaphore
);
4614 for (ust
= (struct UndoStep
*) globalRedoList
.lh_Head
;
4615 ust
!= (struct UndoStep
*) &globalRedoList
.lh_Tail
; )
4617 struct UndoStep
*ustNext
= (struct UndoStep
*) ust
->ust_Node
.ln_Succ
;
4619 struct UndoEvent
*uev
;
4621 d1(kprintf("%s/%s/%ld: ust=%08lx \n", __FILE__
, __FUNC__
, __LINE__
, ust
));
4623 for (uev
= (struct UndoEvent
*) ust
->ust_EventList
.lh_Head
;
4624 uev
!= (struct UndoEvent
*) &ust
->ust_EventList
.lh_Tail
;
4625 uev
= (struct UndoEvent
*) uev
->uev_Node
.ln_Succ
)
4627 d1(kprintf("%s/%s/%ld: uev=%08lx uev_Type=%ld uev_UndoHook=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, uev
, uev
->uev_Type
, uev
->uev_UndoHook
));
4628 if (UNDO_Cleanup
== uev
->uev_Type
)
4630 if (uev
->uev_Data
.uev_CleanupData
.ucd_WindowTask
== &iwt
->iwt_WindowTask
)
4636 else if (UNDO_SizeWindow
== uev
->uev_Type
)
4638 if (uev
->uev_Data
.uev_SizeWindowData
.uswd_WindowTask
== &iwt
->iwt_WindowTask
)
4648 Remove(&ust
->ust_Node
);
4649 UndoDisposeStep(ust
);
4653 d1(kprintf("%s/%s/%ld: ust=%08lx \n", __FILE__
, __FUNC__
, __LINE__
, ust
));
4656 ScalosReleaseSemaphore(&RedoListListSemaphore
);
4660 d1(kprintf("%s/%s/%ld: END\n", __FILE__
, __FUNC__
, __LINE__
));
4663 //----------------------------------------------------------------------------
4665 static BOOL
UndoFindWindowAndIcon(CONST_STRPTR DirName
, CONST_STRPTR IconName
,
4666 struct internalScaWindowTask
**iwt
, struct ScaIconNode
**in
)
4672 SCA_LockWindowList(SCA_LockWindowList_Shared
);
4674 DirLock
= Lock(DirName
, ACCESS_READ
);
4675 if (BNULL
== DirLock
)
4678 // First check whether icon is on desktop window (left-out)
4679 *iwt
= (struct internalScaWindowTask
*) iInfos
.xii_iinfos
.ii_MainWindowStruct
->ws_WindowTask
;
4681 ScalosLockIconListShared(*iwt
);
4683 for ((*in
)=(*iwt
)->iwt_WindowTask
.wt_IconList
; *in
; *in
= (struct ScaIconNode
*) (*in
)->in_Node
.mln_Succ
)
4685 if ((*in
)->in_Lock
&& (LOCK_SAME
== SameLock((*in
)->in_Lock
, DirLock
)) &&
4686 (0 == Stricmp(GetIconName(*in
), IconName
)))
4689 d1(kprintf("%s/%s/%ld: in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, *in
, GetIconName(*in
)));
4695 break; // icon found on desktop window
4697 // icon not found in desktop window
4698 ScalosUnLockIconList(*iwt
);
4700 SCA_UnLockWindowList();
4702 *iwt
= UndoFindWindowByDir(DirName
);
4706 *in
= UndoFindIconByName(*iwt
, IconName
);
4718 ScalosUnLockIconList(*iwt
);
4721 SCA_UnLockWindowList();
4730 //----------------------------------------------------------------------------